Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1446cec
Save terminal-pane state explicitly - destroy signal unsuitable
jeremypw May 27, 2025
3737cda
Use common action to set active project
jeremypw May 27, 2025
68eb0fb
Disambiguate action name
jeremypw May 29, 2025
c303756
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw May 29, 2025
d738599
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jun 5, 2025
debbf2d
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jun 10, 2025
dd04b48
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jun 16, 2025
1b24dfe
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jun 20, 2025
8b9c7b3
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jun 28, 2025
6d25e42
Match self in get_project_for_file
jeremypw Jun 28, 2025
20b82ba
Lose FileView.ACTION_SET_PROJECT_ACTIVE call MainWindow action directly
jeremypw Jun 28, 2025
4e451de
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jul 2, 2025
eb54627
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Jul 16, 2025
0751854
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Aug 9, 2025
b505e03
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Aug 18, 2025
a985df6
Merge branch 'master' into jeremypw/terminal-pane/save-state
jeremypw Oct 18, 2025
367b672
Revert renaming function
jeremypw Nov 5, 2025
7635580
Merge branch 'master' into jeremypw/terminal-pane/save-state
zeebok Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/FolderManager/FileView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane
foreach (var child in root.children) {
var project_folder_item = (ProjectFolderItem) child;
if (project_folder_item != folder_root) {
toplevel_action_group.activate_action (MainWindow.ACTION_CLOSE_PROJECT_DOCS, new Variant.string (project_folder_item.path));
toplevel_action_group.activate_action (
MainWindow.ACTION_CLOSE_PROJECT_DOCS,
new Variant.string (project_folder_item.path)
);
root.remove (project_folder_item);
git_manager.remove_project (project_folder_item);
}
}

//Make remaining project the active one
git_manager.active_project_path = path;

write_settings ();
set_active_project (path);
}

private void action_set_active_project (SimpleAction action, GLib.Variant? parameter) {
Expand All @@ -138,7 +138,14 @@ public class Scratch.FolderManager.FileView : Code.Widgets.SourceList, Code.Pane
return;
}

git_manager.active_project_path = path;
set_active_project (path);
}

private void set_active_project (string path) {
toplevel_action_group.activate_action (
MainWindow.ACTION_SET_ACTIVE_PROJECT,
new Variant.string (path)
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems recursive no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so; there are two actions named ACTION_SET_ACTIVE_PROJECT but with different prefixes. The FileView one activates the MainWindow one as well as doing some local stuff. I'll check and see if this can be clarified.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof yeah, what's the reason for having two actions? Why can't we call the same one always?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MainWindow action is called by two different FileView actions (ACTION_CLOSE_OTHER_PROJECTS and ACTION_SET_ACTIVE_PROJECT) and there is some pre- and post- processing specific to FileView involved so not sure if that's possible. I could change the name of the FileView action to avoid confusion I guess.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now lost the FileView action altogether and call the MainWindow one directly. Need to check for regressions but seems OK. There didn't seem a reason to re-write the opened-folders setting on changing active project and this way should improve consistency of behaviour.


write_settings ();
}
Expand Down
26 changes: 17 additions & 9 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ namespace Scratch {
public const string ACTION_TOGGLE_OUTLINE = "action-toggle-outline";
public const string ACTION_TOGGLE_TERMINAL = "action-toggle-terminal";
public const string ACTION_OPEN_IN_TERMINAL = "action-open-in-terminal";
public const string ACTION_SET_ACTIVE_PROJECT = "action-set-active-project";
public const string ACTION_NEXT_TAB = "action-next-tab";
public const string ACTION_PREVIOUS_TAB = "action-previous-tab";
public const string ACTION_CLEAR_LINES = "action-clear-lines";
Expand Down Expand Up @@ -165,6 +166,7 @@ namespace Scratch {
{ ACTION_TOGGLE_SIDEBAR, action_toggle_sidebar, null, "true" },
{ ACTION_TOGGLE_TERMINAL, action_toggle_terminal, null, "false"},
{ ACTION_OPEN_IN_TERMINAL, action_open_in_terminal, "s"},
{ ACTION_SET_ACTIVE_PROJECT, action_set_active_project, "s"},
{ ACTION_TOGGLE_OUTLINE, action_toggle_outline, null, "false" },
{ ACTION_NEXT_TAB, action_next_tab },
{ ACTION_PREVIOUS_TAB, action_previous_tab },
Expand Down Expand Up @@ -629,14 +631,6 @@ namespace Scratch {
}
});

sidebar.choose_project_button.project_chosen.connect (() => {
folder_manager_view.collapse_other_projects ();
if (terminal.visible) {
var open_in_terminal_action = Utils.action_from_group (ACTION_OPEN_IN_TERMINAL, actions);
var param = new Variant.string (Services.GitManager.get_instance ().get_default_build_dir (null));
open_in_terminal_action.activate (param);
}
});

set_widgets_sensitive (false);
}
Expand Down Expand Up @@ -860,6 +854,8 @@ namespace Scratch {
// Plugin panes size
Scratch.saved_state.set_int ("hp1-size", hp1.get_position ());
Scratch.saved_state.set_int ("vp-size", vp.get_position ());

terminal.save_settings ();
}

// SIGTERM/SIGINT Handling
Expand Down Expand Up @@ -1369,7 +1365,7 @@ namespace Scratch {

private void action_open_in_terminal (SimpleAction action, Variant? param) {
// Ensure terminal is visible
if (terminal == null || !terminal.visible) {
if (!terminal.visible) {
var toggle_terminal_action = Utils.action_from_group (ACTION_TOGGLE_TERMINAL, actions);
toggle_terminal_action.activate (null);
}
Expand All @@ -1381,6 +1377,18 @@ namespace Scratch {
terminal.terminal.grab_focus ();
}

private void action_set_active_project (SimpleAction action, Variant? param) {
var project_path = param.get_string ();
git_manager.active_project_path = project_path;
folder_manager_view.collapse_other_projects ();

var new_build_dir = Services.GitManager.get_instance ().get_default_build_dir (null);
terminal.change_location (new_build_dir);
if (terminal.visible) {
terminal.terminal.grab_focus ();
}
}

private void action_toggle_outline (SimpleAction action) {
action.set_state (!action.get_state ().get_boolean ());
document_view.outline_visible = action.get_state ().get_boolean ();
Expand Down
12 changes: 10 additions & 2 deletions src/Widgets/ChooseProjectButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
private Gtk.Label label_widget;
private Gtk.ListBox project_listbox;

public ActionGroup toplevel_action_group { get; construct; }
public signal void project_chosen ();

construct {
realize.connect (() => {
toplevel_action_group = get_action_group (Scratch.MainWindow.ACTION_GROUP);
assert_nonnull (toplevel_action_group);
});

var img = new Gtk.Image () {
gicon = new ThemedIcon ("git-symbolic"),
icon_size = Gtk.IconSize.SMALL_TOOLBAR
Expand Down Expand Up @@ -114,8 +120,10 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {

project_listbox.row_activated.connect ((row) => {
var project_entry = ((ProjectRow) row);
git_manager.active_project_path = project_entry.project_path;
project_chosen ();
toplevel_action_group.activate_action (
Scratch.MainWindow.ACTION_SET_ACTIVE_PROJECT,
new Variant.string (project_entry.project_path)
);
});

toggled.connect (() => {
Expand Down
8 changes: 4 additions & 4 deletions src/Widgets/Terminal.vala
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ public class Code.Terminal : Gtk.Box {

add (scrolled_window);

destroy.connect (() => {
settings.set_string ("last-opened-path", get_shell_location ());
});

show_all ();
}

Expand Down Expand Up @@ -196,6 +192,10 @@ public class Code.Terminal : Gtk.Box {
this.terminal.set_colors (foreground_color, background_color, palette);
}

public void save_settings () {
Scratch.saved_state.set_string ("last-opened-path", get_shell_location ());
}

public void increment_size () {
terminal.font_scale = (terminal.font_scale + 0.1).clamp (MIN_SCALE, MAX_SCALE);
}
Expand Down