[gnome-music/wip/mschraal/albumwidget-pass-application: 1/4] albumwidget: Pass application



commit ef9904903fd190b9757846c1e782226cfd987749
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Feb 13 16:56:56 2020 +0100

    albumwidget: Pass application
    
    Reduce init arguments.

 gnomemusic/views/albumsview.py    |  2 +-
 gnomemusic/views/searchview.py    |  2 +-
 gnomemusic/widgets/albumwidget.py | 19 +++++++++----------
 3 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 7fc34e92..40b1043b 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -80,7 +80,7 @@ class AlbumsView(Gtk.Stack):
         self._window.connect(
             "notify::selection-mode", self._on_selection_mode_changed)
 
-        self._album_widget = AlbumWidget(application.props.player, self)
+        self._album_widget = AlbumWidget(self._application)
         self._album_widget.bind_property(
             "selection-mode", self, "selection-mode",
             GObject.BindingFlags.BIDIRECTIONAL)
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 2f50633c..a4572361 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -128,7 +128,7 @@ class SearchView(Gtk.Stack):
             'selection-mode', self._window, 'selection-mode',
             GObject.BindingFlags.BIDIRECTIONAL)
 
-        self._album_widget = AlbumWidget(player, self)
+        self._album_widget = AlbumWidget(self._application)
         self._album_widget.bind_property(
             "selection-mode", self, "selection-mode",
             GObject.BindingFlags.BIDIRECTIONAL)
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 92438d98..a81c4046 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -55,21 +55,21 @@ class AlbumWidget(Gtk.EventBox):
 
     _duration = 0
 
-    def __init__(self, player, parent_view):
+    def __init__(self, application):
         """Initialize the AlbumWidget.
 
-        :param player: The player object
-        :param parent_view: The view this widget is part of
+        :param Application application: The Application object
         """
         super().__init__()
 
+        self._application = application
         self._corealbum = None
+        self._coremodel = self._application.props.coremodel
         self._duration_signal_id = None
         self._model_signal_id = None
 
         self._cover_stack.props.size = Art.Size.LARGE
-        self._parent_view = parent_view
-        self._player = player
+        self._player = self._application.props.player
 
         self.bind_property(
             "selection-mode", self._disc_list_box, "selection-mode",
@@ -170,14 +170,13 @@ class AlbumWidget(Gtk.EventBox):
             return
 
         signal_id = None
-        coremodel = self._parent_view._window._app.props.coremodel
-
         def _on_playlist_loaded(klass, playlist_type):
             self._player.play(song_widget.props.coresong)
-            coremodel.disconnect(signal_id)
+            self._coremodel.disconnect(signal_id)
 
-        signal_id = coremodel.connect("playlist-loaded", _on_playlist_loaded)
-        coremodel.set_player_model(
+        signal_id = self._coremodel.connect(
+            "playlist-loaded", _on_playlist_loaded)
+        self._coremodel.set_player_model(
             PlayerPlaylist.Type.ALBUM, self._album_model)
 
         return True


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