[gnome-music] Move grilo.tracker checks to grilo
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Move grilo.tracker checks to grilo
- Date: Thu, 3 Nov 2016 09:59:33 +0000 (UTC)
commit 83c5022125c1f3ef69400472b612d2b8f21456b6
Author: Marinus Schraal <mschraal src gnome org>
Date: Tue Oct 11 09:37:06 2016 +0200
Move grilo.tracker checks to grilo
We were checking for a grilo.tracker instance all around the codebase,
while this could be just as well be done inside grilo.
gnomemusic/grilo.py | 16 ++++++++++++----
gnomemusic/mpris.py | 5 +----
gnomemusic/views/albumsview.py | 5 ++---
gnomemusic/views/artistsview.py | 5 ++---
gnomemusic/views/playlistview.py | 7 +++----
gnomemusic/views/songsview.py | 5 ++---
gnomemusic/widgets/playlistdialog.py | 3 +--
7 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index 7d32264..6d4d137 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -232,19 +232,27 @@ class Grilo(GObject.GObject):
@log
def populate_artists(self, offset, callback, count=-1):
- self.populate_items(Query.all_artists(), offset, callback, count)
+ if self.tracker:
+ GLib.idle_add(self.populate_items, Query.all_artists(), offset,
+ callback, count)
@log
def populate_albums(self, offset, callback, count=-1):
- self.populate_items(Query.all_albums(), offset, callback, count)
+ if self.tracker:
+ GLib.idle_add(self.populate_items, Query.all_albums(), offset,
+ callback, count)
@log
def populate_songs(self, offset, callback, count=-1):
- self.populate_items(Query.all_songs(), offset, callback, count)
+ if self.tracker:
+ GLib.idle_add(self.populate_items, Query.all_songs(), offset,
+ callback, count)
@log
def populate_playlists(self, offset, callback, count=-1):
- self.populate_items(Query.all_playlists(), offset, callback, count)
+ if self.tracker:
+ GLib.idle_add(self.populate_items, Query.all_playlists(), offset,
+ callback, count)
@log
def populate_album_songs(self, album, callback, count=-1):
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 995e579..40146fa 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -384,10 +384,7 @@ class MediaPlayer2Service(Server):
else:
callback(playlists)
- if grilo.tracker:
- GLib.idle_add(grilo.populate_playlists, 0, populate_callback)
- else:
- callback(playlists)
+ grilo.populate_playlists(0, populate_callback)
@log
def _get_active_playlist(self):
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index e196f4c..2259ab0 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -123,9 +123,8 @@ class AlbumsView(BaseView):
@log
def populate(self):
- if grilo.tracker:
- self.window._init_loading_notification()
- GLib.idle_add(grilo.populate_albums, self._offset, self._add_item)
+ self.window._init_loading_notification()
+ GLib.idle_add(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 eba4717..022ccba 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -167,9 +167,8 @@ class ArtistsView(BaseView):
@log
def populate(self):
- if grilo.tracker:
- self.window._init_loading_notification()
- GLib.idle_add(grilo.populate_artists, self._offset, self._add_item)
+ self.window._init_loading_notification()
+ GLib.idle_add(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 f2d5acc..af38645 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -524,10 +524,9 @@ class PlaylistView(BaseView):
@log
def populate(self):
- if grilo.tracker:
- self.playlists_model.clear()
- GLib.idle_add(grilo.populate_playlists, self._offset,
- self._add_playlist_item)
+ self.playlists_model.clear()
+ GLib.idle_add(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 d7e8092..ba341d4 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -222,9 +222,8 @@ class SongsView(BaseView):
@log
def populate(self):
self._init = True
- if grilo.tracker:
- self.window._init_loading_notification()
- GLib.idle_add(grilo.populate_songs, self._offset, self._add_item)
+ self.window._init_loading_notification()
+ GLib.idle_add(grilo.populate_songs, self._offset, self._add_item)
@log
def get_selected_tracks(self, callback):
diff --git a/gnomemusic/widgets/playlistdialog.py b/gnomemusic/widgets/playlistdialog.py
index 93d9d70..8998106 100644
--- a/gnomemusic/widgets/playlistdialog.py
+++ b/gnomemusic/widgets/playlistdialog.py
@@ -100,8 +100,7 @@ class PlaylistDialog():
@log
def populate(self):
- if grilo.tracker:
- GLib.idle_add(grilo.populate_playlists, 0, self._add_item)
+ grilo.populate_playlists(0, self._add_item)
@log
def _add_item(self, source, param, item, remaining=0, data=None):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]