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



commit 9f4b01d0c23b16b81d2d8fabece03ffbca54ced0
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 |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)
---
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..503ff690 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -31,7 +31,6 @@ gi.require_versions({"Grl": "0.3"})
 from gi.repository import Gio, Grl, GLib, GObject
 
 from gnomemusic.coresong import CoreSong
-from gnomemusic.trackerwrapper import TrackerWrapper
 import gnomemusic.utils as utils
 
 
@@ -68,7 +67,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]