[gnome-music] views: Remove redundant GLib.idle_add calls



commit 0d77105ae838fcaad91cb3c9ded911deb9213043
Author: Marinus Schraal <mschraal src gnome org>
Date:   Thu Nov 3 11:47:27 2016 +0100

    views: Remove redundant GLib.idle_add calls

 gnomemusic/grilo.py              |    7 ++++++-
 gnomemusic/views/albumsview.py   |    2 +-
 gnomemusic/views/artistsview.py  |    2 +-
 gnomemusic/views/playlistview.py |    5 ++---
 gnomemusic/views/songsview.py    |    2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index cba798c..a3bf159 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -257,6 +257,8 @@ class Grilo(GObject.GObject):
     @log
     def populate_album_songs(self, album, callback, count=-1):
         if album.get_source() == 'grl-tracker-source':
+            GLib.idle_add(self.populate_items,
+                          Query.album_songs(album.get_id()), 0, callback, count)
             self.populate_items(Query.album_songs(album.get_id()), 0, callback, count)
         else:
             source = self.sources[album.get_source()]
@@ -267,7 +269,10 @@ class Grilo(GObject.GObject):
 
     @log
     def populate_playlist_songs(self, playlist, callback, count=-1):
-        self.populate_items(Query.playlist_songs(playlist.get_id()), 0, callback, count)
+        if self.tracker:
+            GLib.idle_add(self.populate_items,
+                          Query.playlist_songs(playlist.get_id()), 0, callback,
+                          count)
 
     @log
     def populate_custom_query(self, query, callback, count=-1, data=None):
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 2259ab0..9f7c16d 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -124,7 +124,7 @@ class AlbumsView(BaseView):
     @log
     def populate(self):
         self.window._init_loading_notification()
-        GLib.idle_add(grilo.populate_albums, self._offset, self._add_item)
+        grilo.populate_albums(self._offset, self._add_item)
 
     @log
     def get_selected_tracks(self, callback):
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 022ccba..74ba460 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -168,7 +168,7 @@ class ArtistsView(BaseView):
     @log
     def populate(self):
         self.window._init_loading_notification()
-        GLib.idle_add(grilo.populate_artists, self._offset, self._add_item)
+        grilo.populate_artists(self._offset, self._add_item)
 
     @log
     def _on_header_bar_toggled(self, button):
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index af38645..defd39d 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -374,7 +374,7 @@ class PlaylistView(BaseView):
         self.view.set_model(None)
         self.model.clear()
         self.songs_count = 0
-        GLib.idle_add(grilo.populate_playlist_songs, playlist, self._add_item)
+        grilo.populate_playlist_songs(playlist, self._add_item)
 
         # disable delete button if current playlist is a smart playlist
         if self.current_playlist_is_protected():
@@ -525,8 +525,7 @@ class PlaylistView(BaseView):
     @log
     def populate(self):
         self.playlists_model.clear()
-        GLib.idle_add(grilo.populate_playlists, self._offset,
-                      self._add_playlist_item)
+        grilo.populate_playlists(self._offset, self._add_playlist_item)
 
     @log
     def get_selected_tracks(self, callback):
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index ba341d4..880ab88 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -223,7 +223,7 @@ class SongsView(BaseView):
     def populate(self):
         self._init = True
         self.window._init_loading_notification()
-        GLib.idle_add(grilo.populate_songs, self._offset, self._add_item)
+        grilo.populate_songs(self._offset, self._add_item)
 
     @log
     def get_selected_tracks(self, callback):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]