[gnome-music/wip/jfelder/mpris-cleanup: 1/12] mpris: Simplify query playlists logic
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-cleanup: 1/12] mpris: Simplify query playlists logic
- Date: Fri, 7 Jun 2019 14:00:32 +0000 (UTC)
commit 0c8e8b9cb969d130148ce581bc2430c336e2b49a
Author: Jean Felder <jfelder src gnome org>
Date: Fri Jun 7 15:53:27 2019 +0200
mpris: Simplify query playlists logic
Merge _query_playlists and _reload_playlists functions. Indeed,
_query_playlists is only called by _reload_playlists.
gnomemusic/mpris.py | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 0b66bc70..755b9630 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -433,18 +433,6 @@ class MPRIS(DBusInterface):
return playlist
return None
- @log
- def _query_playlists(self, callback):
- playlists = []
-
- def populate_callback(source, param, item, remaining=0, data=None):
- if item:
- playlists.append(item)
- else:
- callback(playlists)
-
- grilo.populate_playlists(0, populate_callback)
-
@log
def _get_active_playlist(self):
"""Get Active Maybe_Playlist
@@ -551,13 +539,17 @@ class MPRIS(DBusInterface):
@log
def _reload_playlists(self):
- def query_playlists_callback(playlists):
- self._stored_playlists = playlists
- self.PropertiesChanged(
- MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
- {'PlaylistCount': GLib.Variant('u', len(playlists)), }, [])
+ def _populate_cb(source, param, item, remaining=0, data=None):
+ if item:
+ self._stored_playlists.append(item)
+ else:
+ playlists_nr = len(self._stored_playlists)
+ self.PropertiesChanged(
+ MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+ {'PlaylistCount': GLib.Variant('u', playlists_nr), }, [])
- self._query_playlists(query_playlists_callback)
+ self._stored_playlists = []
+ grilo.populate_playlists(0, _populate_cb)
@log
def _on_playlists_count_changed(self, playlists, item):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]