From eac8be259abb0f35b5d2e846fe76fe8497477fff Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 24 Oct 2024 18:49:07 +0200 Subject: [PATCH] Browser.py: In header bar, don't crash on empty gallery. --- browser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser.py b/browser.py index b775516..8db39e3 100755 --- a/browser.py +++ b/browser.py @@ -1125,7 +1125,9 @@ class MainWindow(Gtk.Window): """Update .metadata about individual file, .topbar also on idx/total""" self.metadata.set_text('') selected_item = self.gallery.selected_item + display_name = '(none)' if selected_item: + display_name = selected_item.full_path if isinstance(selected_item, ImgItem): params_strs = [f'{k}: {getattr(selected_item, k.lower())}' for k in GEN_PARAMS] @@ -1136,7 +1138,7 @@ class MainWindow(Gtk.Window): total = len([s for s in self.gallery.slots if isinstance(s.item, (DirItem, ImgItem))]) n_selected = self.gallery.selected_idx + 1 - txt = f' {n_selected} of {total} – {selected_item.full_path}' + txt = f' {n_selected} of {total} – {display_name}' self.topbar.set_text(txt) self.topbar.set_use_markup(True) -- 2.30.2