forked from Tomha/gnome-shell-extension-netspeed-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.js
52 lines (40 loc) · 1.66 KB
/
settings.js
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
42
43
44
45
46
47
48
49
50
51
52
/* Copyright (C) 2017 Tom Hartill
settings.js - Part of the NetSpeed Plus Gnome Shell Extension.
NetSpeed Plus is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
NetSpeed Plus is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
NetSpeed Plus; if not, see http://www.gnu.org/licenses/.
An up to date version can also be found at:
https://github.com/Tomha/gnome-shell-extension-netspeed-plus */
const Gio = imports.gi.Gio;
const SchemaSource = imports.gi.Gio.SettingsSchemaSource;
const ExtensionUtils = imports.misc.extensionUtils;
function getSettings() {
let extension = ExtensionUtils.getCurrentExtension();
let schema = extension.metadata["settings-schema"];
let schemaDir = extension.dir.get_child("schema");
if (!schemaDir.query_exists(null))
throw new Error(
"Schema directory " +
schemaDir +
" for " +
extension.metadata.uuid +
" not found."
);
let schemaSrc = SchemaSource.new_from_directory(
schemaDir.get_path(),
SchemaSource.get_default(),
false
);
let schemaObj = schemaSrc.lookup(schema, true);
if (!schemaObj)
throw new Error(
"Schema " + schemaDir + " for " + extension.metadata.uuid + " not found."
);
return new Gio.Settings({ settings_schema: schemaObj });
}