[gnome-music/wip/jfelder/tracker3: 1/2] coregrilo: Clean up plugin activation for Tracker
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/tracker3: 1/2] coregrilo: Clean up plugin activation for Tracker
- Date: Mon, 24 Aug 2020 20:17:52 +0000 (UTC)
commit db1df5126b6fcb843f6dfd18fe96ed957a504960
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jul 29 14:36:07 2020 +0200
coregrilo: Clean up plugin activation for Tracker
The Tracker plugin loading has proven to be problematic over time, due
to how the plugin behaves and it interacts with Grilo and Music code,
see d7425fabf6 and 11f796999c for reference. This has resulted in
a difficult to comprehend loading procedure which needs background
knowledge to make sense.
Rework CoreGrilo plugin loading and activation to be different steps and
only activate the Tracker plugin when TrackerWrapper becomes available.
gnomemusic/coregrilo.py | 49 +++++++++++++++++++++++++++----------------------
meson.build | 2 +-
2 files changed, 28 insertions(+), 23 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index d96eb1b5..aabd3f74 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -74,9 +74,6 @@ class CoreGrilo(GObject.GObject):
"tracker-available", self, "tracker-available",
GObject.BindingFlags.SYNC_CREATE)
- self._tracker_wrapper.connect(
- "notify::tracker-available", self._on_tracker_available_changed)
-
GLib.setenv("GRL_PLUGIN_RANKS", self._grl_plugin_ranks, True)
Grl.init(None)
@@ -96,17 +93,34 @@ class CoreGrilo(GObject.GObject):
self._registry.connect('source-added', self._on_source_added)
self._registry.connect('source-removed', self._on_source_removed)
- self._registry.load_all_plugins(True)
+ self._registry.load_all_plugins(False)
+
+ tracker_available_state = self._tracker_wrapper.props.tracker_available
+ if tracker_available_state != TrackerState.AVAILABLE:
+ self._tracker_wrapper.connect(
+ "notify::tracker-available",
+ self._on_tracker_available_changed)
+ else:
+ self._on_tracker_available_changed(None, None)
+
+ for plugin in self._registry.get_plugins(False):
+ plugin_id = plugin.get_id()
+ # Activate the Tracker plugin only when TrackerWrapper
+ # is available by listening to the tracker-available
+ # property, so skip it here.
+ if plugin_id != "grl-tracker3":
+ try:
+ self._registry.activate_plugin_by_id(plugin_id)
+ except GLib.GError:
+ self._log.debug(
+ "Failed to activate {} plugin.".format(plugin_id))
weakref.finalize(self, Grl.deinit)
def _on_tracker_available_changed(self, klass, value):
- new_state = self._tracker_wrapper.props.tracker_available
# FIXME:No removal support yet.
+ new_state = self._tracker_wrapper.props.tracker_available
if new_state == TrackerState.AVAILABLE:
- tracker_plugin = self._registry.lookup_plugin("grl-tracker3")
- if tracker_plugin:
- self._registry.unload_plugin("grl-tracker3")
self._registry.activate_plugin_by_id("grl-tracker3")
def _on_source_added(self, registry, source):
@@ -135,21 +149,12 @@ class CoreGrilo(GObject.GObject):
self._thumbnail_sources_timeout = GLib.timeout_add_seconds(
5, _trigger_art_update)
- new_wrapper = None
-
- new_state = self._tracker_wrapper.props.tracker_available
if (source.props.source_id == "grl-tracker3-source"
- and self._tracker_wrapper.location_filter() is not None
- and new_state == TrackerState.AVAILABLE):
- if source.props.source_id not in self._wrappers.keys():
- new_wrapper = GrlTrackerWrapper(
- source, self._application, self._tracker_wrapper)
- self._wrappers[source.props.source_id] = new_wrapper
- self._log.debug("Adding wrapper {}".format(new_wrapper))
- else:
- grl_tracker_wrapper = self._wrappers[source.props.source_id]
- registry.unregister_source(grl_tracker_wrapper.props.source)
- grl_tracker_wrapper.props.source = source
+ and self._tracker_wrapper.location_filter() is not None):
+ new_wrapper = GrlTrackerWrapper(
+ source, self._application, self._tracker_wrapper)
+ self._wrappers[source.props.source_id] = new_wrapper
+ self._log.debug("Adding wrapper {}".format(new_wrapper))
elif (source.props.source_id not in self._search_wrappers.keys()
and source.props.source_id not in self._wrappers.keys()
and source.props.source_id != "grl-tracker3-source"
diff --git a/meson.build b/meson.build
index a01c1c90..2cc2566f 100644
--- a/meson.build
+++ b/meson.build
@@ -46,7 +46,7 @@ dependency('tracker-sparql-3.0', version: '>= 2.99.2')
dependency('pango', version: '>= 1.44.0')
dependency('pygobject-3.0', version: '>= 3.36.1')
dependency('py3cairo', version: '>= 1.14.0')
-dependency('grilo-0.3', version: '>= 0.3.12', fallback: ['grilo', 'libgrl_dep'])
+dependency('grilo-0.3', version: '>= 0.3.13', fallback: ['grilo', 'libgrl_dep'])
dependency('grilo-plugins-0.3', version: '>= 0.3.12', fallback: ['grilo-plugins', 'grilo_plugins_dep'])
subproject('libgd',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]