-
Notifications
You must be signed in to change notification settings - Fork 3
/
prefs.js
131 lines (113 loc) · 3.2 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const Gtk = imports.gi.Gtk;
const Gettext = imports.gettext.domain("[email protected]");
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
imports.searchPath.unshift(Me.path);
// required, otherwise:
// TypeError: prefsModule.init is not a function
//
// Stack trace:
// _getExtensionPrefsModule@resource:///org/gnome/shell/extensionPrefs/main.js:76:9
// ...
function init() {}
function buildPrefsWidget() {
let notebook = new Gtk.Notebook();
let frame = new Gtk.VBox({ border_width: 10, spacing: 6 });
notebook.append_page(
frame,
new Gtk.Label({
label: _("Settings"),
use_markup: true,
//xalign: 0,
}),
);
// :TRICKY: section title is not needed for one setting
// frame.pack_start(
// new Gtk.Label({
// label: _("<b>Title</b>"),
// use_markup: true,
// xalign: 0,
// }),
// false,
// false,
// 0,
// );
let settings_vbox = new Gtk.VBox({
margin_left: 20,
margin_top: 10,
spacing: 6,
});
// gtk_box_pack_start (GtkBox *box, GtkWidget *child, gboolean expand, gboolean fill, guint padding);
frame.pack_start(settings_vbox, true, true, 0);
let settings = imports.configuration.getSettings(
Me.dir.get_child("schemas").get_path(),
);
function appendBoolean(storageName, label) {
settings_onoff = new Gtk.Switch({
active: settings.get_boolean(storageName),
});
settings_onoff.connect("notify::active", function(w) {
settings.set_boolean(storageName, w.active);
});
settings.connect("changed::" + storageName, function(k, b) {
settings_onoff.set_active(settings.get_boolean(b));
});
settings_hbox = new Gtk.HBox();
settings_hbox.pack_start(
new Gtk.Label({
label: label,
use_markup: true,
xalign: 0,
}),
true,
true,
0,
);
settings_hbox.pack_end(settings_onoff, false, false, 0);
settings_vbox.pack_start(settings_hbox, false, false, 0);
}
appendBoolean("mute-audio", _("Mute audio while do-not-disturb period"));
appendBoolean("show-number-of-notifications", _("Show the number of notifications"));
// About
{
let frame = new Gtk.VBox({ border_width: 10 });
notebook.append_page(
frame,
new Gtk.Label({
label: _("About"),
use_markup: true,
}),
);
frame.pack_start(
new Gtk.Label({
label: "<b>Do Not Disturb Time</b>",
use_markup: true,
}),
true,
true,
0,
);
function appendLabel(text) {
frame.pack_start(
new Gtk.Label({
label: text,
use_markup: true,
}),
false,
false,
10,
);
}
appendLabel(
'Created by <a href="mailto:[email protected]">Ilya Murav\'jov</a> 2018 ©',
);
appendLabel(
'<a href="https://github.com/muravjov/do-not-disturb">Webpage</a>',
);
appendLabel(`<small>This program comes with absolutely no warranty.
See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, version 2 or later</a> for details.</small>`);
}
notebook.show_all();
return notebook;
}