<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>le-Web.org &#187; nautilus</title>
	<atom:link href="http://www.le-web.org/tag/nautilus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.le-web.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 04 Dec 2008 10:21:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PyGTK: Copy a file to clipboard (paste it in Nautilus)</title>
		<link>http://www.le-web.org/2008/12/04/pygtk-copy-a-file-to-clipboard-paste-it-in-nautilus/</link>
		<comments>http://www.le-web.org/2008/12/04/pygtk-copy-a-file-to-clipboard-paste-it-in-nautilus/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 10:21:13 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Python/PyGTK]]></category>
		<category><![CDATA[Tips, Tricks & Scripts]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[nautilus]]></category>
		<category><![CDATA[pygtk]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.le-web.org/?p=74</guid>
		<description><![CDATA[PyGTK provide clipboard functionality for standard targets: text, file(s) and image. Nautilus if does not use the standard URI target for copy/cat/paste file because this target does not provide the desired action (copy or cut).


For copy/cat/paste Nautilus use a special clipboard target named &#8220;x-special/gnome-copied-files&#8221;. The content of this target is a text with items separated [...]]]></description>
			<content:encoded><![CDATA[<p>PyGTK provide clipboard functionality for standard targets: text, file(s) and image. Nautilus if does not use the standard URI target for copy/cat/paste file because this target does not provide the desired action (copy or cut).<br />
<span id="more-74"></span><br />
<!--adsense--><br />
For copy/cat/paste Nautilus use a special clipboard target named &#8220;x-special/gnome-copied-files&#8221;. The content of this target is a text with items separated by new line character (&#8220;\n&#8221;). The first line is the action (&#8220;copy&#8221; or &#8220;cut&#8221;) and then one URI per line.</p>
<p>To copy the file /path/abc.txt the target &#8220;x-special/gnome-copied-files&#8221; contains the text:</p>
<pre>copy
file:///path/abc.txt</pre>
<p>The class &#8220;gtk.Clipboard&#8221; has the method</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> set_with_data<span style="color: black;">&#40;</span>targets, get_func, clear_func, user_data<span style="color: black;">&#41;</span></pre></div></div>

<p>to set the content of the clipboard to any targets and to provide functions for clipboard requests (get/clean).<br />
<!--adsense--><br />
Using this method I write a simple code to handle copy path to clipboard (<a href="http://www.le-web.org/wp-content/uploads/2008/12/gnomeclipboardtools.py">gnomeclipboardtools.py</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>br /<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>b<span style="color: #66cc66;">&gt;</span>Warning<span style="color: #66cc66;">&lt;</span>/b<span style="color: #66cc66;">&gt;</span>:  include<span style="color: black;">&#40;</span>/home2/macadanc/public_html/le-web.<span style="color: black;">org</span>/wp-content/uploads/<span style="color: #ff4500;">2008</span>/<span style="color: #ff4500;">12</span>/gnomeclipboardtools.<span style="color: black;">py</span><span style="color: black;">&#41;</span> <span style="color: black;">&#91;</span><span style="color: #66cc66;">&lt;</span>a href=<span style="color: #483d8b;">'function.include'</span><span style="color: #66cc66;">&gt;</span>function.<span style="color: black;">include</span><span style="color: #66cc66;">&lt;</span>/a<span style="color: #66cc66;">&gt;</span><span style="color: black;">&#93;</span>: failed to <span style="color: #008000;">open</span> stream: No such <span style="color: #008000;">file</span> <span style="color: #ff7700;font-weight:bold;">or</span> directory <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #66cc66;">&lt;</span>b<span style="color: #66cc66;">&gt;</span>/home2/macadanc/public_html/le-web.<span style="color: black;">org</span>/wp-content/plugins/include-it/plugin.<span style="color: black;">php</span><span style="color: #66cc66;">&lt;</span>/b<span style="color: #66cc66;">&gt;</span> on line <span style="color: #66cc66;">&lt;</span>b<span style="color: #66cc66;">&gt;</span><span style="color: #ff4500;">86</span><span style="color: #66cc66;">&lt;</span>/b<span style="color: #66cc66;">&gt;&lt;</span>br /<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>br /<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>b<span style="color: #66cc66;">&gt;</span>Warning<span style="color: #66cc66;">&lt;</span>/b<span style="color: #66cc66;">&gt;</span>:  include<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#91;</span><span style="color: #66cc66;">&lt;</span>a href=<span style="color: #483d8b;">'function.include'</span><span style="color: #66cc66;">&gt;</span>function.<span style="color: black;">include</span><span style="color: #66cc66;">&lt;</span>/a<span style="color: #66cc66;">&gt;</span><span style="color: black;">&#93;</span>: Failed opening <span style="color: #483d8b;">'/home2/macadanc/public_html/le-web.org/wp-content/uploads/2008/12/gnomeclipboardtools.py'</span> <span style="color: #ff7700;font-weight:bold;">for</span> inclusion <span style="color: black;">&#40;</span>include_path=<span style="color: #483d8b;">'.:/usr/share/pear'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #66cc66;">&lt;</span>b<span style="color: #66cc66;">&gt;</span>/home2/macadanc/public_html/le-web.<span style="color: black;">org</span>/wp-content/plugins/include-it/plugin.<span style="color: black;">php</span><span style="color: #66cc66;">&lt;</span>/b<span style="color: #66cc66;">&gt;</span> on line <span style="color: #66cc66;">&lt;</span>b<span style="color: #66cc66;">&gt;</span><span style="color: #ff4500;">86</span><span style="color: #66cc66;">&lt;</span>/b<span style="color: #66cc66;">&gt;&lt;</span>br /<span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Using it is very simple:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> gnomeclipboardtools
gnomeclipboardtools.<span style="color: black;">clipboard_copy_path</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">'/path/abc.txt'</span> <span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.le-web.org/2008/12/04/pygtk-copy-a-file-to-clipboard-paste-it-in-nautilus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

