-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs.js
171 lines (152 loc) · 5.12 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
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Gettext = imports.gettext.domain('gnome-shell-extension-tuxedocontrol');
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const Lang = imports.lang;
const TUX_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.tuxedocontrol';
const TUX_BRIGHTNESS = 'brightness';
const TUX_LEFT = 'clr-left';
const TUX_MIDDLE = 'clr-middle';
const TUX_RIGHT = 'clr-right';
function init() {
Convenience.initTranslations('gnome-shell-extension-tuxedocontrol');
}
const TuxedoPrefsWidget = new GObject.Class({
Name: 'TuxedoControlExtension.Prefs.Widget',
GTypeName: 'TuxedoControlExtensionPrefsWidget',
Extends: Gtk.Grid,
_init: function(params) {
this._loadConfig();
this.parent(params);
this.margin = 12;
this.row_spacing = this.column_spacing = 6;
this.set_orientation(Gtk.Orientation.VERTICAL);
// Brightness
let hbox = new Gtk.HBox();
let label = new Gtk.Label({
label: _("Brightness"),
hexpand: true,
halign: Gtk.Align.CENTER
});
let ad = new Gtk.Adjustment({
lower: 0.0,
step_increment: 1.0,
upper: 255.0,
value: 1.0
});
let spinButton = new Gtk.SpinButton({
adjustment: ad,
digits: 0,
xalign: 1,
halign: Gtk.Align.CENTER
});
spinButton.set_value(this._brightnessV);
spinButton.connect("value_changed", Lang.bind(this, function() {
this._brightnessV = spinButton.value;
}));
hbox.pack_start(label, false, false, 100);
hbox.pack_end(spinButton, false, false, 100);
this.add(hbox);
// Colors left
hbox = new Gtk.HBox();
label = new Gtk.Label({
label: _("Section: left"),
use_markup: true,
halign: Gtk.Align.START
});
this._clr_left = new Gtk.ColorButton({});
this._clr_left.connect('color_activated', Lang.bind(this, this._onColorChanged));
hbox.pack_start(label, false, false, 100);
hbox.pack_end(this._clr_left, false, false, 100);
this.add(hbox);
// Colors middle
hbox = new Gtk.HBox();
label = new Gtk.Label({
label: _("Section: middle"),
use_markup: true,
halign: Gtk.Align.START
});
this._clr_middle = new Gtk.ColorButton({});
this._clr_middle.connect('color_activated', Lang.bind(this, this._onColorChanged));
hbox.pack_start(label, false, false, 100);
hbox.pack_end(this._clr_middle, false, false, 100);
this.add(hbox);
// Colors right
hbox = new Gtk.HBox();
label = new Gtk.Label({
label: _("Section: right"),
use_markup: true,
halign: Gtk.Align.START
});
this._clr_right = new Gtk.ColorButton({});
this._clr_right.connect('color_activated', Lang.bind(this, this._onColorChanged));
hbox.pack_start(label, false, false, 100);
hbox.pack_end(this._clr_right, false, false, 100);
this.add(hbox);
},
_onColorChanged: function() {
let l = this._clr_left.get_color();
let m = this._clr_middle.get_color();
let r = this._clr_right.get_color();
let clr = l.red<<0xf + l.green<<0x8 + l.blue;
this._sectionLeft = clr;
clr = m.red<<0xf + m.green<<0x8 + m.blue;
this._sectionMiddle = clr;
clr = r.red<<0xf + r.green<<0x8 + r.blue;
this._sectionRight = clr;
},
_loadConfig: function() {
this._settings = Convenience.getSettings(TUX_SETTINGS_SCHEMA);
},
get _sectionLeft() {
if (!this._settings)
this._loadConfig();
return this._settings.get_int(TUX_LEFT);
},
set _sectionLeft(v) {
if (!this._settings)
this._loadConfig();
this._settings.set_int(TUX_LEFT, v);
},
get _sectionMiddle() {
if (!this._settings)
this._loadConfig();
return this._settings.get_int(TUX_MIDDLE);
},
set _sectionMiddle(v) {
if (!this._settings)
this._loadConfig();
this._settings.set_int(TUX_MIDDLE, v);
},
get _sectionRight() {
if (!this._settings)
this._loadConfig();
return this._settings.get_int(TUX_RIGHT);
},
set _sectionRight(v) {
if (!this._settings)
this._loadConfig();
this._settings.set_int(TUX_RIGHT, v);
},
get _brightnessV() {
if (!this._settings)
this._loadConfig();
return this._settings.get_int(TUX_BRIGHTNESS);
},
set _brightnessV(v) {
if (!this._settings)
this._loadConfig();
this._settings.set_int(TUX_BRIGHTNESS, v);
},
});
function buildPrefsWidget() {
let widget = new TuxedoPrefsWidget();
widget.show_all();
return widget;
}