[gnome-music/wip/mschraal/coresong-thumbnail-prop: 160/179] coresong: Pass Application to init



commit 43a34dfb720a7357d95056152d8219fc1649dbcb
Author: Marinus Schraal <mschraal gnome org>
Date:   Tue Dec 24 10:55:10 2019 +0100

    coresong: Pass Application to init
    
    The Application object holds the Grilo and CoreSelection objects,
    removing an argument.

 gnomemusic/coremodel.py                         | 21 +++++----------------
 gnomemusic/coresong.py                          |  6 +++---
 gnomemusic/grilowrappers/grlsearchwrapper.py    |  3 ++-
 gnomemusic/grilowrappers/grltrackerplaylists.py | 23 ++++++++---------------
 gnomemusic/grilowrappers/grltrackerwrapper.py   | 11 +++++------
 5 files changed, 23 insertions(+), 41 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 37c8f230..8b4a09db 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -89,7 +89,7 @@ class CoreModel(GObject.GObject):
         self._model = Gio.ListStore.new(CoreSong)
         self._songliststore = SongListStore(self._model)
 
-        self._coreselection = application.props.coreselection
+        self._application = application
         self._album_model = Gio.ListStore()
         self._album_model_sort = Gfm.SortListModel.new(self._album_model)
         self._album_model_sort.set_sort_func(
@@ -137,9 +137,6 @@ class CoreModel(GObject.GObject):
             self._wrap_list_store_sort_func(self._playlists_sort))
 
         self.props.grilo = CoreGrilo(self, application)
-        # FIXME: Not all instances of internal _grilo use have been
-        # fixed.
-        self._grilo = self.props.grilo
 
         self._model.connect("items-changed", self._on_songs_items_changed)
 
@@ -248,9 +245,7 @@ class CoreModel(GObject.GObject):
             if added > 0:
                 for i in list(range(added)):
                     coresong = model[position + i]
-                    song = CoreSong(
-                        coresong.props.media, self._coreselection,
-                        self.props.grilo)
+                    song = CoreSong(coresong.props.media, self._application)
 
                     self._playlist_model.insert(position + i, song)
 
@@ -289,9 +284,7 @@ class CoreModel(GObject.GObject):
             self._current_playlist_model = self._flatten_model
 
             for model_song in self._flatten_model:
-                song = CoreSong(
-                    model_song.props.media, self._coreselection,
-                    self.props.grilo)
+                song = CoreSong(model_song.props.media, self._application)
 
                 songs_added.append(song)
                 song.bind_property(
@@ -314,9 +307,7 @@ class CoreModel(GObject.GObject):
             self._current_playlist_model = self._flatten_model
 
             for model_song in self._flatten_model:
-                song = CoreSong(
-                    model_song.props.media, self._coreselection,
-                    self.props.grilo)
+                song = CoreSong(model_song.props.media, self._application)
 
                 songs_added.append(song)
                 song.bind_property(
@@ -346,9 +337,7 @@ class CoreModel(GObject.GObject):
             self._current_playlist_model = model
 
             for model_song in model:
-                song = CoreSong(
-                    model_song.props.media, self._coreselection,
-                    self.props.grilo)
+                song = CoreSong(model_song.props.media, self._application)
 
                 songs_added.append(song)
 
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index c2befcb6..2b2632c1 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -55,11 +55,11 @@ class CoreSong(GObject.GObject):
         FAILED = 2
         SUCCEEDED = 3
 
-    def __init__(self, media, coreselection, grilo):
+    def __init__(self, media, application):
         super().__init__()
 
-        self._grilo = grilo
-        self._coreselection = coreselection
+        self._grilo = application.props.coremodel.props.grilo
+        self._coreselection = application.props.coreselection
         self._favorite = False
         self._selected = False
 
diff --git a/gnomemusic/grilowrappers/grlsearchwrapper.py b/gnomemusic/grilowrappers/grlsearchwrapper.py
index ab263e6c..b2a1c2b6 100644
--- a/gnomemusic/grilowrappers/grlsearchwrapper.py
+++ b/gnomemusic/grilowrappers/grlsearchwrapper.py
@@ -67,6 +67,7 @@ class GrlSearchWrapper(GObject.GObject):
         """
         super().__init__()
 
+        self._application = application
         self._coremodel = coremodel
         self._coreselection = application.props.coreselection
         self._grilo = grilo
@@ -104,7 +105,7 @@ class GrlSearchWrapper(GObject.GObject):
             if not media:
                 return
 
-            coresong = CoreSong(media, self._coreselection, self._grilo)
+            coresong = CoreSong(media, self._application)
             coresong.props.title = (
                 coresong.props.title + " (" + source.props.source_name + ")")
 
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index f63da4af..aa0a304a 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -55,14 +55,13 @@ class GrlTrackerPlaylists(GObject.GObject):
     ]
 
     def __init__(
-            self, source, coremodel, application, grilo, tracker_wrapper):
+            self, source, coremodel, application, tracker_wrapper):
         """Initialize GrlTrackerPlaylists.
 
         :param Grl.TrackerSource source: The Tracker source to wrap
         :param CoreModel coremodel: CoreModel instance to use models
                                     from
         :param Application application: Application instance
-        :param CoreGrilo grilo: The CoreGrilo instance
         :param TrackerWrapper tracker_wrapper: The TrackerWrapper
                                                instance
         """
@@ -70,8 +69,6 @@ class GrlTrackerPlaylists(GObject.GObject):
 
         self._application = application
         self._coremodel = coremodel
-        self._coreselection = application.props.coreselection
-        self._grilo = grilo
         self._log = application.props.log
         self._source = source
         self._model = self._coremodel.props.playlists
@@ -94,7 +91,6 @@ class GrlTrackerPlaylists(GObject.GObject):
         args = {
             "source": self._source,
             "application": self._application,
-            "grilo": self._grilo,
             "tracker_wrapper": self._tracker_wrapper
         }
 
@@ -148,7 +144,7 @@ class GrlTrackerPlaylists(GObject.GObject):
 
         playlist = Playlist(
             media=media, source=self._source, coremodel=self._coremodel,
-            application=self._application, grilo=self._grilo,
+            application=self._application,
             tracker_wrapper=self._tracker_wrapper)
 
         self._model.append(playlist)
@@ -291,8 +287,7 @@ class Playlist(GObject.GObject):
 
     def __init__(
             self, media=None, query=None, tag_text=None, source=None,
-            coremodel=None, application=None, grilo=None,
-            tracker_wrapper=None):
+            coremodel=None, application=None, tracker=None):
 
         super().__init__()
         """Initialize a playlist
@@ -304,9 +299,7 @@ class Playlist(GObject.GObject):
        :param Grl.Source source: The Grilo Tracker source object
        :param CoreModel coremodel: The CoreModel instance
        :param Application application: The Application instance
-       :param CoreGrilo grilo: The CoreGrilo instance
-       :param TrackerWrapper tracker_wrapper: The TrackerWrapper
-            instance
+       :param TrackerWrapper tracker_wrapper: The TrackerWrapper instance
         """
         if media:
             self.props.pl_id = media.get_id()
@@ -318,11 +311,11 @@ class Playlist(GObject.GObject):
 
         self.props.query = query
         self.props.tag_text = tag_text
+        self._application = application
         self._model = None
         self._source = source
         self._coremodel = coremodel
         self._coreselection = application.props.coreselection
-        self._grilo = grilo
         self._log = application.props.log
         self._tracker = tracker_wrapper.props.tracker
         self._tracker_wrapper = tracker_wrapper
@@ -397,7 +390,7 @@ class Playlist(GObject.GObject):
                 self._window.notifications_popup.pop_loading()
                 return
 
-            coresong = CoreSong(media, self._coreselection, self._grilo)
+            coresong = CoreSong(media, self._application)
             if coresong not in self._songs_todelete:
                 self._model.append(coresong)
 
@@ -569,7 +562,7 @@ class Playlist(GObject.GObject):
                 self.props.count = self._model.get_n_items()
                 return
 
-            coresong = CoreSong(media, self._coreselection, self._grilo)
+            coresong = CoreSong(media, self._application)
             if coresong not in self._songs_todelete:
                 self._model.append(coresong)
 
@@ -719,7 +712,7 @@ class SmartPlaylist(Playlist):
                     self.emit("playlist-loaded")
                     return
 
-                coresong = CoreSong(media, self._coreselection, self._grilo)
+                coresong = CoreSong(media, self._application)
                 self._model.append(coresong)
 
             options = self._fast_options.copy()
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index fb3568a4..8ae3e349 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -74,12 +74,11 @@ class GrlTrackerWrapper(GObject.GObject):
         """
         super().__init__()
 
+        self._application = application
         self._coremodel = coremodel
-        self._coreselection = application.props.coreselection
-        self._grilo = grilo
-        self._source = None
         self._log = application.props.log
         self._model = self._coremodel.props.songs
+        self._source = None
         self._albums_model = self._coremodel.props.albums
         self._album_ids = {}
         self._artists_model = self._coremodel.props.artists
@@ -109,7 +108,7 @@ class GrlTrackerWrapper(GObject.GObject):
         self._initial_artists_fill(self.props.source)
 
         self._tracker_playlists = GrlTrackerPlaylists(
-            source, coremodel, application, grilo, tracker_wrapper)
+            source, coremodel, application, tracker_wrapper)
 
     @GObject.Property(type=Grl.Source, default=None)
     def source(self):
@@ -357,7 +356,7 @@ class GrlTrackerWrapper(GObject.GObject):
                 self._log.debug(
                     "Media {} not in hash".format(media.get_id()))
 
-                song = CoreSong(media, self._coreselection, self._grilo)
+                song = CoreSong(media, self._application)
                 self._model.append(song)
                 self._hash[media.get_id()] = song
             else:
@@ -384,7 +383,7 @@ class GrlTrackerWrapper(GObject.GObject):
                 self._window.notifications_popup.pop_loading()
                 return
 
-            song = CoreSong(media, self._coreselection, self._grilo)
+            song = CoreSong(media, self._application)
             songs_added.append(song)
             self._hash[media.get_id()] = song
             if len(songs_added) == self._SPLICE_SIZE:


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