Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-12-13 21:43:14 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-12-17 15:15:20 (GMT)
commitdc027d6253c467d8f4459b90919b358629cff829 (patch)
tree05e179c046691e4f98a7fc2fea834480da147839
parent52076ffdd0d7d107e86b7559955cc6a56fd3bc14 (diff)
Journal details view: Style KeepIcon - SL #4304
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. - Remove debug log Signed-off-by: Manuel Kaufmann <humitos@gmail.com> Signed-off-by: Manuel Quiñones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/jarabe/journal/keepicon.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/jarabe/journal/keepicon.py b/src/jarabe/journal/keepicon.py
index 16e3a57..3515194 100644
--- a/src/jarabe/journal/keepicon.py
+++ b/src/jarabe/journal/keepicon.py
@@ -16,7 +16,6 @@
from gi.repository import Gtk
from gi.repository import GConf
-import logging
from sugar3.graphics.icon import Icon
from sugar3.graphics import style
@@ -24,6 +23,8 @@ from sugar3.graphics.xocolor import XoColor
class KeepIcon(Gtk.ToggleButton):
+ __gtype_name__ = 'SugarKeepIcon'
+
def __init__(self):
Gtk.ToggleButton.__init__(self)
self.set_relief(Gtk.ReliefStyle.NONE)
@@ -35,21 +36,42 @@ class KeepIcon(Gtk.ToggleButton):
self.connect('toggled', self.__toggled_cb)
self.connect('leave-notify-event', self.__leave_notify_event_cb)
self.connect('enter-notify-event', self.__enter_notify_event_cb)
+ self.connect('button-press-event', self.__button_press_event_cb)
+ self.connect('button-release-event', self.__button_release_event_cb)
+
+ client = GConf.Client.get_default()
+ self._xo_color = XoColor(client.get_string(
+ '/desktop/sugar/user/color'))
+
+ def do_get_preferred_width(self):
+ return 0, style.GRID_CELL_SIZE
+
+ def do_get_preferred_height(self):
+ return 0, style.GRID_CELL_SIZE
+
+ def __button_press_event_cb(self, widget, event):
+ # We need to use a custom CSS class because in togglebuttons
+ # the 'active' class doesn't only match the button press, they
+ # can be left in the active state.
+ style_context = self.get_style_context()
+ style_context.add_class('toggle-press')
+
+ def __button_release_event_cb(self, widget, event):
+ style_context = self.get_style_context()
+ style_context.remove_class('toggle-press')
def __toggled_cb(self, widget):
if self.get_active():
- client = GConf.Client.get_default()
- color = XoColor(client.get_string('/desktop/sugar/user/color'))
- self._icon.props.xo_color = color
- logging.debug('KEEPICON: setting xo_color')
+ self._icon.props.xo_color = self._xo_color
else:
self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
def __enter_notify_event_cb(self, icon, event):
if not self.get_active():
- self._icon.props.fill_color = style.COLOR_BUTTON_GREY.get_svg()
+ self._icon.props.xo_color = self._xo_color
def __leave_notify_event_cb(self, icon, event):
if not self.get_active():
+ self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()