[gnome-music/wip/jfelder/fix-tracker-playlists: 1/2] grltrackerplaylists: Correctly retrieve tracker connection



commit 749ccf58b645cf09906a0ce7084dfddae1cc050d
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Sep 2 23:09:28 2019 +0200

    grltrackerplaylists: Correctly retrieve tracker connection
    
    The call to Tracker.SparqlConnection is an async. So, the connection
    is not set when TrackerWrapper is initialized.
    
    By adding a tracker_wrapper property to CoreGrilo, it is possible to
    get the Tracker.SparqlConnection once it is available.

 gnomemusic/coregrilo.py                         | 10 ++++++++++
 gnomemusic/grilowrappers/grltrackerplaylists.py |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index d047f87f..4d8d3431 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -144,6 +144,16 @@ class CoreGrilo(GObject.GObject):
         # FIXME: Only removes search sources atm.
         self._search_wrappers.pop(source.props.source_id, None)
 
+    @GObject.Property(
+        type=TrackerWrapper, default=None, flags=GObject.ParamFlags.READABLE)
+    def tracker_wrapper(self):
+        """Get TrackerWrapper
+
+        :returns: Tracker connection wrapper
+        :rtype: TrackerWrapper
+        """
+        return self._tracker_wrapper
+
     def get_artist_albums(self, artist, filter_model):
         for wrapper in self._wrappers.values():
             wrapper.get_artist_albums(artist, filter_model)
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index e21d59ba..89753b1d 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -68,7 +68,8 @@ class GrlTrackerPlaylists(GObject.GObject):
         self._model = self._coremodel.props.playlists
         self._model_filter = self._coremodel.props.playlists_filter
         self._pls_todelete = []
-        self._tracker = TrackerWrapper().props.tracker
+        tracker_wrapper = self._grilo.props.tracker_wrapper
+        self._tracker = tracker_wrapper.props.tracker
 
         self._fast_options = Grl.OperationOptions()
         self._fast_options.set_resolution_flags(


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