[gnome-terminal/wip/rishi/keypad-accels] accels: Support using the '0', '+' and '-' keys from the numeric keypad
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/wip/rishi/keypad-accels] accels: Support using the '0', '+' and '-' keys from the numeric keypad
- Date: Thu, 19 Nov 2020 18:35:03 +0000 (UTC)
commit d97c86be44b935805763b0554c7b144140b1106e
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Nov 19 19:25:05 2020 +0100
accels: Support using the '0', '+' and '-' keys from the numeric keypad
Currently, the default accelerators for zooming (ie., Ctrl+0, Ctrl++
and Ctrl+-) only work with the alphanumeric keys, not the numeric
keypad, which can confuse users. From now on, any accelerator that has
the '0', '+' or '-' key will work with both sets of keys.
https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/313
src/terminal-accels.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/src/terminal-accels.c b/src/terminal-accels.c
index 333c6d17..00f52e8a 100644
--- a/src/terminal-accels.c
+++ b/src/terminal-accels.c
@@ -22,6 +22,7 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "terminal-accels.h"
@@ -264,7 +265,7 @@ key_changed_cb (GSettings *settings,
gpointer user_data)
{
GtkApplication *application = user_data;
- const gchar *accels[2] = { NULL, NULL };
+ const gchar *accels[3] = { NULL, NULL, NULL };
_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
"key %s changed\n",
@@ -280,6 +281,7 @@ key_changed_cb (GSettings *settings,
}
gs_free char *value = g_settings_get_string (settings, settings_key);
+ gs_free char *alternate_value = NULL;
gs_free char *detailed = g_action_print_detailed_name (key_entry->action_name,
key_entry->parameter);
@@ -300,6 +302,40 @@ key_changed_cb (GSettings *settings,
accels[0] = NULL;
} else {
accels[0] = value;
+
+ GdkModifierType mods;
+ guint key;
+ gtk_accelerator_parse (value, &key, &mods);
+
+ guint alternate_key = 0;
+
+ switch (key) {
+ case GDK_KEY_0:
+ alternate_key = GDK_KEY_KP_0;
+ break;
+ case GDK_KEY_minus:
+ alternate_key = GDK_KEY_KP_Subtract;
+ break;
+ case GDK_KEY_plus:
+ alternate_key = GDK_KEY_KP_Add;
+ break;
+ case GDK_KEY_KP_0:
+ alternate_key = GDK_KEY_0;
+ break;
+ case GDK_KEY_KP_Add:
+ alternate_key = GDK_KEY_plus;
+ break;
+ case GDK_KEY_KP_Subtract:
+ alternate_key = GDK_KEY_minus;
+ break;
+ default:
+ break;
+ }
+
+ if (alternate_key != 0) {
+ alternate_value = gtk_accelerator_name (alternate_key, mods);
+ accels[1] = alternate_value;
+ }
}
gtk_application_set_accels_for_action (application,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]