[gtk+] gtk: Fix parsing of accelerators with keycodes



commit c30d313afcc6941d8c64c83854fdd0fe33049917
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Nov 10 10:59:44 2011 +0000

    gtk: Fix parsing of accelerators with keycodes
    
    GDK_KEY_VoidSymbol is not the same as keycode 0. This fixes
    keycodes such as "0xb3" being parsed as "VoidSymbol" keysyms.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663761

 gtk/gtkaccelgroup.c |    4 +---
 gtk/tests/accel.c   |   10 +++++++---
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c
index cb31d02..6d30880 100644
--- a/gtk/gtkaccelgroup.c
+++ b/gtk/gtkaccelgroup.c
@@ -1323,8 +1323,6 @@ gtk_accelerator_parse_with_keycode (const gchar     *accelerator,
                gchar *endptr;
                gint tmp_keycode;
 
-               keyval = GDK_KEY_VoidSymbol;
-
                memcpy (keystring, accelerator, 4);
                keystring [4] = '\000';
 
@@ -1367,7 +1365,7 @@ gtk_accelerator_parse_with_keycode (const gchar     *accelerator,
 		}
 	    }
 
-          if (keyval != GDK_KEY_VoidSymbol && accelerator_codes != NULL)
+          if (keyval && accelerator_codes != NULL)
             {
               GdkKeymapKey *keys;
               gint n_keys, i, j;
diff --git a/gtk/tests/accel.c b/gtk/tests/accel.c
index 43e1425..0726413 100644
--- a/gtk/tests/accel.c
+++ b/gtk/tests/accel.c
@@ -21,19 +21,22 @@
 
 static void
 test_one_accel (const char *accel,
-		const char *exp_label)
+		const char *exp_label,
+		gboolean has_keysym)
 {
   guint accel_key;
   GdkModifierType mods;
   guint *keycodes;
   char *label, *name;
 
+  accel_key = 0;
   gtk_accelerator_parse_with_keycode (accel,
 				      &accel_key,
 				      &keycodes,
 				      &mods);
 
-  g_assert (accel_key != 0);
+  if (has_keysym)
+    g_assert (accel_key != 0);
   g_assert (keycodes);
   g_assert (keycodes[0] != 0);
 
@@ -58,7 +61,8 @@ test_one_accel (const char *accel,
 static void
 accel (void)
 {
-  test_one_accel ("<Primary><Alt>z", "Ctrl+Alt+Z");
+  test_one_accel ("0xb3", "0xb3", FALSE);
+  test_one_accel ("<Primary><Alt>z", "Ctrl+Alt+Z", TRUE);
 }
 
 int



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]