@@ -23,7 +23,7 @@ export var EEPSPrefsPage = GObject.registerClass(
23
23
24
24
// Shortcut group
25
25
// --------------
26
- let resetShortcutsButton = new Gtk . Button ( {
26
+ this . resetShortcutsButton = new Gtk . Button ( {
27
27
icon_name : 'view-refresh-symbolic' ,
28
28
valign : Gtk . Align . CENTER ,
29
29
css_classes : [ 'destructive-action' ] ,
@@ -32,7 +32,7 @@ export var EEPSPrefsPage = GObject.registerClass(
32
32
} ) ;
33
33
let shortcutGroup = new Adw . PreferencesGroup ( {
34
34
title : _ ( 'Keyboard Shortcuts' ) ,
35
- header_suffix : resetShortcutsButton ,
35
+ header_suffix : this . resetShortcutsButton ,
36
36
} ) ;
37
37
38
38
// Cycle Output Presets Keyboard shortcut
@@ -49,38 +49,51 @@ export var EEPSPrefsPage = GObject.registerClass(
49
49
_ ( 'Cycle Input Presets' ) ,
50
50
_ ( 'Keyboard shortcut to cycle through input presets' )
51
51
) ;
52
+ // Toggle Global Bypass Keyboard shortcut
53
+ this . toggleBypassRow = new ShortcutRow (
54
+ this . _settings ,
55
+ 'toggle-global-bypass' ,
56
+ _ ( 'Toggle Global Bypass' ) ,
57
+ _ ( 'Keyboard shortcut to toggle global bypass' )
58
+ ) ;
52
59
53
60
// Hide/Show delete button
54
- if ( ! ( this . outputShortcutRow . isAcceleratorChanged ( ) || this . inputShortcutRow . isAcceleratorChanged ( ) ) )
55
- resetShortcutsButton . visible = false ;
61
+ if ( ! this . _isAnyAcceleratorChanged ( ) )
62
+ this . resetShortcutsButton . visible = false ;
56
63
57
64
58
65
// Add elements
59
66
shortcutGroup . add ( this . outputShortcutRow ) ;
60
67
shortcutGroup . add ( this . inputShortcutRow ) ;
68
+ shortcutGroup . add ( this . toggleBypassRow ) ;
61
69
this . add ( shortcutGroup ) ;
62
70
63
71
64
72
// Bind signals
65
73
// --------------
66
- resetShortcutsButton . connect ( 'clicked' , this . _resetShortcuts . bind ( this ) ) ;
67
- this . _settings . connect ( 'changed::cycle-output-presets' , ( ) => {
68
- if ( this . outputShortcutRow . isAcceleratorChanged ( ) || this . inputShortcutRow . isAcceleratorChanged ( ) )
69
- resetShortcutsButton . visible = true ;
70
- else
71
- resetShortcutsButton . visible = false ;
72
- } ) ;
73
- this . _settings . connect ( 'changed::cycle-input-presets' , ( ) => {
74
- if ( this . outputShortcutRow . isAcceleratorChanged ( ) || this . inputShortcutRow . isAcceleratorChanged ( ) )
75
- resetShortcutsButton . visible = true ;
76
- else
77
- resetShortcutsButton . visible = false ;
78
- } ) ;
74
+ this . resetShortcutsButton . connect ( 'clicked' , this . _resetShortcuts . bind ( this ) ) ;
75
+ this . _settings . connect ( 'changed::cycle-output-presets' , this . _changeResetButtonVisibility . bind ( this ) ) ;
76
+ this . _settings . connect ( 'changed::cycle-input-presets' , this . _changeResetButtonVisibility . bind ( this ) ) ;
77
+ this . _settings . connect ( 'changed::toggle-global-bypass' , this . _changeResetButtonVisibility . bind ( this ) ) ;
78
+ }
79
+
80
+ _changeResetButtonVisibility ( ) {
81
+ if ( this . _isAnyAcceleratorChanged ( ) )
82
+ this . resetShortcutsButton . visible = true ;
83
+ else
84
+ this . resetShortcutsButton . visible = false ;
85
+ }
86
+
87
+ _isAnyAcceleratorChanged ( ) {
88
+ return this . outputShortcutRow . isAcceleratorChanged ( ) ||
89
+ this . inputShortcutRow . isAcceleratorChanged ( ) ||
90
+ this . toggleBypassRow . isAcceleratorChanged ( ) ;
79
91
}
80
92
81
93
_resetShortcuts ( ) {
82
94
this . outputShortcutRow . resetAccelerator ( ) ;
83
95
this . inputShortcutRow . resetAccelerator ( ) ;
96
+ this . toggleBypassRow . resetAccelerator ( ) ;
84
97
}
85
98
} ) ;
86
99
0 commit comments