home · contact · privacy
browser.py: Update topbar design.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 16 Oct 2024 13:48:40 +0000 (15:48 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 16 Oct 2024 13:48:40 +0000 (15:48 +0200)
browser.py

index 92bd4c15b32621a59a5bea214aaf1e201acaf44e..dd83eca0e28c2667ccdb0ee99f5ba07cc269a097 100755 (executable)
@@ -962,7 +962,7 @@ class MainWindow(Gtk.Window):
     """Image browser app top-level window."""
     metadata: Gtk.TextBuffer
     prev_key: list
-    counter: Gtk.Label
+    topbar: Gtk.Label
 
     def __init__(self, app, **kwargs):
         super().__init__(**kwargs)
@@ -970,9 +970,9 @@ class MainWindow(Gtk.Window):
 
         def init_navbar():
             navbar = Gtk.Box(orientation=OR_H)
-            self.counter = Gtk.Label()
-            navbar.append(self.counter)
             _add_button(navbar, 'sidebar', lambda _: self.toggle_side_box())
+            self.topbar = Gtk.Label()
+            navbar.append(self.topbar)
             return navbar
 
         def init_metadata_box():
@@ -1084,7 +1084,7 @@ class MainWindow(Gtk.Window):
         self.gallery.on_resize(self.get_width() - side_box_width)
 
     def update_metadata_on_gallery_selection(self):
-        """Update .metadata about individual file, .counter on its idx/total"""
+        """Update .metadata about individual file, .topbar also on idx/total"""
         self.metadata.set_text('')
         selected_item = self.gallery.selected_item
         if selected_item:
@@ -1097,7 +1097,10 @@ class MainWindow(Gtk.Window):
                         '\n'.join([title, bookmarked] + params_strs))
         total = len([s for s in self.gallery.slots
                      if isinstance(s.item, (DirItem, ImgItem))])
-        self.counter.set_text(f' {self.gallery.selected_idx + 1} of {total} ')
+        n_selected = self.gallery.selected_idx + 1
+        txt = f' {n_selected} of {total} – <b>{selected_item.full_path}</b>'
+        self.topbar.set_text(txt)
+        self.topbar.set_use_markup(True)
 
     def handle_keypress(self, keyval):
         """Handle keys if not in Gtk.Entry, return True if key handling done"""