[gnome-shell-extensions] convenience: allow system-wide installation again



commit a4fac964dced50d0fd80b977e773bb150f5cdd9b
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Fri Feb 10 18:15:31 2012 +0100

    convenience: allow system-wide installation again
    
    Check if necessary files are installed in the extension folder
    (as done by "make zip-file"), and if not, fallback to the standard
    paths.

 lib/convenience.js |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/lib/convenience.js b/lib/convenience.js
index 6421ef5..74c02fb 100644
--- a/lib/convenience.js
+++ b/lib/convenience.js
@@ -3,6 +3,7 @@
 const Gettext = imports.gettext;
 const Gio = imports.gi.Gio;
 
+const Config = imports.misc.config;
 const ExtensionUtils = imports.misc.extensionUtils;
 
 /**
@@ -17,8 +18,15 @@ function initTranslations(domain) {
 
     domain = domain || extension.metadata['gettext-domain'];
 
-    let localeDir = extension.dir.get_child('locale').get_path();
-    Gettext.bindtextdomain(domain, localeDir);
+    // check if this extension was built with "make zip-file", and thus
+    // has the locale files in a subfolder
+    // otherwise assume that extension has been installed in the
+    // same prefix as gnome-shell
+    let localeDir = extension.dir.get_child('locale');
+    if (localeDir.query_exists(null))
+        Gettext.bindtextdomain(domain, localeDir.get_path());
+    else
+        Gettext.bindtextdomain(domain, Config.LOCALEDIR);
 }
 
 /**
@@ -34,11 +42,26 @@ function getSettings(schema) {
 
     schema = schema || extension.metadata['settings-schema'];
 
-    let schemaDir = extension.dir.get_child('schemas').get_path();
-    let schemaSource = Gio.SettingsSchemaSource.new_from_directory(schemaDir,
-                                                                   Gio.SettingsSchemaSource.get_default(),
-                                                                   false);
+    const GioSSS = Gio.SettingsSchemaSource;
+
+    // check if this extension was built with "make zip-file", and thus
+    // has the schema files in a subfolder
+    // otherwise assume that extension has been installed in the
+    // same prefix as gnome-shell (and therefore schemas are available
+    // in the standard folders)
+    let schemaDir = extension.dir.get_child('schemas');
+    let schemaSource;
+    if (schemaDir.query_exists(null))
+        schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
+                                                 GioSSS.get_default(),
+                                                 false);
+    else
+        schemaSource = GioSSS.get_default();
+
     let schemaObj = schemaSource.lookup(schema, false);
+    if (!schemaObj)
+        throw new Error('Schema ' + schema + ' could not be found for extension '
+                        + extension.metadata.uuid + '. Please check your installation.');
 
     return new Gio.Settings({ settings_schema: schemaObj });
 }



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