[bitbake-devel] [PATCH 2/9] lib/bb/ui/crumbs/hobwidget: HobAltButton different visual when insensitive

Joshua Lock josh at linux.intel.com
Sat Mar 24 00:23:00 UTC 2012


Use an alternative, grey, colour when the button is insensitive so that
the insensitivity is easily noticed.

Signed-off-by: Joshua Lock <josh at linux.intel.com>
---
 lib/bb/ui/crumbs/hobwidget.py |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/bb/ui/crumbs/hobwidget.py b/lib/bb/ui/crumbs/hobwidget.py
index 020c5e2..6b8fc1b 100644
--- a/lib/bb/ui/crumbs/hobwidget.py
+++ b/lib/bb/ui/crumbs/hobwidget.py
@@ -221,9 +221,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, "<span color='%s'><b>%s</b></span>" % (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("<span color='%s'><b>%s</b></span>" % (colour, gobject.markup_escape_text(self.text)))
+        self.child.set_use_markup(True)
 
 class HobImageButton(gtk.Button):
     """
-- 
1.7.7.6





More information about the bitbake-devel mailing list