From: Christian Heller Date: Mon, 28 Oct 2024 12:54:47 +0000 (+0100) Subject: Browser: More refactoring. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/todos?a=commitdiff_plain;h=9b21d08b8932ea16c906127cec33164571bac6f2;p=stable_plom Browser: More refactoring. --- diff --git a/browser.py b/browser.py index bc2167f..91355ed 100755 --- a/browser.py +++ b/browser.py @@ -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: