[gnome-music/wip/jfelder/grilo-misc-cleanups: 9/9] grilo: Use a configuration file



commit ea55536925078a865b50c7189e0d69dde81cf09d
Author: Jean Felder <jfelder src gnome org>
Date:   Thu May 2 14:56:33 2019 +0200

    grilo: Use a configuration file
    
    This configuration file is used to store theaudiodb api key.

 data/music-grilo.conf              | 2 ++
 data/org.gnome.Music.gresource.xml | 1 +
 gnomemusic/grilo.py                | 8 ++------
 3 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/data/music-grilo.conf b/data/music-grilo.conf
new file mode 100644
index 00000000..93af88ba
--- /dev/null
+++ b/data/music-grilo.conf
@@ -0,0 +1,2 @@
+[grl-theaudiodb-cover]
+api-key         = 195003
\ No newline at end of file
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index 2ac5d2c6..db2600fe 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/gnome/Music">
     <file alias="gtk/help-overlay.ui" preprocess="xml-stripblanks">ui/help-overlay.ui</file>
+    <file>music-grilo.conf</file>
     <file>org.gnome.Music.css</file>
     <file>icons/initial-state.png</file>
     <file preprocess="xml-stripblanks">ui/AboutDialog.ui</file>
diff --git a/gnomemusic/grilo.py b/gnomemusic/grilo.py
index fe7fb0ab..63f7f907 100644
--- a/gnomemusic/grilo.py
+++ b/gnomemusic/grilo.py
@@ -78,8 +78,6 @@ class Grilo(GObject.GObject):
     CHANGED_MEDIA_MAX_ITEMS = 500
     CHANGED_MEDIA_SIGNAL_TIMEOUT = 2000
 
-    _theaudiodb_api_key = "195003"
-
     sources = GObject.Property()
     cover_sources = GObject.Property(type=bool, default=False)
     tracker_available = GObject.Property(type=bool, default=False)
@@ -124,6 +122,8 @@ class Grilo(GObject.GObject):
         self._thumbnail_sources_timeout = None
 
         self.registry = Grl.Registry.get_default()
+        self.registry.add_config_from_resource(
+            "/org/gnome/Music/music-grilo.conf")
 
         self._tracker_wrapper = TrackerWrapper()
         self.tracker_sparql = self._tracker_wrapper.props.tracker
@@ -135,10 +135,6 @@ class Grilo(GObject.GObject):
 
     @log
     def _find_sources(self):
-        config = Grl.Config.new('grl-lua-factory', 'grl-theaudiodb-cover')
-        config.set_api_key(self._theaudiodb_api_key)
-        self.registry.add_config(config)
-
         self.registry.connect('source_added', self._on_source_added)
         self.registry.connect('source_removed', self._on_source_removed)
 


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