Patchwork [bitbake-devel,7/9] lib/bb/ui/crumbs/hobwidget: add HobButton widget for the primary action

login
register
mail settings
Submitter Joshua Lock
Date March 22, 2012, 11:31 p.m.
Message ID <132d0f52c83344c7ebb2fb972ff814038db3ff75.1332458487.git.josh@linux.intel.com>
Download mbox | patch
Permalink /patch/24213/
State Accepted
Commit 9aa477f7bd16d3e360bf9b51c1f9d5032a6c5288
Headers show

Comments

Joshua Lock - March 22, 2012, 11:31 p.m.
The design uses a big, bold labelled, orange button for the primary action
on each dialogue. The HobButton implements this design as a reusable widget.

HobButton makes use of Pango Markup to use a relative size, x-large, for
the button text to ensure it's relative to the system configured font
sizes.

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

Patch

diff --git a/lib/bb/ui/crumbs/hobwidget.py b/lib/bb/ui/crumbs/hobwidget.py
index b93e9d4..9d144c9 100644
--- a/lib/bb/ui/crumbs/hobwidget.py
+++ b/lib/bb/ui/crumbs/hobwidget.py
@@ -196,6 +196,26 @@  def soften_color(widget, state=gtk.STATE_NORMAL):
     color.blue = color.blue * blend + style.base[state].blue * (1.0 - blend)
     return color.to_string()
 
+class HobButton(gtk.Button):
+    """
+    A gtk.Button subclass which follows the visual design of Hob for primary
+    action buttons
+
+    label: the text to display as the button's label
+    """
+    def __init__(self, label):
+        gtk.Button.__init__(self, "<span size='x-large'><b>%s</b></span>" % gobject.markup_escape_text(label))
+        self.child.set_use_markup(True)
+
+        style = self.get_style()
+        button_color = gtk.gdk.Color(HobColors.ORANGE)
+        self.modify_bg(gtk.STATE_NORMAL, button_color)
+        self.modify_bg(gtk.STATE_PRELIGHT, button_color)
+        self.modify_bg(gtk.STATE_SELECTED, button_color)
+
+        self.set_flags(gtk.CAN_DEFAULT)
+        self.grab_default()
+
 class HobAltButton(gtk.Button):
     """
     A gtk.Button subclass which has no relief, and so is more discrete