[gnome-music/wip/mschraal/coresong-thumbnail-prop: 16/35] coresong: Pass Application to init
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/coresong-thumbnail-prop: 16/35] coresong: Pass Application to init
- Date: Sun, 5 Jan 2020 16:14:40 +0000 (UTC)
commit 124d97eaeacfb769c3e2ba4fa5840ffa1d3a425f
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/coregrilo.py | 2 +-
gnomemusic/coremodel.py | 21 +++++----------------
gnomemusic/coresong.py | 6 +++---
gnomemusic/grilowrappers/grlsearchwrapper.py | 7 ++++---
gnomemusic/grilowrappers/grltrackerplaylists.py | 21 +++++++--------------
gnomemusic/grilowrappers/grltrackerwrapper.py | 9 ++++-----
6 files changed, 24 insertions(+), 42 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index ed2c9993..67a3101c 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -149,7 +149,7 @@ class CoreGrilo(GObject.GObject):
and source.get_supported_media() & Grl.MediaType.AUDIO
and source.supported_operations() & Grl.SupportedOps.SEARCH):
self._search_wrappers[source.props.source_id] = GrlSearchWrapper(
- source, self._coremodel, self._coreselection, self)
+ source, self._application, self._coremodel, self)
print("search source", source)
def _on_source_removed(self, registry, source):
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 13a8bc0e..60f7548a 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)
@@ -249,9 +246,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)
@@ -290,9 +285,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(
@@ -315,9 +308,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(
@@ -347,9 +338,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 1b50dcba..d7ceedc7 100644
--- a/gnomemusic/grilowrappers/grlsearchwrapper.py
+++ b/gnomemusic/grilowrappers/grlsearchwrapper.py
@@ -51,11 +51,12 @@ class GrlSearchWrapper(GObject.GObject):
def __repr__(self):
return "<GrlSearchWrapper>"
- def __init__(self, source, coremodel, coreselection, grilo):
+ def __init__(self, source, application, coremodel, grilo):
super().__init__()
+ self._application = application
self._coremodel = coremodel
- self._coreselection = coreselection
+ self._coreselection = application.props.coreselection
self._grilo = grilo
self._source = source
@@ -85,7 +86,7 @@ class GrlSearchWrapper(GObject.GObject):
if media is None:
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 acd626a9..9a717eaa 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -59,14 +59,13 @@ class GrlTrackerPlaylists(GObject.GObject):
return "<GrlTrackerPlaylists>"
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
"""
@@ -74,8 +73,6 @@ class GrlTrackerPlaylists(GObject.GObject):
self._application = application
self._coremodel = coremodel
- self._coreselection = application.props.coreselection
- self._grilo = grilo
self._source = source
self._model = self._coremodel.props.playlists
self._model_filter = self._coremodel.props.playlists_filter
@@ -96,7 +93,6 @@ class GrlTrackerPlaylists(GObject.GObject):
args = {
"source": self._source,
"application": self._application,
- "grilo": self._grilo,
"tracker": self._tracker
}
@@ -151,8 +147,7 @@ class GrlTrackerPlaylists(GObject.GObject):
playlist = Playlist(
media=media, source=self._source, coremodel=self._coremodel,
- application=self._application, grilo=self._grilo,
- tracker=self._tracker)
+ application=self._application, tracker=self._tracker)
self._model.append(playlist)
callback = data
@@ -299,7 +294,7 @@ class Playlist(GObject.GObject):
def __init__(
self, media=None, query=None, tag_text=None, source=None,
- coremodel=None, application=None, grilo=None, tracker=None):
+ coremodel=None, application=None, tracker=None):
super().__init__()
"""Initialize a playlist
@@ -311,7 +306,6 @@ 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: The TrackerWrapper instance
"""
if media:
@@ -322,11 +316,10 @@ 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._tracker = tracker
self._window = application.props.window
@@ -399,7 +392,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)
@@ -554,7 +547,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)
@@ -705,7 +698,7 @@ class SmartPlaylist(Playlist):
self._window.notifications_popup.pop_loading()
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 debe4d21..34ccb08c 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -78,9 +78,8 @@ class GrlTrackerWrapper(GObject.GObject):
"""
super().__init__()
+ self._application = application
self._coremodel = coremodel
- self._coreselection = application.props.coreselection
- self._grilo = grilo
self._source = source
self._model = self._coremodel.props.songs
self._albums_model = self._coremodel.props.albums
@@ -108,7 +107,7 @@ class GrlTrackerWrapper(GObject.GObject):
self._initial_artists_fill(self._source)
self._tracker_playlists = GrlTrackerPlaylists(
- source, coremodel, application, grilo, tracker_wrapper)
+ source, coremodel, application, tracker_wrapper)
self._source.notify_change_start()
self._source.connect("content-changed", self._batch_content_changed)
@@ -335,7 +334,7 @@ class GrlTrackerWrapper(GObject.GObject):
if media.get_id() not in self._hash:
print("Media not in hash", 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:
@@ -362,7 +361,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]