[geary/wip/3.32-ux: 314/314] Update keyboard accelerators



commit 937ed6b4049677fc11ae411eaa5ee231a3985559
Author: Michael Gratton <mike vee net>
Date:   Sun Feb 24 21:44:03 2019 +1100

    Update keyboard accelerators
    
    Make accelerators for app actions work again (Quit, etc), add accel
    for closing the window.

 src/client/application/geary-application.vala | 26 +++++++++++++++++++++++---
 src/client/application/geary-controller.vala  | 17 ++++++++---------
 2 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index 69bd59f3..a7bf896d 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -47,6 +47,7 @@ public class GearyApplication : Gtk.Application {
     // Common window actions
     public const string ACTION_CLOSE = "close";
     public const string ACTION_COPY = "copy";
+    public const string ACTION_HELP_OVERLAY = "show-help-overlay";
     public const string ACTION_REDO = "redo";
     public const string ACTION_UNDO = "undo";
 
@@ -54,8 +55,8 @@ public class GearyApplication : Gtk.Application {
     private const string ACTION_ABOUT = "about";
     private const string ACTION_ACCOUNTS = "accounts";
     private const string ACTION_COMPOSE = "compose";
-    private const string ACTION_MAILTO = "mailto";
     private const string ACTION_HELP = "help";
+    private const string ACTION_MAILTO = "mailto";
     private const string ACTION_PREFERENCES = "preferences";
     private const string ACTION_QUIT = "quit";
 
@@ -63,8 +64,8 @@ public class GearyApplication : Gtk.Application {
         {ACTION_ABOUT, on_activate_about},
         {ACTION_ACCOUNTS, on_activate_accounts},
         {ACTION_COMPOSE, on_activate_compose},
-        {ACTION_MAILTO, on_activate_mailto, "s"},
         {ACTION_HELP, on_activate_help},
+        {ACTION_MAILTO, on_activate_mailto, "s"},
         {ACTION_PREFERENCES, on_activate_preferences},
         {ACTION_QUIT, on_activate_quit},
     };
@@ -246,10 +247,18 @@ public class GearyApplication : Gtk.Application {
 
         config = new Configuration(APP_ID);
 
+        // Application accels
+        add_app_accelerators(ACTION_COMPOSE, { "<Ctrl>N", "N" });
+        add_app_accelerators(ACTION_HELP, { "F1" });
+        add_app_accelerators(ACTION_QUIT, { "<Ctrl>Q" });
+
+        // Common window accels
         add_window_accelerators(ACTION_CLOSE, { "<Ctrl>W" });
         add_window_accelerators(ACTION_COPY, { "<Ctrl>C" });
+        add_window_accelerators(ACTION_HELP_OVERLAY, { "<Ctrl>F1", "<Ctrl>question" });
         add_window_accelerators(ACTION_REDO, { "<Ctrl><Shift>Z" });
         add_window_accelerators(ACTION_UNDO, { "<Ctrl>Z" });
+
         ComposerWidget.add_window_accelerators(this);
 
         yield controller.open_async(null);
@@ -271,7 +280,12 @@ public class GearyApplication : Gtk.Application {
     public void add_window_accelerators(string action,
                                         string[] accelerators,
                                         Variant? param = null) {
-        set_accels_for_action("win." + action, accelerators);
+        string name = "win." + action;
+        string[] all_accel = get_accels_for_action(name);
+        foreach (string accel in accelerators) {
+            all_accel += accel;
+        }
+        set_accels_for_action(name, all_accel);
     }
 
     public void show_accounts() {
@@ -420,6 +434,12 @@ public class GearyApplication : Gtk.Application {
         Posix.exit(1);
     }
 
+    public void add_app_accelerators(string action,
+                                     string[] accelerators,
+                                     Variant? param = null) {
+        set_accels_for_action("app." + action, accelerators);
+    }
+
     private void on_activate_about() {
         Gtk.show_about_dialog(get_active_window(),
             "program-name", NAME,
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 7f88e5a8..8125f14f 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -13,7 +13,6 @@
 public class GearyController : Geary.BaseObject {
 
     // Named actions.
-    public const string ACTION_NEW_MESSAGE = "new-message";
     public const string ACTION_REPLY_TO_MESSAGE = "reply-to-message";
     public const string ACTION_REPLY_ALL_MESSAGE = "reply-all-message";
     public const string ACTION_FORWARD_MESSAGE = "forward-message";
@@ -160,13 +159,14 @@ public class GearyController : Geary.BaseObject {
     private Gee.List<ComposerWidget> waiting_to_close = new Gee.ArrayList<ComposerWidget>();
 
     private const ActionEntry[] win_action_entries = {
-        {ACTION_NEW_MESSAGE,           on_new_message                  },
+        {GearyApplication.ACTION_CLOSE, on_close                       },
+        {GearyApplication.ACTION_UNDO,  on_revoke                      },
+
         {ACTION_CONVERSATION_LIST,     on_conversation_list            },
         {ACTION_FIND_IN_CONVERSATION,  on_find_in_conversation_action  },
         {ACTION_SEARCH,                on_search_activated             },
         {ACTION_EMPTY_SPAM,            on_empty_spam                   },
         {ACTION_EMPTY_TRASH,           on_empty_trash                  },
-        {GearyApplication.ACTION_UNDO, on_revoke                       },
         // Message actions
         {ACTION_REPLY_TO_MESSAGE,      on_reply_to_message_action   },
         {ACTION_REPLY_ALL_MESSAGE,     on_reply_all_message_action  },
@@ -603,7 +603,6 @@ public class GearyController : Geary.BaseObject {
         add_window_accelerators(ACTION_MARK_AS_NOT_SPAM, { "<Ctrl>J", "exclam" });
         add_window_accelerators(ACTION_COPY_MENU, { "L" });
         add_window_accelerators(ACTION_MOVE_MENU, { "M" });
-        add_window_accelerators(ACTION_NEW_MESSAGE, { "<Ctrl>N", "N" });
         add_window_accelerators(ACTION_REPLY_TO_MESSAGE, { "<Ctrl>R", "R" });
         add_window_accelerators(ACTION_REPLY_ALL_MESSAGE, { "<Ctrl><Shift>R", "<Shift>R" });
         add_window_accelerators(ACTION_FORWARD_MESSAGE, { "<Ctrl>L", "F" });
@@ -1246,9 +1245,9 @@ public class GearyController : Geary.BaseObject {
 
     private void on_indicator_activated_composer(uint32 timestamp) {
         on_indicator_activated_application(timestamp);
-        on_new_message(null);
+        compose();
     }
-    
+
     private void on_indicator_activated_inbox(Geary.Folder folder, uint32 timestamp) {
         on_indicator_activated_application(timestamp);
         main_window.folder_list.select_folder(folder);
@@ -2264,9 +2263,9 @@ public class GearyController : Geary.BaseObject {
                 this.application.exit();
         }
     }
-    
-    private void on_new_message(SimpleAction? action) {
-        create_compose_widget(ComposerWidget.ComposeType.NEW_MESSAGE);
+
+    private void on_close() {
+        this.application.exit();
     }
 
     private void on_reply_to_message(ConversationEmail target_view) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]