home · contact · privacy
Browser: Starting some fbox experiments …
authorChristian Heller <c.heller@plomlompom.de>
Wed, 28 Aug 2024 02:44:22 +0000 (04:44 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 28 Aug 2024 02:44:22 +0000 (04:44 +0200)
browser.py

index 67e41cb0b070b18777ee69a038e13ea32a0793e3..5a5ce3f85ef0d70a4051aa0b8028b561f0f2436f 100755 (executable)
@@ -5,9 +5,11 @@ from operator import attrgetter
 from exiftool import ExifToolHelper  # type: ignore
 import gi  # type: ignore
 gi.require_version('Gtk', '4.0')
+gi.require_version('Gdk', '4.0')
+gi.require_version('GdkPixbuf', '2.0')
 gi.require_version('Gio', '2.0')
 # pylint: disable=wrong-import-position
-from gi.repository import Gtk, Gio, GObject  # type: ignore  # noqa: E402
+from gi.repository import Gdk, GdkPixbuf, Gtk, Gio, GObject  # type: ignore  # noqa: E402
 # pylint: disable=no-name-in-module
 from stable.gen_params import (GenParams,  # noqa: E402
                                GEN_PARAMS, GEN_PARAMS_STR)  # noqa: E402
@@ -93,8 +95,14 @@ class Window(Gtk.ApplicationWindow):
         add_button('reload', lambda _: self.reload_dir(), box_files_selection)
         self.box_sort_order = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
         box_files_selection.append(self.box_sort_order)
+
+        # self.fbox = Gtk.FlowBox(orientation=Gtk.Orientation.VERTICAL)
+        # self.fbox.set_max_children_per_line(3)
+        # self.fbox.set_selection_mode(Gtk.SelectionMode.NONE)
+
         self.viewer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
         self.viewer.append(box_files_selection)
+        # self.viewer.append(self.fbox)
         self.viewer.append(self.metadata)
         self.viewer.append(self.label_nothing_to_show)
 
@@ -143,6 +151,7 @@ class Window(Gtk.ApplicationWindow):
         self.dir_box.props.visible = not self.dir_box.props.visible
 
     def sort(self):
+        # self.fbox.remove_all()
         self.list_store.remove_all()
         for key in self.sort_order:
             self.unsorted_files.sort(key=attrgetter(key))
@@ -158,6 +167,13 @@ class Window(Gtk.ApplicationWindow):
                         self.selection.set_selected(pos)
                 return
         self.update_selected()
+        # for file_item in self.unsorted_files:
+        #     pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(file_item.full_path, 128, 128, True)
+        #     img = Gtk.Image()
+        #     img.set_from_pixbuf(pixbuf)
+        #     box = Gtk.Box()
+        #     box.img = img
+        #     self.fbox.append(box)
 
     def update_selected(self, *_args):
         if isinstance(self.selection.props.selected_item, ImgItem):