From ae735e1b2bb7b076b016fb03889c2736cbe3d564 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Wed, 20 Mar 2002 17:32:37 +0000 Subject: [PATCH] Allow arrow keys as accelerators, as long as some modifier is pressed. Wed Mar 20 12:27:07 2002 Owen Taylor * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow arrow keys as accelerators, as long as some modifier is pressed. (#75495) * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix incorrect example in the docs. --- ChangeLog | 9 +++++++++ ChangeLog.pre-2-10 | 9 +++++++++ ChangeLog.pre-2-2 | 9 +++++++++ ChangeLog.pre-2-4 | 9 +++++++++ ChangeLog.pre-2-6 | 9 +++++++++ ChangeLog.pre-2-8 | 9 +++++++++ gtk/gtkaccelgroup.c | 22 ++++++++++++++++++---- 7 files changed, 72 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3dbb38803..782376abf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Mar 20 12:27:07 2002 Owen Taylor + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow + arrow keys as accelerators, as long as some modifier + is pressed. (#75495) + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix + incorrect example in the docs. + Wed Mar 20 12:06:30 2002 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_child_visible): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d3dbb38803..782376abf1 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +Wed Mar 20 12:27:07 2002 Owen Taylor + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow + arrow keys as accelerators, as long as some modifier + is pressed. (#75495) + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix + incorrect example in the docs. + Wed Mar 20 12:06:30 2002 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_child_visible): diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d3dbb38803..782376abf1 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +Wed Mar 20 12:27:07 2002 Owen Taylor + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow + arrow keys as accelerators, as long as some modifier + is pressed. (#75495) + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix + incorrect example in the docs. + Wed Mar 20 12:06:30 2002 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_child_visible): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d3dbb38803..782376abf1 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +Wed Mar 20 12:27:07 2002 Owen Taylor + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow + arrow keys as accelerators, as long as some modifier + is pressed. (#75495) + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix + incorrect example in the docs. + Wed Mar 20 12:06:30 2002 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_child_visible): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d3dbb38803..782376abf1 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +Wed Mar 20 12:27:07 2002 Owen Taylor + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow + arrow keys as accelerators, as long as some modifier + is pressed. (#75495) + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix + incorrect example in the docs. + Wed Mar 20 12:06:30 2002 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_child_visible): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d3dbb38803..782376abf1 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +Wed Mar 20 12:27:07 2002 Owen Taylor + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow + arrow keys as accelerators, as long as some modifier + is pressed. (#75495) + + * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Fix + incorrect example in the docs. + Wed Mar 20 12:06:30 2002 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_child_visible): diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c index 0cfa9e685c..a3cf12d55a 100644 --- a/gtk/gtkaccelgroup.c +++ b/gtk/gtkaccelgroup.c @@ -798,8 +798,8 @@ gtk_accel_groups_activate (GObject *object, * Determines whether a given keyval and modifier mask constitute * a valid keyboard accelerator. For example, the #GDK_a keyval * plus #GDK_CONTROL_MASK is valid - this is a "Ctrl+a" accelerator. - * But by default (see gtk_accelerator_set_default_mod_mask()) you - * cannot use the NumLock key as an accelerator modifier. + * But, you can't, for instance, use the #GDL_Control_L keyval + * as an accelerator. */ gboolean gtk_accelerator_valid (guint keyval, @@ -813,13 +813,17 @@ gtk_accelerator_valid (guint keyval, GDK_ISO_First_Group, GDK_ISO_Last_Group, GDK_Mode_switch, GDK_Num_Lock, GDK_Multi_key, GDK_Scroll_Lock, GDK_Sys_Req, - GDK_Up, GDK_Down, GDK_Left, GDK_Right, GDK_Tab, GDK_ISO_Left_Tab, - GDK_KP_Up, GDK_KP_Down, GDK_KP_Left, GDK_KP_Right, GDK_KP_Tab, + GDK_Tab, GDK_ISO_Left_Tab, GDK_KP_Tab, GDK_First_Virtual_Screen, GDK_Prev_Virtual_Screen, GDK_Next_Virtual_Screen, GDK_Last_Virtual_Screen, GDK_Terminate_Server, GDK_AudibleBell_Enable, 0 }; + static const guint invalid_unmodified_vals[] = { + GDK_Up, GDK_Down, GDK_Left, GDK_Right, + GDK_KP_Up, GDK_KP_Down, GDK_KP_Left, GDK_KP_Right, + 0 + }; const guint *ac_val; modifiers &= GDK_MODIFIER_MASK; @@ -834,6 +838,16 @@ gtk_accelerator_valid (guint keyval, return FALSE; } + if (!modifiers) + { + ac_val = invalid_unmodified_vals; + while (*ac_val) + { + if (keyval == *ac_val++) + return FALSE; + } + } + return TRUE; }