[gnome-music/wip/jfelder/fix-tracker-playlists: 1/2] grltrackerplaylists: Correctly retrieve tracker connection
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/fix-tracker-playlists: 1/2] grltrackerplaylists: Correctly retrieve tracker connection
- Date: Mon, 2 Sep 2019 22:34:46 +0000 (UTC)
commit 8b91254d5c944fbc0dfda33be59e3827d5f33d7b
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 parameter to the constructor, it is
possible to get the Tracker.SparqlConnection once it is available.
gnomemusic/coregrilo.py | 3 ++-
gnomemusic/grilowrappers/grltrackerplaylists.py | 17 ++++++++++++++---
gnomemusic/grilowrappers/grltrackerwrapper.py | 6 ++++--
3 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index d047f87f..47b3151e 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -122,7 +122,8 @@ class CoreGrilo(GObject.GObject):
and source.props.source_id not in self._wrappers.keys()
and new_state == TrackerState.AVAILABLE):
new_wrapper = GrlTrackerWrapper(
- source, self._coremodel, self._coreselection, self)
+ source, self._coremodel, self._coreselection, self,
+ self._tracker_wrapper)
self._wrappers[source.props.source_id] = new_wrapper
# elif source.props.source_id[:10] == "grl-dleyna":
# new_wrapper = GrlDLeynaWrapper(
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index e21d59ba..1313dfc5 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
@@ -58,7 +57,19 @@ class GrlTrackerPlaylists(GObject.GObject):
def __repr__(self):
return "<GrlTrackerPlaylists>"
- def __init__(self, source, coremodel, coreselection, grilo):
+ def __init__(
+ self, source, coremodel, coreselection, grilo, tracker_wrapper):
+ """Initialize GrlTrackerPlaylists.
+
+ :param Grl.TrackerSource source: The Tracker source to wrap
+ :param CoreModel coremodel: CoreModel instance to use models
+ from
+ :param CoreSelection coreselection: CoreSelection instance to
+ use
+ :param CoreGrilo grilo: The CoreGrilo instance
+ :param TrackerWrapper tracker_wrapper: The TrackerWrapper
+ instance
+ """
super().__init__()
self._coremodel = coremodel
@@ -68,7 +79,7 @@ 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
+ self._tracker = tracker_wrapper.props.tracker
self._fast_options = Grl.OperationOptions()
self._fast_options.set_resolution_flags(
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index c9a1a2bc..4aa57609 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -62,7 +62,8 @@ class GrlTrackerWrapper(GObject.GObject):
def __repr__(self):
return "<GrlTrackerWrapper>"
- def __init__(self, source, coremodel, coreselection, grilo):
+ def __init__(
+ self, source, coremodel, coreselection, grilo, tracker_wrapper):
"""Initialize the Tracker wrapper
:param Grl.TrackerSource source: The Tracker source to wrap
@@ -71,6 +72,7 @@ class GrlTrackerWrapper(GObject.GObject):
:param CoreSelection coreselection: CoreSelection instance to
use
:param CoreGrilo grilo: The CoreGrilo instance
+ :param TrackerWrapper tracker_wrapper: The TrackerWrapper instance
"""
super().__init__()
@@ -103,7 +105,7 @@ class GrlTrackerWrapper(GObject.GObject):
self._initial_artists_fill(self._source)
self._tracker_playlists = GrlTrackerPlaylists(
- source, coremodel, coreselection, grilo)
+ source, coremodel, coreselection, grilo, tracker_wrapper)
self._source.notify_change_start()
self._source.connect("content-changed", self._batch_content_changed)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]