[gnome-music/wip/carlosg/tracker3: 7/55] Port to tracker3




commit 926785a05fd314ba4d8e1b51f0cf9553b3bc7626
Author: Jean Felder <jfelder src gnome org>
Date:   Mon May 25 20:23:35 2020 +0200

    Port to tracker3

 gnomemusic/coregrilo.py                       | 34 +++++++++++++--------------
 gnomemusic/grilowrappers/grltrackerwrapper.py |  2 +-
 gnomemusic/trackerwrapper.py                  | 18 ++++++++------
 gnomemusic/views/emptyview.py                 |  2 +-
 meson.build                                   |  4 ++--
 5 files changed, 32 insertions(+), 28 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index dcdfa8f8..cf58894d 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -97,10 +97,10 @@ class CoreGrilo(GObject.GObject):
         new_state = self._tracker_wrapper.props.tracker_available
         # FIXME:No removal support yet.
         if new_state == TrackerState.AVAILABLE:
-            tracker_plugin = self._registry.lookup_plugin("grl-tracker")
+            tracker_plugin = self._registry.lookup_plugin("grl-tracker3")
             if tracker_plugin:
-                self._registry.unload_plugin("grl-tracker")
-            self._registry.activate_plugin_by_id("grl-tracker")
+                self._registry.unload_plugin("grl-tracker3")
+            self._registry.activate_plugin_by_id("grl-tracker3")
 
     def _on_source_added(self, registry, source):
 
@@ -131,7 +131,7 @@ class CoreGrilo(GObject.GObject):
         new_wrapper = None
 
         new_state = self._tracker_wrapper.props.tracker_available
-        if (source.props.source_id == "grl-tracker-source"
+        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():
@@ -145,7 +145,7 @@ class CoreGrilo(GObject.GObject):
                 grl_tracker_wrapper.props.source = source
         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-tracker-source"
+                and source.props.source_id != "grl-tracker3-source"
                 and source.get_supported_media() & Grl.MediaType.AUDIO
                 and source.supported_operations() & Grl.SupportedOps.SEARCH
                 and "net:internet" not in source.props.source_tags):
@@ -220,32 +220,32 @@ class CoreGrilo(GObject.GObject):
 
         :param CoreSong coresong: CoreSong to retrieve art for
         """
-        if "grl-tracker-source" in self._wrappers:
-            self._wrappers["grl-tracker-source"].get_song_art(coresong)
+        if "grl-tracker3-source" in self._wrappers:
+            self._wrappers["grl-tracker3-source"].get_song_art(coresong)
 
     def get_album_art(self, corealbum):
         """Retrieve album art for the given CoreAlbum
 
         :param CoreAlbum corealbum: CoreAlbum to retrieve art for
         """
-        if "grl-tracker-source" in self._wrappers:
-            self._wrappers["grl-tracker-source"].get_album_art(corealbum)
+        if "grl-tracker3-source" in self._wrappers:
+            self._wrappers["grl-tracker3-source"].get_album_art(corealbum)
 
     def get_artist_art(self, coreartist):
         """Retrieve artist art for the given CoreArtist
 
         :param CoreArtist coreartist: CoreArtist to retrieve art for
         """
-        if "grl-tracker-source" in self._wrappers:
-            self._wrappers["grl-tracker-source"].get_artist_art(coreartist)
+        if "grl-tracker3-source" in self._wrappers:
+            self._wrappers["grl-tracker3-source"].get_artist_art(coreartist)
 
     def stage_playlist_deletion(self, playlist):
         """Prepares playlist deletion.
 
         :param Playlist playlist: playlist
         """
-        if "grl-tracker-source" in self._wrappers:
-            self._wrappers["grl-tracker-source"].stage_playlist_deletion(
+        if "grl-tracker3-source" in self._wrappers:
+            self._wrappers["grl-tracker3-source"].stage_playlist_deletion(
                 playlist)
 
     def finish_playlist_deletion(self, playlist, deleted):
@@ -254,8 +254,8 @@ class CoreGrilo(GObject.GObject):
         :param Playlist playlist: playlist
         :param bool deleted: indicates if the playlist has been deleted
         """
-        if "grl-tracker-source" in self._wrappers:
-            self._wrappers["grl-tracker-source"].finish_playlist_deletion(
+        if "grl-tracker3-source" in self._wrappers:
+            self._wrappers["grl-tracker3-source"].finish_playlist_deletion(
                 playlist, deleted)
 
     def create_playlist(self, playlist_title, callback):
@@ -264,6 +264,6 @@ class CoreGrilo(GObject.GObject):
         :param str playlist_title: playlist title
         :param callback: function to perform once, the playlist is created
         """
-        if "grl-tracker-source" in self._wrappers:
-            self._wrappers["grl-tracker-source"].create_playlist(
+        if "grl-tracker3-source" in self._wrappers:
+            self._wrappers["grl-tracker3-source"].create_playlist(
                 playlist_title, callback)
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 5ab90bc3..7b2f8277 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -23,7 +23,7 @@
 # delete this exception statement from your version.
 
 import gi
-gi.require_versions({"Gfm": "0.1", "Grl": "0.3", 'Tracker': "2.0"})
+gi.require_versions({"Gfm": "0.1", "Grl": "0.3", "Tracker": "3.0"})
 from gi.repository import Gfm, Gio, Grl, GLib, GObject, Tracker
 
 from gnomemusic.corealbum import CoreAlbum
diff --git a/gnomemusic/trackerwrapper.py b/gnomemusic/trackerwrapper.py
index 0990eedb..caa14260 100644
--- a/gnomemusic/trackerwrapper.py
+++ b/gnomemusic/trackerwrapper.py
@@ -47,21 +47,25 @@ class TrackerWrapper(GObject.GObject):
         self._tracker = None
         self._tracker_available = TrackerState.UNAVAILABLE
 
-        Tracker.SparqlConnection.get_async(None, self._connection_async_cb)
-
-    def _connection_async_cb(self, klass, result):
         try:
-            self._tracker = Tracker.SparqlConnection.get_finish(result)
+            self._tracker = Tracker.SparqlConnection.bus_new(
+                "org.freedesktop.Tracker3.Miner.Files", None, None)
         except GLib.Error as error:
             self._log.warning(
                 "Error: {}, {}".format(error.domain, error.message))
             self.notify("tracker-available")
             return
 
-        query = "SELECT ?e WHERE { ?e a tracker:ExternalReference . }"
+        query = """
+        SELECT
+            ?e
+        {
+            GRAPH tracker:Audio {
+                ?e a tracker:ExternalReference .
+            }
+        }""".replace("\n", "").strip()
 
-        self._tracker.query_async(
-            query, None, self._query_version_check)
+        self._tracker.query_async(query, None, self._query_version_check)
 
     def _query_version_check(self, klass, result):
         try:
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index b8ed23ea..e82a1d21 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -143,7 +143,7 @@ class EmptyView(Gtk.Stack):
             "Your system Tracker version seems outdated")
         self._icon.props.margin_bottom = 18
         self._information_label.props.label = _(
-            "Music needs Tracker version 2.3.0 or higher")
+            "Music needs Tracker version 3.0.0 or higher")
 
         self._icon.props.icon_name = "dialog-error-symbolic"
 
diff --git a/meson.build b/meson.build
index 0ef5b9b9..2693e5dc 100644
--- a/meson.build
+++ b/meson.build
@@ -42,12 +42,12 @@ dependency('gtk+-3.0', version: '>= 3.24.7')
 dependency('libdazzle-1.0', version: '>= 3.28.0')
 dependency('libmediaart-2.0', version: '>= 1.9.1')
 dependency('libsoup-2.4')
-dependency('tracker-sparql-2.0', version: '>= 2.3.0')
+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-plugins-0.3', version: '>= 0.3.10', fallback: ['grilo-plugins', 'grilo_plugins_dep'])
+dependency('grilo-plugins-0.3', version: '>= 0.3.12', fallback: ['grilo-plugins', 'grilo_plugins_dep'])
 
 subproject('libgd',
     default_options: [


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