| Top |
Accelerator GroupsAccelerator Groups — Groups of global keyboard accelerators for an entire CtkWindow |
| struct | CtkAccelGroup |
| struct | CtkAccelGroupClass |
| enum | CtkAccelFlags |
| struct | CtkAccelKey |
A CtkAccelGroup represents a group of keyboard accelerators,
typically attached to a toplevel CtkWindow (with
ctk_window_add_accel_group()). Usually you won’t need to create a
CtkAccelGroup directly; instead, when using CtkUIManager, CTK+
automatically sets up the accelerators for your menus in the ui
manager’s CtkAccelGroup.
Note that “accelerators” are different from
“mnemonics”. Accelerators are shortcuts for
activating a menu item; they appear alongside the menu item they’re a
shortcut for. For example “Ctrl+Q” might appear alongside the “Quit”
menu item. Mnemonics are shortcuts for GUI elements such as text
entries or buttons; they appear as underlined characters. See
ctk_label_new_with_mnemonic(). Menu items can have both accelerators
and mnemonics, of course.
void ctk_accel_group_connect (CtkAccelGroup *accel_group,guint accel_key,CdkModifierType accel_mods,CtkAccelFlags accel_flags,GClosure *closure);
Installs an accelerator in this group. When accel_group
is being
activated in response to a call to ctk_accel_groups_activate(),
closure
will be invoked if the accel_key
and accel_mods
from
ctk_accel_groups_activate() match those of this connection.
The signature used for the closure
is that of CtkAccelGroupActivate.
Note that, due to implementation details, a single closure can only be connected to one accelerator group.
void ctk_accel_group_connect_by_path (CtkAccelGroup *accel_group,const gchar *accel_path,GClosure *closure);
Installs an accelerator in this group, using an accelerator path
to look up the appropriate key and modifiers (see
ctk_accel_map_add_entry()). When accel_group
is being activated
in response to a call to ctk_accel_groups_activate(), closure
will
be invoked if the accel_key
and accel_mods
from
ctk_accel_groups_activate() match the key and modifiers for the path.
The signature used for the closure
is that of CtkAccelGroupActivate.
Note that accel_path
string will be stored in a GQuark. Therefore,
if you pass a static string, you can save some memory by interning it
first with g_intern_static_string().
gboolean (*CtkAccelGroupActivate) (CtkAccelGroup *accel_group,GObject *acceleratable,guint keyval,CdkModifierType modifier);
gboolean (*CtkAccelGroupFindFunc) (CtkAccelKey *key,GClosure *closure,gpointer data);
Since: 2.2
gboolean ctk_accel_group_disconnect (CtkAccelGroup *accel_group,GClosure *closure);
Removes an accelerator previously installed through
ctk_accel_group_connect().
Since 2.20 closure
can be NULL.
gboolean ctk_accel_group_disconnect_key (CtkAccelGroup *accel_group,guint accel_key,CdkModifierType accel_mods);
Removes an accelerator previously installed through
ctk_accel_group_connect().
gboolean ctk_accel_group_activate (CtkAccelGroup *accel_group,GQuark accel_quark,GObject *acceleratable,guint accel_key,CdkModifierType accel_mods);
Finds the first accelerator in accel_group
that matches
accel_key
and accel_mods
, and activates it.
accel_group |
||
accel_quark |
the quark for the accelerator name |
|
acceleratable |
the GObject, usually a CtkWindow, on which to activate the accelerator |
|
accel_key |
accelerator keyval from a key event |
|
accel_mods |
keyboard state mask from a key event |
void
ctk_accel_group_lock (CtkAccelGroup *accel_group);
Locks the given accelerator group.
Locking an acelerator group prevents the accelerators contained
within it to be changed during runtime. Refer to
ctk_accel_map_change_entry() about runtime accelerator changes.
If called more than once, accel_group
remains locked until
ctk_accel_group_unlock() has been called an equivalent number
of times.
void
ctk_accel_group_unlock (CtkAccelGroup *accel_group);
Undoes the last call to ctk_accel_group_lock() on this accel_group
.
gboolean
ctk_accel_group_get_is_locked (CtkAccelGroup *accel_group);
Locks are added and removed using ctk_accel_group_lock() and
ctk_accel_group_unlock().
Since: 2.14
CtkAccelGroup *
ctk_accel_group_from_accel_closure (GClosure *closure);
Finds the CtkAccelGroup to which closure
is connected;
see ctk_accel_group_connect().
CdkModifierType
ctk_accel_group_get_modifier_mask (CtkAccelGroup *accel_group);
Gets a CdkModifierType representing the mask for this
accel_group
. For example, CDK_CONTROL_MASK, CDK_SHIFT_MASK, etc.
Since: 2.14
gboolean ctk_accel_groups_activate (GObject *object,guint accel_key,CdkModifierType accel_mods);
Finds the first accelerator in any CtkAccelGroup attached
to object
that matches accel_key
and accel_mods
, and
activates that accelerator.
object |
the GObject, usually a CtkWindow, on which to activate the accelerator |
|
accel_key |
accelerator keyval from a key event |
|
accel_mods |
keyboard state mask from a key event |
GSList *
ctk_accel_groups_from_object (GObject *object);
Gets a list of all accel groups which are attached to object
.
CtkAccelKey * ctk_accel_group_find (CtkAccelGroup *accel_group,CtkAccelGroupFindFunc find_func,gpointer data);
Finds the first entry in an accelerator group for which
find_func
returns TRUE and returns its CtkAccelKey.
gboolean ctk_accelerator_valid (guint keyval,CdkModifierType modifiers);
Determines whether a given keyval and modifier mask constitute a valid keyboard accelerator. For example, the CDK_KEY_a keyval plus CDK_CONTROL_MASK is valid - this is a “Ctrl+a” accelerator. But, you can't, for instance, use the CDK_KEY_Control_L keyval as an accelerator.
void ctk_accelerator_parse (const gchar *accelerator,guint *accelerator_key,CdkModifierType *accelerator_mods);
Parses a string representing an accelerator. The format looks like “<Control>a” or “<Shift><Alt>F1” or “<Release>z” (the last one is for key release).
The parser is fairly liberal and allows lower or upper case, and also
abbreviations such as “<Ctl>” and “<Ctrl>”. Key names are parsed using
cdk_keyval_from_name(). For character keys the name is not the symbol,
but the lowercase name, e.g. one would use “<Ctrl>minus” instead of
“<Ctrl>-”.
If the parse fails, accelerator_key
and accelerator_mods
will
be set to 0 (zero).
gchar * ctk_accelerator_name (guint accelerator_key,CdkModifierType accelerator_mods);
Converts an accelerator keyval and modifier mask into a string
parseable by ctk_accelerator_parse(). For example, if you pass in
CDK_KEY_q and CDK_CONTROL_MASK, this function returns “<Control>q”.
If you need to display accelerators in the user interface,
see ctk_accelerator_get_label().
gchar * ctk_accelerator_get_label (guint accelerator_key,CdkModifierType accelerator_mods);
Converts an accelerator keyval and modifier mask into a string which can be used to represent the accelerator to the user.
Since: 2.6
void ctk_accelerator_parse_with_keycode (const gchar *accelerator,guint *accelerator_key,guint **accelerator_codes,CdkModifierType *accelerator_mods);
Parses a string representing an accelerator, similarly to
ctk_accelerator_parse() but handles keycodes as well. This is only
useful for system-level components, applications should use
ctk_accelerator_parse() instead.
If accelerator_codes
is given and the result stored in it is non-NULL,
the result must be freed with g_free().
If a keycode is present in the accelerator and no accelerator_codes
is given, the parse will fail.
If the parse fails, accelerator_key
, accelerator_mods
and
accelerator_codes
will be set to 0 (zero).
accelerator |
string representing an accelerator |
|
accelerator_key |
return location for accelerator
keyval, or |
[out][allow-none] |
accelerator_codes |
return location for accelerator keycodes, or |
[out][array zero-terminated=1][transfer full][allow-none] |
accelerator_mods |
return location for accelerator
modifier mask, |
[out][allow-none] |
Since: 3.4
gchar * ctk_accelerator_name_with_keycode (CdkDisplay *display,guint accelerator_key,guint keycode,CdkModifierType accelerator_mods);
Converts an accelerator keyval and modifier mask
into a string parseable by ctk_accelerator_parse_with_keycode(),
similarly to ctk_accelerator_name() but handling keycodes.
This is only useful for system-level components, applications
should use ctk_accelerator_parse() instead.
display |
a CdkDisplay or |
[allow-none] |
accelerator_key |
accelerator keyval |
|
keycode |
accelerator keycode |
|
accelerator_mods |
accelerator modifier mask |
Since: 3.4
gchar * ctk_accelerator_get_label_with_keycode (CdkDisplay *display,guint accelerator_key,guint keycode,CdkModifierType accelerator_mods);
Converts an accelerator keyval and modifier mask
into a (possibly translated) string that can be displayed to
a user, similarly to ctk_accelerator_get_label(), but handling
keycodes.
This is only useful for system-level components, applications
should use ctk_accelerator_parse() instead.
display |
a CdkDisplay or |
[allow-none] |
accelerator_key |
accelerator keyval |
|
keycode |
accelerator keycode |
|
accelerator_mods |
accelerator modifier mask |
Since: 3.4
void
ctk_accelerator_set_default_mod_mask (CdkModifierType default_mod_mask);
Sets the modifiers that will be considered significant for keyboard accelerators. The default mod mask depends on the CDK backend in use, but will typically include CDK_CONTROL_MASK | CDK_SHIFT_MASK | CDK_MOD1_MASK | CDK_SUPER_MASK | CDK_HYPER_MASK | CDK_META_MASK. In other words, Control, Shift, Alt, Super, Hyper and Meta. Other modifiers will by default be ignored by CtkAccelGroup.
You must include at least the three modifiers Control, Shift and Alt in any value you pass to this function.
The default mod mask should be changed on application startup, before using any accelerator groups.
CdkModifierType
ctk_accelerator_get_default_mod_mask (void);
Gets the modifier mask.
The modifier mask determines which modifiers are considered significant
for keyboard accelerators. See ctk_accelerator_set_default_mod_mask().
struct CtkAccelGroup;
An object representing and maintaining a group of accelerators.
struct CtkAccelGroupClass {
GObjectClass parent_class;
void (*accel_changed) (CtkAccelGroup *accel_group,
guint keyval,
CdkModifierType modifier,
GClosure *accel_closure);
};
struct CtkAccelKey {
guint accel_key;
CdkModifierType accel_mods;
guint accel_flags : 16;
};
The accelerator keyval |
||
CdkModifierType |
The accelerator modifiers |
|
The accelerator flags |
“is-locked” property “is-locked” gboolean
Is the accel group locked.
Owner: CtkAccelGroup
Flags: Read
Default value: FALSE
“modifier-mask” property“modifier-mask” CdkModifierType
Modifier Mask.
Owner: CtkAccelGroup
Flags: Read
“accel-activate” signalgboolean user_function (CtkAccelGroup *accel_group, GObject *acceleratable, guint keyval, CdkModifierType modifier, gpointer user_data)
The accel-activate signal is an implementation detail of CtkAccelGroup and not meant to be used by applications.
accel_group |
the CtkAccelGroup which received the signal |
|
acceleratable |
the object on which the accelerator was activated |
|
keyval |
the accelerator keyval |
|
modifier |
the modifier combination of the accelerator |
|
user_data |
user data set when the signal handler was connected. |
Flags: Has Details
“accel-changed” signalvoid user_function (CtkAccelGroup *accel_group, guint keyval, CdkModifierType modifier, GClosure *accel_closure, gpointer user_data)
The accel-changed signal is emitted when an entry is added to or removed from the accel group.
Widgets like CtkAccelLabel which display an associated
accelerator should connect to this signal, and rebuild
their visual representation if the accel_closure
is theirs.
accel_group |
the CtkAccelGroup which received the signal |
|
keyval |
the accelerator keyval |
|
modifier |
the modifier combination of the accelerator |
|
accel_closure |
the GClosure of the accelerator |
|
user_data |
user data set when the signal handler was connected. |
Flags: Has Details