From 6dd70d8c968574d72719f1907e329f5b348e2c61 Mon Sep 17 00:00:00 2001 From: Manuel QuiƱones Date: Tue, 02 Oct 2012 02:42:40 +0000 Subject: 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 Acked-by: Simon Schampijer --- 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) -- cgit v0.9.1