diff options
author | António Fernandes <antoniof@gnome.org> | 2021-08-08 10:42:19 +0100 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2021-08-16 10:36:46 +0100 |
commit | 597256721ee12151d1c106c1ee73dd9edd0cb3e3 (patch) | |
tree | 0319ace71b27809af7cb1c79746729bc216b9782 | |
parent | 57544f2e35a41cfc9af1004eef6f014956f439b5 (diff) | |
download | nautilus-597256721ee12151d1c106c1ee73dd9edd0cb3e3.tar.gz |
window: Set media keys as regular accels
Media keys are handled in the ::key-press-event signal.
This signal is going away in GTK4 and there is no reason not to set
these keyboard shortcuts the same way as all other accels.
-rw-r--r-- | src/nautilus-window.c | 56 |
1 files changed, 7 insertions, 49 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 29f44655a..9d011a7f3 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -164,25 +164,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (NautilusWindow, nautilus_window, HDY_TYPE_APPLICATION_WINDOW); -static const struct -{ - unsigned int keyval; - const char *action; -} extra_window_keybindings [] = -{ - /* Window actions */ - { GDK_KEY_AddFavorite, "bookmark-current-location" }, - { GDK_KEY_Go, "enter-location" }, - { GDK_KEY_HomePage, "go-home" }, - { GDK_KEY_OpenURL, "enter-location" }, - { GDK_KEY_Refresh, "reload" }, - { GDK_KEY_Reload, "reload" }, - { GDK_KEY_Start, "go-home" }, - { GDK_KEY_Stop, "stop" }, - { GDK_KEY_Back, "back" }, - { GDK_KEY_Forward, "forward" }, -}; - static const GtkPadActionEntry pad_actions[] = { { GTK_PAD_ACTION_BUTTON, 0, -1, N_("Parent folder"), "up" }, @@ -2062,21 +2043,22 @@ nautilus_window_initialize_actions (NautilusWindow *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"); - nautilus_application_set_accelerator (app, "win.enter-location", "<control>l"); + nautilus_application_set_accelerators (app, "win.back", ACCELS ("<alt>Left", "Back")); + nautilus_application_set_accelerators (app, "win.forward", ACCELS ("<alt>Right", "Forward")); + nautilus_application_set_accelerators (app, "win.enter-location", ACCELS ("<control>l", "Go", "OpenURL")); nautilus_application_set_accelerator (app, "win.new-tab", "<control>t"); 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", ACCELS ("F5", "<ctrl>r")); + nautilus_application_set_accelerators (app, "win.reload", ACCELS ("F5", "<ctrl>r", "Refresh", "Reload")); + nautilus_application_set_accelerator (app, "win.stop", "Stop"); nautilus_application_set_accelerator (app, "win.undo", "<control>z"); nautilus_application_set_accelerator (app, "win.redo", "<shift><control>z"); /* Only accesible by shorcuts */ - nautilus_application_set_accelerator (app, "win.bookmark-current-location", "<control>d"); + nautilus_application_set_accelerators (app, "win.bookmark-current-location", ACCELS ("<control>d", "AddFavorite")); nautilus_application_set_accelerator (app, "win.up", "<alt>Up"); - nautilus_application_set_accelerator (app, "win.go-home", "<alt>Home"); + nautilus_application_set_accelerators (app, "win.go-home", ACCELS ("<alt>Home", "HomePage", "Start")); nautilus_application_set_accelerator (app, "win.go-starred", "Favorites"); nautilus_application_set_accelerator (app, "win.tab-previous", "<control>Page_Up"); nautilus_application_set_accelerator (app, "win.tab-next", "<control>Page_Down"); @@ -2411,30 +2393,6 @@ nautilus_window_key_press_event (GtkWidget *widget, } } - for (int i = 0; i < G_N_ELEMENTS (extra_window_keybindings); i++) - { - if (extra_window_keybindings[i].keyval == keyval) - { - GAction *action; - - action = g_action_map_lookup_action (G_ACTION_MAP (window), extra_window_keybindings[i].action); - - g_assert (action != NULL); - if (g_action_get_enabled (action)) - { - g_action_activate (action, NULL); - return GDK_EVENT_STOP; - } - - break; - } - } - - if (GTK_WIDGET_CLASS (nautilus_window_parent_class)->key_press_event (widget, event)) - { - return GDK_EVENT_STOP; - } - if (window->active_slot != NULL && nautilus_window_slot_handle_event (window->active_slot, (GdkEvent *) event)) { |