From e00b232bdffa7a94d174730a8e0bb95e9b81d3f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Thu, 13 Dec 2012 18:43:14 -0300
Subject: [PATCH shell] Journal details view: Style KeepIcon - SL #4304
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
Use the same style as in the Journal list view:
- Add a __gtype_name__ so it can be styled in the theme.
- Set width and height to GRID_CELL_SIZE .
- Use a dark grey background as the press feedback. We need to add a
custom CSS class to distinguish the press from the active state, as
this is a toggle button and can be left in the active state.
- Paint the icon on the user colors when mouse is over.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
src/jarabe/journal/keepicon.py | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/src/jarabe/journal/keepicon.py b/src/jarabe/journal/keepicon.py
index 16e3a57..233d668 100644
a
|
b
|
from sugar3.graphics.xocolor import XoColor |
24 | 24 | |
25 | 25 | |
26 | 26 | class KeepIcon(Gtk.ToggleButton): |
| 27 | __gtype_name__ = 'SugarKeepIcon' |
| 28 | |
27 | 29 | def __init__(self): |
28 | 30 | Gtk.ToggleButton.__init__(self) |
29 | 31 | self.set_relief(Gtk.ReliefStyle.NONE) |
… |
… |
class KeepIcon(Gtk.ToggleButton): |
35 | 37 | self.connect('toggled', self.__toggled_cb) |
36 | 38 | self.connect('leave-notify-event', self.__leave_notify_event_cb) |
37 | 39 | self.connect('enter-notify-event', self.__enter_notify_event_cb) |
| 40 | self.connect('button-press-event', self.__button_press_event_cb) |
| 41 | self.connect('button-release-event', self.__button_release_event_cb) |
| 42 | |
| 43 | logging.debug('KEEPICON: setting xo_color') |
| 44 | client = GConf.Client.get_default() |
| 45 | self._xo_color = XoColor(client.get_string( |
| 46 | '/desktop/sugar/user/color')) |
| 47 | |
| 48 | def do_get_preferred_width(self): |
| 49 | return 0, style.GRID_CELL_SIZE |
| 50 | |
| 51 | def do_get_preferred_height(self): |
| 52 | return 0, style.GRID_CELL_SIZE |
| 53 | |
| 54 | def __button_press_event_cb(self, widget, event): |
| 55 | # We need to use a custom CSS class because in togglebuttons |
| 56 | # the 'active' class doesn't only match the button press, they |
| 57 | # can be left in the active state. |
| 58 | style_context = self.get_style_context() |
| 59 | style_context.add_class('toggle-press') |
| 60 | |
| 61 | def __button_release_event_cb(self, widget, event): |
| 62 | style_context = self.get_style_context() |
| 63 | style_context.remove_class('toggle-press') |
38 | 64 | |
39 | 65 | def __toggled_cb(self, widget): |
40 | 66 | if self.get_active(): |
41 | | client = GConf.Client.get_default() |
42 | | color = XoColor(client.get_string('/desktop/sugar/user/color')) |
43 | | self._icon.props.xo_color = color |
44 | | logging.debug('KEEPICON: setting xo_color') |
| 67 | self._icon.props.xo_color = self._xo_color |
45 | 68 | else: |
46 | 69 | self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg() |
47 | 70 | self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg() |
48 | 71 | |
49 | 72 | def __enter_notify_event_cb(self, icon, event): |
50 | 73 | if not self.get_active(): |
51 | | self._icon.props.fill_color = style.COLOR_BUTTON_GREY.get_svg() |
| 74 | self._icon.props.xo_color = self._xo_color |
52 | 75 | |
53 | 76 | def __leave_notify_event_cb(self, icon, event): |
54 | 77 | if not self.get_active(): |
| 78 | self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg() |
55 | 79 | self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg() |