[gnome-music/wip/mschraal/assorted-cleanups: 10/32] coresong: Pass Application to init
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/assorted-cleanups: 10/32] coresong: Pass Application to init
- Date: Mon, 30 Mar 2020 20:58:06 +0000 (UTC)
commit f0daa7845738412f1d8eaf15f4e40b9545cc5cd9
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 | 11 ++++++---
gnomemusic/grilowrappers/grlsearchwrapper.py | 3 ++-
gnomemusic/grilowrappers/grltrackerplaylists.py | 30 ++++++++++---------------
gnomemusic/grilowrappers/grltrackerwrapper.py | 10 ++++-----
5 files changed, 31 insertions(+), 44 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index ca09c307..9dfffb0d 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -88,7 +88,7 @@ class CoreModel(GObject.GObject):
self._songs_model = Gio.ListStore.new(CoreSong)
self._songliststore = SongListStore(self._songs_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(
@@ -136,9 +136,6 @@ class CoreModel(GObject.GObject):
utils.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._songs_model.connect(
"items-changed", self._on_songs_items_changed)
@@ -242,9 +239,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(self._application, coresong.props.media)
_bind_song_properties(coresong, song)
songs_list.append(song)
@@ -277,9 +272,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(self._application, model_song.props.media)
_bind_song_properties(model_song, song)
songs_added.append(song)
@@ -295,9 +288,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(self._application, model_song.props.media)
_bind_song_properties(model_song, song)
songs_added.append(song)
@@ -320,9 +311,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(self._application, model_song.props.media)
_bind_song_properties(model_song, song)
songs_added.append(song)
diff --git a/gnomemusic/coresong.py b/gnomemusic/coresong.py
index c2befcb6..8748df66 100644
--- a/gnomemusic/coresong.py
+++ b/gnomemusic/coresong.py
@@ -55,11 +55,16 @@ class CoreSong(GObject.GObject):
FAILED = 2
SUCCEEDED = 3
- def __init__(self, media, coreselection, grilo):
+ def __init__(self, application, media):
+ """Initiate the CoreSong object
+
+ :param Application application: The application object
+ :param Grl.Media media: A media object
+ """
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..fe0256af 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(self._application, media)
coresong.props.title = (
coresong.props.title + " (" + source.props.source_name + ")")
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index 0324ed68..8a762582 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -55,24 +55,21 @@ class GrlTrackerPlaylists(GObject.GObject):
]
def __init__(
- self, source, coremodel, application, grilo, tracker_wrapper,
- songs_hash):
+ self, source, coremodel, application, tracker_wrapper, songs_hash):
"""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
+ :param dict songs_hash: The songs hash table
"""
super().__init__()
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
@@ -96,7 +93,6 @@ class GrlTrackerPlaylists(GObject.GObject):
args = {
"source": self._source,
"application": self._application,
- "grilo": self._grilo,
"tracker_wrapper": self._tracker_wrapper,
"songs_hash": self._songs_hash
}
@@ -151,7 +147,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, songs_hash=self._songs_hash)
self._model.append(playlist)
@@ -308,9 +304,8 @@ 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, songs_hash=None):
-
+ coremodel=None, application=None, tracker_wrapper=None,
+ songs_hash=None):
super().__init__()
"""Initialize a playlist
@@ -321,9 +316,8 @@ 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
+ :param dict songs_hash: The songs hash table
"""
if media:
self.props.pl_id = media.get_id()
@@ -335,11 +329,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._songs_hash = songs_hash
self._tracker = tracker_wrapper.props.tracker
@@ -417,7 +411,7 @@ class Playlist(GObject.GObject):
self._window.notifications_popup.pop_loading()
return
- coresong = CoreSong(media, self._coreselection, self._grilo)
+ coresong = CoreSong(self._application, media)
self._bind_to_main_song(coresong)
if coresong not in self._songs_todelete:
self._model.append(coresong)
@@ -610,7 +604,7 @@ class Playlist(GObject.GObject):
self.props.count = self._model.get_n_items()
return
- coresong = CoreSong(media, self._coreselection, self._grilo)
+ coresong = CoreSong(self._application, media)
self._bind_to_main_song(coresong)
if coresong not in self._songs_todelete:
self._model.append(coresong)
@@ -765,7 +759,7 @@ class SmartPlaylist(Playlist):
self.emit("playlist-loaded")
return
- coresong = CoreSong(media, self._coreselection, self._grilo)
+ coresong = CoreSong(self._application, media)
self._bind_to_main_song(coresong)
self._model.append(coresong)
@@ -818,7 +812,7 @@ class SmartPlaylist(Playlist):
for idx, media in enumerate(new_model_medias):
if media.get_id() not in current_models_ids:
- coresong = CoreSong(media, self._coreselection, self._grilo)
+ coresong = CoreSong(self._application, media)
self._bind_to_main_song(coresong)
self._model.append(coresong)
self.props.count += 1
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 97216261..8576678b 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -76,11 +76,9 @@ class GrlTrackerWrapper(GObject.GObject):
self._application = application
self._coremodel = coremodel
- self._coreselection = application.props.coreselection
- self._grilo = grilo
- self._source = None
self._log = application.props.log
self._songs_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
@@ -357,7 +355,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(self._application, media)
self._songs_model.append(song)
self._hash[media.get_id()] = song
else:
@@ -389,11 +387,11 @@ class GrlTrackerWrapper(GObject.GObject):
# hashtable.
self._tracker_playlists = GrlTrackerPlaylists(
self.props.source, self._coremodel, self._application,
- self._grilo, self._tracker_wrapper, self._hash)
+ self._tracker_wrapper, self._hash)
return
- song = CoreSong(media, self._coreselection, self._grilo)
+ song = CoreSong(self._application, media)
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]