From e0fab92d3c7e981d217ea1f134f4a27cc4723f88 Mon Sep 17 00:00:00 2001 From: Jeremias Ortega Date: Sun, 17 Jan 2021 16:55:49 -0600 Subject: [PATCH] application-main-window: Add shortcut to select inbox Closes: https://gitlab.gnome.org/GNOME/geary/-/issues/1108 --- .../application/application-main-window.vala | 25 +++++++++++++++++++ ui/gtk/help-overlay.ui | 7 ++++++ 2 files changed, 32 insertions(+) diff --git a/src/client/application/application-main-window.vala b/src/client/application/application-main-window.vala index 589dc6cf..d5255a41 100644 --- a/src/client/application/application-main-window.vala +++ b/src/client/application/application-main-window.vala @@ -25,6 +25,7 @@ public class Application.MainWindow : public const string ACTION_REPLY_ALL_CONVERSATION = "reply-all-conversation"; public const string ACTION_REPLY_CONVERSATION = "reply-conversation"; public const string ACTION_SEARCH = "search"; + public const string ACTION_SELECT_INBOX = "select-inbox"; public const string ACTION_SHOW_COPY_MENU = "show-copy-menu"; public const string ACTION_SHOW_MARK_MENU = "show-mark-menu"; public const string ACTION_SHOW_MOVE_MENU = "show-move-menu"; @@ -44,6 +45,7 @@ public class Application.MainWindow : { ACTION_FIND_IN_CONVERSATION, on_find_in_conversation_action }, { ACTION_SEARCH, on_search_activated }, + { ACTION_SELECT_INBOX, on_select_inbox, "i" }, { ACTION_NAVIGATION_BACK, focus_previous_pane}, // Message actions @@ -221,6 +223,12 @@ public class Application.MainWindow : public static void add_accelerators(Client owner) { + for (int i = 1; i <= 9; i++) { + owner.add_window_accelerators( + ACTION_SELECT_INBOX+("(%d)".printf(i - 1)), { "%d".printf(i) } + ); + } + // Zoom owner.add_window_accelerators( ACTION_ZOOM+("('in')"), { "equal", "plus" } @@ -2187,6 +2195,23 @@ public class Application.MainWindow : this.select_folder.begin(folder, true); } + private void on_select_inbox(SimpleAction action, Variant? parameter) { + if (parameter != null) { + int account_number = parameter.get_int32(); + try { + Gee.Collection accounts = + this.application.engine.get_accounts(); + if (account_number < accounts.size) { + Geary.Account account = accounts.to_array()[account_number]; + Geary.Folder inbox = account.get_special_folder(INBOX); + this.select_folder.begin(inbox, true); + } + } catch (GLib.Error error) { + debug("Error getting accounts"); + } + } + } + private void on_search(string text) { if (Geary.String.is_empty_or_whitespace(text)) { stop_search(true); diff --git a/ui/gtk/help-overlay.ui b/ui/gtk/help-overlay.ui index af657451..7e8336fd 100644 --- a/ui/gtk/help-overlay.ui +++ b/ui/gtk/help-overlay.ui @@ -389,6 +389,13 @@ True Keyboard navigation + + + True + Select inbox + <Alt>1...9 + + True