forked from phocean/TopIcons-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
175 lines (157 loc) · 6.86 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
//const MainUI = imports.ui.main;
const Gettext = imports.gettext.domain('TopIcons-Plus');
const _ = Gettext.gettext;
const N_ = function(e) { return e; }
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
function init() {
Convenience.initTranslations();
}
const Settings = new Lang.Class({
Name: 'Settings',
_init: function(params) {
this.w = new Gtk.Grid(params);
this.w.set_orientation(Gtk.Orientation.VERTICAL);
this._settings = Convenience.getSettings();
this._changedPermitted = false;
// Icon opacity
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7, spacing:50});
let label = new Gtk.Label({label: "Opacity", xalign: 0});
let widget = new Gtk.SpinButton();
widget.set_sensitive(true);
widget.set_range(0, 255);
widget.set_value(this._settings.get_int('icon-opacity'));
widget.set_increments(1, 2);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value_as_int();
this._settings.set_int('icon-opacity', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
// Icon saturation
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: "Desaturation", xalign: 0});
let widget = new Gtk.SpinButton({halign:Gtk.Align.END, digits:3});
widget.set_sensitive(true);
widget.set_range(0.000, 1.000);
widget.set_value(this._settings.get_double('icon-saturation'));
widget.set_increments(0.001, 0.010);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value();
this._settings.set_double('icon-saturation', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
// Icon brightness
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: "Brightness", xalign: 0});
let widget = new Gtk.SpinButton({halign:Gtk.Align.END, digits:3});
widget.set_sensitive(true);
widget.set_range(-1.000, 1.000);
widget.set_value(this._settings.get_double('icon-brightness'));
widget.set_increments(0.001, 0.010);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value();
this._settings.set_double('icon-brightness', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
// Icon contrast
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: "Contrast", xalign: 0});
let widget = new Gtk.SpinButton({halign:Gtk.Align.END, digits:3});
widget.set_sensitive(true);
widget.set_range(-1.000, 1.000);
widget.set_value(this._settings.get_double('icon-contrast'));
widget.set_increments(0.001, 0.010);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value();
this._settings.set_double('icon-contrast', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
// Icon size
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: _("Size"), xalign: 0});
let widget = new Gtk.SpinButton({halign:Gtk.Align.END});
widget.set_sensitive(true);
widget.set_range(0, 512);
widget.set_value(this._settings.get_int('icon-size'));
widget.set_increments(1, 2);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value_as_int();
this._settings.set_int('icon-size', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
// Icon tray spacing
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: _("Spacing"), xalign: 0});
let widget = new Gtk.SpinButton({halign:Gtk.Align.END});
widget.set_sensitive(true);
widget.set_range(0, 20);
widget.set_value(this._settings.get_int('icon-spacing'));
widget.set_increments(1, 2);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value_as_int();
this._settings.set_int('icon-spacing', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
// Tray position in panel
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: _("Tray side"), xalign: 0});
let positions = {'left': N_("left"), 'right': N_("right"),}
let currentPos = this._settings.get_string('tray-pos');
hbox.pack_start(label, true, true, 0);
let radio = null;
for (let pos in positions) {
let position = pos;
let name = Gettext.gettext(positions[pos]);
radio = new Gtk.RadioButton({ group: radio, label: name, halign: Gtk.Align.CENTER });
radio.connect('toggled', Lang.bind(this, function(widget) {
if (widget.active)
this._settings.set_string('tray-pos', position);
}));
hbox.add(radio);
if (pos == currentPos)
radio.active = true;
}
this.w.add(hbox);
// Tray order in panel
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, margin: 7});
let label = new Gtk.Label({label: _("Tray position"), xalign: 0});
let widget = new Gtk.SpinButton({halign:Gtk.Align.END});
widget.set_sensitive(true);
widget.set_range(0, 20);
widget.set_value(this._settings.get_int('tray-order'));
widget.set_increments(1, 2);
widget.connect('value-changed', Lang.bind(this, function(w){
let value = w.get_value_as_int();
this._settings.set_int('tray-order', value);
}));
hbox.pack_start(label, true, true, 0);
hbox.add(widget);
this.w.add(hbox);
this._changedPermitted = true;
}
});
function buildPrefsWidget() {
let widget = new Settings();
widget.w.show_all();
return widget.w;
}