home · contact · privacy
Browser: More refactoring.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 28 Oct 2024 12:54:47 +0000 (13:54 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 28 Oct 2024 12:54:47 +0000 (13:54 +0100)
browser.py

index bc2167fb8a849f398aa551a2d4fe0b40580ad57c..91355ed3818cce6a64d363f18c41753f870d21ca 100755 (executable)
@@ -352,7 +352,7 @@ class GallerySlot(Gtk.Button):
         self.item = item
         self.item.slot = self
         if on_click_file:
-            self.connect('clicked', on_click_file)
+            self.connect('clicked', lambda _: on_click_file())
 
     def mark(self, css_class, do_add=True):
         """Add or remove css_class from self."""
@@ -810,12 +810,6 @@ class Gallery:
         def build_grid(entries_filtered):
             i_row_ref, i_slot_ref = [0], [0]
 
-            def item_clicker(idx):
-                def f(_):
-                    self._set_selection(idx)
-                    self._on_hit_item()
-                return f
-
             def build_rows_by_attrs(remaining, items_of_parent, ancestors):
                 if not items_of_parent:
                     return
@@ -833,11 +827,9 @@ class Gallery:
                             item.with_others = True
                         row[idx_val_in_attr_values] = item
                     for i_col, item in enumerate(row):
-                        if item:
-                            slot = GallerySlot(item, self._slots_geometry)
-                        else:
-                            slot = GallerySlot(GalleryItem('', ''),  # dummy
-                                               self._slots_geometry)
+                        slot = GallerySlot(  # build empty dummy if necessary
+                                item if item else GalleryItem('', ''),
+                                self._slots_geometry)
                         self.slots += [slot]
                         i_slot_ref[0] += 1
                         self._grid.attach(slot, i_col + len(ancestors),
@@ -890,7 +882,7 @@ class Gallery:
                         i_col = 0
                         i_row += 1
                     slot = GallerySlot(item, self._slots_geometry,
-                                       item_clicker(i))
+                                       self._on_hit_item)
                     self._grid.attach(slot, i_col, i_row, 1, 1)
                     self.slots += [slot]
                     i_col += 1
@@ -966,8 +958,7 @@ class Gallery:
                     break
                 i_vlabels += 1
         max_slot_width = (vp_width - side_offset) // self._per_row
-        slot_size = min(vp_height, max_slot_width)
-        self._slots_geometry.set_size(slot_size)
+        self._slots_geometry.set_size(min(vp_height, max_slot_width))
         if self._by_1st:
             i_widgets = 0
             while True: