[gnome-music/wip/jfelder/playlists-core-rewrite-prep-work: 16/24] playlists: Introduce a ready property
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/playlists-core-rewrite-prep-work: 16/24] playlists: Introduce a ready property
- Date: Wed, 3 Jul 2019 16:49:11 +0000 (UTC)
commit b2a776221b38607f2e302c9215be5cdfe925f30f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Dec 1 11:39:09 2016 -0200
playlists: Introduce a ready property
The Playlists:ready property informs us whether we're still
fetching the playlists or not. This property will be consumed
by the Playlists view to show a loading notification.
gnomemusic/playlists.py | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 97439f49..e1329333 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -204,7 +204,11 @@ class Playlists(GObject.GObject):
self._pls_todelete = {}
- grilo.connect('ready', self._on_grilo_ready)
+ self._loading_counter = len(self._smart_playlists)
+ self._user_playlists_ready = False
+ self._ready = False
+
+ grilo.connect("ready", self._on_grilo_ready)
@log
def _on_grilo_ready(self, data=None):
@@ -242,6 +246,8 @@ class Playlists(GObject.GObject):
cursor.next_async(None, playlist_id_fetched_cb, playlist)
self._tracker = grilo.tracker_sparql
+ self.notify("ready")
+
# Start fetching all the smart playlists
for playlist in self._smart_playlists.values():
self._tracker.query_async(
@@ -257,6 +263,8 @@ class Playlists(GObject.GObject):
self, source, param, item, remaining=0, data=None):
"""Fill in the list of playlists currently available"""
if not item:
+ self._user_playlists_ready = True
+ self._check_ready()
return
playlist = Playlist(
@@ -387,6 +395,10 @@ class Playlists(GObject.GObject):
self._model.insert_sorted(
smart_playlist, Playlist.compare_playlist_func)
+ # Check if we're ready
+ self._loading_counter = self._loading_counter - 1
+ self._check_ready()
+
@log
def update_all_smart_playlists(self):
for playlist in self._smart_playlists.values():
@@ -623,3 +635,20 @@ class Playlists(GObject.GObject):
self._model.insert(index, playlist)
return index
+
+ @GObject.Property(
+ type=bool, default=False, flags=GObject.ParamFlags.READABLE)
+ def ready(self):
+ """Playlists ready getter
+
+ :returns: True if the playlists are loaded
+ :rtype: bool
+ """
+ return self._ready
+
+ def _check_ready(self):
+ ready = (self._user_playlists_ready
+ and self._loading_counter == 0)
+ if ready != self._ready:
+ self._ready = ready
+ self.notify("ready")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]