From df2847a371210e1773d7e062ead312e125fa7f0c Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Fri, 23 Mar 2012 17:23:00 -0700 Subject: [PATCH] lib/bb/ui/crumbs/hobwidget: HobAltButton different visual when insensitive Use an alternative, grey, colour when the button is insensitive so that the insensitivity is easily noticed. (Bitbake rev: 53af6a962aa2f6b4d68d59792be9c7f33cf887b4) Signed-off-by: Joshua Lock Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hobwidget.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py index 1213b11..7988975 100644 --- a/bitbake/lib/bb/ui/crumbs/hobwidget.py +++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py @@ -222,9 +222,32 @@ class HobAltButton(gtk.Button): A gtk.Button subclass which has no relief, and so is more discrete """ def __init__(self, label): - gtk.Button.__init__(self, "%s" % (HobColors.PALE_BLUE, gobject.markup_escape_text(label))) - self.child.set_use_markup(True) + gtk.Button.__init__(self) + self.text = label + self.set_text() self.set_relief(gtk.RELIEF_NONE) + self.connect("state-changed", self.desensitise_on_state_change_cb) + + """ + A callback for the state-changed event to ensure the text is displayed + differently when the widget is not sensitive + """ + def desensitise_on_state_change_cb(self, widget, state): + if widget.get_state() == gtk.STATE_INSENSITIVE: + self.set_text(False) + else: + self.set_text(True) + + """ + Set the button label with an appropriate colour for the current widget state + """ + def set_text(self, sensitive=True): + if sensitive: + colour = HobColors.PALE_BLUE + else: + colour = HobColors.LIGHT_GRAY + self.set_label("%s" % (colour, gobject.markup_escape_text(self.text))) + self.child.set_use_markup(True) class HobImageButton(gtk.Button): """ -- 2.7.4