Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-10-02 02:42:40 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-10-03 18:15:19 (GMT)
commit6dd70d8c968574d72719f1907e329f5b348e2c61 (patch)
tree3a2d025dd8db1a1904b3bf4f8459873991bf4e4a
parent7d039ea4d3ec1af00e19d99c4517fbde90fc9d67 (diff)
Favorites view: get back hover feedback in activity icons - SL #3894
Since de-hippo, our icons are implemented as Gtk.EventBox. If a frame is drawn in the do_draw method using Gtk.render_frame, it can be styled in the theme, setting border rules. Listening to the enter-notify and leave-notify events, we can set the prelight state to the eventbox. Then in the theme we can style that state. This is convenient to get back the grey rectangle in the favorites view when an activity icon is hovered. The previous cairo drawing that this patch removes is broken, and seems more complicated than using Gtk.render_frame. Also is better to do the styling in the theme. This patch will be accompanied with an artwork patch that adds the styling. Signed-off-by: Manuel Quiñones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/jarabe/desktop/favoritesview.py34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index 26a89e6..17d014e 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -355,7 +355,6 @@ class ActivityIcon(EventIcon):
self._activity_info = activity_info
self._journal_entries = []
- self._hovering = False
self._resume_mode = True
self.connect('enter-notify-event', self.__enter_notify_event_cb)
@@ -430,40 +429,19 @@ class ActivityIcon(EventIcon):
self._resume(metadata)
def __enter_notify_event_cb(self, icon, event):
- self._hovering = True
- self.queue_draw()
+ self.set_state(Gtk.StateFlags.PRELIGHT)
def __leave_notify_event_cb(self, icon, event):
- self._hovering = False
- self.queue_draw()
+ self.set_state(Gtk.StateFlags.NORMAL)
def do_draw(self, cr):
EventIcon.do_draw(self, cr)
- if not self._hovering:
- return
-
allocation = self.get_allocation()
- width = allocation.width
- height = allocation.height
-
- x = allocation.x + ActivityIcon._BORDER_WIDTH / 2.0
- y = allocation.y + ActivityIcon._BORDER_WIDTH / 2.0
- width -= ActivityIcon._BORDER_WIDTH
- height -= ActivityIcon._BORDER_WIDTH
- radius = width / 10.0
-
- cr.move_to(x + radius, y)
- cr.arc(x + width - radius, y + radius, radius, math.pi * 1.5,
- math.pi * 2.0)
- cr.arc(x + width - radius, y + height - radius, radius, 0,
- math.pi * 0.5)
- cr.arc(x + radius, y + height - radius, radius, math.pi * 0.5, math.pi)
- cr.arc(x + radius, y + radius, radius, math.pi, math.pi * 1.5)
-
- cr.set_source_rgba(*style.COLOR_SELECTION_GREY.get_rgba())
- cr.set_line_width(ActivityIcon._BORDER_WIDTH)
- cr.stroke()
+ context = self.get_style_context()
+ Gtk.render_frame(context, cr, 0, 0,
+ allocation.width,
+ allocation.height)
def do_size_request(self, req):
EventIcon.do_size_request(self, req)