]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkaccelgroup.c
fix typo.
[~andy/gtk] / gtk / gtkaccelgroup.c
index 0e9b4866a615598209fab061b6b5df5eb57ffa40..e244fdb9c7038d010168b7ff8c8c2e4bab99bf5e 100644 (file)
@@ -29,7 +29,6 @@
 #include "gtkmarshalers.h"
 #include "gtksignal.h"
 
-#include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -241,6 +240,13 @@ _gtk_accel_group_detach (GtkAccelGroup *accel_group,
   g_object_unref (accel_group);
 }
 
+/**
+ * gtk_accel_groups_from_object:
+ * @object:        a #GObject, usually a #GtkWindow 
+ * @returns: a list of all accel groups which are attached to @object
+ *
+ * Gets a list of all accel groups which are attached to @object.
+ */
 GSList*
 gtk_accel_groups_from_object (GObject *object)
 {
@@ -249,6 +255,18 @@ gtk_accel_groups_from_object (GObject *object)
   return g_object_get_qdata (object, quark_acceleratable_groups);
 }
 
+/**
+ * gtk_accel_group_find:
+ * @accel_group: a #GtkAccelGroup
+ * @find_func: a function to filter the entries of @accel_group with
+ * @data: data to pass to @find_func
+ * @returns: the key of the first entry passing @find_func. The key is 
+ * owned by GTK+ and must not be freed.
+ *
+ * Finds the first entry in an accelerator group for which 
+ * @find_func returns %TRUE and returns its #GtkAccelKey.
+ *
+ */
 GtkAccelKey*
 gtk_accel_group_find (GtkAccelGroup  *accel_group,
                      gboolean (*find_func) (GtkAccelKey *key,
@@ -495,7 +513,9 @@ gtk_accel_group_connect (GtkAccelGroup      *accel_group,
 
   g_object_ref (accel_group);
   if (!closure->is_invalid)
-    quick_accel_add (accel_group, accel_key, accel_mods, accel_flags, closure, 0);
+    quick_accel_add (accel_group,
+                    gdk_keyval_to_lower (accel_key),
+                    accel_mods, accel_flags, closure, 0);
   g_object_unref (accel_group);
 }
 
@@ -534,7 +554,7 @@ gtk_accel_group_connect_by_path (GtkAccelGroup      *accel_group,
 
   if (gtk_accel_map_lookup_entry (accel_path, &key))
     {
-      accel_key = key.accel_key;
+      accel_key = gdk_keyval_to_lower (key.accel_key);
       accel_mods = key.accel_mods;
     }
 
@@ -597,6 +617,7 @@ gtk_accel_group_disconnect_key (GtkAccelGroup  *accel_group,
 
   g_object_ref (accel_group);
   
+  accel_key = gdk_keyval_to_lower (accel_key);
   entries = quick_accel_find (accel_group, accel_key, accel_mods, &n);
   while (n--)
     {
@@ -651,6 +672,17 @@ _gtk_accel_group_reconnect (GtkAccelGroup *accel_group,
   g_object_unref (accel_group);
 }
 
+/**
+ * gtk_accel_group_query:
+ * @accel_group:      the accelerator group to query
+ * @accel_key:        key value of the accelerator
+ * @accel_mods:       modifier combination of the accelerator
+ * @n_entries:        location to return the number of entries found, or %NULL
+ * @returns:          an array of @n_entries #GtkAccelGroupEntry elements, or %NULL. The array is owned by GTK+ and must not be freed. 
+ *
+ * Queries an accelerator group for all entries matching @accel_key and 
+ * @accel_mods.
+ */
 GtkAccelGroupEntry*
 gtk_accel_group_query (GtkAccelGroup  *accel_group,
                       guint           accel_key,
@@ -670,6 +702,14 @@ gtk_accel_group_query (GtkAccelGroup  *accel_group,
   return entries;
 }
 
+/**
+ * gtk_accel_group_from_accel_closure:
+ * @closure: a #GClosure
+ * @returns: the #GtkAccelGroup to which @closure is connected, or %NULL.
+ *
+ * Finds the #GtkAccelGroup to which @closure is connected; 
+ * see gtk_accel_group_connect().
+ */
 GtkAccelGroup*
 gtk_accel_group_from_accel_closure (GClosure *closure)
 {
@@ -677,7 +717,7 @@ gtk_accel_group_from_accel_closure (GClosure *closure)
 
   g_return_val_if_fail (closure != NULL, NULL);
 
-  /* a few remarks on wat we do here. in general, we need a way to reverse lookup
+  /* a few remarks on what we do here. in general, we need a way to reverse lookup
    * accel_groups from closures that are being used in accel groups. this could
    * be done e.g via a hashtable. it is however cheaper (memory wise) to just
    * use the invalidation notifier on the closure itself (which we need to install
@@ -711,7 +751,7 @@ _gtk_accel_group_activate (GtkAccelGroup  *accel_group,
 
 /**
  * gtk_accel_groups_activate:
- * @object:        the #Gobject, usually a #GtkWindow, on which
+ * @object:        the #GObject, usually a #GtkWindow, on which
  *                 to activate the accelerator.
  * @accel_key:     accelerator keyval from a key event
  * @accel_mods:    keyboard state mask from a key event
@@ -736,7 +776,7 @@ gtk_accel_groups_activate (GObject    *object,
       GQuark accel_quark;
       GSList *slist;
 
-      accel_name = gtk_accelerator_name (accel_key, accel_mods);
+      accel_name = gtk_accelerator_name (accel_key, (accel_mods & gtk_accelerator_get_default_mod_mask ()));
       accel_quark = g_quark_from_string (accel_name);
       g_free (accel_name);
       
@@ -765,10 +805,11 @@ gtk_accelerator_valid (guint                keyval,
                       GdkModifierType    modifiers)
 {
   static const guint invalid_accelerator_vals[] = {
-    GDK_BackSpace, GDK_Delete, GDK_KP_Delete,
     GDK_Shift_L, GDK_Shift_R, GDK_Shift_Lock, GDK_Caps_Lock, GDK_ISO_Lock,
     GDK_Control_L, GDK_Control_R, GDK_Meta_L, GDK_Meta_R,
     GDK_Alt_L, GDK_Alt_R, GDK_Super_L, GDK_Super_R, GDK_Hyper_L, GDK_Hyper_R,
+    GDK_ISO_Level3_Shift, GDK_ISO_Next_Group, GDK_ISO_Prev_Group,
+    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,
@@ -1117,6 +1158,8 @@ gtk_accelerator_name (guint           accelerator_key,
  * accelerators. The default mod mask is #GDK_CONTROL_MASK |
  * #GDK_SHIFT_MASK | #GDK_MOD1_MASK, that is, Control, Shift, and Alt.
  * Other modifiers will by default be ignored by #GtkAccelGroup.
+ * You must include at least the three default modifiers in any
+ * value you pass to this function.
  *
  * The default mod mask should be changed on application startup,
  * before using any accelerator groups.
@@ -1124,7 +1167,8 @@ gtk_accelerator_name (guint           accelerator_key,
 void
 gtk_accelerator_set_default_mod_mask (GdkModifierType default_mod_mask)
 {
-  default_accel_mod_mask = default_mod_mask & GDK_MODIFIER_MASK;
+  default_accel_mod_mask = (default_mod_mask & GDK_MODIFIER_MASK) |
+    (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK);
 }
 
 /**