Ticket #4304: sugar.patch

File sugar.patch, 3.0 KB (added by humitos, 11 years ago)
  • src/jarabe/journal/keepicon.py

    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 
    2424
    2525
    2626class KeepIcon(Gtk.ToggleButton):
     27    __gtype_name__ = 'SugarKeepIcon'
     28
    2729    def __init__(self):
    2830        Gtk.ToggleButton.__init__(self)
    2931        self.set_relief(Gtk.ReliefStyle.NONE)
    class KeepIcon(Gtk.ToggleButton): 
    3537        self.connect('toggled', self.__toggled_cb)
    3638        self.connect('leave-notify-event', self.__leave_notify_event_cb)
    3739        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)
    3860
    3961    def __toggled_cb(self, widget):
    4062        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
    4464            logging.debug('KEEPICON: setting xo_color')
    4565        else:
    4666            self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
    class KeepIcon(Gtk.ToggleButton): 
    4868
    4969    def __enter_notify_event_cb(self, icon, event):
    5070        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
    5272
    5373    def __leave_notify_event_cb(self, icon, event):
    5474        if not self.get_active():
    5575            self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
     76        else:
     77            self._icon.props.xo_color = self._xo_color