From 5755a327b4f4cc02b69ea5cff9f3c4c14dae78f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Mon, 1 Oct 2012 23:42:40 -0300
Subject: [PATCH shell] Favorites view: get back hover feedback in activity
icons - SL #3894
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
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>
---
src/jarabe/desktop/favoritesview.py | 34 ++++++----------------------------
1 file changed, 6 insertions(+), 28 deletions(-)
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index 26a89e6..17d014e 100644
a
|
b
|
class ActivityIcon(EventIcon): |
355 | 355 | |
356 | 356 | self._activity_info = activity_info |
357 | 357 | self._journal_entries = [] |
358 | | self._hovering = False |
359 | 358 | self._resume_mode = True |
360 | 359 | |
361 | 360 | self.connect('enter-notify-event', self.__enter_notify_event_cb) |
… |
… |
class ActivityIcon(EventIcon): |
430 | 429 | self._resume(metadata) |
431 | 430 | |
432 | 431 | def __enter_notify_event_cb(self, icon, event): |
433 | | self._hovering = True |
434 | | self.queue_draw() |
| 432 | self.set_state(Gtk.StateFlags.PRELIGHT) |
435 | 433 | |
436 | 434 | def __leave_notify_event_cb(self, icon, event): |
437 | | self._hovering = False |
438 | | self.queue_draw() |
| 435 | self.set_state(Gtk.StateFlags.NORMAL) |
439 | 436 | |
440 | 437 | def do_draw(self, cr): |
441 | 438 | EventIcon.do_draw(self, cr) |
442 | 439 | |
443 | | if not self._hovering: |
444 | | return |
445 | | |
446 | 440 | allocation = self.get_allocation() |
447 | | width = allocation.width |
448 | | height = allocation.height |
449 | | |
450 | | x = allocation.x + ActivityIcon._BORDER_WIDTH / 2.0 |
451 | | y = allocation.y + ActivityIcon._BORDER_WIDTH / 2.0 |
452 | | width -= ActivityIcon._BORDER_WIDTH |
453 | | height -= ActivityIcon._BORDER_WIDTH |
454 | | radius = width / 10.0 |
455 | | |
456 | | cr.move_to(x + radius, y) |
457 | | cr.arc(x + width - radius, y + radius, radius, math.pi * 1.5, |
458 | | math.pi * 2.0) |
459 | | cr.arc(x + width - radius, y + height - radius, radius, 0, |
460 | | math.pi * 0.5) |
461 | | cr.arc(x + radius, y + height - radius, radius, math.pi * 0.5, math.pi) |
462 | | cr.arc(x + radius, y + radius, radius, math.pi, math.pi * 1.5) |
463 | | |
464 | | cr.set_source_rgba(*style.COLOR_SELECTION_GREY.get_rgba()) |
465 | | cr.set_line_width(ActivityIcon._BORDER_WIDTH) |
466 | | cr.stroke() |
| 441 | context = self.get_style_context() |
| 442 | Gtk.render_frame(context, cr, 0, 0, |
| 443 | allocation.width, |
| 444 | allocation.height) |
467 | 445 | |
468 | 446 | def do_size_request(self, req): |
469 | 447 | EventIcon.do_size_request(self, req) |