From: Christian Heller Date: Wed, 25 Sep 2024 05:36:34 +0000 (+0200) Subject: Browser: Minor refactoring. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/pick_tasks?a=commitdiff_plain;h=793338e962b72cf69e3ca7bddf1b103c6c02aa9e;p=stable_plom Browser: Minor refactoring. --- diff --git a/browser.py b/browser.py index 15d82c2..858fa8d 100755 --- a/browser.py +++ b/browser.py @@ -67,9 +67,8 @@ class Sorter(GObject.GObject): self.widget = widget title = f'{self.name} ({len(vals_filtered)}/{len(vals_full)}) ' widget.get_first_child().get_first_child().set_text(title) - vals_listed = [f'{val}' if val in vals_filtered - else f'{val}' - for val in sorted(vals_full)] + vals_listed = [f'{v}' if v in vals_filtered else f'{v}' + for v in vals_full] widget.get_last_child().set_text(', '.join(vals_listed)) widget.get_last_child().set_use_markup(True) filter_entry = widget.get_first_child().get_last_child() @@ -359,6 +358,9 @@ class Gallery: self.items_attrs_filtered[attr_name].add(val) if passes_filters: entries_filtered += [entry] + for d in (self.items_attrs, self.items_attrs_filtered): + for k, v in d.items(): + d[k] = sorted(list(v)) return entries_filtered def _build_grid(self, entries_filtered): @@ -405,8 +407,8 @@ class Gallery: self.show_dirs = False sort_attrs = [] for sorter in reversed(self._sort_order): - values = self.items_attrs_filtered[sorter.name] - sort_attrs += [(sorter.name, sorted(list(values)))] + sort_attrs += [(sorter.name, + self.items_attrs_filtered[sorter.name])] i_row_ref = [0] i_slot_ref = [0] self.per_row = len(sort_attrs[-1][1]) @@ -490,8 +492,7 @@ class Gallery: if self.per_row_by_first_sorter: self._col_headers_grid = Gtk.Grid() self._col_headers_frame.put(self._col_headers_grid, 0, 0) - attr_name = self._sort_order[0].name - attr_values = sorted(self.items_attrs_filtered[attr_name]) + attr_values = self.items_attrs_filtered[self._sort_order[0].name] for i, val in enumerate(attr_values): label = Gtk.Label(label=str(val)) label.set_size_request(slot_size, -1)