Patchwork [bitbake-devel] hob: giving focus to the search field loses the table sorting

login
register
mail settings
Submitter Cristiana Voicu
Date April 1, 2013, 10:36 a.m.
Message ID <1364812585-25371-1-git-send-email-cristiana.voicu@intel.com>
Download mbox | patch
Permalink /patch/47199/
State New
Headers show

Comments

Cristiana Voicu - April 1, 2013, 10:36 a.m.
Giving focus to the search text field should not impact the table
sorting.

[YOCTO #4113]
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
---
 bitbake/lib/bb/ui/crumbs/hoblistmodel.py         |    2 +-
 bitbake/lib/bb/ui/crumbs/hobwidget.py            |    4 ++
 bitbake/lib/bb/ui/crumbs/packageselectionpage.py |   45 +++++++++++++---------
 bitbake/lib/bb/ui/crumbs/recipeselectionpage.py  |   45 +++++++++++++---------
 4 files changed, 59 insertions(+), 37 deletions(-)

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
index 67d40e0..0bd9734 100644
--- a/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
+++ b/bitbake/lib/bb/ui/crumbs/hoblistmodel.py
@@ -91,7 +91,7 @@  class PackageListModel(gtk.ListStore):
         for key in filter.keys():
             if key == self.COL_NAME:
                 if filter[key] != 'Search packages by name':
-                    if filter[key] not in name:
+                    if name and filter[key] not in name:
                         return False
             else:
                 if model.get_value(it, key) not in filter[key]:
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index 9b4261a..1d1ae1a 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -481,6 +481,8 @@  class HobNotebook(gtk.Notebook):
         self.pages = []
 
         self.search = None
+        self.search_focus = False
+        self.page_changed = False
 
         self.connect("switch-page", self.page_changed_cb)
 
@@ -494,6 +496,7 @@  class HobNotebook(gtk.Notebook):
                 lbl.set_active(False)
 
         if self.search:
+            self.page_changed = True
             self.reset_entry(self.search, page_num)
 
     def append_page(self, child, tab_label, tab_tooltip=None):
@@ -537,6 +540,7 @@  class HobNotebook(gtk.Notebook):
                 child.set_count(0)
 
     def set_search_entry_editable_cb(self, search, event):
+        self.search_focus = True
         search.set_editable(True)
         text = search.get_text()
         if text in self.search_names:
diff --git a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
index 781d579..89f67c6 100755
--- a/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/packageselectionpage.py
@@ -181,24 +181,33 @@  class PackageSelectionPage (HobPage):
 
     def search_entry_changed(self, entry):
         text = entry.get_text()
-        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)
+        if self.ins.search_focus:
+            self.ins.search_focus = False
+        elif self.ins.page_changed:
+            self.ins.page_change = False
+            self.filter_search(entry)
+        elif text not in self.ins.search_names:
+            self.filter_search(entry)
+
+    def filter_search(self, entry):
+        text = entry.get_text()
+        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 47bb253..b29de2c 100755
--- a/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
+++ b/bitbake/lib/bb/ui/crumbs/recipeselectionpage.py
@@ -196,24 +196,33 @@  class RecipeSelectionPage (HobPage):
 
     def search_entry_changed(self, entry):
         text = entry.get_text()
-        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)
+        if self.ins.search_focus:
+            self.ins.search_focus = False
+        elif self.ins.page_changed:
+            self.ins.page_change = False
+            self.filter_search(entry)
+        elif text not in self.ins.search_names:
+            self.filter_search(entry)
+
+    def filter_search(self, entry):
+        text = entry.get_text()
+        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()