[Sugar-devel] [Sugar 1/2] Only add a group of selections to the clipboard if there are anything available.

godiard at sugarlabs.org godiard at sugarlabs.org
Thu Jan 26 16:17:57 EST 2012


From: Gonzalo Odiard <godiard at gmail.com>

This problem is affecting Text to Speech with Write activity,
because there are only a selection in the secondary clipboard
but a icon is displayed in the frame without anything selected.

Signed-off-by: Gonzalo Odiard
---
 src/jarabe/frame/clipboardpanelwindow.py |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/jarabe/frame/clipboardpanelwindow.py b/src/jarabe/frame/clipboardpanelwindow.py
index aefec7b..209c508 100644
--- a/src/jarabe/frame/clipboardpanelwindow.py
+++ b/src/jarabe/frame/clipboardpanelwindow.py
@@ -56,10 +56,9 @@ class ClipboardPanelWindow(FrameWindow):
             return
 
         cb_service = clipboard.get_instance()
-        key = cb_service.add_object(name="")
-        cb_service.set_object_percent(key, percent=0)
 
         targets = x_clipboard.wait_for_targets()
+        cb_selections = []
         for target in targets:
             if target not in ('TIMESTAMP', 'TARGETS',
                               'MULTIPLE', 'SAVE_TARGETS'):
@@ -68,9 +67,13 @@ class ClipboardPanelWindow(FrameWindow):
                 if not selection:
                     logging.warning('no data for selection target %s.', target)
                     continue
+                cb_selections.append(selection)
+        if len(cb_selections) > 0:
+            key = cb_service.add_object(name="")
+            cb_service.set_object_percent(key, percent=0)
+            for selection in cb_selections:
                 self._add_selection(key, selection)
-
-        cb_service.set_object_percent(key, percent=100)
+            cb_service.set_object_percent(key, percent=100)
 
     def _add_selection(self, key, selection):
         if not selection.data:
-- 
1.7.7.5



More information about the Sugar-devel mailing list