From: Christian Heller Date: Sat, 24 Aug 2024 04:46:18 +0000 (+0200) Subject: Extend Browser's sorting capabilities to all GenParams. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/ledger?a=commitdiff_plain;h=d3297649bf4fb9c186422116648fd36b90f77141;p=stable_plom Extend Browser's sorting capabilities to all GenParams. --- diff --git a/browser.py b/browser.py index ac1afc7..9479889 100755 --- a/browser.py +++ b/browser.py @@ -69,14 +69,19 @@ class Window(Gtk.ApplicationWindow): self.viewer.append(self.metadata) self.viewer.append(self.label_nothing_to_show) + vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + radio1 = Gtk.CheckButton(label='last_mod_time') + radio1.connect('toggled', self.on_sort_select) + vbox.append(radio1) + for name in GEN_PARAMS: + radio = Gtk.CheckButton(label=name.lower(), group=radio1) + radio.connect('toggled', self.on_sort_select) + vbox.append(radio) + popover_menu = Gtk.Popover() + popover_menu.props.child = vbox + self.sorter = Gtk.MenuButton(label='SORT', popover=popover_menu) dir_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) - - btn_sort_date = Gtk.Button(label='by age') - btn_sort_date.connect('clicked', lambda _: self.sort('last_mod_time')) - dir_box.append(btn_sort_date) - btn_sort_seed = Gtk.Button(label='by seed') - btn_sort_seed.connect('clicked', lambda _: self.sort('seed')) - dir_box.append(btn_sort_seed) + dir_box.append(self.sorter) img_dir_absolute = abspath(IMG_DIR) self.dir = Gio.File.new_for_path(img_dir_absolute) @@ -120,6 +125,10 @@ class Window(Gtk.ApplicationWindow): with open(CACHE_PATH, 'w', encoding='utf8') as f: json_dump(cache, f) + def on_sort_select(self, button): + self.sort(button.props.label) + self.sorter.props.label = f'SORT: {button.props.label}' + def sort(self, attr_name): self.list_store.remove_all() for file_item in sorted(self.unsorted,