diff options
author | Manuel Quiñones <manuq@laptop.org> | 2012-10-15 14:28:44 (GMT) |
---|---|---|
committer | Manuel Quiñones <manuq@laptop.org> | 2012-10-15 20:25:18 (GMT) |
commit | e4e1881662f773ae8dedc2cea87396f9047ed2fd (patch) | |
tree | 8c8030be55b44fb6b4fd197071dfb2904d8d2ef3 | |
parent | e591d9aa80a2ccbf90bac2f61b540c949f69bad6 (diff) |
CanvasIcon: use set_state_flags and unset_state_flags instead of deprecated set_state - SL #3989
set_state is deprecated [1] and using flags improves the code and
makes it less error prone, because there is no need to handle the
prelight state in a variable _in_prelight_state .
[1] http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-state
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r-- | src/sugar3/graphics/icon.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py index 95a72b8..5863118 100644 --- a/src/sugar3/graphics/icon.py +++ b/src/sugar3/graphics/icon.py @@ -694,8 +694,6 @@ class CanvasIcon(EventIcon): def __init__(self, **kwargs): EventIcon.__init__(self, **kwargs) - self._in_prelight_state = False - self.connect('enter-notify-event', self.__enter_notify_event_cb) self.connect('leave-notify-event', self.__leave_notify_event_cb) self.connect('button-press-event', self.__button_press_event_cb) @@ -716,32 +714,27 @@ class CanvasIcon(EventIcon): EventIcon.do_draw(self, cr) def __enter_notify_event_cb(self, icon, event): - self._in_prelight_state = True - if self.get_state() != Gtk.StateFlags.ACTIVE: - self.set_state(Gtk.StateFlags.PRELIGHT) + self.set_state_flags(self.get_state_flags() | Gtk.StateFlags.PRELIGHT, + clear=True) def __leave_notify_event_cb(self, icon, event): if self.palette and self.palette.is_up(): return - self._in_prelight_state = False - if self.get_state() != Gtk.StateFlags.ACTIVE: - self.set_state(False) + self.unset_state_flags(Gtk.StateFlags.PRELIGHT) def __button_press_event_cb(self, icon, event): - self.set_state(Gtk.StateFlags.ACTIVE) + self.set_state_flags(self.get_state_flags() | Gtk.StateFlags.ACTIVE, + clear=True) def __button_release_event_cb(self, icon, event): - if self._in_prelight_state: - self.set_state(Gtk.StateFlags.PRELIGHT) - else: - self.set_state(False) + self.unset_state_flags(Gtk.StateFlags.ACTIVE) def __palette_popup_cb(self, palette): - self.set_state(Gtk.StateFlags.PRELIGHT) + self.set_state_flags(Gtk.StateFlags.PRELIGHT, clear=True) def __palette_popdown_cb(self, palette): - self.set_state(False) + self.unset_state_flags(Gtk.StateFlags.PRELIGHT) class CellRendererIcon(Gtk.CellRenderer): |