[gnome-music/wip/jfelder/coregrilo-tracker-plugin] coregrilo: Properly load tracker plugin



commit 94b591fee1d6bed5d938755b4b48bb55be31d742
Author: Jean Felder <jfelder src gnome org>
Date:   Wed Feb 19 17:56:06 2020 +0100

    coregrilo: Properly load tracker plugin
    
    All grilo plugins are loaded at startup. However, TrackerWrapper may
    not be available yet. In that case, GrlTrackerWrapper is not
    created. Once TrackerWrapper becomes available, all grilo plugins are
    loaded again in order to instantiate GrlTrackerWrapper.
    This approach has two issues:
    - all plugins are activated two times
    - TrackerWrapper may become available while the first tracker source
    is added. In that case, GrlTrackerWrapper is instantiated with a first
    source but a second source will be created by the second
    load_all_plugins call (a new source is created everytime the tracker
    plugin is activated). Then, GrlTrackerWrapper won't get any
    notification because they will be associated with the second source
    and not the first one.
    
    Both issues can be solved by only (re)loading the tracker plugin when
    TrackerWrapper becomes available.

 gnomemusic/coregrilo.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 628645fb..c3c13a8d 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -94,9 +94,10 @@ class CoreGrilo(GObject.GObject):
         new_state = self._tracker_wrapper.props.tracker_available
         # FIXME:No removal support yet.
         if new_state == TrackerState.AVAILABLE:
-            # FIXME: Look for a better way to just activate the Tracker
-            # plugin.
-            self._registry.load_all_plugins(True)
+            tracker_plugin = self._registry.lookup_plugin("grl-tracker")
+            if tracker_plugin:
+                self._registry.unload_plugin("grl-tracker")
+            self._registry.lookup_plugin("grl-tracker")
 
     def _on_source_added(self, registry, source):
 


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