Palette Menu Item: set/unset INSENSITIVE state flag - SL #4144

The theme will display the insensitive items grayed out.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
Manuel Quiñones 2012-11-05 09:33:00 -03:00
parent 8f4474f3f5
commit f0fe248e30

View File

@ -43,7 +43,6 @@ class PaletteMenuItem(Gtk.EventBox):
def __init__(self, text_label=None, icon_name=None, text_maxlen=60, def __init__(self, text_label=None, icon_name=None, text_maxlen=60,
xo_color=None, file_name=None): xo_color=None, file_name=None):
Gtk.EventBox.__init__(self) Gtk.EventBox.__init__(self)
self._sensitive = True
self.set_above_child(True) self.set_above_child(True)
self.icon = None self.icon = None
@ -105,17 +104,20 @@ class PaletteMenuItem(Gtk.EventBox):
self._hbox.reorder_child(icon, 0) self._hbox.reorder_child(icon, 0)
def set_sensitive(self, sensitive): def set_sensitive(self, sensitive):
if self._sensitive == sensitive: is_sensitive = bool(not self.get_state_flags() & \
Gtk.StateFlags.INSENSITIVE)
if is_sensitive == sensitive:
return return
self._sensitive = sensitive
if sensitive: if sensitive:
self.handler_unblock(self.id_bt_release_cb) self.handler_unblock(self.id_bt_release_cb)
self.handler_unblock(self.id_enter_notify_cb) self.handler_unblock(self.id_enter_notify_cb)
self.handler_unblock(self.id_leave_notify_cb) self.handler_unblock(self.id_leave_notify_cb)
self.unset_state_flags(Gtk.StateFlags.INSENSITIVE)
else: else:
self.handler_block(self.id_bt_release_cb) self.handler_block(self.id_bt_release_cb)
self.handler_block(self.id_enter_notify_cb) self.handler_block(self.id_enter_notify_cb)
self.handler_block(self.id_leave_notify_cb) self.handler_block(self.id_leave_notify_cb)
self.modify_bg(Gtk.StateType.NORMAL, self.set_state_flags(self.get_state_flags() | \
style.COLOR_BLACK.get_gdk_color()) Gtk.StateFlags.INSENSITIVE,
clear=True)