From af566aaa85a790f37ee3f3499b5b8f23eb0c3ace Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Thu, 13 Dec 2012 18:43:14 -0300
Subject: [PATCH sugar] Journal Detailed View: Favourite Icon (KeepIcon)
styled properly SL #4304
Use the same behaviour as in Journal List View for the Favourite Icon.
In the List View this behaviour is done by CellRendererIcon, but in
Detailed View this is handled by the
'jarabe.journal.keepicon.KeepIcon' class.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
---
src/jarabe/journal/keepicon.py | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/jarabe/journal/keepicon.py b/src/jarabe/journal/keepicon.py
index 16e3a57..3b22f1f 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 | client = GConf.Client.get_default() |
| 44 | self._xo_color = XoColor(client.get_string( |
| 45 | '/desktop/sugar/user/color')) |
| 46 | |
| 47 | def do_get_preferred_width(self): |
| 48 | return 0, style.GRID_CELL_SIZE |
| 49 | |
| 50 | def do_get_preferred_height(self): |
| 51 | return 0, style.GRID_CELL_SIZE |
| 52 | |
| 53 | def __button_press_event_cb(self, widget, event): |
| 54 | self.override_background_color( |
| 55 | Gtk.StateFlags.ACTIVE, |
| 56 | style.COLOR_ZOOM_VIEWS_ACTIVE.get_gdk_rgba_color()) |
| 57 | |
| 58 | def __button_release_event_cb(self, widget, event): |
| 59 | self.override_background_color(Gtk.StateFlags.ACTIVE, None) |
38 | 60 | |
39 | 61 | def __toggled_cb(self, widget): |
40 | 62 | 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 |
| 63 | self._icon.props.xo_color = self._xo_color |
44 | 64 | logging.debug('KEEPICON: setting xo_color') |
45 | 65 | else: |
46 | 66 | self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg() |
… |
… |
class KeepIcon(Gtk.ToggleButton): |
48 | 68 | |
49 | 69 | def __enter_notify_event_cb(self, icon, event): |
50 | 70 | if not self.get_active(): |
51 | | self._icon.props.fill_color = style.COLOR_BUTTON_GREY.get_svg() |
| 71 | self._icon.props.xo_color = self._xo_color |
52 | 72 | |
53 | 73 | def __leave_notify_event_cb(self, icon, event): |
54 | 74 | if not self.get_active(): |
55 | 75 | self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg() |
| 76 | else: |
| 77 | self._icon.props.xo_color = self._xo_color |