[gnome-music/wip/jfelder/window-headerbar-property] views: Use a property to access window headerbar




commit 9abd53a4ec766d7dd907b1e1876c7a18c76894e1
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Aug 2 20:43:18 2022 +0200

    views: Use a property to access window headerbar

 gnomemusic/views/albumsview.py |  2 +-
 gnomemusic/views/searchview.py |  2 +-
 gnomemusic/window.py           | 10 ++++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index f0bbc8052..441232674 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -70,7 +70,7 @@ class AlbumsView(Gtk.Stack):
 
         self._application = application
         self._window = application.props.window
-        self._headerbar = self._window._headerbar
+        self._headerbar = self._window.props.headerbar
 
         self._list_item_bindings: Dict[
             Gtk.ListItem, List[GObject.Binding]] = {}
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 617e39405..cd7cf3f9d 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -97,7 +97,7 @@ class SearchView(Gtk.Stack):
         self._model = self._coremodel.props.songs_search
         self._player = self._application.props.player
         self._window = application.props.window
-        self._headerbar = self._window._headerbar
+        self._headerbar = self._window.props.headerbar
 
         self._album_model = self._coremodel.props.albums_search
         self._artist_model = self._coremodel.props.artists_search
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 93f1b27d6..f0eb43127 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -282,6 +282,16 @@ class Window(Adw.ApplicationWindow):
 
         self.props.active_view.deselect_all()
 
+    @GObject.Property(
+        type=HeaderBar, default=None, flags=GObject.ParamFlags.READABLE)
+    def headerbar(self) -> HeaderBar:
+        """Get headerbar instance.
+
+        :returns: The headerbar
+        :rtype: HeaderBar
+        """
+        return self._headerbar
+
     @Gtk.Template.Callback()
     def _on_key_press(self, controller, keyval, keycode, state):
         modifiers = state & Gtk.accelerator_get_default_mod_mask()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]