client: Implement showing window menu when F10 pressed

Fixes #1102
This commit is contained in:
Michael Gratton 2021-01-07 11:54:12 +11:00 committed by Michael James Gratton
parent 600be0d5f4
commit 7ec99e1f6b
5 changed files with 39 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/*
* Copyright © 2016 Software Freedom Conservancy Inc.
* Copyright © 2019-2020 Michael Gratton <mike@vee.net>
* Copyright © 2019-2021 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@ -400,6 +400,7 @@ public class Application.Client : Gtk.Application {
add_window_accelerators(
Action.Window.SHORTCUT_HELP, { "<Ctrl>F1", "<Ctrl>question" }
);
add_window_accelerators(Action.Window.SHOW_MENU, { "F10" });
// Common edit accels
add_edit_accelerators(Action.Edit.COPY, { "<Ctrl>C" });

View file

@ -1,6 +1,6 @@
/*
* Copyright © 2016 Software Freedom Conservancy Inc.
* Copyright © 2016, 2019-2020 Michael Gratton <mike@vee.net>
* Copyright © 2016, 2019-2021 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@ -40,10 +40,12 @@ public class Application.MainWindow :
private const ActionEntry[] WINDOW_ACTIONS = {
{ Action.Window.CLOSE, on_close },
{ Action.Window.SHOW_MENU, on_show_window_menu },
{ ACTION_FIND_IN_CONVERSATION, on_find_in_conversation_action },
{ ACTION_SEARCH, on_search_activated },
{ ACTION_NAVIGATION_BACK, focus_previous_pane},
// Message actions
{ ACTION_REPLY_CONVERSATION, on_reply_conversation },
{ ACTION_REPLY_ALL_CONVERSATION, on_reply_all_conversation },
@ -880,6 +882,17 @@ public class Application.MainWindow :
}
}
/** Shows the appopriate window menu, if any. */
public void show_window_menu() {
if (this.main_leaflet.folded) {
this.main_leaflet.navigate(Hdy.NavigationDirection.BACK);
}
if (this.conversations_leaflet.folded) {
this.conversations_leaflet.navigate(Hdy.NavigationDirection.BACK);
}
this.main_toolbar.show_main_menu();
}
/** Displays and focuses the search bar for the window. */
public void show_search_bar(string? text = null) {
this.search_bar.grab_focus();
@ -2250,6 +2263,10 @@ public class Application.MainWindow :
this.create_composer_from_viewer.begin(FORWARD);
}
private void on_show_window_menu() {
show_window_menu();
}
private void on_show_copy_menu() {
this.conversation_actions.copy_message_button.clicked();
}

View file

@ -1,5 +1,5 @@
/*
* Copyright 2019 Michael Gratton <mike@vee.net>
* Copyright 2019-2021 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@ -44,6 +44,7 @@ namespace Action {
public const string CLOSE = "close";
public const string SHORTCUT_HELP = "show-help-overlay";
public const string SHOW_MENU = "show-menu";
/** Returns the given action name prefixed with the group name. */

View file

@ -109,4 +109,9 @@ public class MainToolbar : Hdy.Leaflet {
public void add_conversation_actions(Components.ConversationActions actions) {
conversation_header.add_conversation_actions(actions);
}
public void show_main_menu() {
this.main_menu_button.clicked();
}
}

View file

@ -1,6 +1,6 @@
/*
* Copyright © 2016 Software Freedom Conservancy Inc.
* Copyright © 2017-2020 Michael Gratton <mike@vee.net>
* Copyright © 2017-2021 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
@ -144,6 +144,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
private const ActionEntry[] ACTIONS = {
{ Action.Edit.COPY, on_copy },
{ Action.Window.CLOSE, on_close },
{ Action.Window.SHOW_MENU, on_show_window_menu },
{ ACTION_ADD_ATTACHMENT, on_add_attachment },
{ ACTION_ADD_ORIGINAL_ATTACHMENTS, on_pending_attachments },
{ ACTION_CLOSE, on_close },
@ -2440,6 +2441,16 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
conditional_close(this.container is Window);
}
private void on_show_window_menu() {
Application.MainWindow main = null;
if (this.container != null) {
main = this.container.top_window as Application.MainWindow;
}
if (main != null) {
main.show_window_menu();
}
}
private void on_discard() {
if (this.container is Window) {
conditional_close(true);