[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 14/21] window: Inline accels array




commit 5a734f25ae6f708ae2018f6edb06a76fe5e2eaea
Author: António Fernandes <antoniof gnome org>
Date:   Mon Aug 16 10:23:49 2021 +0100

    window: Inline accels array
    
    This is more readable and prepares for next commit where even more
    arrays are to be introduced.

 src/nautilus-window.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)
---
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 238271ae8..e64be679f 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2055,29 +2055,13 @@ nautilus_window_initialize_actions (NautilusWindow *window)
     gchar detailed_action[80];
     gchar accel[80];
     gint i;
-    const gchar *reload_accels[] =
-    {
-        "F5",
-        "<ctrl>r",
-        NULL
-    };
-    const gchar *prompt_root_location_accels[] =
-    {
-        "slash",
-        "KP_Divide",
-        NULL
-    };
-    const gchar *prompt_home_location_accels[] =
-    {
-        "asciitilde",
-        "dead_tilde",
-        NULL
-    };
 
     g_action_map_add_action_entries (G_ACTION_MAP (window),
                                      win_entries, G_N_ELEMENTS (win_entries),
                                      window);
 
+#define ACCELS(...) ((const char *[]) { __VA_ARGS__, NULL })
+
     app = g_application_get_default ();
     nautilus_application_set_accelerator (app, "win.back", "<alt>Left");
     nautilus_application_set_accelerator (app, "win.forward", "<alt>Right");
@@ -2086,7 +2070,7 @@ nautilus_window_initialize_actions (NautilusWindow *window)
     nautilus_application_set_accelerator (app, "win.close-current-view", "<control>w");
 
     /* Special case reload, since users are used to use two shortcuts instead of one */
-    nautilus_application_set_accelerators (app, "win.reload", reload_accels);
+    nautilus_application_set_accelerators (app, "win.reload", ACCELS ("F5", "<ctrl>r"));
 
     nautilus_application_set_accelerator (app, "win.undo", "<control>z");
     nautilus_application_set_accelerator (app, "win.redo", "<shift><control>z");
@@ -2099,9 +2083,9 @@ nautilus_window_initialize_actions (NautilusWindow *window)
     nautilus_application_set_accelerator (app, "win.tab-next", "<control>Page_Down");
     nautilus_application_set_accelerator (app, "win.tab-move-left", "<shift><control>Page_Up");
     nautilus_application_set_accelerator (app, "win.tab-move-right", "<shift><control>Page_Down");
-    nautilus_application_set_accelerators (app, "win.prompt-root-location", prompt_root_location_accels);
+    nautilus_application_set_accelerators (app, "win.prompt-root-location", ACCELS ("slash", "KP_Divide"));
     /* Support keyboard layouts which have a dead tilde key but not a tilde key. */
-    nautilus_application_set_accelerators (app, "win.prompt-home-location", prompt_home_location_accels);
+    nautilus_application_set_accelerators (app, "win.prompt-home-location", ACCELS ("asciitilde", 
"dead_tilde"));
     nautilus_application_set_accelerator (app, "win.view-menu", "F10");
     nautilus_application_set_accelerator (app, "win.restore-tab", "<shift><control>t");
 
@@ -2113,6 +2097,8 @@ nautilus_window_initialize_actions (NautilusWindow *window)
         nautilus_application_set_accelerator (app, detailed_action, accel);
     }
 
+#undef ACCELS
+
     action = g_action_map_lookup_action (G_ACTION_MAP (app), "show-hide-sidebar");
     state = g_action_get_state (action);
     if (g_variant_get_boolean (state))


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