home · contact · privacy
Browser.py: In header bar, don't crash on empty gallery.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 24 Oct 2024 16:49:07 +0000 (18:49 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 24 Oct 2024 16:49:07 +0000 (18:49 +0200)
browser.py

index b775516a4c596f3af11466954c7d68d1ae263522..8db39e30a774b12c667f5c3e929d28cbe8133458 100755 (executable)
@@ -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} – <b>{selected_item.full_path}</b>'
+        txt = f' {n_selected} of {total} – <b>{display_name}</b>'
         self.topbar.set_text(txt)
         self.topbar.set_use_markup(True)