#include "gtkmarshalers.h"
#include "gtksignal.h"
-#include <ctype.h>
#include <string.h>
#include <stdlib.h>
/* --- functions --- */
/**
- * gtk_accel_group_get_type
- * @returns: the type ID for accelerator groups
+ * gtk_accel_group_get_type:
+ * @returns: the type ID for accelerator groups.
*/
GType
gtk_accel_group_get_type (void)
}
/**
- * gtk_accel_group_new
+ * gtk_accel_group_new:
* @returns: a new #GtkAccelGroup object
*
* Creates a new #GtkAccelGroup.
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_acceleratable (GObject *object)
+gtk_accel_groups_from_object (GObject *object)
{
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
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,
}
/**
- * gtk_accel_group_lock
+ * gtk_accel_group_lock:
* @accel_group: a #GtkAccelGroup
*
+ * Locks the given accelerator group.
+ *
* Locking an acelerator group prevents the accelerators contained
* within it to be changed during runtime. Refer to
* gtk_accel_map_change_entry() about runtime accelerator changes.
}
/**
- * gtk_accel_group_unlock
+ * gtk_accel_group_unlock:
* @accel_group: a #GtkAccelGroup
*
- * This function undoes the last call to gtk_accel_group_lock()
- * on this @accel_group.
+ * Undoes the last call to gtk_accel_group_lock() on this @accel_group.
*/
void
gtk_accel_group_unlock (GtkAccelGroup *accel_group)
}
/**
- * gtk_accel_group_connect
- * @accel_group: the ccelerator group to install an accelerator in
+ * gtk_accel_group_connect:
+ * @accel_group: the accelerator group to install an accelerator in
* @accel_key: key value of the accelerator
* @accel_mods: modifier combination of the accelerator
* @accel_flags: a flag mask to configure this accelerator
* @closure: closure to be executed upon accelerator activation
*
- * Install an accelerator in this group. When @accel_group is being activated
+ * Installs an accelerator in this group. When @accel_group is being activated
* in response to a call to gtk_accel_groups_activate(), @closure will be
* invoked if the @accel_key and @accel_mods from gtk_accel_groups_activate()
* match those of this connection.
+ *
* The signature used for the @closure is that of #GtkAccelGroupActivate.
+ *
* Note that, due to implementation details, a single closure can only be
* connected to one accelerator 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);
}
/**
- * gtk_accel_group_connect_by_path
- * @accel_group: the ccelerator group to install an accelerator in
+ * gtk_accel_group_connect_by_path:
+ * @accel_group: the accelerator group to install an accelerator in
* @accel_path: path used for determining key and modifiers.
* @closure: closure to be executed upon accelerator activation
*
- * Install an accelerator in this group, using a accelerator path to look
- * up the appropriate key and modifiers. (See gtk_accel_map_add_entry())
+ * Installs an accelerator in this group, using an accelerator path to look
+ * up the appropriate key and modifiers (see gtk_accel_map_add_entry()).
* When @accel_group is being activated in response to a call to
* gtk_accel_groups_activate(), @closure will be invoked if the @accel_key and
* @accel_mods from gtk_accel_groups_activate() match the key and modifiers
* for the path.
+ *
* The signature used for the @closure is that of #GtkAccelGroupActivate.
*/
void
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;
}
}
/**
- * gtk_accel_group_disconnect
+ * gtk_accel_group_disconnect:
* @accel_group: the accelerator group to remove an accelerator from
* @closure: the closure to remove from this accelerator group
* @returns: %TRUE if the closure was found and got disconnected
*
- * Remove an accelerator previously installed through
+ * Removes an accelerator previously installed through
* gtk_accel_group_connect().
*/
gboolean
}
/**
- * gtk_accel_group_disconnect_key
- * @accel_group: the ccelerator group to install an accelerator in
+ * gtk_accel_group_disconnect_key:
+ * @accel_group: the accelerator group to install an accelerator in
* @accel_key: key value of the accelerator
* @accel_mods: modifier combination of the accelerator
- * @returns: %TRUE if there was an accelerator which could be removed, %FALSE otherwise
+ * @returns: %TRUE if there was an accelerator which could be
+ * removed, %FALSE otherwise
*
- * Remove an accelerator previously installed through
+ * Removes an accelerator previously installed through
* gtk_accel_group_connect().
*/
gboolean
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--)
{
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,
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)
{
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
/**
* gtk_accel_groups_activate:
- * @acceleratable: usually a #GtkWindow
+ * @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
* @returns: %TRUE if the accelerator was handled, %FALSE otherwise
*
* Finds the first accelerator in any #GtkAccelGroup attached
- * to @acceleratable that matches @accel_key and @accel_mods, and
+ * to @object that matches @accel_key and @accel_mods, and
* activates that accelerator.
* If an accelerator was activated and handled this keypress, %TRUE
* is returned.
*/
gboolean
-gtk_accel_groups_activate (GObject *acceleratable,
+gtk_accel_groups_activate (GObject *object,
guint accel_key,
GdkModifierType accel_mods)
{
- g_return_val_if_fail (G_IS_OBJECT (acceleratable), FALSE);
+ g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
if (gtk_accelerator_valid (accel_key, accel_mods))
{
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);
- for (slist = gtk_accel_groups_from_acceleratable (acceleratable); slist; slist = slist->next)
- if (_gtk_accel_group_activate (slist->data, accel_quark, acceleratable, accel_key, accel_mods))
+ for (slist = gtk_accel_groups_from_object (object); slist; slist = slist->next)
+ if (_gtk_accel_group_activate (slist->data, accel_quark, object, accel_key, accel_mods))
return TRUE;
}
}
/**
- * gtk_accelerator_valid
+ * gtk_accelerator_valid:
* @keyval: a GDK keyval
* @modifiers: modifier mask
* @returns: %TRUE if the accelerator is valid
*
* 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.
+ * 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.
*/
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,
}
/**
- * gtk_accelerator_parse
+ * gtk_accelerator_parse:
* @accelerator: string representing an accelerator
* @accelerator_key: return location for accelerator keyval
* @accelerator_mods: return location for accelerator modifier mask
}
/**
- * gtk_accelerator_name
+ * gtk_accelerator_name:
* @accelerator_key: accelerator keyval
* @accelerator_mods: accelerator modifier mask
- * @returns: a newly allocated accelerator name
+ * @returns: a newly-allocated accelerator name
*
* Converts an accelerator keyval and modifier mask
* into a string parseable by gtk_accelerator_parse().
- * For example, if you pass in GDK_q and GDK_CONTROL_MASK,
+ * For example, if you pass in #GDK_q and #GDK_CONTROL_MASK,
* this function returns "<Control>q".
*
* The caller of this function must free the returned string.
}
/**
- * gtk_accelerator_set_default_mod_mask
+ * gtk_accelerator_set_default_mod_mask:
* @default_mod_mask: accelerator modifier mask
*
* Sets the modifiers that will be considered significant for keyboard
* 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.
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);
}
/**
- * gtk_accelerator_get_default_mod_mask
+ * gtk_accelerator_get_default_mod_mask:
* @returns: the default accelerator modifier mask
*
* Gets the value set by gtk_accelerator_set_default_mod_mask().