ui/crumbs/hobwidget: add clear icon to search entries in HobNotebook

It's a common pattern on Gtk+ desktops to be able to clear a search/filter
entry using an icon in that entry.

(From Poky rev: 6394283522ef2f259397d8bd294291fb20354c8b)

(Bitbake rev: f55372d542995fd0797b11f42dcfdbe57858449a)

Signed-off-by: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Lock 2012-03-20 09:50:15 -07:00 committed by Richard Purdie
parent b6817986df
commit c9202eb042
1 changed files with 14 additions and 5 deletions

View File

@ -622,6 +622,8 @@ class HobNotebook(gtk.VBox):
self.search.set_style(style)
self.search.set_text(name)
self.search.set_editable(False)
self.search.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, gtk.STOCK_CLEAR)
self.search.connect("icon-release", self.set_search_entry_clear_cb)
self.search.show()
self.align = gtk.Alignment(xalign=1.0, yalign=0.7)
self.align.add(self.search)
@ -682,9 +684,16 @@ class HobNotebook(gtk.VBox):
style.text[gtk.STATE_NORMAL] = self.get_colormap().alloc_color(HobColors.BLACK, False, False)
search.set_style(style)
def set_search_entry_reset_cb(self, search, event):
style = search.get_style()
def reset_entry(self, entry):
style = entry.get_style()
style.text[gtk.STATE_NORMAL] = self.get_colormap().alloc_color(HobColors.GRAY, False, False)
search.set_style(style)
search.set_text(self.search_name)
search.set_editable(False)
entry.set_style(style)
entry.set_text(self.search_name)
entry.set_editable(False)
def set_search_entry_reset_cb(self, search, event):
self.reset_entry(search)
def set_search_entry_clear_cb(self, search, icon_pos, event):
self.reset_entry(search)