summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobwidget.py53
1 files changed, 33 insertions, 20 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 7988975621..8936f0a42a 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -205,49 +205,62 @@ class HobButton(gtk.Button):
205 label: the text to display as the button's label 205 label: the text to display as the button's label
206 """ 206 """
207 def __init__(self, label): 207 def __init__(self, label):
208 gtk.Button.__init__(self, "<span size='x-large'><b>%s</b></span>" % gobject.markup_escape_text(label)) 208 gtk.Button.__init__(self, label)
209 self.child.set_use_markup(True) 209 HobButton.style_button(self)
210 210
211 style = self.get_style() 211 @staticmethod
212 def style_button(button):
213 style = button.get_style()
212 button_color = gtk.gdk.Color(HobColors.ORANGE) 214 button_color = gtk.gdk.Color(HobColors.ORANGE)
213 self.modify_bg(gtk.STATE_NORMAL, button_color) 215 button.modify_bg(gtk.STATE_NORMAL, button_color)
214 self.modify_bg(gtk.STATE_PRELIGHT, button_color) 216 button.modify_bg(gtk.STATE_PRELIGHT, button_color)
215 self.modify_bg(gtk.STATE_SELECTED, button_color) 217 button.modify_bg(gtk.STATE_SELECTED, button_color)
218
219 button.set_flags(gtk.CAN_DEFAULT)
220 button.grab_default()
216 221
217 self.set_flags(gtk.CAN_DEFAULT) 222 label = "<span size='x-large'><b>%s</b></span>" % gobject.markup_escape_text(button.get_label())
218 self.grab_default() 223 button.set_label(label)
224 button.child.set_use_markup(True)
219 225
220class HobAltButton(gtk.Button): 226class HobAltButton(gtk.Button):
221 """ 227 """
222 A gtk.Button subclass which has no relief, and so is more discrete 228 A gtk.Button subclass which has no relief, and so is more discrete
223 """ 229 """
224 def __init__(self, label): 230 def __init__(self, label):
225 gtk.Button.__init__(self) 231 gtk.Button.__init__(self, label)
226 self.text = label 232 HobAltButton.style_button(self)
227 self.set_text()
228 self.set_relief(gtk.RELIEF_NONE)
229 self.connect("state-changed", self.desensitise_on_state_change_cb)
230 233
231 """ 234 """
232 A callback for the state-changed event to ensure the text is displayed 235 A callback for the state-changed event to ensure the text is displayed
233 differently when the widget is not sensitive 236 differently when the widget is not sensitive
234 """ 237 """
235 def desensitise_on_state_change_cb(self, widget, state): 238 @staticmethod
236 if widget.get_state() == gtk.STATE_INSENSITIVE: 239 def desensitise_on_state_change_cb(button, state):
237 self.set_text(False) 240 if button.get_state() == gtk.STATE_INSENSITIVE:
241 HobAltButton.set_text(button, False)
238 else: 242 else:
239 self.set_text(True) 243 HobAltButton.set_text(button, True)
240 244
241 """ 245 """
242 Set the button label with an appropriate colour for the current widget state 246 Set the button label with an appropriate colour for the current widget state
243 """ 247 """
244 def set_text(self, sensitive=True): 248 @staticmethod
249 def set_text(button, sensitive=True):
245 if sensitive: 250 if sensitive:
246 colour = HobColors.PALE_BLUE 251 colour = HobColors.PALE_BLUE
247 else: 252 else:
248 colour = HobColors.LIGHT_GRAY 253 colour = HobColors.LIGHT_GRAY
249 self.set_label("<span color='%s'><b>%s</b></span>" % (colour, gobject.markup_escape_text(self.text))) 254 button.set_label("<span color='%s'><b>%s</b></span>" % (colour, gobject.markup_escape_text(button.text)))
250 self.child.set_use_markup(True) 255 button.child.set_use_markup(True)
256
257 @staticmethod
258 def style_button(button):
259 button.text = button.get_label()
260 button.connect("state-changed", HobAltButton.desensitise_on_state_change_cb)
261 HobAltButton.set_text(button)
262 button.child.set_use_markup(True)
263 button.set_relief(gtk.RELIEF_NONE)
251 264
252class HobImageButton(gtk.Button): 265class HobImageButton(gtk.Button):
253 """ 266 """