blob: c4f6815f8fdc32448ba09c819f36002d0efb7ff5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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); },
};
};
|