home · contact · privacy
Add toggler for folder view.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 25 Aug 2024 23:42:53 +0000 (01:42 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 25 Aug 2024 23:42:53 +0000 (01:42 +0200)
browser.py

index 97def1da7fc95d753987b875171ae08eb59c805c..a3e09791e92d3d62e5728043344d6c907edc2773 100755 (executable)
@@ -61,6 +61,9 @@ class Window(Gtk.ApplicationWindow):
             box_buttons.append(btn)
 
         box_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
+        btn = Gtk.Button(label='folder')
+        btn.connect('clicked', self.toggle_folder_view)
+        box_buttons.append(btn)
         btn = Gtk.Button(label='reload')
         btn.connect('clicked', lambda _: self.reload_dir())
         box_buttons.append(btn)
@@ -90,8 +93,8 @@ class Window(Gtk.ApplicationWindow):
         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)
-        dir_box.append(self.sorter)
+        self.dir_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+        self.dir_box.append(self.sorter)
 
         self.img_dir_absolute = abspath(IMG_DIR)
         self.dir = Gio.File.new_for_path(self.img_dir_absolute)
@@ -104,10 +107,11 @@ class Window(Gtk.ApplicationWindow):
         self.selector = Gtk.ListView(model=self.selection, factory=factory)
         scrolled = Gtk.ScrolledWindow(child=self.selector, vexpand=True,
                                       propagate_natural_width=True)
-        dir_box.append(scrolled)
+        self.dir_box.append(scrolled)
+        self.dir_box.hide()
 
         box_outer = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
-        box_outer.append(dir_box)
+        box_outer.append(self.dir_box)
         box_outer.append(self.viewer)
         self.props.child = box_outer
 
@@ -115,6 +119,9 @@ class Window(Gtk.ApplicationWindow):
         self.sort_order = ['last_mod_time']
         self.reload_dir()
 
+    def toggle_folder_view(self, _):
+        self.dir_box.props.visible = not self.dir_box.props.visible
+
     def on_sort_select(self, button):
         self.update_sort_order(button.props.label)
         self.sort()