[gnome-tweaks] Search for GSettings schemas in system data dirs



commit da84d4ff457f74a3bc2e85fd92e50039528e5a6c
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Dec 17 17:23:05 2017 +0100

    Search for GSettings schemas in system data dirs
    
    XDG Base Directory Specification requires that all directories in
    XDG_DATA_DIRS environment variable are checked.
    
    This patch modifies the GSettings schema loader to respect the spec.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-tweaks/issues/114

 gtweak/gsettings.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gtweak/gsettings.py b/gtweak/gsettings.py
index 0b66c9e..e0116e9 100644
--- a/gtweak/gsettings.py
+++ b/gtweak/gsettings.py
@@ -22,10 +22,15 @@ class GSettingsMissingError(Exception):
 
 class _GSettingsSchema:
     def __init__(self, schema_name, schema_dir=None, schema_filename=None, **options):
-        if not schema_dir:
-            schema_dir = gtweak.GSETTINGS_SCHEMA_DIR
         if not schema_filename:
             schema_filename = schema_name + ".gschema.xml"
+        if not schema_dir:
+            schema_dir = gtweak.GSETTINGS_SCHEMA_DIR
+            for xdg_dir in GLib.get_system_data_dirs():
+                dir = os.path.join(xdg_dir, "glib-2.0", "schemas")
+                if os.path.exists(os.path.join(dir, schema_filename)):
+                    schema_dir = dir
+                    break
 
         schema_path = os.path.join(schema_dir, schema_filename)
         if not os.path.exists(schema_path):


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