This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
prefs.js
80 lines (62 loc) · 2.37 KB
/
prefs.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (C) 2018 O. Alperen Elhan
//
// This file is part of Extensions Sync.
//
// Extensions Sync 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 2 of the License, or
// (at your option) any later version.
//
// Extensions Sync 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 Extensions Sync. If not, see <http:https://www.gnu.org/licenses/>.
//
imports.searchPath.unshift(imports.misc.extensionUtils.getCurrentExtension().path);
const Gtk = imports.gi.Gtk;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const { getSettings } = imports.convenience;
const { logger } = imports.utils;
const debug = logger('prefs');
const Preferences = class Preferences {
constructor() {
this.settings = getSettings('org.gnome.shell.extensions.sync');
this.widget = new Gtk.Box();
this.builder = Gtk.Builder.new_from_file(Me.dir.get_path() + "/ui/settings.glade");
this.builder.connect_signals_full((builder,object,signal,handler) => {
object.connect(signal, this[handler].bind(this));
});
const settingsBox = this.builder.get_object('gist-settings');
this.gistIdEntry = this.builder.get_object('gist-id-entry');
this.gistTokenEntry = this.builder.get_object('gist-token-entry');
this.widget.pack_start(settingsBox,true,true,0);
this.initValues();
}
initValues() {
const gistId = this.settings.get_string('gist-id');
this.gistIdEntry.set_text(gistId);
const gistToken = this.settings.get_string('gist-token');
this.gistTokenEntry.set_text(gistToken);
}
onSave() {
const gistId = this.gistIdEntry.get_text();
this.settings.set_string('gist-id', gistId.trim());
const gistToken = this.gistTokenEntry.get_text();
this.settings.set_string('gist-token', gistToken.trim());
this.onClose();
}
onClose() {
this.widget.get_toplevel().destroy();
}
}
function init() {
}
function buildPrefsWidget() {
let prefs = new Preferences();
prefs.widget.show_all();
return prefs.widget;
}