From 31080bf8a7cc0fb7c9b73762fd38244110256ff9 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 18 Dec 2017 11:01:42 +0000 Subject: [PATCH] Add keyboard accelerators in the GtkApplication menu. Now that they actually _work_, it seems more useful to start putting them in on purpose. --- unix/gtkapp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/unix/gtkapp.c b/unix/gtkapp.c index 2a592eb3..4a4af5a0 100644 --- a/unix/gtkapp.c +++ b/unix/gtkapp.c @@ -118,6 +118,19 @@ static void startup(GApplication *app, gpointer user_data) g_menu_append(section, "Copy", "win.copy"); g_menu_append(section, "Paste", "win.paste"); +#define SET_ACCEL(app, command, accel) do \ + { \ + static const char *const accels[] = { accel, NULL }; \ + gtk_application_set_accels_for_action( \ + GTK_APPLICATION(app), command, accels); \ + } while (0) + + SET_ACCEL(app, "app.newwin", "n"); + SET_ACCEL(app, "win.copy", "c"); + SET_ACCEL(app, "win.paste", "v"); + +#undef SET_ACCEL + gtk_application_set_menubar(GTK_APPLICATION(app), G_MENU_MODEL(menubar)); }