diff options
Diffstat (limited to '')
-rw-r--r-- | impatience/settings.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/impatience/settings.js b/impatience/settings.js new file mode 100644 index 0000000..c4f6815 --- /dev/null +++ b/impatience/settings.js @@ -0,0 +1,41 @@ +const Gio = imports.gi.Gio; +const ExtensionUtils = imports.misc.extensionUtils; +const Extension = ExtensionUtils.getCurrentExtension(); + +const SCHEMA_PATH = 'org.gnome.shell.extensions.net.gfxmonk.impatience'; + +function get_local_gsettings(schema_path) { + const GioSSS = Gio.SettingsSchemaSource; + + let schemaDir = Extension.dir.get_child('schemas'); + + let schemaSource = GioSSS.get_default(); + if (schemaDir.query_exists(null)) { + schemaSource = GioSSS.new_from_directory( + schemaDir.get_path(), + schemaSource, + false); + } + + let schemaObj = schemaSource.lookup(schema_path, true); + if (!schemaObj) { + throw new Error( + 'Schema ' + schema_path + + ' could not be found for extension ' + + Extension.metadata.uuid + ); + } + return new Gio.Settings({ settings_schema: schemaObj }); +}; + +function Prefs() { + var self = this; + var settings = this.settings = get_local_gsettings(SCHEMA_PATH); + this.SPEED = { + key: 'speed-factor', + get: function() { return settings.get_double(this.key); }, + set: function(v) { settings.set_double(this.key, v); }, + changed: function(cb) { return settings.connect('changed::' + this.key, cb); }, + disconnect: function() { return settings.disconnect.apply(settings, arguments); }, + }; +}; |