@@ -110,6 +110,7 @@ namespace Scratch {
110110 public const string ACTION_TOGGLE_OUTLINE = " action-toggle-outline" ;
111111 public const string ACTION_TOGGLE_TERMINAL = " action-toggle-terminal" ;
112112 public const string ACTION_OPEN_IN_TERMINAL = " action-open-in-terminal" ;
113+ public const string ACTION_SET_ACTIVE_PROJECT = " action-set-active-project" ;
113114 public const string ACTION_NEXT_TAB = " action-next-tab" ;
114115 public const string ACTION_PREVIOUS_TAB = " action-previous-tab" ;
115116 public const string ACTION_CLEAR_LINES = " action-clear-lines" ;
@@ -169,6 +170,7 @@ namespace Scratch {
169170 { ACTION_TOGGLE_SIDEBAR , action_toggle_sidebar, null , " true" },
170171 { ACTION_TOGGLE_TERMINAL , action_toggle_terminal, null , " false" },
171172 { ACTION_OPEN_IN_TERMINAL , action_open_in_terminal, " s" },
173+ { ACTION_SET_ACTIVE_PROJECT , action_set_active_project, " s" },
172174 { ACTION_TOGGLE_OUTLINE , action_toggle_outline, null , " false" },
173175 { ACTION_NEXT_TAB , action_next_tab },
174176 { ACTION_PREVIOUS_TAB , action_previous_tab },
@@ -633,14 +635,6 @@ namespace Scratch {
633635 }
634636 });
635637
636- sidebar. choose_project_button. project_chosen. connect (() = > {
637- folder_manager_view. collapse_other_projects ();
638- if (terminal. visible) {
639- var open_in_terminal_action = Utils . action_from_group (ACTION_OPEN_IN_TERMINAL , actions);
640- var param = new Variant .string (Services . GitManager . get_instance (). get_default_build_dir (null ));
641- open_in_terminal_action. activate (param);
642- }
643- });
644638
645639 set_widgets_sensitive (false );
646640 }
@@ -865,6 +859,8 @@ namespace Scratch {
865859 // Plugin panes size
866860 Scratch . saved_state. set_int (" hp1-size" , hp1. get_position ());
867861 Scratch . saved_state. set_int (" vp-size" , vp. get_position ());
862+
863+ terminal. save_settings ();
868864 }
869865
870866 // SIGTERM/SIGINT Handling
@@ -1450,7 +1446,7 @@ namespace Scratch {
14501446
14511447 private void action_open_in_terminal (SimpleAction action, Variant ? param) {
14521448 // Ensure terminal is visible
1453- if (terminal == null || ! terminal. visible) {
1449+ if (! terminal. visible) {
14541450 var toggle_terminal_action = Utils . action_from_group (ACTION_TOGGLE_TERMINAL , actions);
14551451 toggle_terminal_action. activate (null );
14561452 }
@@ -1462,6 +1458,24 @@ namespace Scratch {
14621458 terminal. terminal. grab_focus ();
14631459 }
14641460
1461+ private void action_set_active_project (SimpleAction action, Variant ? param) {
1462+ var project_path = param. get_string ();
1463+ if (folder_manager_view. project_is_open (project_path)) {
1464+ git_manager. active_project_path = project_path;
1465+ folder_manager_view. collapse_other_projects ();
1466+ // The opened folders are not changed so no need to update "opened-folders" setting
1467+ } else {
1468+ warning (" Attempt to set folder path %s which is not opened as active project ignored" , project_path);
1469+ // TODO Handle this by opening the folder
1470+ }
1471+
1472+ var new_build_dir = Services . GitManager . get_instance (). get_default_build_dir (null );
1473+ terminal. change_location (new_build_dir);
1474+ if (terminal. visible) {
1475+ terminal. terminal. grab_focus ();
1476+ }
1477+ }
1478+
14651479 private void action_toggle_outline (SimpleAction action) {
14661480 action. set_state (! action. get_state (). get_boolean ());
14671481 document_view. outline_visible = action. get_state (). get_boolean ();
0 commit comments