[Sugar-devel] [record v3 PATCH] sl#4442: Now, Copy-to-Clipboard works fine, after the recipient clicks on the thumbnail, and the complete-data isfetched.

Ajay Garg ajay at activitycentral.com
Mon Feb 25 13:32:09 EST 2013


v1 -> v2 ::

Added the explanation of the fix.

v2 -> v3 ::

Minor fix in the header.


Initially, the bug was due to the fact that the thumbnail-palette was initiated just once (when the 
thumbnail was first created). 

Now, when the thumbnail is first created for a "received" thumbnail, initially no "Copy to Clipboard" option is
shown. However, after the user clicks the thumbnail and the data is fetched, the  option is shown.

At code level, every time the user hovers over the thumbnail, the "expose-event" signal is emitted, thereby calling the 
"do_expose_event" method. As the fix, we override this method, first checking to see if the data has been fetched for 
the thumbnail. If yes, we add the "Copy to Clipboard" option in the palette, and mark a flag for the same, so that it
is not re-added on subsequent "expose-event" signal.

 activity/activity.info |  2 +-
 button.py              | 12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/button.py b/button.py
index 66cf80b..be32b60 100644
--- a/button.py
+++ b/button.py
@@ -28,7 +28,13 @@ class RecdButton(TrayButton):
-        self._add_copy_menu_item()
+        self._copy_menu_item_added = False
+    def do_expose_event(self, event):
+        if not self._copy_menu_item_added:
+            self._add_copy_menu_item()
+        TrayButton.do_expose_event(self, event)
     def _add_copy_menu_item( self ):
         if self._recd.buddy and not self._recd.downloadedFromBuddy:
@@ -38,7 +44,9 @@ class RecdButton(TrayButton):
         self._copy_menu_item_handler = self._copy_menu_item.connect('activate', self._copy_clipboard_clicked)
+        self._copy_menu_item_added = True
     def get_recd(self):
         return self._recd

More information about the Sugar-devel mailing list