forked from rostegg/public-ip-gnome-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs.js
56 lines (48 loc) · 1.64 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
const { Gtk, Gio, GLib } = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const REFRESH_RATE = 'refresh-rate';
const DISPLAY_ONLY_ICONS = 'display-only-icon';
const init = () => {/* Empty */};
class PublicIpPrefs extends Gtk.Grid {
constructor() {
super();
this.margin = 15;
this.row_spacing = 3;
this._settings = Convenience.getSettings();
let label = null;
let container = null;
/* Refresh rate */
container = new Gtk.HBox({spacing: 5});
label = new Gtk.Label({
label: "Refresh rate (in seconds)",
margin_left: 10
});
let refreshSpinButton = new Gtk.SpinButton();
refreshSpinButton.set_sensitive(true);
refreshSpinButton.set_range(1, 1800);
refreshSpinButton.set_value(this._settings.get_int(REFRESH_RATE));
refreshSpinButton.set_increments(5, 10);
this._settings.bind(REFRESH_RATE, refreshSpinButton, 'value', Gio.SettingsBindFlags.DEFAULT);
container.pack_start(label, 0,0,0);
container.pack_end(refreshSpinButton, 0,0,0);
this.attach(container, 0, 1, 1, 1);
/* Display only flag */
container = new Gtk.HBox({spacing: 5});
label = new Gtk.Label({
label: "Display only flag",
margin_left: 10
});
let displayIconButton = new Gtk.CheckButton({margin_top: 5});
this._settings.bind(DISPLAY_ONLY_ICONS, displayIconButton, 'active', Gio.SettingsBindFlags.DEFAULT);
container.pack_start(label, 0,0,0);
container.pack_end(displayIconButton, 0,0,0);
this.attach(container, 0, 2, 1, 1);
}
}
const buildPrefsWidget = () => {
let widget = new PublicIpPrefs();
widget.show_all();
return widget;
}