Commit 83c50221 authored by Marinus Schraal's avatar Marinus Schraal

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.
parent 2601c2d9
...@@ -232,19 +232,27 @@ class Grilo(GObject.GObject): ...@@ -232,19 +232,27 @@ class Grilo(GObject.GObject):
@log @log
def populate_artists(self, offset, callback, count=-1): 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 @log
def populate_albums(self, offset, callback, count=-1): 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 @log
def populate_songs(self, offset, callback, count=-1): 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 @log
def populate_playlists(self, offset, callback, count=-1): 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 @log
def populate_album_songs(self, album, callback, count=-1): def populate_album_songs(self, album, callback, count=-1):
......
...@@ -384,10 +384,7 @@ class MediaPlayer2Service(Server): ...@@ -384,10 +384,7 @@ class MediaPlayer2Service(Server):
else: else:
callback(playlists) callback(playlists)
if grilo.tracker: grilo.populate_playlists(0, populate_callback)
GLib.idle_add(grilo.populate_playlists, 0, populate_callback)
else:
callback(playlists)
@log @log
def _get_active_playlist(self): def _get_active_playlist(self):
......
...@@ -123,9 +123,8 @@ class AlbumsView(BaseView): ...@@ -123,9 +123,8 @@ class AlbumsView(BaseView):
@log @log
def populate(self): def populate(self):
if grilo.tracker: self.window._init_loading_notification()
self.window._init_loading_notification() GLib.idle_add(grilo.populate_albums, self._offset, self._add_item)
GLib.idle_add(grilo.populate_albums, self._offset, self._add_item)
@log @log
def get_selected_tracks(self, callback): def get_selected_tracks(self, callback):
......
...@@ -167,9 +167,8 @@ class ArtistsView(BaseView): ...@@ -167,9 +167,8 @@ class ArtistsView(BaseView):
@log @log
def populate(self): def populate(self):
if grilo.tracker: self.window._init_loading_notification()
self.window._init_loading_notification() GLib.idle_add(grilo.populate_artists, self._offset, self._add_item)
GLib.idle_add(grilo.populate_artists, self._offset, self._add_item)
@log @log
def _on_header_bar_toggled(self, button): def _on_header_bar_toggled(self, button):
......
...@@ -524,10 +524,9 @@ class PlaylistView(BaseView): ...@@ -524,10 +524,9 @@ class PlaylistView(BaseView):
@log @log
def populate(self): def populate(self):
if grilo.tracker: self.playlists_model.clear()
self.playlists_model.clear() GLib.idle_add(grilo.populate_playlists, self._offset,
GLib.idle_add(grilo.populate_playlists, self._offset, self._add_playlist_item)
self._add_playlist_item)
@log @log
def get_selected_tracks(self, callback): def get_selected_tracks(self, callback):
......
...@@ -222,9 +222,8 @@ class SongsView(BaseView): ...@@ -222,9 +222,8 @@ class SongsView(BaseView):
@log @log
def populate(self): def populate(self):
self._init = True self._init = True
if grilo.tracker: self.window._init_loading_notification()
self.window._init_loading_notification() GLib.idle_add(grilo.populate_songs, self._offset, self._add_item)
GLib.idle_add(grilo.populate_songs, self._offset, self._add_item)
@log @log
def get_selected_tracks(self, callback): def get_selected_tracks(self, callback):
......
...@@ -100,8 +100,7 @@ class PlaylistDialog(): ...@@ -100,8 +100,7 @@ class PlaylistDialog():
@log @log
def populate(self): def populate(self):
if grilo.tracker: grilo.populate_playlists(0, self._add_item)
GLib.idle_add(grilo.populate_playlists, 0, self._add_item)
@log @log
def _add_item(self, source, param, item, remaining=0, data=None): def _add_item(self, source, param, item, remaining=0, data=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