Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace Scratch {
public const string ACTION_TOGGLE_COMMENT = "action-toggle-comment";
public const string ACTION_TOGGLE_SHOW_FIND = "action-toggle_show-find";
public const string ACTION_TOGGLE_SIDEBAR = "action-toggle-sidebar";
public const string ACTION_FOCUS_SIDEBAR = "action-focus-sidebar";
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";
Expand Down Expand Up @@ -166,6 +167,7 @@ namespace Scratch {
{ ACTION_ZOOM_OUT, action_zoom_out},
{ ACTION_TOGGLE_COMMENT, action_toggle_comment },
{ ACTION_TOGGLE_SIDEBAR, action_toggle_sidebar, null, "true" },
{ ACTION_FOCUS_SIDEBAR, action_focus_sidebar },
{ 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"},
Expand Down Expand Up @@ -236,6 +238,7 @@ namespace Scratch {
action_accelerators.set (ACTION_TOGGLE_COMMENT, "<Control>slash");
action_accelerators.set (ACTION_TOGGLE_SIDEBAR, "F9"); // GNOME
action_accelerators.set (ACTION_TOGGLE_SIDEBAR, "<Control>backslash"); // Atom
action_accelerators.set (ACTION_FOCUS_SIDEBAR, "<Control><Alt>Left");
action_accelerators.set (ACTION_TOGGLE_TERMINAL, "<Control><Alt>t");
action_accelerators.set (ACTION_OPEN_IN_TERMINAL + "::", "<Control><Alt><Shift>t");
action_accelerators.set (ACTION_TOGGLE_OUTLINE, "<Alt>backslash");
Expand Down Expand Up @@ -1427,6 +1430,19 @@ namespace Scratch {
sidebar.visible = action.get_state ().get_boolean ();
}

private void action_focus_sidebar () {
if (sidebar == null) {
return;
}

if (!sidebar.visible) {
var toggle_sidebar_action = Utils.action_from_group (ACTION_TOGGLE_SIDEBAR, actions);
toggle_sidebar_action.activate (null);
}

sidebar.focus_sidebar ();
}

private void action_toggle_terminal () {
var toggle_terminal_action = Utils.action_from_group (ACTION_TOGGLE_TERMINAL, actions);
toggle_terminal_action.set_state (!toggle_terminal_action.get_state ().get_boolean ());
Expand Down
8 changes: 8 additions & 0 deletions src/Widgets/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,12 @@ public class Code.Sidebar : Gtk.Grid {
public void notify_cloning_success () {
cloning_success_toast.send_notification ();
}

public void focus_sidebar () {
if (stack.visible_child != null) {
stack.visible_child.grab_focus ();
} else {
grab_focus ();
}
}
}
4 changes: 4 additions & 0 deletions src/Widgets/SourceList/SourceList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2937,5 +2937,9 @@ public class SourceList : Gtk.ScrolledWindow {

return null;
}

public override void grab_focus () {
tree.grab_focus ();
}
}
}