-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
181 lines (156 loc) · 8.28 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
176
177
178
179
180
181
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
const Lang = imports.lang;
const Gettext = imports.gettext.domain('extendedgestures');
const _ = Gettext.gettext;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
let schema = null;
function init() {
schema = Convenience.getSettings();
}
const ExtendedGesturesSettingsWidget = new GObject.Class({
Name: 'ExtendedGestures.prefs.ExtendedGesturesSettingsWidget',
GTypeName: 'ExtendedGesturesSettingsWidget',
Extends: Gtk.VBox,
_init: function (params) {
this.parent (params);
this._buildUI();
this._initUI();
},
_buildUI: function() {
// The swipe options grid setup
this._swipeOptionsFrame = new Gtk.Frame();
this._swipeOptionsFrame.set_label("Swipe Options");
this._swipeOptionsGrid = new Gtk.Grid({
column_homogeneous: false,
column_spacing: 20
});
this._swipeOptionsFrame.add(this._swipeOptionsGrid);
// The swipe options
// Three finger horizontal
this._leftThreeLabel = new Gtk.Label({label: "3 Finger Left Horizontal Gestures"});
this._leftThreeSwitch = new Gtk.Switch();
this._leftThreeCombo = new Gtk.ComboBoxText();
this._swipeOptionsGrid.attach(this._leftThreeLabel, 0, 0, 1, 1);
this._swipeOptionsGrid.attach(this._leftThreeSwitch, 1, 0, 1, 1);
this._swipeOptionsGrid.attach(this._leftThreeCombo, 2, 0, 1, 1);
this._rightThreeLabel = new Gtk.Label({label: "3 Finger Right Horizontal Gestures"});
this._rightThreeSwitch = new Gtk.Switch();
this._rightThreeCombo = new Gtk.ComboBoxText();
this._swipeOptionsGrid.attach(this._rightThreeLabel, 0, 1, 1, 1);
this._swipeOptionsGrid.attach(this._rightThreeSwitch, 1, 1, 1, 1);
this._swipeOptionsGrid.attach(this._rightThreeCombo, 2, 1, 1, 1);
// Three finger vertical
this._upThreeLabel = new Gtk.Label({label: "3 Finger Up Vertical Gestures"});
this._upThreeSwitch = new Gtk.Switch();
this._upThreeCombo = new Gtk.ComboBoxText();
this._swipeOptionsGrid.attach(this._upThreeLabel, 0, 2, 1, 1);
this._swipeOptionsGrid.attach(this._upThreeSwitch, 1, 2, 1, 1);
this._swipeOptionsGrid.attach(this._upThreeCombo, 2, 2, 1, 1);
this._downThreeLabel = new Gtk.Label({label: "3 Finger Down Vertical Gestures"});
this._downThreeSwitch = new Gtk.Switch();
this._downThreeCombo = new Gtk.ComboBoxText();
this._swipeOptionsGrid.attach(this._downThreeLabel, 0, 3, 1, 1);
this._swipeOptionsGrid.attach(this._downThreeSwitch, 1, 3, 1, 1);
this._swipeOptionsGrid.attach(this._downThreeCombo, 2, 3, 1, 1);
// Four finger horizontal
this._horizontalFourLabel = new Gtk.Label({label: "4 Finger Horizontal Gestures"});
this._horizontalFourSwitch = new Gtk.Switch();
this._horizontalFourCombo = new Gtk.ComboBoxText();
this._swipeOptionsGrid.attach(this._horizontalFourLabel, 0, 4, 1, 1);
this._swipeOptionsGrid.attach(this._horizontalFourSwitch, 1, 4, 1, 1);
this._swipeOptionsGrid.attach(this._horizontalFourCombo, 2, 4, 1, 1);
// Four finger vertical
this._verticalFourLabel = new Gtk.Label({label: "4 Finger Vertical Gestures"});
this._verticalFourSwitch = new Gtk.Switch();
this._verticalFourCombo = new Gtk.ComboBoxText();
this._swipeOptionsGrid.attach(this._verticalFourLabel, 0, 5, 1, 1);
this._swipeOptionsGrid.attach(this._verticalFourSwitch, 1, 5, 1, 1);
this._swipeOptionsGrid.attach(this._verticalFourCombo, 2, 5, 1, 1);
// The sensitivity options
this._sensitivityOptionsFrame = new Gtk.Frame();
this._sensitivityOptionsFrame.set_label("Sensitivity Options");
this._sensitivityOptionsGrid = new Gtk.Grid({
column_homogeneous: false,
column_spacing: 20
});
this._sensitivityOptionsFrame.add(this._sensitivityOptionsGrid);
// Vertical sensitivity
this._verticalSensitivityLabel = new Gtk.Label({label: "Vertical Sensitivity Adjustment"});
this._verticalSensitivitySpinButton = Gtk.SpinButton.new_with_range(-50, 50, 1);
this._sensitivityOptionsGrid.attach(this._verticalSensitivityLabel, 0, 0, 1, 1);
this._sensitivityOptionsGrid.attach(this._verticalSensitivitySpinButton, 1, 0, 1, 1);
// Horizontal sensitivity
this._horizontalSensitivityLabel = new Gtk.Label({label: "Horizontal Sensitivity Adjustment"});
this._horizontalSensitivitySpinButton = Gtk.SpinButton.new_with_range(-50, 50, 1);
this._sensitivityOptionsGrid.attach(this._horizontalSensitivityLabel, 0, 1, 1, 1);
this._sensitivityOptionsGrid.attach(this._horizontalSensitivitySpinButton, 1, 1, 1, 1);
// Add everything to the main view
this.add(this._swipeOptionsFrame);
this.add(this._sensitivityOptionsFrame);
},
_initUI: function() {
const actions = [
'Toggle Overview',
'Cycle Applications',
'Show App Drawer',
'Switch Workspace',
'Show desktop',
'Nothing',
'Next Workspace',
'Previous Workspace'
];
// Disable four finger options for now :(
this._horizontalFourSwitch.set_active(false);
this._horizontalFourSwitch.set_sensitive(false);
this._verticalFourSwitch.set_active(true);
this._verticalFourSwitch.set_sensitive(false);
// Bind the three swipe toggles to their setting values
schema.bind('left-three-swipes', this._leftThreeSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
schema.bind('right-three-swipes', this._rightThreeSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
schema.bind('up-three-swipes', this._upThreeSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
schema.bind('down-three-swipes', this._downThreeSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
// Action set up
this._leftThreeCombo.connect('changed', Lang.bind(this, this._leftThreeComboChanged));
this._rightThreeCombo.connect('changed', Lang.bind(this, this._rightThreeComboChanged));
this._upThreeCombo.connect('changed', Lang.bind(this, this._upThreeComboChanged));
this._downThreeCombo.connect('changed', Lang.bind(this, this._downThreeComboChanged));
this._horizontalFourCombo.set_sensitive(false);
this._verticalFourCombo.set_sensitive(false);
for (let i = 0; i < actions.length; i++) {
this._leftThreeCombo.append_text(actions[i]);
this._rightThreeCombo.append_text(actions[i]);
this._upThreeCombo.append_text(actions[i]);
this._downThreeCombo.append_text(actions[i]);
this._horizontalFourCombo.append_text(actions[i]);
this._verticalFourCombo.append_text(actions[i]);
}
this._leftThreeCombo.set_active(schema.get_enum('left-three-action'));
this._rightThreeCombo.set_active(schema.get_enum('right-three-action'));
this._upThreeCombo.set_active(schema.get_enum('up-three-action'));
this._downThreeCombo.set_active(schema.get_enum('down-three-action'));
this._horizontalFourCombo.set_active(0);
this._verticalFourCombo.set_active(3);
// Sensitivity options setup
schema.bind('vertical-sensitivity-adjustment', this._verticalSensitivitySpinButton, 'value', Gio.SettingsBindFlags.DEFAULT);
schema.bind('horizontal-sensitivity-adjustment', this._horizontalSensitivitySpinButton, 'value', Gio.SettingsBindFlags.DEFAULT);
},
_leftThreeComboChanged: function () {
schema.set_enum('left-three-action', this._leftThreeCombo.get_active());
},
_rightThreeComboChanged: function () {
schema.set_enum('right-three-action', this._rightThreeCombo.get_active());
},
_upThreeComboChanged: function () {
schema.set_enum('up-three-action', this._upThreeCombo.get_active());
},
_downThreeComboChanged: function () {
schema.set_enum('down-three-action', this._downThreeCombo.get_active());
},
});
function buildPrefsWidget () {
let settingsWidget = new ExtendedGesturesSettingsWidget ();
settingsWidget.show_all ();
return settingsWidget;
}