This patch disables the frame from popping up when you copy an object to the
clipboard and instead pops up a notification icon in the bottom left hand
corner. It also adds the ability to add_notification() for future use to
place icons in any of the four corners.
From daf8f85895a4e61cd64fbdf145515b4df57c7316 Mon Sep 17 00:00:00 2001
From: Eric Burns <[EMAIL PROTECTED]>
Date: Fri, 18 Apr 2008 13:28:54 -0500
Subject: [PATCH] Clipboard - disabled frame popup and enabled icon notification

When an object is added to the clipboard the frame no longer pops up but a pulsing notification icon is displayed in the bottom left corner.
---
 src/view/clipboardicon.py |    8 ++++++++
 src/view/frame/frame.py   |   23 ++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/view/clipboardicon.py b/src/view/clipboardicon.py
index 4b36395..d53a234 100644
--- a/src/view/clipboardicon.py
+++ b/src/view/clipboardicon.py
@@ -32,6 +32,8 @@ from sugar import profile
 
 from view.clipboardmenu import ClipboardMenu
 from view.frame.frameinvoker import FrameWidgetInvoker
+from view.frame.notification import NotificationIcon
+import view.frame.frame
 
 class ClipboardIcon(RadioToolButton):
     __gtype_name__ = 'SugarClipboardIcon'
@@ -145,6 +147,12 @@ class ClipboardIcon(RadioToolButton):
         if old_percent < 100 and self._percent == 100:
             self.props.active = True
 
+            # Display the notification icon for the clipping
+            self._notif_icon = NotificationIcon()
+            self._notif_icon.props.icon_name = self._icon.props.icon_name
+            self._notif_icon.props.xo_color = profile.get_color()
+            view.frame.frame.get_instance().add_notification(self._notif_icon, 'top-right')
+
     def _notify_active_cb(self, widget, pspec):
         if self.props.active:
             self._put_in_clipboard()
diff --git a/src/view/frame/frame.py b/src/view/frame/frame.py
index 4a407b6..669a27b 100644
--- a/src/view/frame/frame.py
+++ b/src/view/frame/frame.py
@@ -117,8 +117,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)
+        # Disable the Frame from popping up when a clipping is added
+        # 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)
@@ -283,12 +284,24 @@ class Frame(object):
     def notify_key_press(self):
         self._key_listener.key_press()
 
-    def add_notification(self, icon):
+    def add_notification(self, icon, corner='top-left'):
         if not isinstance(icon, NotificationIcon):
             raise TypeError('icon must be a NotificationIcon.')
-        
+
         window = NotificationWindow()
-        window.move(0, 0)
+
+        # Get the screen size
+        screen = gtk.gdk.screen_get_default()
+        # Set the icon in the passed corner
+        if corner == 'top-left':
+            window.move(0, 0)
+        elif corner == 'top-right':
+            window.move(screen.get_width() - style.GRID_CELL_SIZE, 0)
+        elif corner == 'bottom-left':
+            window.move(0, screen.get_height() - style.GRID_CELL_SIZE)
+        elif corner == 'bottom-right':
+            window.move(screen.get_width() - style.GRID_CELL_SIZE, screen.get_height() - style.GRID_CELL_SIZE)
+
         window.add(icon)
         icon.show()
         window.show()
-- 
1.5.2.5

_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to