[gnome-music/wip/mschraal/window-template: 5/5] window: Simplify initial views creation



commit f2d49aea6362534af943c2af3af2b631688fb4e1
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon May 6 00:33:51 2019 +0200

    window: Simplify initial views creation

 gnomemusic/window.py | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index ce999789..9844245b 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -151,8 +151,6 @@ class Window(Gtk.ApplicationWindow):
         self._player_toolbar = PlayerToolbar()
         self._player_toolbar.props.player = self._player
 
-        self.views = [None] * len(View)
-
         self._headerbar.connect(
             'back-button-clicked', self._switch_back_from_childview)
 
@@ -172,6 +170,7 @@ class Window(Gtk.ApplicationWindow):
         self.bind_property(
             'selection-mode', self._selection_toolbar, 'visible')
 
+        self.views = [Gtk.Box()] * len(View)
         # Create only the empty view at startup
         # if no music, switch to empty view and hide stack
         # if some music is available, populate stack with mainviews,
@@ -238,6 +237,8 @@ class Window(Gtk.ApplicationWindow):
         self._btn_ctrl.props.button = 8
         self._btn_ctrl.connect("pressed", self._on_back_button_pressed)
 
+        self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
+
         # FIXME: In case Grilo is already initialized before the views
         # get created, they never receive a 'ready' signal to trigger
         # population. To fix this another check was added to baseview
@@ -247,13 +248,6 @@ class Window(Gtk.ApplicationWindow):
         # to window._stack. For this to succeed, the stack needs to be
         # filled with something: Gtk.Box.
         # This is a bit of circular logic that needs to be fixed.
-        self.views[View.ALBUM] = Gtk.Box()
-        self.views[View.ARTIST] = Gtk.Box()
-        self.views[View.SONG] = Gtk.Box()
-        self.views[View.PLAYLIST] = Gtk.Box()
-        self.views[View.SEARCH] = Gtk.Box()
-
-        self.views[View.EMPTY].props.state = EmptyView.State.SEARCH
         self._headerbar.props.state = HeaderBar.State.MAIN
         self._headerbar.props.stack = self._stack
         self._searchbar.show()


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