diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 1e09bc066..748bdf801 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -521,6 +521,9 @@ namespace Scratch { visible = false }; + terminal.terminal.focus_in_event.connect (on_terminal_focus_change); + terminal.terminal.focus_out_event.connect (on_terminal_focus_change); + var view_grid = new Gtk.Grid () { orientation = Gtk.Orientation.VERTICAL }; @@ -734,6 +737,27 @@ namespace Scratch { toolbar.share_menu_button.sensitive = val; } + private bool on_terminal_focus_change () { + var focused = terminal.terminal.has_focus; + //r +- shift + Utils.action_from_group (ACTION_SHOW_REPLACE, actions).set_enabled (!focused); + Utils.action_from_group (ACTION_RESTORE_PROJECT_DOCS, actions).set_enabled (!focused); + //z +- shift + Utils.action_from_group (ACTION_UNDO, actions).set_enabled (!focused); + Utils.action_from_group (ACTION_REDO, actions).set_enabled (!focused); + + //u + Utils.action_from_group (ACTION_TO_UPPER_CASE, actions).set_enabled (!focused); + + //k +- shift + Utils.action_from_group (ACTION_DUPLICATE_TAB, actions).set_enabled (!focused); + Utils.action_from_group (ACTION_CLEAR_LINES, actions).set_enabled (!focused); + + //l + Utils.action_from_group (ACTION_TO_LOWER_CASE, actions).set_enabled (!focused); + return false; + } + // Get current document public Scratch.Services.Document? get_current_document () { return document_view.current_document; @@ -1282,6 +1306,10 @@ namespace Scratch { } private void action_show_replace (SimpleAction action) { + if (terminal.terminal.has_focus) { + return; + } + find (); // May have to wait for the search bar to be revealed before we can grab focus