These two patches are both pretty simple, and each add a prelight
state to buttons in the list view of the Journal.  I include them
together as they're similar, but also because they both suffer a
common glitch, which I'm going to assume is a bug in Hippo.  Despite
connecting to MOTION_NOTIFY events for both ENTER and LEAVE, the
prelight states only appear when the mouse is clicked on the icons.
Something in the event processing is acting strangely.

Ideas as to the cause (or corrections of a stupid mistake of my own)
are appreciated.

- Eben
From ad37e9584c51ad21671ebcc251305287049e1c97 Mon Sep 17 00:00:00 2001
From: Eben Eliason <[EMAIL PROTECTED]>
Date: Wed, 16 Apr 2008 01:50:25 -0400
Subject: [PATCH] Add prelight to favorite icons

---
 keepicon.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/keepicon.py b/keepicon.py
index ace98e2..ba0f180 100644
--- a/keepicon.py
+++ b/keepicon.py
@@ -15,6 +15,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 import gobject
+import hippo
 
 from sugar.graphics.icon import CanvasIcon
 from sugar.graphics import style
@@ -30,6 +31,8 @@ class KeepIcon(CanvasIcon):
         CanvasIcon.__init__(self, icon_name='emblem-favorite',
                             box_width=style.GRID_CELL_SIZE * 3 / 5,
                             size=style.SMALL_ICON_SIZE)
+        self.connect('motion-notify-event', self.__motion_notify_event_cb)
+
         self._keep = None
         self._set_keep(keep)
 
@@ -56,3 +59,10 @@ class KeepIcon(CanvasIcon):
         else:
             return CanvasIcon.do_get_property(self, pspec)
 
+    def __motion_notify_event_cb(self, icon, event):
+        if not self._keep:
+            if event.detail == hippo.MOTION_DETAIL_ENTER:
+                icon.props.fill_color = style.COLOR_BUTTON_GREY.get_svg()
+            elif event.detail == hippo.MOTION_DETAIL_LEAVE:
+                icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
+
-- 
1.5.3.3

From 3a51a492d0b3394188b25e08fa8f8ea6d747a32b Mon Sep 17 00:00:00 2001
From: Eben Eliason <[EMAIL PROTECTED]>
Date: Wed, 16 Apr 2008 18:01:54 -0400
Subject: [PATCH] Add prelight to detail button of journal entries

---
 collapsedentry.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/collapsedentry.py b/collapsedentry.py
index 26a9642..8584ac4 100644
--- a/collapsedentry.py
+++ b/collapsedentry.py
@@ -105,6 +105,8 @@ class CollapsedEntry(hippo.CanvasBox):
         self.append(self._date)
 
         self._detail_button = self._create_detail_button()
+        self._detail_button.connect('motion-notify-event',
+                                    self._detail_button_motion_notify_event_cb)
         self.append(self._detail_button)
         if not self._allow_resume:
              self.set_child_visible(self._detail_button, False)
@@ -282,6 +284,12 @@ class CollapsedEntry(hippo.CanvasBox):
             self.emit('entry-activated')
         return True
 
+    def _detail_button_motion_notify_event_cb(self, button, event):
+        if event.detail == hippo.MOTION_DETAIL_ENTER:
+            button.props.fill_color = style.COLOR_TOOLBAR_GREY.get_svg()
+        elif event.detail == hippo.MOTION_DETAIL_LEAVE:
+            button.props.fill_color = style.COLOR_BUTTON_GREY.get_svg()
+
     def _cancel_button_release_event_cb(self, button, event):
         logging.debug('_cancel_button_release_event_cb')
         datastore.delete(self._jobject.object_id)
-- 
1.5.3.3

_______________________________________________
Sugar mailing list
Sugar@lists.laptop.org
http://lists.laptop.org/listinfo/sugar

Reply via email to