From: Christian Heller Date: Sun, 27 Oct 2024 03:39:16 +0000 (+0100) Subject: Browser: Fix by_1st view showing wrong first-row attributes. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/index.html?a=commitdiff_plain;h=4e3faaae593ea0aa77f925dfe1766055dac7c525;p=stable_plom Browser: Fix by_1st view showing wrong first-row attributes. --- diff --git a/browser.py b/browser.py index 57c84c3..28ed0c6 100755 --- a/browser.py +++ b/browser.py @@ -831,6 +831,8 @@ class Gallery: if self._grid: self._fixed_frame.remove(self._grid) + if self._col_headers_grid: + self._col_headers_frame.remove(self._col_headers_grid) self.slots = [] self._grid = Gtk.Grid() self._fixed_frame.put(self._grid, 0, 0) @@ -846,6 +848,17 @@ class Gallery: sort_attrs += [(s_name, self.items_attrs[s_name]['incl'])] self._per_row = len(sort_attrs[-1][1]) build_rows_by_attrs(sort_attrs, entries_filtered, []) + self._col_headers_grid = Gtk.Grid() + self._col_headers_frame.put(self._col_headers_grid, 0, 0) + self._col_headers_grid.attach(Gtk.Box(), 0, 0, 1, 1) + top_attr_name = sort_attrs[-1][0] + for i, val in enumerate(sort_attrs[-1][1]): + label = Gtk.Label(label=f'{top_attr_name}: {val}', + xalign=0, + ellipsize=Pango.EllipsizeMode.MIDDLE) + label.set_use_markup(True) + self._col_headers_grid.attach(label, i + 1, 0, 1, 1) + else: dir_entries_filtered_sorted = sorted( entries_filtered, key=cmp_to_key(self._sort_cmp)) @@ -930,23 +943,17 @@ class Gallery: i_vlabels += 1 max_slot_width = (vp_width - side_offset) // self._per_row slot_size = min(vp_height, max_slot_width) - if self._col_headers_grid: - self._col_headers_frame.remove(self._col_headers_grid) - self._col_headers_grid = None if self._by_1st: - self._col_headers_grid = Gtk.Grid() - spacer_box = Gtk.Box() - spacer_box.set_size_request(side_offset, -1) - self._col_headers_grid.attach(spacer_box, 0, 0, 1, 1) - self._col_headers_frame.put(self._col_headers_grid, 0, 0) - attr_name = self._sort_order[0].name - attr_values = self.items_attrs[attr_name]['incl'] - for i, val in enumerate(attr_values): - label = Gtk.Label(label=f'{attr_name}: {val}', xalign=0, - ellipsize=Pango.EllipsizeMode.MIDDLE) - label.set_use_markup(True) - label.set_size_request(slot_size, -1) - self._col_headers_grid.attach(label, i + 1, 0, 1, 1) + i_widgets = 0 + while True: + widget = self._col_headers_grid.get_child_at(i_widgets, 0) + if 0 == i_widgets: + widget.set_size_request(side_offset, -1) + elif isinstance(widget, Gtk.Label): + widget.set_size_request(slot_size, -1) + else: + break + i_widgets += 1 slot_size_sans_margin = slot_size - self._slot_margin for idx, slot in enumerate(self.slots): slot.ensure_slot_size(slot_size_sans_margin, self._slot_margin)