bitbake: hob: Search strings and results should be persistent
authorCristiana Voicu <cristiana.voicu@intel.com>
Wed, 27 Mar 2013 15:20:07 +0000 (17:20 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 29 Mar 2013 10:41:25 +0000 (10:41 +0000)
Now, the search results stay until I clear the search field,
so that I can manipulate the search results.

[YOCTO #4112 & #4117]
(Bitbake rev: d880ce966ca825aa66a23755fcb47497fb3f26c3)

Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/ui/crumbs/hobwidget.py
bitbake/lib/bb/ui/crumbs/packageselectionpage.py
bitbake/lib/bb/ui/crumbs/recipeselectionpage.py

index 17d9cee..51ae782 100644 (file)
@@ -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:
index 3b00ff2..781d579 100755 (executable)
@@ -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()
index aa0cd60..47bb253 100755 (executable)
@@ -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()