From: Christian Heller Date: Mon, 9 Sep 2024 21:20:15 +0000 (+0200) Subject: browser.py: Minor improvements/fixes to gallery sorting and display. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/conditions?a=commitdiff_plain;h=f490ba7612a6abdff1dbf49660852e8c4e484f7e;p=stable_plom browser.py: Minor improvements/fixes to gallery sorting and display. --- diff --git a/browser.py b/browser.py index 873b35b..ae77c9a 100755 --- a/browser.py +++ b/browser.py @@ -263,7 +263,6 @@ class MainWindow(Gtk.Window): elif isinstance(b, DirItem): return +1 # apply self.sort_order within DirItems and FileItems (separately) - result = 0 for key in self.sort_order: a_cmp = None b_cmp = None @@ -272,14 +271,14 @@ class MainWindow(Gtk.Window): if hasattr(b, key): b_cmp = getattr(b, key) if a_cmp is None and b_cmp is not None: - result = -1 + return -1 elif a_cmp is not None and b_cmp is None: - result = +1 + return +1 elif a_cmp > b_cmp: - result = +1 + return +1 elif a_cmp < b_cmp: - result = -1 - return result + return -1 + return 0 def init_gallery_slot(file_item): slot = Gtk.Box() @@ -320,13 +319,13 @@ class MainWindow(Gtk.Window): self.gallery.set_max_children_per_line(self.per_row) vp = self.gallery.get_parent().get_parent() # because sometimes vp.[size] updates too late for our measurements - vp_height = self.force_height if self.force_height else vp.get_width() + vp_height = self.force_height if self.force_height else vp.get_height() vp_width = self.force_width if self.force_width else vp.get_width() vp_scroll = vp.get_vadjustment() vp_top = vp_scroll.get_value() vp_bottom = vp_top + vp_height margin = 6 - max_slot_width = vp_width / self.per_row - margin + max_slot_width = (vp_width // self.per_row) - margin prefered_slot_height = vp_height - margin slot_size = min(prefered_slot_height, max_slot_width) for i in range(self.gallery_store_filtered.get_n_items()):