[gnome-music/wip/mschraal/restore-loading-notifications: 2/2] grltrackerwrapper: Enable notifications
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/restore-loading-notifications: 2/2] grltrackerwrapper: Enable notifications
- Date: Mon, 16 Sep 2019 15:56:47 +0000 (UTC)
commit fbcccdcb8cd4b13316bafe49383745b6a61ae489
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Sep 16 16:50:37 2019 +0200
grltrackerwrapper: Enable notifications
With the core rewrite loading notifcations had been disabled.
Restore loading notifications for GrlTrackerWrapper.
gnomemusic/coregrilo.py | 3 ++-
gnomemusic/grilowrappers/grltrackerplaylists.py | 36 +++++++++++++++++++------
gnomemusic/grilowrappers/grltrackerwrapper.py | 34 +++++++++++++++++++----
3 files changed, 59 insertions(+), 14 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 1c47624f..3da67772 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -54,6 +54,7 @@ class CoreGrilo(GObject.GObject):
def __init__(self, coremodel, application):
super().__init__()
+ self._application = application
self._coremodel = coremodel
self._coreselection = application.props.coreselection
self._search_wrappers = {}
@@ -122,7 +123,7 @@ class CoreGrilo(GObject.GObject):
and source.props.source_id not in self._wrappers.keys()
and new_state == TrackerState.AVAILABLE):
new_wrapper = GrlTrackerWrapper(
- source, self._coremodel, self._coreselection, self,
+ source, self._coremodel, self._application, self,
self._tracker_wrapper)
self._wrappers[source.props.source_id] = new_wrapper
# elif source.props.source_id[:10] == "grl-dleyna":
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index 0e2a0a4f..36b742ae 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -58,22 +58,23 @@ class GrlTrackerPlaylists(GObject.GObject):
return "<GrlTrackerPlaylists>"
def __init__(
- self, source, coremodel, coreselection, grilo, tracker_wrapper):
+ self, source, coremodel, application, grilo, tracker_wrapper):
"""Initialize GrlTrackerPlaylists.
:param Grl.TrackerSource source: The Tracker source to wrap
:param CoreModel coremodel: CoreModel instance to use models
from
- :param CoreSelection coreselection: CoreSelection instance to
- use
+ :param Application application: Application instance
:param CoreGrilo grilo: The CoreGrilo instance
:param TrackerWrapper tracker_wrapper: The TrackerWrapper
instance
"""
super().__init__()
+ self._application = application
self._coremodel = coremodel
- self._coreselection = coreselection
+ self._coreselection = application.props.coreselection
+ self._window = application.props.window
self._grilo = grilo
self._source = source
self._model = self._coremodel.props.playlists
@@ -93,7 +94,7 @@ class GrlTrackerPlaylists(GObject.GObject):
def _initial_playlists_fill(self):
args = {
"source": self._source,
- "coreselection": self._coreselection,
+ "application": self._application,
"grilo": self._grilo,
"tracker": self._tracker
}
@@ -109,6 +110,7 @@ class GrlTrackerPlaylists(GObject.GObject):
for playlist in smart_playlists.values():
self._model.append(playlist)
+ self._window.notifications_popup.push_loading()
query = """
SELECT DISTINCT
rdf:type(?playlist)
@@ -139,14 +141,16 @@ class GrlTrackerPlaylists(GObject.GObject):
self, source, op_id, media, remaining, data=None, error=None):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
self._coremodel.emit("playlists-loaded")
+ self._window.notifications_popup.pop_loading()
return
playlist = Playlist(
media=media, source=self._source, coremodel=self._coremodel,
- coreselection=self._coreselection, grilo=self._grilo,
+ application=self._application, grilo=self._grilo,
tracker=self._tracker)
self._model.append(playlist)
@@ -191,7 +195,9 @@ class GrlTrackerPlaylists(GObject.GObject):
break
self._model_filter.set_filter_func(self._playlists_filter)
+ self._window.notifications_popup.pop_loading()
+ self._window.notifications_popup.push_loading()
query = """
DELETE {
?playlist a rdfs:Resource .
@@ -242,6 +248,7 @@ class GrlTrackerPlaylists(GObject.GObject):
query, self.METADATA_KEYS, options, self._add_user_playlist,
callback)
+ self._window.notifications_popup.push_loading()
query = """
INSERT {
_:playlist a nmm:Playlist ;
@@ -291,7 +298,7 @@ class Playlist(GObject.GObject):
def __init__(
self, media=None, query=None, tag_text=None, source=None,
- coremodel=None, coreselection=None, grilo=None, tracker=None):
+ coremodel=None, application=None, grilo=None, tracker=None):
super().__init__()
if media:
@@ -305,9 +312,10 @@ class Playlist(GObject.GObject):
self._model = None
self._source = source
self._coremodel = coremodel
- self._coreselection = coreselection
+ self._coreselection = application.props.coreselection
self._grilo = grilo
self._tracker = tracker
+ self._window = application.props.window
self._fast_options = Grl.OperationOptions()
self._fast_options.set_resolution_flags(
@@ -329,6 +337,8 @@ class Playlist(GObject.GObject):
self._model = value
def _populate_model(self):
+ self._window.notifications_popup.push_loading()
+
query = """
SELECT
rdf:type(?song)
@@ -373,6 +383,7 @@ class Playlist(GObject.GObject):
if not media:
self.props.count = self._model.get_n_items()
self.emit("playlist-loaded")
+ self._window.notifications_popup.pop_loading()
return
coresong = CoreSong(media, self._coreselection, self._grilo)
@@ -391,11 +402,14 @@ class Playlist(GObject.GObject):
:param str new_name: new playlist name
"""
+ self._window.notifications_popup.push_loading()
+
def update_cb(conn, res, data):
# FIXME: Check for failure.
conn.update_finish(res)
# FIXME: Requery instead?
self.props.title = new_name
+ self._window.notifications_popup.pop_loading()
query = """
INSERT OR REPLACE {
@@ -448,7 +462,9 @@ class Playlist(GObject.GObject):
def update_cb(conn, res, data):
# FIXME: Check for failure.
conn.update_finish(res)
+ self._window.notifications_popup.pop_loading()
+ self._window.notifications_popup.push_loading()
query = """
INSERT OR REPLACE {
?entry nfo:listPosition ?position .
@@ -663,13 +679,17 @@ class SmartPlaylist(Playlist):
if self._model is None:
self._model = Gio.ListStore.new(CoreSong)
+ self._window.notifications_popup.push_loading()
+
def _add_to_model(source, op_id, media, remaining, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
self.props.count = self._model.get_n_items()
+ self._window.notifications_popup.pop_loading()
return
coresong = CoreSong(media, self._coreselection, self._grilo)
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 4aa57609..f6f44d22 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -63,21 +63,21 @@ class GrlTrackerWrapper(GObject.GObject):
return "<GrlTrackerWrapper>"
def __init__(
- self, source, coremodel, coreselection, grilo, tracker_wrapper):
+ self, source, coremodel, application, grilo, tracker_wrapper):
"""Initialize the Tracker wrapper
:param Grl.TrackerSource source: The Tracker source to wrap
:param CoreModel coremodel: CoreModel instance to use models
from
- :param CoreSelection coreselection: CoreSelection instance to
- use
+ :param Application application: Application instance
:param CoreGrilo grilo: The CoreGrilo instance
:param TrackerWrapper tracker_wrapper: The TrackerWrapper instance
"""
super().__init__()
self._coremodel = coremodel
- self._coreselection = coreselection
+ self._coreselection = application.props.coreselection
+ self._window = application.props.window
self._grilo = grilo
self._source = source
self._model = self._coremodel.props.songs
@@ -105,7 +105,7 @@ class GrlTrackerWrapper(GObject.GObject):
self._initial_artists_fill(self._source)
self._tracker_playlists = GrlTrackerPlaylists(
- source, coremodel, coreselection, grilo, tracker_wrapper)
+ source, coremodel, application, grilo, tracker_wrapper)
self._source.notify_change_start()
self._source.connect("content-changed", self._batch_content_changed)
@@ -352,13 +352,16 @@ class GrlTrackerWrapper(GObject.GObject):
options, _update_changed_media)
def _initial_songs_fill(self, source):
+ self._window.notifications_popup.push_loading()
def _add_to_model(source, op_id, media, user_data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
+ self._window.notifications_popup.pop_loading()
return
song = CoreSong(media, self._coreselection, self._grilo)
@@ -398,13 +401,16 @@ class GrlTrackerWrapper(GObject.GObject):
self._source.query(query, self.METADATA_KEYS, options, _add_to_model)
def _initial_albums_fill(self, source):
+ self._window.notifications_popup.push_loading()
def _add_to_albums_model(source, op_id, media, user_data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
+ self._window.notifications_popup.pop_loading()
return
album = CoreAlbum(media, self._coremodel)
@@ -442,14 +448,17 @@ class GrlTrackerWrapper(GObject.GObject):
source.query(query, self.METADATA_KEYS, options, _add_to_albums_model)
def _initial_artists_fill(self, source):
+ self._window.notifications_popup.push_loading()
def _add_to_artists_model(source, op_id, media, user_data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
self._coremodel.emit("artists-loaded")
+ self._window.notifications_popup.pop_loading()
return
artist = CoreArtist(media, self._coremodel)
@@ -485,6 +494,7 @@ class GrlTrackerWrapper(GObject.GObject):
:param Grl.Media media: The media with the artist id
:param Gfm.FilterListModel model: The model to fill
"""
+ self._window.notifications_popup.push_loading()
artist_id = media.get_id()
query = """
@@ -515,10 +525,12 @@ class GrlTrackerWrapper(GObject.GObject):
def query_cb(source, op_id, media, user_data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
model.set_filter_func(albums_filter, albums)
+ self._window.notifications_popup.pop_loading()
return
albums.append(media)
@@ -540,6 +552,7 @@ class GrlTrackerWrapper(GObject.GObject):
:param Grl.Media media: The media with the album id
:param Gfm.SortListModel disc_model: The model to fill
"""
+ self._window.notifications_popup.push_loading()
album_id = media.get_id()
query = """
@@ -562,9 +575,11 @@ class GrlTrackerWrapper(GObject.GObject):
def _disc_nr_cb(source, op_id, media, user_data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
+ self._window.notifications_popup.pop_loading()
return
disc_nr = media.get_album_disc_number()
@@ -632,6 +647,7 @@ class GrlTrackerWrapper(GObject.GObject):
GLib.utf8_casefold(text, -1), -1, GLib.NormalizeMode.NFKD))
# Artist search
+ self._window.notifications_popup.push_loading()
query = """
SELECT DISTINCT
@@ -673,10 +689,12 @@ class GrlTrackerWrapper(GObject.GObject):
def artist_search_cb(source, op_id, media, data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
self._artist_search_model.set_filter_func(artist_filter)
+ self._window.notifications_popup.pop_loading()
return
artist_filter_ids.append(media.get_id())
@@ -686,6 +704,7 @@ class GrlTrackerWrapper(GObject.GObject):
query, self.METADATA_KEYS, options, artist_search_cb)
# Album search
+ self._window.notifications_popup.push_loading()
query = """
SELECT DISTINCT
@@ -725,10 +744,12 @@ class GrlTrackerWrapper(GObject.GObject):
def albums_search_cb(source, op_id, media, data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
self._album_search_model.set_filter_func(album_filter)
+ self._window.notifications_popup.pop_loading()
return
album_filter_ids.append(media.get_id())
@@ -738,6 +759,7 @@ class GrlTrackerWrapper(GObject.GObject):
query, self.METADATA_KEYS, options, albums_search_cb)
# Song search
+ self._window.notifications_popup.push_loading()
query = """
SELECT DISTINCT
@@ -783,10 +805,12 @@ class GrlTrackerWrapper(GObject.GObject):
def songs_search_cb(source, op_id, media, data, error):
if error:
print("ERROR", error)
+ self._window.notifications_popup.pop_loading()
return
if not media:
self._song_search_tracker.set_filter_func(songs_filter)
+ self._window.notifications_popup.pop_loading()
return
filter_ids.append(media.get_id())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]