[gnome-music] playlists: More async work
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] playlists: More async work
- Date: Tue, 15 Nov 2016 15:25:52 +0000 (UTC)
commit c75599e0e3b350ee702842930aedd2faceabf3f6
Author: Marinus Schraal <mschraal src gnome org>
Date: Tue Nov 15 16:18:06 2016 +0100
playlists: More async work
gnomemusic/playlists.py | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/playlists.py b/gnomemusic/playlists.py
index 7ced2c7..2a7f5cc 100644
--- a/gnomemusic/playlists.py
+++ b/gnomemusic/playlists.py
@@ -273,7 +273,7 @@ class Playlists(GObject.GObject):
# Get a list of matching songs
try:
- cursor = self.tracker.query_finish(res)
+ cursor = connection.query_finish(res)
except GLib.Error as err:
logger.warn("Error: %s, %s", err.__class__, err)
return
@@ -313,13 +313,32 @@ class Playlists(GObject.GObject):
if item:
self.emit('playlist-created', item)
- def query_callback(conn, res, data):
- cursor = conn.query_finish(res)
- if not cursor or not cursor.next():
+ def cursor_callback(cursor, res, data):
+ try:
+ has_next = cursor.next_finish()
+ except GLib.Error as err:
+ logger.warn("Error: %s, %s", err.__class__, err)
return
+
+ if has_next:
+ cursor.next_async(None, cursor_callback, data)
+ return
+
playlist_id = cursor.get_integer(0)
grilo.get_playlist_with_id(playlist_id, get_callback)
+ def query_callback(conn, res, data):
+ try:
+ cursor = conn.query_finish(res)
+ except GLib.Error as err:
+ logger.warn("Error: %s, %s", err.__class__, err)
+ return
+
+ if not cursor:
+ return
+
+ cursor.next_async(None, cursor_callback, data)
+
def update_callback(conn, res, data):
playlist_urn = conn.update_blank_finish(res)[0][0]['playlist']
self.tracker.query_async(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]