home · contact · privacy
Extend sorting to filename.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 24 Aug 2024 04:54:16 +0000 (06:54 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 24 Aug 2024 04:54:16 +0000 (06:54 +0200)
browser.py

index 9479889b1f3e6f0a7c11398f67798b0bb0cc1b6c..f2886261394dec2ac86efc788e6436641f677999 100755 (executable)
@@ -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)