From c2f71564c61ef6deaed356d37741d5733d5ffae5 Mon Sep 17 00:00:00 2001 From: B Stack Date: Mon, 16 Mar 2020 08:23:20 -0400 Subject: WIP: add search widget but it is not connected to the listview yet --- src/cat_mode/mime_editor_cat_mode.py | 7 +++++++ src/cat_mode/ui_cat_mode.glade | 33 +++++++++++++++++++++++++++------ src/common/mime_view.py | 5 +++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/cat_mode/mime_editor_cat_mode.py b/src/cat_mode/mime_editor_cat_mode.py index fcd1ed8..7b216d7 100644 --- a/src/cat_mode/mime_editor_cat_mode.py +++ b/src/cat_mode/mime_editor_cat_mode.py @@ -51,6 +51,8 @@ class CategoriesView(gtk_common.CategoriesWidget): #register callback tree_selection = self.categories_view.get_selection() tree_selection.connect("changed", self.on_selection_changes) + self.searchbox = builder.get_object("searchbox") + self.searchbox.connect("search-changed", self.on_searchbox_changed) def _fill_list_store(self): categories = sorted((_(name), cat ,id_) @@ -77,6 +79,10 @@ class CategoriesView(gtk_common.CategoriesWidget): self.on_category_changed(cat_ids) + def on_searchbox_changed(self, search_widget): + print("INSIDE on_searchbox_changed, value ", '"' + search_widget.get_text() + '"' ) + print(self) + #self.mime_view.filter_category(category_id[0]) class AddAppDialog: def __init__(self, builder, parent_window, on_add_dialog_apply): @@ -118,6 +124,7 @@ class AddAppDialog: return False #!!! def on_custom_entry_changed(self, *args): + print("INSIDE on_custom_entry_changed") text = self.custom_entry.get_text() if text != self.cline_text: self.cline_text = text diff --git a/src/cat_mode/ui_cat_mode.glade b/src/cat_mode/ui_cat_mode.glade index 10d1bf9..67c537d 100644 --- a/src/cat_mode/ui_cat_mode.glade +++ b/src/cat_mode/ui_cat_mode.glade @@ -1,5 +1,5 @@ - + @@ -8,6 +8,9 @@ True True normal + + + False @@ -181,6 +184,9 @@ 400 dialog True + + + False @@ -330,7 +336,18 @@ False vertical - + + True + True + edit-find-symbolic + False + False + + + False + True + 0 + @@ -362,6 +379,9 @@ 1 + + + True @@ -374,6 +394,7 @@ True True mimetypes_view_adj + 1 True True horizontal @@ -389,7 +410,7 @@ True True - 2 + 3 @@ -409,8 +430,8 @@ Show only associated types True True - False False + False 0 True @@ -431,9 +452,9 @@ gtk-edit True True + False True True - False False @@ -447,9 +468,9 @@ gtk-revert-to-saved True True + False True True - False False diff --git a/src/common/mime_view.py b/src/common/mime_view.py index 6a1eb7c..6470ebd 100644 --- a/src/common/mime_view.py +++ b/src/common/mime_view.py @@ -60,6 +60,7 @@ class MimeView: def _init_filters(self): self.ordered_data_filters = [] #order may be matter self.data_filters = {} # save reference by name + self.search_filters = {} #add category filter category_filter = data_filter.CategoryFilter(self.MIME_CATEGORY, @@ -71,6 +72,10 @@ class MimeView: self.ordered_data_filters.append(data_filter) self.data_filters[filter_name] = data_filter + def _set_search_filter(self, filter_name, data_filter): + self.data_filters[filter_name].set_params(**kwargs) + self.filter_model.refilter() + def _init_model(self): """liststore -> filter -> sort -> view""" self.list_store = Gtk.ListStore(*self.LIST_STORE_COLUMN_TYPES) -- cgit