diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-10-27 11:49:03 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-10-27 14:57:01 -0400 |
commit | 6cc0552ab8efe0b11f3db21224520dc97db17d9f (patch) | |
tree | 55d720e534abd597ae505aa85cf7005fcc892045 | |
parent | 4c77925af6151287d2b123b1e9ffe0d5e56ba234 (diff) | |
download | gtk+-6cc0552ab8efe0b11f3db21224520dc97db17d9f.tar.gz |
Differentiate keypad keysyms in accelerators
When displaying accelerators, differentiate keypad
symbols with a 'KP' prefix. Fixing a 17 year old bug.
Backport of c58d9446f40b36136f25baf.
-rw-r--r-- | gtk/gtkaccellabel.c | 11 | ||||
-rw-r--r-- | testsuite/gtk/accel.c | 6 |
2 files changed, 15 insertions, 2 deletions
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index 0e2c50bb67..75b27a8726 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -883,6 +883,17 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass, if (seen_mod) g_string_append (gstring, klass->mod_separator); + if (accelerator_key >= GDK_KEY_KP_Space && + accelerator_key <= GDK_KEY_KP_Equal) + { + /* Translators: "KP" means "numeric key pad". This string will + * be used in accelerators such as "Ctrl+Shift+KP 1" in menus, + * and therefore the translation needs to be very short. + */ + g_string_append (gstring, C_("keyboard label", "KP")); + g_string_append (gstring, " "); + } + switch (ch) { case ' ': diff --git a/testsuite/gtk/accel.c b/testsuite/gtk/accel.c index da031da7be..d6ea0bc252 100644 --- a/testsuite/gtk/accel.c +++ b/testsuite/gtk/accel.c @@ -55,6 +55,8 @@ test_one_accel (const char *accel, *keycodes, mods); + g_print ("accel %s, label %s\n", accel, label); + g_assert_cmpstr (label, ==, exp_label); name = gtk_accelerator_name_with_keycode (NULL, @@ -83,13 +85,13 @@ accel2 (void) static void accel3 (void) { - test_one_accel ("KP_7", "7", TRUE); + test_one_accel ("KP_7", "KP 7", TRUE); } static void accel4 (void) { - test_one_accel ("<Primary>KP_7", "Ctrl+7", TRUE); + test_one_accel ("<Primary>KP_7", "Ctrl+KP 7", TRUE); } static void |