Patchwork [bitbake-devel] hob: Search strings and results should be persistent

login
register
mail settings
Submitter Cristiana Voicu
Date March 27, 2013, 3:20 p.m.
Message ID <1364397607-22670-1-git-send-email-cristiana.voicu@intel.com>
Download mbox | patch
Permalink /patch/47043/
State New
Headers show

Comments

Cristiana Voicu - March 27, 2013, 3:20 p.m.
Now, the search results stay until I clear the search field,
so that I can manipulate the search results.

[YOCTO #4112 & #4117]
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
---
 bitbake/lib/bb/ui/crumbs/hobwidget.py            |    9 ++++--
 bitbake/lib/bb/ui/crumbs/packageselectionpage.py |   35 +++++++++++-----------
 bitbake/lib/bb/ui/crumbs/recipeselectionpage.py  |   35 +++++++++++-----------
 3 files changed, 43 insertions(+), 36 deletions(-)

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 17d9cee..51ae782 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -537,14 +537,18 @@  class HobNotebook(gtk.Notebook):
 
     def set_search_entry_editable_cb(self, search, event):
         search.set_editable(True)
-        search.set_text("")
+        text = search.get_text()
+        if text in self.search_names:
+            search.set_text("")
         style = self.search.get_style()
         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):
         page_num = self.get_current_page()
-        self.reset_entry(search, page_num)
+        text = search.get_text()
+        if not text:
+            self.reset_entry(search, page_num)
 
     def reset_entry(self, entry, page_num):
         style = entry.get_style()
@@ -559,6 +563,7 @@  class HobNotebook(gtk.Notebook):
         if search.get_editable() == True:
             search.set_text("")
         search.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
+        search.grab_focus()
 
     def set_page(self, title):
         for child in self.pages:
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
index ce2deab..0bb4cb1 100755
--- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
@@ -180,24 +180,25 @@  class PackageSelectionPage (HobPage):
         self.button_box.pack_end(self.back_button, expand=False, fill=False)
 
     def search_entry_changed(self, entry):
-        current_tab = self.ins.get_current_page()
-        filter = self.pages[current_tab]['filter']
         text = entry.get_text()
-        filter[PackageListModel.COL_NAME] = text
-        self.tables[current_tab].set_model(self.package_model.tree_model(filter, search_data=text))
-        if self.package_model.filtered_nb == 0:
-            if not self.ins.get_nth_page(current_tab).top_bar:
-                self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
-            self.ins.get_nth_page(current_tab).top_bar.show()
-            self.ins.get_nth_page(current_tab).scroll.hide()
-        else:
-            if self.ins.get_nth_page(current_tab).top_bar:
-                self.ins.get_nth_page(current_tab).top_bar.hide()
-            self.ins.get_nth_page(current_tab).scroll.show()
-        if entry.get_text() == '':
-            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
-        else:
-            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
+        if text not in self.ins.search_names:
+            current_tab = self.ins.get_current_page()
+            filter = self.pages[current_tab]['filter']
+            filter[PackageListModel.COL_NAME] = text
+            self.tables[current_tab].set_model(self.package_model.tree_model(filter, search_data=text))
+            if self.package_model.filtered_nb == 0:
+                if not self.ins.get_nth_page(current_tab).top_bar:
+                    self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
+                self.ins.get_nth_page(current_tab).top_bar.show()
+                self.ins.get_nth_page(current_tab).scroll.hide()
+            else:
+                if self.ins.get_nth_page(current_tab).top_bar:
+                    self.ins.get_nth_page(current_tab).top_bar.hide()
+                self.ins.get_nth_page(current_tab).scroll.show()
+            if entry.get_text() == '':
+                entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
+            else:
+                entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
 
     def button_click_cb(self, widget, event):
         path, col = widget.table_tree.get_cursor()
diff --git a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
index aa0cd60..47bb253 100755
--- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
@@ -195,24 +195,25 @@  class RecipeSelectionPage (HobPage):
         button_box.pack_end(self.back_button, expand=False, fill=False)
 
     def search_entry_changed(self, entry):
-        current_tab = self.ins.get_current_page()
-        filter = self.pages[current_tab]['filter']
         text = entry.get_text()
-        filter[RecipeListModel.COL_NAME] = text
-        self.tables[current_tab].set_model(self.recipe_model.tree_model(filter, search_data=text))
-        if self.recipe_model.filtered_nb == 0:
-            if not self.ins.get_nth_page(current_tab).top_bar:
-                self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
-            self.ins.get_nth_page(current_tab).top_bar.show()
-            self.ins.get_nth_page(current_tab).scroll.hide()
-        else:
-            if self.ins.get_nth_page(current_tab).top_bar:
-                self.ins.get_nth_page(current_tab).top_bar.hide()
-            self.ins.get_nth_page(current_tab).scroll.show()
-        if entry.get_text() == '':
-            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
-        else:
-            entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
+        if text not in self.ins.search_names:
+            current_tab = self.ins.get_current_page()
+            filter = self.pages[current_tab]['filter']
+            filter[RecipeListModel.COL_NAME] = text
+            self.tables[current_tab].set_model(self.recipe_model.tree_model(filter, search_data=text))
+            if self.recipe_model.filtered_nb == 0:
+                if not self.ins.get_nth_page(current_tab).top_bar:
+                    self.ins.get_nth_page(current_tab).add_no_result_bar(entry)
+                self.ins.get_nth_page(current_tab).top_bar.show()
+                self.ins.get_nth_page(current_tab).scroll.hide()
+            else:
+                if self.ins.get_nth_page(current_tab).top_bar:
+                    self.ins.get_nth_page(current_tab).top_bar.hide()
+                self.ins.get_nth_page(current_tab).scroll.show()
+            if entry.get_text() == '':
+                entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, False)
+            else:
+                entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, True)
 
     def button_click_cb(self, widget, event):
         path, col = widget.table_tree.get_cursor()