From 2f06d2a63baf0e8cddddab6aeabf69573fc55082 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 26 Aug 2024 01:42:53 +0200
Subject: [PATCH] Add toggler for folder view.

---
 browser.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/browser.py b/browser.py
index 97def1d..a3e0979 100755
--- a/browser.py
+++ b/browser.py
@@ -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()
-- 
2.30.2