[gnome-music/sam/tracker3-self-contained] Improve how we get D-Bus connection



commit 55758efba7e853555c1f32c20ba36c74e2efed49
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Jul 10 02:07:24 2020 +0200

    Improve how we get D-Bus connection
    
    We can simplify the previous commit by using the DBusConnection
    from the GApplication instance.

 gnomemusic/coregrilo.py      |  3 +--
 gnomemusic/trackerwrapper.py | 16 ++++++----------
 2 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 636b5165..d415e9f9 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -74,8 +74,7 @@ class CoreGrilo(GObject.GObject):
         self._wrappers = {}
         self._mb_wrappers = {}
 
-        application_id = application.get_application_id()
-        self._tracker_wrapper = TrackerWrapper(application_id)
+        self._tracker_wrapper = TrackerWrapper(application)
         self._tracker_wrapper.bind_property(
             "tracker-available", self, "tracker-available",
             GObject.BindingFlags.SYNC_CREATE)
diff --git a/gnomemusic/trackerwrapper.py b/gnomemusic/trackerwrapper.py
index 20b9f6f2..cfeda71a 100644
--- a/gnomemusic/trackerwrapper.py
+++ b/gnomemusic/trackerwrapper.py
@@ -62,11 +62,11 @@ def in_flatpak():
 class TrackerWrapper(GObject.GObject):
     """Create a connection to an instance of Tracker"""
 
-    def __init__(self, application_id):
+    def __init__(self, application):
         super().__init__()
 
         self._log = MusicLogger()
-        self._application_id = application_id
+        self._application = application
 
         self._local_db = None
         self._local_db_available = TrackerState.UNAVAILABLE
@@ -107,17 +107,13 @@ class TrackerWrapper(GObject.GObject):
                 self.notify('tracker-available')
 
     def _setup_local_miner_fs(self):
-        self._miner_fs_busname = self._application_id + '.Tracker3.Miner.Files'
+        app_id = self._application.get_application_id()
+        bus = self._application.get_dbus_connection()
+
+        self._miner_fs_busname = app_id + '.Tracker3.Miner.Files'
         self._log.debug("Connecting to bundled Tracker indexer at {}"
                         .format(self._miner_fs_busname))
 
-        Gio.bus_get(Gio.BusType.SESSION, None,
-                    self._setup_local_bus_connection_cb)
-
-    def _setup_local_bus_connection_cb(self, klass, result):
-        # Query callback for _setup_local_miner_fs() to connect to session bus
-        bus = Gio.bus_get_finish(result)
-
         miner_fs_startup_timeout_msec = 30 * 1000
         miner_fs_object_path = '/org/freedesktop/Tracker3/Miner/Files'
 


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