Ticket #4304: 0001-Journal-details-view-Style-KeepIcon-SL-4304.patch

File 0001-Journal-details-view-Style-KeepIcon-SL-4304.patch, 3.7 KB (added by manuq, 11 years ago)

Shell patch based on humitos one.

  • src/jarabe/journal/keepicon.py

    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 
    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        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')
    3864
    3965    def __toggled_cb(self, widget):
    4066        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
    4568        else:
    4669            self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
    4770            self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
    4871
    4972    def __enter_notify_event_cb(self, icon, event):
    5073        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
    5275
    5376    def __leave_notify_event_cb(self, icon, event):
    5477        if not self.get_active():
     78            self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
    5579            self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()