From 69f5da327dc2421421c8094fa00ec71e4d9ab271 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 30 Sep 2016 17:32:41 -0700 Subject: [PATCH] app: add more complete keybindings This matches more closely to Epiphany, which for better or worse is the closest use-case we have currently for our zoom design. --- src/sp-application.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/sp-application.c b/src/sp-application.c index 05303522..4efe88ee 100644 --- a/src/sp-application.c +++ b/src/sp-application.c @@ -33,6 +33,16 @@ struct _SpApplication G_DEFINE_TYPE (SpApplication, sp_application, GTK_TYPE_APPLICATION) +struct { + const gchar *action_name; + const gchar *accels[12]; +} default_accels[] = { + { "zoom.zoom-in", { "plus", "KP_Add", "equal", "ZoomIn", NULL } }, + { "zoom.zoom-out", { "minus", "KP_Subtract", "ZoomOut", NULL } }, + { "zoom.zoom-one", { "0", "KP_0", NULL } }, + { NULL } +}; + static void sp_application_activate (GApplication *app) { @@ -90,7 +100,7 @@ sp_application_open (GApplication *app, static void sp_application_startup (GApplication *application) { - GtkCssProvider *provider; + g_autoptr(GtkCssProvider) provider = NULL; g_assert (SP_IS_APPLICATION (application)); @@ -101,7 +111,11 @@ sp_application_startup (GApplication *application) gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - g_clear_object (&provider); + + for (guint i = 0; default_accels[i].action_name; i++) + gtk_application_set_accels_for_action (GTK_APPLICATION (application), + default_accels[i].action_name, + default_accels[i].accels); } static void @@ -259,16 +273,9 @@ sp_application_init (SpApplication *self) { "help", sysprof_help }, { "quit", sysprof_quit }, }; - static const gchar *zoom_in_accels[] = { "plus", NULL }; - static const gchar *zoom_out_accels[] = { "minus", NULL }; - static const gchar *zoom_one_accels[] = { "0", NULL }; g_action_map_add_action_entries (G_ACTION_MAP (self), actions, G_N_ELEMENTS (actions), self); - gtk_application_set_accels_for_action (GTK_APPLICATION (self), "zoom.zoom-in", zoom_in_accels); - gtk_application_set_accels_for_action (GTK_APPLICATION (self), "zoom.zoom-out", zoom_out_accels); - gtk_application_set_accels_for_action (GTK_APPLICATION (self), "zoom.zoom-one", zoom_one_accels); - g_application_set_default (G_APPLICATION (self)); }