hi!
I want to write a program that put files in the clipboard so that they
can be accessed by other programs, namely Nautilus - the gnome file
manager.
The program calls the clipboard method "set_with_data" and waits.
After that, if you go to a Nautilus window, it will show the "paste"
menu option which means it detects the clipboard has file
information...
Then, if you execute the "paste" action in Nautilus, my program's
"get_func" callback is called, with target ==
"x-special/gnome-copied-files", but nothing else happens. The files
are not copied by nautilus.
Can someone tell me what is missing OR point me to a python program
that uses this kind of stuff?
thanks
daniel
--
And here is the program:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require('2.0')
import gtk
import sys
import os.path
clipboard=gtk.clipboard_get()
def get_func(clipboard, selectiondata, info, data):
print "get_func", data
print "target", selectiondata.get_target()
uris = ["file:///tmp/_ola.txt"]
selectiondata.set_uris(uris)
#clipboard.store()??
def clear_func(clipboard, data):
print "clear_func"
#ret = clipboard.set_with_data( [('TEXT',0,0), ('STRING',0,0),
("text/uri-list",0,0), ("text/plain",0,0)] , get_func, clear_func,
"ola")
#targets = []
#targets = gtk.target_list_add_uri_targets(targets, 0)
targets = [('x-special/gnome-copied-files',0,0) ] ###, ("text/uri-list",0,0)]
ret = clipboard.set_with_data(targets, get_func, clear_func)
# returns True
gtk.main()
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/