[gnome-music/wip/mschraal/window-template: 5/6] window: Template the headerbar GtkStack



commit 8e5c2379083d5032a91c785708ddb4ba5af4e7e5
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon May 18 13:31:03 2020 +0200

    window: Template the headerbar GtkStack

 data/ui/Window.ui    |  6 ++++++
 gnomemusic/window.py | 11 +++--------
 2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/Window.ui b/data/ui/Window.ui
index c381c1f9..19e7dc85 100644
--- a/data/ui/Window.ui
+++ b/data/ui/Window.ui
@@ -3,6 +3,12 @@
   <template class="Window" parent="GtkApplicationWindow">
     <property name="default-height">500</property>
     <property name="default-width">300</property>
+    <child type="titlebar">
+      <object class="GtkStack" id="_headerbar_stack">
+        <property name="transition-type">crossfade</property>
+        <property name="visible">True</property>
+      </object>
+    </child>
     <child>
       <object class="GtkBox">
         <property name="orientation">vertical</property>
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 40a8373a..726b75fa 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -56,6 +56,7 @@ class Window(Gtk.ApplicationWindow):
     selection_mode = GObject.Property(type=bool, default=False)
 
     notifications_popup = Gtk.Template.Child()
+    _headerbar_stack = Gtk.Template.Child()
     _overlay = Gtk.Template.Child()
     _player_toolbar = Gtk.Template.Child()
     _selection_toolbar = Gtk.Template.Child()
@@ -97,15 +98,13 @@ class Window(Gtk.ApplicationWindow):
 
     def _setup_view(self):
         self._search = Search()
-        self._headerbar_stack = Gtk.Stack()
-        transition_type = Gtk.StackTransitionType.CROSSFADE
-        self._headerbar_stack.props.transition_type = transition_type
+
         self._headerbar = HeaderBar(self._app)
+        self._headerbar.props.stack = self._stack
         self._search_headerbar = SearchHeaderBar(self._app)
         self._search_headerbar.props.stack = self._stack
         self._headerbar_stack.add_named(self._headerbar, "main")
         self._headerbar_stack.add_named(self._search_headerbar, "search")
-        self._headerbar_stack.props.name = "search"
 
         self._search.bind_property(
             "search-mode-active", self._headerbar, "search-mode-active",
@@ -164,14 +163,11 @@ class Window(Gtk.ApplicationWindow):
         # bottom line of the searchbar
         self._stack.get_style_context().add_class('background')
 
-        self.set_titlebar(self._headerbar_stack)
-
         self._selection_toolbar.connect(
             'add-to-playlist', self._on_add_to_playlist)
         self._search.connect("notify::state", self._on_search_state_changed)
 
         self._headerbar.props.state = HeaderBar.State.MAIN
-        self._headerbar_stack.props.visible = True
 
         self._app.props.coremodel.connect(
             "notify::songs-available", self._on_songs_available)
@@ -241,7 +237,6 @@ class Window(Gtk.ApplicationWindow):
         self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
 
         self._headerbar.props.state = HeaderBar.State.MAIN
-        self._headerbar.props.stack = self._stack
 
         self.views[View.ALBUM] = AlbumsView(self._app)
         self.views[View.ARTIST] = ArtistsView(self._app)


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