forked from micheleg/dash-to-dock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
869 lines (724 loc) · 38.1 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Mainloop = imports.mainloop;
// Use __ () and N__() for the extension gettext domain, and reuse
// the shell domain with the default _() and N_()
const Gettext = imports.gettext.domain('dashtodock');
const __ = Gettext.gettext;
const N__ = function(e) { return e };
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const SCALE_UPDATE_TIMEOUT = 500;
const DEFAULT_ICONS_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ];
const TransparencyMode = {
DEFAULT: 0,
FIXED: 1,
DYNAMIC: 3
};
const RunningIndicatorStyle = {
DEFAULT: 0,
DOTS: 1,
SQUARES: 2,
DASHES: 3,
SEGMENTED: 4,
SOLID: 5,
CILIORA: 6,
METRO: 7
};
/**
* This function was copied from the activities-config extension
* https://github.com/nls1729/acme-code/tree/master/activities-config
* by Norman L. Smith.
*/
function cssHexString(css) {
let rrggbb = '#';
let start;
for (let loop = 0; loop < 3; loop++) {
let end = 0;
let xx = '';
for (let loop = 0; loop < 2; loop++) {
while (true) {
let x = css.slice(end, end + 1);
if ((x == '(') || (x == ',') || (x == ')'))
break;
end++;
}
if (loop == 0) {
end++;
start = end;
}
}
xx = parseInt(css.slice(start, end)).toString(16);
if (xx.length == 1)
xx = '0' + xx;
rrggbb += xx;
css = css.slice(end);
}
return rrggbb;
}
function setShortcut(settings) {
let shortcut_text = settings.get_string('shortcut-text');
let [key, mods] = Gtk.accelerator_parse(shortcut_text);
if (Gtk.accelerator_valid(key, mods)) {
let shortcut = Gtk.accelerator_name(key, mods);
settings.set_strv('shortcut', [shortcut]);
}
else {
settings.set_strv('shortcut', []);
}
}
var Settings = class DashToDock_Settings {
constructor() {
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.dash-to-dock');
this._rtl = (Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL);
this._builder = new Gtk.Builder();
this._builder.set_translation_domain(Me.metadata['gettext-domain']);
this._builder.add_from_file(Me.path + '/Settings.ui');
this.widget = new Gtk.ScrolledWindow({ hscrollbar_policy: Gtk.PolicyType.NEVER });
this._notebook = this._builder.get_object('settings_notebook');
this.widget.add(this._notebook);
// Set a reasonable initial window height
this.widget.connect('realize', () => {
let window = this.widget.get_toplevel();
let [default_width, default_height] = window.get_default_size();
window.resize(default_width, 650);
});
// Timeout to delay the update of the settings
this._dock_size_timeout = 0;
this._icon_size_timeout = 0;
this._opacity_timeout = 0;
this._bindSettings();
this._builder.connect_signals_full(this._connector.bind(this));
}
/**
* Connect signals
*/
_connector(builder, object, signal, handler) {
/**init
* Object containing all signals defined in the glade file
*/
const SignalHandler = {
dock_display_combo_changed_cb(combo) {
this._settings.set_int('preferred-monitor', this._monitors[combo.get_active()]);
},
position_top_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('dock-position', 0);
},
position_right_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('dock-position', 1);
},
position_bottom_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('dock-position', 2);
},
position_left_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('dock-position', 3);
},
icon_size_combo_changed_cb(combo) {
this._settings.set_int('dash-max-icon-size', this._allIconSizes[combo.get_active()]);
},
dock_size_scale_format_value_cb(scale, value) {
return Math.round(value * 100) + ' %';
},
dock_size_scale_value_changed_cb(scale) {
// Avoid settings the size consinuosly
if (this._dock_size_timeout > 0)
Mainloop.source_remove(this._dock_size_timeout);
this._dock_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
this._settings.set_double('height-fraction', scale.get_value());
this._dock_size_timeout = 0;
return GLib.SOURCE_REMOVE;
});
},
icon_size_scale_format_value_cb(scale, value) {
return value + ' px';
},
icon_size_scale_value_changed_cb(scale) {
// Avoid settings the size consinuosly
if (this._icon_size_timeout > 0)
Mainloop.source_remove(this._icon_size_timeout);
this._icon_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
this._settings.set_int('dash-max-icon-size', scale.get_value());
this._icon_size_timeout = 0;
return GLib.SOURCE_REMOVE;
});
},
custom_opacity_scale_value_changed_cb(scale) {
// Avoid settings the opacity consinuosly as it's change is animated
if (this._opacity_timeout > 0)
Mainloop.source_remove(this._opacity_timeout);
this._opacity_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
this._settings.set_double('background-opacity', scale.get_value());
this._opacity_timeout = 0;
return GLib.SOURCE_REMOVE;
});
},
min_opacity_scale_value_changed_cb(scale) {
// Avoid settings the opacity consinuosly as it's change is animated
if (this._opacity_timeout > 0)
Mainloop.source_remove(this._opacity_timeout);
this._opacity_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
this._settings.set_double('min-alpha', scale.get_value());
this._opacity_timeout = 0;
return GLib.SOURCE_REMOVE;
});
},
max_opacity_scale_value_changed_cb(scale) {
// Avoid settings the opacity consinuosly as it's change is animated
if (this._opacity_timeout > 0)
Mainloop.source_remove(this._opacity_timeout);
this._opacity_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
this._settings.set_double('max-alpha', scale.get_value());
this._opacity_timeout = 0;
return GLib.SOURCE_REMOVE;
});
},
custom_opacity_scale_format_value_cb(scale, value) {
return Math.round(value * 100) + ' %';
},
min_opacity_scale_format_value_cb(scale, value) {
return Math.round(value * 100) + ' %';
},
max_opacity_scale_format_value_cb(scale, value) {
return Math.round(value * 100) + ' %';
},
all_windows_radio_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('intellihide-mode', 0);
},
focus_application_windows_radio_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('intellihide-mode', 1);
},
maximized_windows_radio_button_toggled_cb(button) {
if (button.get_active())
this._settings.set_enum('intellihide-mode', 2);
}
}
object.connect(signal, SignalHandler[handler].bind(this));
}
_bindSettings() {
// Position and size panel
// Monitor options
this._monitors = [];
// Build options based on the number of monitors and the current settings.
let n_monitors = Gdk.Screen.get_default().get_n_monitors();
let primary_monitor = Gdk.Screen.get_default().get_primary_monitor();
let monitor = this._settings.get_int('preferred-monitor');
// Add primary monitor with index 0, because in GNOME Shell the primary monitor is always 0
this._builder.get_object('dock_monitor_combo').append_text(__('Primary monitor'));
this._monitors.push(0);
// Add connected monitors
let ctr = 0;
for (let i = 0; i < n_monitors; i++) {
if (i !== primary_monitor) {
ctr++;
this._monitors.push(ctr);
this._builder.get_object('dock_monitor_combo').append_text(__('Secondary monitor ') + ctr);
}
}
// If one of the external monitor is set as preferred, show it even if not attached
if ((monitor >= n_monitors) && (monitor !== primary_monitor)) {
this._monitors.push(monitor)
this._builder.get_object('dock_monitor_combo').append_text(__('Secondary monitor ') + ++ctr);
}
this._builder.get_object('dock_monitor_combo').set_active(this._monitors.indexOf(monitor));
// Position option
let position = this._settings.get_enum('dock-position');
switch (position) {
case 0:
this._builder.get_object('position_top_button').set_active(true);
break;
case 1:
this._builder.get_object('position_right_button').set_active(true);
break;
case 2:
this._builder.get_object('position_bottom_button').set_active(true);
break;
case 3:
this._builder.get_object('position_left_button').set_active(true);
break;
}
if (this._rtl) {
/* Left is Right in rtl as a setting */
this._builder.get_object('position_left_button').set_label(__('Right'));
this._builder.get_object('position_right_button').set_label(__('Left'));
}
// Intelligent autohide options
this._settings.bind('dock-fixed',
this._builder.get_object('intelligent_autohide_switch'),
'active',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this._settings.bind('dock-fixed',
this._builder.get_object('intelligent_autohide_button'),
'sensitive',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this._settings.bind('autohide',
this._builder.get_object('autohide_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('autohide-in-fullscreen',
this._builder.get_object('autohide_enable_in_fullscreen_checkbutton'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('require-pressure-to-show',
this._builder.get_object('require_pressure_checkbutton'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('intellihide',
this._builder.get_object('intellihide_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('animation-time',
this._builder.get_object('animation_duration_spinbutton'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('hide-delay',
this._builder.get_object('hide_timeout_spinbutton'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-delay',
this._builder.get_object('show_timeout_spinbutton'),
'value',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('pressure-threshold',
this._builder.get_object('pressure_threshold_spinbutton'),
'value',
Gio.SettingsBindFlags.DEFAULT);
//this._builder.get_object('animation_duration_spinbutton').set_value(this._settings.get_double('animation-time'));
// Create dialog for intelligent autohide advanced settings
this._builder.get_object('intelligent_autohide_button').connect('clicked', () => {
let dialog = new Gtk.Dialog({ title: __('Intelligent autohide customization'),
transient_for: this.widget.get_toplevel(),
use_header_bar: true,
modal: true });
// GTK+ leaves positive values for application-defined response ids.
// Use +1 for the reset action
dialog.add_button(__('Reset to defaults'), 1);
let box = this._builder.get_object('intelligent_autohide_advanced_settings_box');
dialog.get_content_area().add(box);
this._settings.bind('intellihide',
this._builder.get_object('intellihide_mode_box'),
'sensitive',
Gio.SettingsBindFlags.GET);
// intellihide mode
let intellihideModeRadioButtons = [
this._builder.get_object('all_windows_radio_button'),
this._builder.get_object('focus_application_windows_radio_button'),
this._builder.get_object('maximized_windows_radio_button')
];
intellihideModeRadioButtons[this._settings.get_enum('intellihide-mode')].set_active(true);
this._settings.bind('autohide',
this._builder.get_object('require_pressure_checkbutton'),
'sensitive',
Gio.SettingsBindFlags.GET);
this._settings.bind('autohide',
this._builder.get_object('autohide_enable_in_fullscreen_checkbutton'),
'sensitive',
Gio.SettingsBindFlags.GET);
this._settings.bind('require-pressure-to-show',
this._builder.get_object('show_timeout_spinbutton'),
'sensitive',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this._settings.bind('require-pressure-to-show',
this._builder.get_object('show_timeout_label'),
'sensitive',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this._settings.bind('require-pressure-to-show',
this._builder.get_object('pressure_threshold_spinbutton'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('require-pressure-to-show',
this._builder.get_object('pressure_threshold_label'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
dialog.connect('response', (dialog, id) => {
if (id == 1) {
// restore default settings for the relevant keys
let keys = ['intellihide', 'autohide', 'intellihide-mode', 'autohide-in-fullscreen', 'require-pressure-to-show',
'animation-time', 'show-delay', 'hide-delay', 'pressure-threshold'];
keys.forEach(function(val) {
this._settings.set_value(val, this._settings.get_default_value(val));
}, this);
intellihideModeRadioButtons[this._settings.get_enum('intellihide-mode')].set_active(true);
} else {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
}
return;
});
dialog.show_all();
});
// size options
this._builder.get_object('dock_size_scale').set_value(this._settings.get_double('height-fraction'));
this._builder.get_object('dock_size_scale').add_mark(0.9, Gtk.PositionType.TOP, null);
let icon_size_scale = this._builder.get_object('icon_size_scale');
icon_size_scale.set_range(8, DEFAULT_ICONS_SIZES[0]);
icon_size_scale.set_value(this._settings.get_int('dash-max-icon-size'));
DEFAULT_ICONS_SIZES.forEach(function(val) {
icon_size_scale.add_mark(val, Gtk.PositionType.TOP, val.toString());
});
// Corrent for rtl languages
if (this._rtl) {
// Flip value position: this is not done automatically
this._builder.get_object('dock_size_scale').set_value_pos(Gtk.PositionType.LEFT);
icon_size_scale.set_value_pos(Gtk.PositionType.LEFT);
// I suppose due to a bug, having a more than one mark and one above a value of 100
// makes the rendering of the marks wrong in rtl. This doesn't happen setting the scale as not flippable
// and then manually inverting it
icon_size_scale.set_flippable(false);
icon_size_scale.set_inverted(true);
}
this._settings.bind('icon-size-fixed', this._builder.get_object('icon_size_fixed_checkbutton'), 'active', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('extend-height', this._builder.get_object('dock_size_extend_checkbutton'), 'active', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('extend-height', this._builder.get_object('dock_size_scale'), 'sensitive', Gio.SettingsBindFlags.INVERT_BOOLEAN);
// Apps panel
this._settings.bind('show-running',
this._builder.get_object('show_running_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('isolate-workspaces',
this._builder.get_object('application_button_isolation_button'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('isolate-monitors',
this._builder.get_object('application_button_monitor_isolation_button'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-windows-preview',
this._builder.get_object('windows_preview_button'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('multi-monitor',
this._builder.get_object('multi_monitor_button'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-favorites',
this._builder.get_object('show_favorite_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-trash',
this._builder.get_object('show_trash_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-mounts',
this._builder.get_object('show_mounts_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-show-apps-button',
this._builder.get_object('show_applications_button_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-apps-at-top',
this._builder.get_object('application_button_first_button'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-show-apps-button',
this._builder.get_object('application_button_first_button'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('animate-show-apps',
this._builder.get_object('application_button_animation_button'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-show-apps-button',
this._builder.get_object('application_button_animation_button'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
// Behavior panel
this._settings.bind('hot-keys',
this._builder.get_object('hot_keys_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('hot-keys',
this._builder.get_object('overlay_button'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._builder.get_object('click_action_combo').set_active(this._settings.get_enum('click-action'));
this._builder.get_object('click_action_combo').connect('changed', (widget) => {
this._settings.set_enum('click-action', widget.get_active());
});
this._builder.get_object('scroll_action_combo').set_active(this._settings.get_enum('scroll-action'));
this._builder.get_object('scroll_action_combo').connect('changed', (widget) => {
this._settings.set_enum('scroll-action', widget.get_active());
});
this._builder.get_object('shift_click_action_combo').connect('changed', (widget) => {
this._settings.set_enum('shift-click-action', widget.get_active());
});
this._builder.get_object('middle_click_action_combo').connect('changed', (widget) => {
this._settings.set_enum('middle-click-action', widget.get_active());
});
this._builder.get_object('shift_middle_click_action_combo').connect('changed', (widget) => {
this._settings.set_enum('shift-middle-click-action', widget.get_active());
});
// Create dialog for number overlay options
this._builder.get_object('overlay_button').connect('clicked', () => {
let dialog = new Gtk.Dialog({ title: __('Show dock and application numbers'),
transient_for: this.widget.get_toplevel(),
use_header_bar: true,
modal: true });
// GTK+ leaves positive values for application-defined response ids.
// Use +1 for the reset action
dialog.add_button(__('Reset to defaults'), 1);
let box = this._builder.get_object('box_overlay_shortcut');
dialog.get_content_area().add(box);
this._builder.get_object('overlay_switch').set_active(this._settings.get_boolean('hotkeys-overlay'));
this._builder.get_object('show_dock_switch').set_active(this._settings.get_boolean('hotkeys-show-dock'));
// We need to update the shortcut 'strv' when the text is modified
this._settings.connect('changed::shortcut-text', () => {setShortcut(this._settings);});
this._settings.bind('shortcut-text',
this._builder.get_object('shortcut_entry'),
'text',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('hotkeys-overlay',
this._builder.get_object('overlay_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('hotkeys-show-dock',
this._builder.get_object('show_dock_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('shortcut-timeout',
this._builder.get_object('timeout_spinbutton'),
'value',
Gio.SettingsBindFlags.DEFAULT);
dialog.connect('response', (dialog, id) => {
if (id == 1) {
// restore default settings for the relevant keys
let keys = ['shortcut-text', 'hotkeys-overlay', 'hotkeys-show-dock', 'shortcut-timeout'];
keys.forEach(function(val) {
this._settings.set_value(val, this._settings.get_default_value(val));
}, this);
} else {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
}
return;
});
dialog.show_all();
});
// Create dialog for middle-click options
this._builder.get_object('middle_click_options_button').connect('clicked', () => {
let dialog = new Gtk.Dialog({ title: __('Customize middle-click behavior'),
transient_for: this.widget.get_toplevel(),
use_header_bar: true,
modal: true });
// GTK+ leaves positive values for application-defined response ids.
// Use +1 for the reset action
dialog.add_button(__('Reset to defaults'), 1);
let box = this._builder.get_object('box_middle_click_options');
dialog.get_content_area().add(box);
this._builder.get_object('shift_click_action_combo').set_active(this._settings.get_enum('shift-click-action'));
this._builder.get_object('middle_click_action_combo').set_active(this._settings.get_enum('middle-click-action'));
this._builder.get_object('shift_middle_click_action_combo').set_active(this._settings.get_enum('shift-middle-click-action'));
this._settings.bind('shift-click-action',
this._builder.get_object('shift_click_action_combo'),
'active-id',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('middle-click-action',
this._builder.get_object('middle_click_action_combo'),
'active-id',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('shift-middle-click-action',
this._builder.get_object('shift_middle_click_action_combo'),
'active-id',
Gio.SettingsBindFlags.DEFAULT);
dialog.connect('response', (dialog, id) => {
if (id == 1) {
// restore default settings for the relevant keys
let keys = ['shift-click-action', 'middle-click-action', 'shift-middle-click-action'];
keys.forEach(function(val) {
this._settings.set_value(val, this._settings.get_default_value(val));
}, this);
this._builder.get_object('shift_click_action_combo').set_active(this._settings.get_enum('shift-click-action'));
this._builder.get_object('middle_click_action_combo').set_active(this._settings.get_enum('middle-click-action'));
this._builder.get_object('shift_middle_click_action_combo').set_active(this._settings.get_enum('shift-middle-click-action'));
} else {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
}
return;
});
dialog.show_all();
});
// Appearance Panel
this._settings.bind('apply-custom-theme', this._builder.get_object('customize_theme'), 'sensitive', Gio.SettingsBindFlags.INVERT_BOOLEAN | Gio.SettingsBindFlags.GET);
this._settings.bind('apply-custom-theme', this._builder.get_object('builtin_theme_switch'), 'active', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('custom-theme-shrink', this._builder.get_object('shrink_dash_switch'), 'active', Gio.SettingsBindFlags.DEFAULT);
// Running indicators
this._builder.get_object('running_indicators_combo').set_active(
this._settings.get_enum('running-indicator-style')
);
this._builder.get_object('running_indicators_combo').connect(
'changed',
(widget) => {
this._settings.set_enum('running-indicator-style', widget.get_active());
}
);
if (this._settings.get_enum('running-indicator-style') == RunningIndicatorStyle.DEFAULT)
this._builder.get_object('running_indicators_advance_settings_button').set_sensitive(false);
this._settings.connect('changed::running-indicator-style', () => {
if (this._settings.get_enum('running-indicator-style') == RunningIndicatorStyle.DEFAULT)
this._builder.get_object('running_indicators_advance_settings_button').set_sensitive(false);
else
this._builder.get_object('running_indicators_advance_settings_button').set_sensitive(true);
});
// Create dialog for running indicators advanced settings
this._builder.get_object('running_indicators_advance_settings_button').connect('clicked', () => {
let dialog = new Gtk.Dialog({ title: __('Customize running indicators'),
transient_for: this.widget.get_toplevel(),
use_header_bar: true,
modal: true });
let box = this._builder.get_object('running_dots_advance_settings_box');
dialog.get_content_area().add(box);
this._settings.bind('running-indicator-dominant-color',
this._builder.get_object('dominant_color_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('custom-theme-customize-running-dots',
this._builder.get_object('dot_style_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('custom-theme-customize-running-dots',
this._builder.get_object('dot_style_settings_box'),
'sensitive', Gio.SettingsBindFlags.DEFAULT);
let rgba = new Gdk.RGBA();
rgba.parse(this._settings.get_string('custom-theme-running-dots-color'));
this._builder.get_object('dot_color_colorbutton').set_rgba(rgba);
this._builder.get_object('dot_color_colorbutton').connect('notify::color', (button) => {
let rgba = button.get_rgba();
let css = rgba.to_string();
let hexString = cssHexString(css);
this._settings.set_string('custom-theme-running-dots-color', hexString);
});
rgba.parse(this._settings.get_string('custom-theme-running-dots-border-color'));
this._builder.get_object('dot_border_color_colorbutton').set_rgba(rgba);
this._builder.get_object('dot_border_color_colorbutton').connect('notify::color', (button) => {
let rgba = button.get_rgba();
let css = rgba.to_string();
let hexString = cssHexString(css);
this._settings.set_string('custom-theme-running-dots-border-color', hexString);
});
this._settings.bind('custom-theme-running-dots-border-width',
this._builder.get_object('dot_border_width_spin_button'),
'value',
Gio.SettingsBindFlags.DEFAULT);
dialog.connect('response', (dialog, id) => {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
return;
});
dialog.show_all();
});
this._settings.bind('custom-background-color', this._builder.get_object('custom_background_color_switch'), 'active', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('custom-background-color', this._builder.get_object('custom_background_color'), 'sensitive', Gio.SettingsBindFlags.DEFAULT);
let rgba = new Gdk.RGBA();
rgba.parse(this._settings.get_string('background-color'));
this._builder.get_object('custom_background_color').set_rgba(rgba);
this._builder.get_object('custom_background_color').connect('notify::color', (button) => {
let rgba = button.get_rgba();
let css = rgba.to_string();
let hexString = cssHexString(css);
this._settings.set_string('background-color', hexString);
});
// Opacity
this._builder.get_object('customize_opacity_combo').set_active_id(
this._settings.get_enum('transparency-mode').toString()
);
this._builder.get_object('customize_opacity_combo').connect(
'changed',
(widget) => {
this._settings.set_enum('transparency-mode', parseInt(widget.get_active_id()));
}
);
this._builder.get_object('custom_opacity_scale').set_value(this._settings.get_double('background-opacity'));
if (this._settings.get_enum('transparency-mode') !== TransparencyMode.FIXED)
this._builder.get_object('custom_opacity_scale').set_sensitive(false);
this._settings.connect('changed::transparency-mode', () => {
if (this._settings.get_enum('transparency-mode') !== TransparencyMode.FIXED)
this._builder.get_object('custom_opacity_scale').set_sensitive(false);
else
this._builder.get_object('custom_opacity_scale').set_sensitive(true);
});
if (this._settings.get_enum('transparency-mode') !== TransparencyMode.DYNAMIC) {
this._builder.get_object('dynamic_opacity_button').set_sensitive(false);
}
this._settings.connect('changed::transparency-mode', () => {
if (this._settings.get_enum('transparency-mode') !== TransparencyMode.DYNAMIC) {
this._builder.get_object('dynamic_opacity_button').set_sensitive(false);
}
else {
this._builder.get_object('dynamic_opacity_button').set_sensitive(true);
}
});
// Create dialog for transparency advanced settings
this._builder.get_object('dynamic_opacity_button').connect('clicked', () => {
let dialog = new Gtk.Dialog({ title: __('Cutomize opacity'),
transient_for: this.widget.get_toplevel(),
use_header_bar: true,
modal: true });
let box = this._builder.get_object('advanced_transparency_dialog');
dialog.get_content_area().add(box);
this._settings.bind(
'customize-alphas',
this._builder.get_object('customize_alphas_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT
);
this._settings.bind(
'customize-alphas',
this._builder.get_object('min_alpha_scale'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT
);
this._settings.bind(
'customize-alphas',
this._builder.get_object('max_alpha_scale'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT
);
this._builder.get_object('min_alpha_scale').set_value(
this._settings.get_double('min-alpha')
);
this._builder.get_object('max_alpha_scale').set_value(
this._settings.get_double('max-alpha')
);
dialog.connect('response', (dialog, id) => {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
return;
});
dialog.show_all();
});
this._settings.bind('unity-backlit-items',
this._builder.get_object('unity_backlit_items_switch'),
'active', Gio.SettingsBindFlags.DEFAULT
);
this._settings.bind('force-straight-corner',
this._builder.get_object('force_straight_corner_switch'),
'active', Gio.SettingsBindFlags.DEFAULT);
// About Panel
this._builder.get_object('extension_version').set_label(Me.metadata.version.toString());
}
};
function init() {
ExtensionUtils.initTranslations();
}
function buildPrefsWidget() {
let settings = new Settings();
let widget = settings.widget;
widget.show_all();
return widget;
}