From: Christian Heller Date: Sat, 24 Aug 2024 04:54:16 +0000 (+0200) Subject: Extend sorting to filename. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/blog?a=commitdiff_plain;h=461b804ce55ad9fc75407bbf6850467733132766;p=stable_plom Extend sorting to filename. --- diff --git a/browser.py b/browser.py index 9479889..f288626 100755 --- a/browser.py +++ b/browser.py @@ -69,14 +69,16 @@ 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) + def add_sorter(attr_name, group): + radio = Gtk.CheckButton(label=attr_name, group=group) radio.connect('toggled', self.on_sort_select) vbox.append(radio) + return radio + + vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + radio1 = add_sorter('last_mod_time', None) + for name in ['name'] + list(GEN_PARAMS): + add_sorter(name.lower(), group=radio1) popover_menu = Gtk.Popover() popover_menu.props.child = vbox self.sorter = Gtk.MenuButton(label='SORT', popover=popover_menu) @@ -121,7 +123,7 @@ class Window(Gtk.ApplicationWindow): for item in [item for item in self.unsorted if '' == item.model]: item.set_metadata(et, cache) self.max_index = len(self.unsorted) - 1 - self.sort('last_mod_time') + self.sort('name') with open(CACHE_PATH, 'w', encoding='utf8') as f: json_dump(cache, f)