[Sugar-devel] [PATCH] When a object is removed from the clipboard try, select the last available v3 - SL #1266
godiard at sugarlabs.org
godiard at sugarlabs.org
Tue Apr 24 07:18:27 EDT 2012
From: Gonzalo Odiard <godiard at gmail.com>
If the user remove a object from the clipboard,
the last available object should be selected,
and if no more objects are available, the clipboard should be cleaned.
Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
---
v2: If there no more objects in the try, clean the clipboard
v3: Changes suggested in review by Sascha.
---
src/jarabe/frame/clipboard.py | 4 ++++
src/jarabe/frame/clipboardtray.py | 5 +++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/jarabe/frame/clipboard.py b/src/jarabe/frame/clipboard.py
index f3da89f..3bdc7f2 100644
--- a/src/jarabe/frame/clipboard.py
+++ b/src/jarabe/frame/clipboard.py
@@ -21,6 +21,7 @@ import urlparse
import tempfile
import gobject
+import gtk
from sugar import mime
@@ -94,6 +95,9 @@ class Clipboard(gobject.GObject):
def delete_object(self, object_id):
cb_object = self._objects.pop(object_id)
cb_object.destroy()
+ if not self._objects:
+ gtk_clipboard = gtk.Clipboard()
+ gtk_clipboard.clear()
self.emit('object-deleted', object_id)
logging.debug('Deleted object with object_id %r', object_id)
diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py
index f49b799..37d5e1a 100644
--- a/src/jarabe/frame/clipboardtray.py
+++ b/src/jarabe/frame/clipboardtray.py
@@ -123,6 +123,11 @@ class ClipboardTray(tray.VTray):
icon = self._icons[object_id]
self.remove_item(icon)
del self._icons[object_id]
+ # select the last available icon
+ if self._icons:
+ last_icon = self.get_children()[-1]
+ last_icon.props.active = True
+
logging.debug('ClipboardTray: %r was deleted', object_id)
def drag_motion_cb(self, widget, context, x, y, time):
--
1.7.7.6
More information about the Sugar-devel
mailing list