[gnome-music/wip/mschraal/albumwidget-pass-application: 2/4] window: Remove Player argument for views



commit 9b84a280bdacdc842f75e2ce7ab63129d66f72f6
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Feb 13 17:07:29 2020 +0100

    window: Remove Player argument for views
    
    It can be accessed through the Application object.

 gnomemusic/views/albumsview.py    |  2 +-
 gnomemusic/views/artistsview.py   |  3 +--
 gnomemusic/views/playlistsview.py |  4 +---
 gnomemusic/views/searchview.py    |  2 +-
 gnomemusic/views/songsview.py     |  5 ++---
 gnomemusic/window.py              | 10 +++++-----
 6 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 40b1043b..cd4c89f0 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -48,7 +48,7 @@ class AlbumsView(Gtk.Stack):
     _flowbox = Gtk.Template.Child()
     _flowbox_long_press = Gtk.Template.Child()
 
-    def __init__(self, application, player=None):
+    def __init__(self, application):
         """Initialize AlbumsView
 
         :param application: The Application object
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 9876bf7d..a5454ae5 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -37,11 +37,10 @@ class ArtistsView(BaseView):
     all albums by this artist on the right side.
     """
 
-    def __init__(self, application, player):
+    def __init__(self, application):
         """Initialize
 
         :param GtkApplication application: The application object
-        :param player: The main player object
         """
         self._sidebar = Gtk.ListBox()
         sidebar_container = Gtk.ScrolledWindow()
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index 25a63a20..dfe6ddaf 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -40,11 +40,10 @@ class PlaylistsView(Gtk.Stack):
     _main_container = Gtk.Template.Child()
     _sidebar = Gtk.Template.Child()
 
-    def __init__(self, application, player):
+    def __init__(self, application):
         """Initialize
 
         :param GtkApplication window: The application object
-        :param player: The main player object
         """
         super().__init__(transition_type=Gtk.StackTransitionType.CROSSFADE)
 
@@ -55,7 +54,6 @@ class PlaylistsView(Gtk.Stack):
         self._coremodel = application.props.coremodel
         self._model = self._coremodel.props.playlists_sort
         self._window = application.props.window
-        self._player = player
 
         # This indicates if the current list has been empty and has
         # had no user interaction since.
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index a4572361..3d35bd20 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -72,7 +72,7 @@ class SearchView(Gtk.Stack):
     _view_all_albums = Gtk.Template.Child()
     _view_all_artists = Gtk.Template.Child()
 
-    def __init__(self, application, player=None):
+    def __init__(self, application):
         """Initialize SearchView
 
         :param GtkApplication application: The Application object
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index e3ce8778..d76cd0e1 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -39,11 +39,10 @@ class SongsView(BaseView):
     and the album name.
     """
 
-    def __init__(self, application, player):
+    def __init__(self, application):
         """Initialize
 
         :param GtkApplication window: The application object
-        :param player: The main player object
         """
         self._coremodel = application.props.coremodel
         super().__init__('songs', _("Songs"), application)
@@ -56,7 +55,7 @@ class SongsView(BaseView):
 
         self._playlist_model = self._coremodel.props.playlist_sort
 
-        self._player = player
+        self._player = application.props.player
         self._player.connect('song-changed', self._update_model)
 
         self._model = self._view.props.model
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index cfc62af9..bff2b8ec 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -256,11 +256,11 @@ class Window(Gtk.ApplicationWindow):
         self._headerbar.props.state = HeaderBar.State.MAIN
         self._headerbar.props.stack = self._stack
 
-        self.views[View.ALBUM] = AlbumsView(self._app, self._player)
-        self.views[View.ARTIST] = ArtistsView(self._app, self._player)
-        self.views[View.SONG] = SongsView(self._app, self._player)
-        self.views[View.PLAYLIST] = PlaylistsView(self._app, self._player)
-        self.views[View.SEARCH] = SearchView(self._app, self._player)
+        self.views[View.ALBUM] = AlbumsView(self._app)
+        self.views[View.ARTIST] = ArtistsView(self._app)
+        self.views[View.SONG] = SongsView(self._app)
+        self.views[View.PLAYLIST] = PlaylistsView(self._app)
+        self.views[View.SEARCH] = SearchView(self._app)
 
         # empty view has already been created in self._setup_view starting at
         # View.ALBUM


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