[sugar] more clipboard questions

Erik Blankinship erikb
Sat Jul 28 23:16:27 EDT 2007

I have a problem knowing when I can remove a file in /tmp after it has been
placed on the clipboard successfully.

Responding to a key-press-event callback, I call the following:

gtk.Clipboard().set_with_data( [('text/uri-list', 0, 0)],
self._clipboardGetFuncCb, self._clipboardClearFuncCb, tempImgPath )

which, in turn, calls back:

def _clipboardGetFuncCb( self, clipboard, selection_data, info,
     tempImgUri = "file://" + tempImgPath
     selection_data.set( "text/uri-list", 8, tempImgUri )

def _clipboardClearFuncCb( self, clipboard, tempImgPath):
     if (tempImgPath != None):
          if (os.path.exists(tempImgPath)):
               os.remove( tempImgPath )

_clipboardGetFuncCb is called before _clipboardClearFuncCb, but the second
callback prevents any data from being placed on the clipboard (an image icon
appears, but it has no data).  If the second callback doesn't delete the
file, the copy works!  It would seem I need a callback to know when the
clipboard has completed copying the data from /tmp before deleting the file
from /tmp.

Looking into the clipboardservice.py code, it seems that a
call can fire a "file-completed"... but I am not sure of the right way for
an activity to plug into that logic.  Suggestions?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/sugar/attachments/20070728/634bd34f/attachment.htm 

More information about the Sugar-devel mailing list