@@ -10,6 +10,17 @@ const Me = ExtensionUtils.getCurrentExtension();
10
10
const Gettext = imports . gettext ;
11
11
const _ = Gettext . domain ( 'wintile' ) . gettext ;
12
12
13
+ let gschema = Gio . SettingsSchemaSource . new_from_directory (
14
+ Me . dir . get_child ( 'schemas' ) . get_path ( ) ,
15
+ Gio . SettingsSchemaSource . get_default ( ) ,
16
+ false
17
+ ) ;
18
+
19
+ const gsettings = new Gio . Settings ( {
20
+ settings_schema : gschema . lookup ( 'org.gnome.shell.extensions.wintile' , true )
21
+ } ) ;
22
+
23
+
13
24
function init ( ) {
14
25
}
15
26
@@ -30,17 +41,6 @@ function createColOptions(){
30
41
}
31
42
32
43
function buildPrefsWidget ( ) {
33
- // Copy the same GSettings code from `extension.js`
34
- let gschema = Gio . SettingsSchemaSource . new_from_directory (
35
- Me . dir . get_child ( 'schemas' ) . get_path ( ) ,
36
- Gio . SettingsSchemaSource . get_default ( ) ,
37
- false
38
- ) ;
39
-
40
- this . settings = new Gio . Settings ( {
41
- settings_schema : gschema . lookup ( 'org.gnome.shell.extensions.wintile' , true )
42
- } ) ;
43
-
44
44
let rendererText = new Gtk . CellRendererText ( ) ;
45
45
46
46
// Create a parent widget that we'll return from this function
@@ -86,15 +86,15 @@ function buildPrefsWidget() {
86
86
halign : Gtk . Align . START
87
87
} ) ;
88
88
let maximizeInput = new Gtk . Switch ( {
89
- active : this . settings . get_boolean ( 'use-maximize' ) ,
89
+ active : gsettings . get_boolean ( 'use-maximize' ) ,
90
90
halign : Gtk . Align . END ,
91
91
visible : true
92
92
} ) ;
93
93
layout . attach ( maximizeLabel , 0 , row , 1 , 1 ) ;
94
94
layout . attach ( maximizeInput , 1 , row ++ , 1 , 1 ) ;
95
95
96
96
// Preview settings
97
- let previewEnabled = this . settings . get_boolean ( 'preview' ) ;
97
+ let previewEnabled = gsettings . get_boolean ( 'preview' ) ;
98
98
let previewLabel = new Gtk . Label ( {
99
99
label : _ ( "Enable preview and snapping when dragging windows" ) ,
100
100
visible : true ,
@@ -117,13 +117,65 @@ function buildPrefsWidget() {
117
117
halign : Gtk . Align . START
118
118
} ) ;
119
119
let doubleWidthInput = new Gtk . Switch ( {
120
- active : this . settings . get_boolean ( 'double-width' ) ,
120
+ active : gsettings . get_boolean ( 'double-width' ) ,
121
121
halign : Gtk . Align . END ,
122
122
visible : true
123
123
} ) ;
124
124
layout . attach ( doubleWidthLabel , 0 , row , 1 , 1 ) ;
125
125
layout . attach ( doubleWidthInput , 1 , row ++ , 1 , 1 ) ;
126
126
127
+ // Preview distance
128
+ let previewDistanceLabel = new Gtk . Label ( {
129
+ label : _ ( " Pixels from edge to start preview" ) ,
130
+ visible : true ,
131
+ hexpand : true ,
132
+ halign : Gtk . Align . START
133
+ } ) ;
134
+ let previewDistanceInput = new Gtk . Box ( {
135
+ orientation : Gtk . Orientation . HORIZONTAL ,
136
+ visible : true
137
+ } ) ;
138
+ let previewDistanceAdjustment = new Gtk . Adjustment ( {
139
+ lower : 0 ,
140
+ upper : 150 ,
141
+ step_increment : 1
142
+ } ) ;
143
+ let previewDistanceSettingInt = new Gtk . SpinButton ( {
144
+ adjustment : previewDistanceAdjustment ,
145
+ snap_to_ticks : true ,
146
+ visible : true
147
+ } ) ;
148
+ previewDistanceSettingInt . set_value ( gsettings . get_int ( 'distance' ) ) ;
149
+ previewDistanceInput . add ( previewDistanceSettingInt ) ;
150
+ layout . attach ( previewDistanceLabel , 0 , row , 1 , 1 ) ;
151
+ layout . attach ( previewDistanceInput , 1 , row ++ , 1 , 1 ) ;
152
+
153
+ // Delay
154
+ let previewDelayLabel = new Gtk . Label ( {
155
+ label : _ ( " Delay in ms before preview dislpays" ) ,
156
+ visible : true ,
157
+ hexpand : true ,
158
+ halign : Gtk . Align . START
159
+ } ) ;
160
+ let previewDelayInput = new Gtk . Box ( {
161
+ orientation : Gtk . Orientation . HORIZONTAL ,
162
+ visible : true
163
+ } ) ;
164
+ let previewDelayAdjustment = new Gtk . Adjustment ( {
165
+ lower : 100 ,
166
+ upper : 1000 ,
167
+ step_increment : 1
168
+ } ) ;
169
+ let previewDelaySettingInt = new Gtk . SpinButton ( {
170
+ adjustment : previewDelayAdjustment ,
171
+ snap_to_ticks : true ,
172
+ visible : true
173
+ } ) ;
174
+ previewDelaySettingInt . set_value ( gsettings . get_int ( 'delay' ) ) ;
175
+ previewDelayInput . add ( previewDelaySettingInt ) ;
176
+ layout . attach ( previewDelayLabel , 0 , row , 1 , 1 ) ;
177
+ layout . attach ( previewDelayInput , 1 , row ++ , 1 , 1 ) ;
178
+
127
179
// Debug setting
128
180
let debugLabel = new Gtk . Label ( {
129
181
label : _ ( "Turn on debugging" ) ,
@@ -132,18 +184,25 @@ function buildPrefsWidget() {
132
184
halign : Gtk . Align . START
133
185
} ) ;
134
186
let debugInput = new Gtk . Switch ( {
135
- active : this . settings . get_boolean ( 'debug' ) ,
187
+ active : gsettings . get_boolean ( 'debug' ) ,
136
188
halign : Gtk . Align . END ,
137
189
visible : true
138
190
} ) ;
139
191
layout . attach ( debugLabel , 0 , row , 1 , 1 ) ;
140
192
layout . attach ( debugInput , 1 , row ++ , 1 , 1 ) ;
141
193
142
- this . settings . bind ( 'cols' , colsInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
143
- this . settings . bind ( 'double-width' , doubleWidthInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
144
- this . settings . bind ( 'use-maximize' , maximizeInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
145
- this . settings . bind ( 'preview' , previewInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
146
- this . settings . bind ( 'debug' , debugInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
194
+ gsettings . bind ( 'cols' , colsInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
195
+ gsettings . bind ( 'use-maximize' , maximizeInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
196
+ gsettings . bind ( 'preview' , previewInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
197
+ gsettings . bind ( 'double-width' , doubleWidthInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
198
+ previewDistanceSettingInt . connect ( 'value-changed' , function ( entry ) {
199
+ gsettings . set_int ( 'distance' , entry . value ) ;
200
+ } ) ;
201
+ previewDelaySettingInt . connect ( 'value-changed' , function ( entry ) {
202
+ gsettings . set_int ( 'delay' , entry . value ) ;
203
+ } ) ;
204
+ gsettings . bind ( 'debug' , debugInput , 'active' , Gio . SettingsBindFlags . DEFAULT ) ;
205
+
147
206
148
207
let setDoubleWidthWidgetsEnabled = function ( enabled ) {
149
208
doubleWidthLabel . set_sensitive ( enabled ) ;
0 commit comments