[gnome-music] window: Change sync call to async while setting up views
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] window: Change sync call to async while setting up views
- Date: Sun, 20 Nov 2016 18:11:07 +0000 (UTC)
commit 5a613e05f08ec25dcfade1ddc2be789d212d0373
Author: Yash Singh <yashdev10p gmail com>
Date: Fri Nov 18 11:27:35 2016 +0530
window: Change sync call to async while setting up views
https://bugzilla.gnome.org/show_bug.cgi?id=772689
gnomemusic/window.py | 42 +++++++++++++++++++++++++-----------------
1 files changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 3893b07..9f5631d 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -214,27 +214,35 @@ class Window(Gtk.ApplicationWindow):
self._box.pack_start(self.player.actionbar, False, False, 0)
self._box.pack_start(self.selection_toolbar.actionbar, False, False, 0)
self.add(self._box)
- count = 0
- cursor = None
- Query()
- if Query.music_folder:
+ def cursor_next_cb(conn, res, data):
try:
- cursor = tracker.query(Query.all_songs_count(), None)
- if cursor is not None and cursor.next(None):
- count = cursor.get_integer(0)
- except Exception as e:
- logger.error("Tracker query crashed: %s", e)
- count = 0
-
- if count > 0:
- self._switch_to_player_view()
- # To revert to the No Music View when no songs are found
- else:
- if self.toolbar._selectionMode is False:
+ has_next = conn.next_finish(res)
+ except GLib.Error as err:
+ logger.warn("Error: %s, %s", err.__class__, err)
+ return
+
+ if has_next:
+ count = conn.get_integer(0)
+ if count > 0:
+ self._switch_to_player_view()
+ else:
self._switch_to_empty_view()
+
+ def songs_query_cb(conn, res, data):
+ try:
+ cursor = conn.query_finish(res)
+ except GLib.Error as err:
+ logger.warn("Error: %s, %s", err.__class__, err)
+ return
+
+ cursor.next_async(None, cursor_next_cb, None)
+
+ Query()
+ if Query.music_folder:
+ tracker.query_async(Query.all_songs_count(), None, songs_query_cb,
+ None)
else:
- # Revert to No Music view if XDG dirs are not set
self._switch_to_empty_view()
self.toolbar._search_button.connect('toggled', self._on_search_toggled)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]