Patchwork [bitbake-devel,3/6] ui/crumbs/hobwidget: implement HobInfoButton per Hob interaction design

login
register
mail settings
Submitter Joshua Lock
Date March 3, 2012, 12:39 a.m.
Message ID <78a24cabc5d886fe39cddbc3dcab58e0fd8d9614.1330734444.git.josh@linux.intel.com>
Download mbox | patch
Permalink /patch/22607/
State Accepted
Commit 43f33dcd6b7d1a08651cdf0715c2c2a9d488b103
Headers show

Comments

Joshua Lock - March 3, 2012, 12:39 a.m.
This button-like widget will display a persistent tooltip with the
supplied Pango Markup when it is clicked by the user. This widget features
prominently in the interaction design to offer help in a more prominent
manner.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
---
 lib/bb/ui/crumbs/hobwidget.py |   49 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
Shane Wang - March 5, 2012, 10:31 p.m.
Joshua Lock wrote onĀ 2012-03-02:

> This button-like widget will display a persistent tooltip with the
> supplied Pango Markup when it is clicked by the user. This widget
> features prominently in the interaction design to offer help in a more
> prominent manner.
> 
> Signed-off-by: Joshua Lock <josh@linux.intel.com>

ACK.

--
Shane

Patch

diff --git a/lib/bb/ui/crumbs/hobwidget.py b/lib/bb/ui/crumbs/hobwidget.py
index 9afbfdb..f4ff1dc 100644
--- a/lib/bb/ui/crumbs/hobwidget.py
+++ b/lib/bb/ui/crumbs/hobwidget.py
@@ -23,6 +23,7 @@  import gobject
 import os
 import os.path
 from bb.ui.crumbs.hobcolor import HobColors
+from bb.ui.crumbs.persistenttooltip import PersistentTooltip
 
 class hwc:
 
@@ -311,3 +312,51 @@  class HobXpmLabelButtonBox(gtk.EventBox):
         """ Hide items - first time """
         pass
 
+class HobInfoButton(gtk.EventBox):
+    """
+    This class implements a button-like widget per the Hob visual and UX designs
+    which will display a persistent tooltip, with the contents of tip_markup, when
+    clicked.
+
+    tip_markup: the Pango Markup to be displayed in the persistent tooltip
+    """
+    def __init__(self, tip_markup, parent=None):
+        gtk.EventBox.__init__(self)
+        self.image = gtk.Image()
+        self.image.set_from_file(hic.ICON_INFO_DISPLAY_FILE)
+        self.image.show()
+        self.add(self.image)
+
+        self.set_events(gtk.gdk.BUTTON_RELEASE |
+                        gtk.gdk.ENTER_NOTIFY_MASK |
+                        gtk.gdk.LEAVE_NOTIFY_MASK)
+
+        self.ptip = PersistentTooltip(tip_markup)
+
+        if parent:
+            self.ptip.set_parent(parent)
+            self.ptip.set_transient_for(parent)
+            self.ptip.set_destroy_with_parent(True)
+
+        self.connect("button-release-event", self.button_release_cb)
+        self.connect("enter-notify-event", self.mouse_in_cb)
+        self.connect("leave-notify-event", self.mouse_out_cb)
+
+    """
+    When the mouse click is released emulate a button-click and show the associated
+    PersistentTooltip
+    """
+    def button_release_cb(self, widget, event):
+        self.ptip.show()
+
+    """
+    Change to the prelight image when the mouse enters the widget
+    """
+    def mouse_in_cb(self, widget, event):
+        self.image.set_from_file(hic.ICON_INFO_HOVER_FILE)
+
+    """
+    Change to the stock image when the mouse enters the widget
+    """
+    def mouse_out_cb(self, widget, event):
+        self.image.set_from_file(hic.ICON_INFO_DISPLAY_FILE)