From: Christian Heller Date: Mon, 11 Nov 2024 00:29:28 +0000 (+0100) Subject: Browser: Only use single FilterInputs everywhere. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/%27%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28escapeHTML%28span%5B2%5D%29%29;%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20chunks.push%28%27?a=commitdiff_plain;p=stable_plom Browser: Only use single FilterInputs everywhere. --- diff --git a/browser.py b/browser.py index eeb78f1..df219d2 100755 --- a/browser.py +++ b/browser.py @@ -208,6 +208,7 @@ class SorterAndFiltererOrder: def __init__(self, as_list: list[SorterAndFilterer]) -> None: self._list = as_list + self.filter_inputs: FilterInputs = {} def __eq__(self, other) -> bool: return self._list == other._list @@ -479,14 +480,14 @@ class GalleryConfig(): entry.remove_css_class('temp') text: str = entry.get_buffer().get_text() if '' != text.rstrip(): - self.filter_inputs[sorter.name] = text - elif sorter.name in self.filter_inputs: - del self.filter_inputs[sorter.name] + self.order.filter_inputs[sorter.name] = text + elif sorter.name in self.order.filter_inputs: + del self.order.filter_inputs[sorter.name] self._filter_inputs_changed = True sorter: SorterAndFilterer = list_item.props.item sorter.setup_on_bind(list_item.props.child, on_filter_activate, - self.filter_inputs.get(sorter.name, ''), + self.order.filter_inputs.get(sorter.name, ''), self._gallery_items_attrs[sorter.name]) def select_sort_order(_a, _b, _c) -> None: @@ -507,11 +508,12 @@ class GalleryConfig(): self.order.sync_from(self._tmp_order) self._tmp_order = None self._gallery_request_update(build_grid=True) + if self._filter_inputs_changed: + self._gallery_request_update(build_grid=True) self._gallery_update_settings( per_row=self._btn_per_row.get_value_as_int(), by_1st=self._btn_by_1st.get_active(), show_dirs=self._btn_show_dirs.get_active(), - filter_inputs=self.filter_inputs.copy(), recurse_dirs=self._btn_recurse.get_active()) self._gallery_request_update(select=True) self._set_recurse_changed = False @@ -522,7 +524,6 @@ class GalleryConfig(): self._gallery_request_update(load=True) self._btn_apply.set_sensitive(True) - self.filter_inputs: FilterInputs = {} self._filter_inputs_changed = False self._set_recurse_changed = False self._last_selected: Optional[Gtk.Widget] = None @@ -665,7 +666,6 @@ class Gallery: self._on_selection_change = on_selection_change self._bookmarks_db, self._cache_db = bookmarks_db, cache_db self._sort_order = sort_order - self._filter_inputs: FilterInputs = {} self._img_dir_path = '' self._shall_load = False @@ -738,15 +738,13 @@ class Gallery: show_dirs: Optional[bool] = None, recurse_dirs: Optional[bool] = None, img_dir_path: Optional[str] = None, - filter_inputs: Optional[FilterInputs] = None ) -> None: """Set Gallery setup fields, request appropriate updates.""" for val, attr_name in [(per_row, '_per_row'), (by_1st, '_by_1st'), (show_dirs, '_show_dirs'), (recurse_dirs, '_recurse_dirs'), - (img_dir_path, '_img_dir_path'), - (filter_inputs, '_filter_inputs')]: + (img_dir_path, '_img_dir_path')]: if val is not None and getattr(self, attr_name) != val: setattr(self, attr_name, val) if attr_name in {'_recurse_dirs', '_img_dir_path'}: @@ -916,11 +914,11 @@ class Gallery: return False return True - if attr_name not in self._filter_inputs: + if attr_name not in self._sort_order.filter_inputs: return True if val is None: return False - pattern = self._filter_inputs[attr_name] + pattern = self._sort_order.filter_inputs[attr_name] if attr_name in number_attributes: if not passes_number_filter(attr_name, pattern, val): return False @@ -1291,8 +1289,7 @@ class MainWindow(Gtk.Window): # only now we're ready for actually running the gallery GLib.idle_add(lambda: self.gallery.update_settings( - img_dir_path=self.app.img_dir_absolute, - filter_inputs=self.conf.filter_inputs.copy())) + img_dir_path=self.app.img_dir_absolute)) def on_focus_change(self) -> None: """Handle reactions on focus changes in .gallery and .conf."""