@@ -17,7 +17,7 @@ export default class ExecutorPreferences extends ExtensionPreferences {
1717 2 : _ ( 'Right' ) ,
1818 } ;
1919
20- this . settings = this . getSettings ( ) ;
20+ const settings = this . getSettings ( ) ;
2121
2222 let prefsWidget = new Gtk . Grid ( { visible : true , column_homogeneous : true } ) ;
2323 this . notebook = new Gtk . Notebook ( { visible : true } ) ;
@@ -31,12 +31,12 @@ export default class ExecutorPreferences extends ExtensionPreferences {
3131 this . commandsArrayCopy [ position ] = [ ] ;
3232 try {
3333 this . commandsArray [ position ] = JSON . parse (
34- this . settings . get_value ( POSITIONS [ position ] + '-commands-json' ) . deep_unpack ( )
34+ settings . get_value ( POSITIONS [ position ] + '-commands-json' ) . deep_unpack ( )
3535 ) . commands ;
3636 this . commandsArrayCopy [ position ] = JSON . parse ( JSON . stringify ( this . commandsArray [ position ] ) ) ;
3737 } catch ( e ) {
38- log ( 'Error in json file for position:' , POSITIONS [ position ] ) ;
39- this . settings . set_string (
38+ console . log ( 'Error in json file for position:' , POSITIONS [ position ] ) ;
39+ settings . set_string (
4040 POSITIONS [ position ] + '-commands-json' ,
4141 '{"commands":[{"command":"echo Executor works!","interval":1}]}'
4242 ) ;
@@ -64,9 +64,14 @@ export default class ExecutorPreferences extends ExtensionPreferences {
6464 valign : Gtk . Align . CENTER ,
6565 hexpand : true ,
6666 } ) ;
67- active . set_active ( this . settings . get_value ( POSITIONS [ position ] + '-active' ) . deep_unpack ( ) ) ;
67+ active . set_active ( settings . get_value ( POSITIONS [ position ] + '-active' ) . deep_unpack ( ) ) ;
6868 active . connect ( 'notify::active' , ( ) => {
69- this . activeClicked ( active . get_active ( ) ) ;
69+ let position = this . notebook . get_current_page ( ) ;
70+ if ( active . get_active ( ) ) {
71+ this . saveCommands ( settings ) ;
72+ }
73+
74+ settings . set_boolean ( POSITIONS [ position ] + '-active' , active . get_active ( ) ) ;
7075 } ) ;
7176 let index = new Gtk . SpinButton ( {
7277 adjustment : new Gtk . Adjustment ( { lower : 0 , upper : 10 , step_increment : 1 } ) ,
@@ -133,7 +138,7 @@ export default class ExecutorPreferences extends ExtensionPreferences {
133138 this . commandsArray [ position ] = JSON . parse ( JSON . stringify ( this . commandsArrayCopy [ position ] ) ) ;
134139 this . populateCommandList ( position ) ;
135140 } ) ;
136- saveButton . connect ( 'clicked' , this . saveCommands . bind ( this ) ) ;
141+ saveButton . connect ( 'clicked' , this . saveCommands . bind ( this , settings ) ) ;
137142 buttonsHbox . append ( addButton ) ;
138143 buttonsHbox . append ( cancelButton ) ;
139144 buttonsHbox . append ( saveButton ) ;
@@ -142,7 +147,7 @@ export default class ExecutorPreferences extends ExtensionPreferences {
142147 let pos = postrans [ position ] ;
143148 this . notebook . append_page ( grid , new Gtk . Label ( { label : _ ( pos ) , visible : true , hexpand : true } ) ) ;
144149
145- this . settings . bind ( POSITIONS [ position ] + '-index' , index , 'value' , Gio . SettingsBindFlags . DEFAULT ) ;
150+ settings . bind ( POSITIONS [ position ] + '-index' , index , 'value' , Gio . SettingsBindFlags . DEFAULT ) ;
146151 }
147152
148153 /* General tab */
@@ -167,9 +172,9 @@ export default class ExecutorPreferences extends ExtensionPreferences {
167172 valign : Gtk . Align . CENTER ,
168173 hexpand : true ,
169174 } ) ;
170- clickOnOutputActive . set_active ( this . settings . get_value ( 'click-on-output-active' ) . deep_unpack ( ) ) ;
175+ clickOnOutputActive . set_active ( settings . get_value ( 'click-on-output-active' ) . deep_unpack ( ) ) ;
171176 clickOnOutputActive . connect ( 'notify::active' , ( ) => {
172- this . clickOnOutputActiveClicked ( clickOnOutputActive . get_active ( ) ) ;
177+ settings . set_boolean ( 'click-on-output-active' , clickOnOutputActive . get_active ( ) ) ;
173178 } ) ;
174179 topHbox . append (
175180 new Gtk . Label ( { label : _ ( 'Click on output in top bar active:' ) , use_markup : true , visible : true } )
@@ -179,9 +184,9 @@ export default class ExecutorPreferences extends ExtensionPreferences {
179184 this . notebook . append_page ( grid , new Gtk . Label ( { label : _ ( 'General' ) , visible : true , hexpand : true } ) ) ;
180185 /* End of general tab */
181186
182- this . notebook . set_current_page ( this . settings . get_value ( 'location' ) . deep_unpack ( ) ) ;
187+ this . notebook . set_current_page ( settings . get_value ( 'location' ) . deep_unpack ( ) ) ;
183188 this . notebook . connect ( 'switch-page' , ( notebook , page , index ) => {
184- this . settings . set_int ( 'location' , index ) ;
189+ settings . set_int ( 'location' , index ) ;
185190 } ) ;
186191 return prefsWidget ;
187192 }
@@ -291,7 +296,7 @@ export default class ExecutorPreferences extends ExtensionPreferences {
291296 array . splice ( toIndex , 0 , element ) ;
292297 }
293298
294- saveCommands ( ) {
299+ saveCommands ( settings ) {
295300 let position = this . notebook . get_current_page ( ) ;
296301 this . commandsArray [ position ] . splice ( 0 , this . commandsArray [ position ] . length ) ;
297302
@@ -321,7 +326,7 @@ export default class ExecutorPreferences extends ExtensionPreferences {
321326 }
322327
323328 this . commandsArrayCopy [ position ] = JSON . parse ( JSON . stringify ( this . commandsArray [ position ] ) ) ;
324- this . settings . set_string (
329+ settings . set_string (
325330 POSITIONS [ position ] + '-commands-json' ,
326331 '{"commands":' + JSON . stringify ( this . commandsArray [ position ] ) + '}'
327332 ) ;
@@ -335,16 +340,4 @@ export default class ExecutorPreferences extends ExtensionPreferences {
335340 } ) ;
336341 }
337342
338- activeClicked ( isActive ) {
339- let position = this . notebook . get_current_page ( ) ;
340- if ( isActive ) {
341- this . saveCommands ( ) ;
342- }
343-
344- this . settings . set_boolean ( POSITIONS [ position ] + '-active' , isActive ) ;
345- }
346-
347- clickOnOutputActiveClicked ( isActive ) {
348- this . settings . set_boolean ( 'click-on-output-active' , isActive ) ;
349- }
350343}
0 commit comments