From 7ec99e1f6bc1d0abda68ae4b1aae98d98884f8d6 Mon Sep 17 00:00:00 2001 From: Michael Gratton Date: Thu, 7 Jan 2021 11:54:12 +1100 Subject: [PATCH] client: Implement showing window menu when F10 pressed Fixes #1102 --- .../application/application-client.vala | 3 ++- .../application/application-main-window.vala | 19 ++++++++++++++++++- src/client/client-action.vala | 3 ++- src/client/components/main-toolbar.vala | 5 +++++ src/client/composer/composer-widget.vala | 13 ++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala index db8cdfdc..0bd704fc 100644 --- a/src/client/application/application-client.vala +++ b/src/client/application/application-client.vala @@ -1,6 +1,6 @@ /* * Copyright © 2016 Software Freedom Conservancy Inc. - * Copyright © 2019-2020 Michael Gratton + * Copyright © 2019-2021 Michael Gratton * * 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, { "F1", "question" } ); + add_window_accelerators(Action.Window.SHOW_MENU, { "F10" }); // Common edit accels add_edit_accelerators(Action.Edit.COPY, { "C" }); diff --git a/src/client/application/application-main-window.vala b/src/client/application/application-main-window.vala index 27526e0e..589dc6cf 100644 --- a/src/client/application/application-main-window.vala +++ b/src/client/application/application-main-window.vala @@ -1,6 +1,6 @@ /* * Copyright © 2016 Software Freedom Conservancy Inc. - * Copyright © 2016, 2019-2020 Michael Gratton + * Copyright © 2016, 2019-2021 Michael Gratton * * 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(); } diff --git a/src/client/client-action.vala b/src/client/client-action.vala index 70997d20..3204ae89 100644 --- a/src/client/client-action.vala +++ b/src/client/client-action.vala @@ -1,5 +1,5 @@ /* - * Copyright 2019 Michael Gratton + * Copyright 2019-2021 Michael Gratton * * 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. */ diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala index ab0e3ba1..252b106c 100644 --- a/src/client/components/main-toolbar.vala +++ b/src/client/components/main-toolbar.vala @@ -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(); + } + } diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala index 3d893d43..37172593 100644 --- a/src/client/composer/composer-widget.vala +++ b/src/client/composer/composer-widget.vala @@ -1,6 +1,6 @@ /* * Copyright © 2016 Software Freedom Conservancy Inc. - * Copyright © 2017-2020 Michael Gratton + * Copyright © 2017-2021 Michael Gratton * * 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);