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.
This commit is contained in:
Giovanni Campagna
2012-02-10 18:15:31 +01:00
parent 245ab96a27
commit a4fac964dc

View File

@@ -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 });
}