From 440baae7d96503e5ddd1606f36e847b4d13b5a6f Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 18 Mar 2007 12:56:11 +0100 Subject: [PATCH 1/2] Show and hide the frame when an object is added to the clipboard. --- shell/view/frame/frame.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/view/frame/frame.py b/shell/view/frame/frame.py index aedc56dc..94748085 100644 --- a/shell/view/frame/frame.py +++ b/shell/view/frame/frame.py @@ -30,6 +30,7 @@ from view.frame.framepopupcontext import FramePopupContext from model.ShellModel import ShellModel from sugar.graphics import animator from sugar.graphics import units +from sugar.clipboard import clipboardservice MODE_NONE = 0 MODE_MOUSE = 1 @@ -156,6 +157,9 @@ class Frame(object): screen = gtk.gdk.screen_get_default() screen.connect('size-changed', self._size_changed_cb) + cb_service = clipboardservice.get_instance() + cb_service.connect_after('object-added', self._clipboard_object_added_cb) + self._key_listener = _KeyListener(self) self._mouse_listener = _MouseListener(self) @@ -297,7 +301,12 @@ class Frame(object): def _size_changed_cb(self, screen): self._update_position() - + + def _clipboard_object_added_cb(self, cb_service, object_id, name): + if not self.visible: + self.show() + gobject.timeout_add(2000, lambda: self.hide()) + def _popup_context_activated_cb(self, popup_context): self._mouse_listener.mouse_enter() From 5104e24ffa76768707551f4cf2c2e0528bdee408 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 18 Mar 2007 13:16:09 +0100 Subject: [PATCH 2/2] Hack for detecting an onDisk format. Need to improve the clipboard API for the right fix. --- shell/view/clipboardicon.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py index 5e941f67..0844dd21 100644 --- a/shell/view/clipboardicon.py +++ b/shell/view/clipboardicon.py @@ -114,7 +114,14 @@ class ClipboardIcon(CanvasIcon): formats = obj['FORMATS'] if len(formats) > 0: path = cb_service.get_object_data(self._object_id, formats[0]) - if os.path.exists(path): + + # FIXME: would be better to check for format.onDisk + try: + path_exists = os.path.exists(path) + except TypeError: + path_exists = False + + if path_exists: activityfactory.create_with_uri(self._activity, path) else: logging.debug("Clipboard item file path %s didn't exist" % path)