Commit 398a74c7 authored by Yash Singh's avatar Yash Singh Committed by Marinus Schraal

window: Change sync calls to async while selecting/deselecting songs
parent 2455435f
...@@ -108,28 +108,46 @@ class Window(Gtk.ApplicationWindow): ...@@ -108,28 +108,46 @@ class Window(Gtk.ApplicationWindow):
@log @log
def _on_changes_pending(self, data=None): def _on_changes_pending(self, data=None):
count = 1
cursor = tracker.query(Query.all_songs_count(), None) def cursor_next_cb(conn, res, data):
if cursor is not None and try:
count = cursor.get_integer(0) has_next = conn.next_finish(res)
if not count > 0: except GLib.Error as err:
if self.toolbar._selectionMode is False and len(self.views) != 1: logger.warn("Error: %s, %s", err.__class__, err)
self._stack.disconnect(self._on_notify_model_id) return
view_count = len(self.views) if has_next:
for i in range(0, view_count): count = conn.get_integer(0)
view = self.views.pop() if (count > 0):
view.destroy() if (self.views[0] == self.views[-1]):
self.toolbar.hide_stack() view = self.views.pop()
self._switch_to_empty_view() view.destroy()
else: self._switch_to_player_view()
if (self.views[0] == self.views[-1]): self.toolbar._search_button.set_sensitive(True)
view = self.views.pop() self.toolbar._select_button.set_sensitive(True)
view.destroy() self.toolbar.show_stack()
self._switch_to_player_view() elif (self.toolbar._selectionMode is False
self.toolbar._search_button.set_sensitive(True) and len(self.views) != 1):
self.toolbar._select_button.set_sensitive(True) self._stack.disconnect(self._on_notify_model_id)
self.toolbar.show_stack() self.disconnect(self._key_press_event_id)
view_count = len(self.views)
for i in range(0, view_count):
view = self.views.pop()
def songs_query_cb(conn, res, data):
cursor = conn.query_finish(res)
except GLib.Error as err:
logger.warn("Error: %s, %s", err.__class__, err)
cursor.next_async(None, cursor_next_cb, None)
tracker.query_async(Query.all_songs_count(), None, songs_query_cb,
def _on_configure_event(self, widget, event): def _on_configure_event(self, widget, event):
if self.window_size_update_timeout is None: if self.window_size_update_timeout is None:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment