Top |
Functions
Object Hierarchy
GObject ╰── GtkShortcutTrigger ├── GtkKeyvalTrigger ├── GtkNeverTrigger ╰── GtkAlternativeTrigger
Description
GtkShortcutTrigger is the object used to track if a GtkShortcut should be
activated. For this purpose, gtk_shortcut_trigger_trigger()
can be called
on a GdkEvent.
GtkShortcutTriggers contain functions that allow easy presentation to end users as well as being printed for debugging.
All GtkShortcutTriggers are immutable, you can only specify their properties during construction. If you want to change a trigger, you have to replace it with a new one.
Functions
gtk_shortcut_trigger_trigger ()
GdkKeyMatch gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self
,GdkEvent *event
,gboolean enable_mnemonics
);
Checks if the given event
triggers self
.
gtk_shortcut_trigger_hash ()
guint
gtk_shortcut_trigger_hash (gconstpointer trigger
);
Generates a hash value for a GtkShortcutTrigger.
The output of this function is guaranteed to be the same for a given value only per-process. It may change between different processor architectures or even different versions of GTK. Do not use this function as a basis for building protocols or file formats.
The types of trigger
is gconstpointer only to allow use of this
function with GHashTable. They must each be a GtkShortcutTrigger.
gtk_shortcut_trigger_equal ()
gboolean gtk_shortcut_trigger_equal (gconstpointer trigger1
,gconstpointer trigger2
);
Checks if trigger1
and trigger2
trigger under the same conditions.
The types of one
and two
are gconstpointer only to allow use of this
function with GHashTable. They must each be a GtkShortcutTrigger.
gtk_shortcut_trigger_compare ()
int gtk_shortcut_trigger_compare (gconstpointer trigger1
,gconstpointer trigger2
);
The types of trigger1
and trigger2
are gconstpointer only to allow
use of this function as a GCompareFunc. They must each be a
GtkShortcutTrigger.
gtk_shortcut_trigger_to_string ()
char *
gtk_shortcut_trigger_to_string (GtkShortcutTrigger *self
);
Prints the given trigger into a human-readable string.
This is a small wrapper around gtk_shortcut_trigger_print()
to help when debugging.
gtk_shortcut_trigger_print ()
void gtk_shortcut_trigger_print (GtkShortcutTrigger *self
,GString *string
);
Prints the given trigger into a string for the developer. This is meant for debugging and logging.
The form of the representation may change at any time and is not guaranteed to stay identical.
gtk_shortcut_trigger_to_label ()
char * gtk_shortcut_trigger_to_label (GtkShortcutTrigger *self
,GdkDisplay *display
);
Gets textual representation for the given trigger. This function is returning a translated string for presentation to end users for example in menu items or in help texts.
The display
in use may influence the resulting string in
various forms, such as resolving hardware keycodes or by
causing display-specific modifier names.
The form of the representation may change at any time and is not guaranteed to stay identical.
gtk_shortcut_trigger_print_label ()
gboolean gtk_shortcut_trigger_print_label (GtkShortcutTrigger *self
,GdkDisplay *display
,GString *string
);
Prints the given trigger into a string. This function is returning a translated string for presentation to end users for example in menu items or in help texts.
The display
in use may influence the resulting string in
various forms, such as resolving hardware keycodes or by
causing display-specific modifier names.
The form of the representation may change at any time and is not guaranteed to stay identical.
gtk_shortcut_trigger_parse_string ()
GtkShortcutTrigger *
gtk_shortcut_trigger_parse_string (const char *string
);
Tries to parse the given string into a trigger. On success,
the parsed trigger is returned. When parsing failed, NULL
is
returned.
The accepted strings are:
never
, for GtkNeverTriggera string parsed by
gtk_accelerator_parse()
, for a GtkKeyvalTrigger, e.g.<Control>C
underscore, followed by a single character, for MnemonicTrigger, e.g.
_l
two valid trigger strings, separated by a
|
character, for a GtkAlternativeTrigger:<Control>q|<Control>w
Note that you will have to escape the <
and >
characters when specifying
triggers in XML files, such as GtkBuilder ui files. Use <
instead of
<
and >
instead of >
.
[constructor]
gtk_keyval_trigger_new ()
GtkShortcutTrigger * gtk_keyval_trigger_new (guint keyval
,GdkModifierType modifiers
);
Creates a GtkShortcutTrigger that will trigger whenever
the key with the given keyval
and modifiers
is pressed.
gtk_keyval_trigger_get_modifiers ()
GdkModifierType
gtk_keyval_trigger_get_modifiers (GtkKeyvalTrigger *self
);
Gets the modifiers that must be present to succeed
triggering self
.
gtk_keyval_trigger_get_keyval ()
guint
gtk_keyval_trigger_get_keyval (GtkKeyvalTrigger *self
);
Gets the keyval that must be pressed to succeed
triggering self
.
gtk_mnemonic_trigger_new ()
GtkShortcutTrigger *
gtk_mnemonic_trigger_new (guint keyval
);
Creates a GtkShortcutTrigger that will trigger whenever the key with
the given keyval
is pressed and mnemonics have been activated.
Mnemonics are activated by calling code when a key event with the right modifiers is detected.
gtk_mnemonic_trigger_get_keyval ()
guint
gtk_mnemonic_trigger_get_keyval (GtkMnemonicTrigger *self
);
Gets the keyval that must be pressed to succeed triggering self
.
gtk_alternative_trigger_new ()
GtkShortcutTrigger * gtk_alternative_trigger_new (GtkShortcutTrigger *first
,GtkShortcutTrigger *second
);
Creates a GtkShortcutTrigger that will trigger whenever either of the two given triggers gets triggered.
Note that nesting is allowed, so if you want more than two alternative, create a new alternative trigger for each option.
gtk_alternative_trigger_get_first ()
GtkShortcutTrigger *
gtk_alternative_trigger_get_first (GtkAlternativeTrigger *self
);
Gets the first of the two alternative triggers that may
trigger self
. gtk_alternative_trigger_get_second()
will
return the other one.
gtk_alternative_trigger_get_second ()
GtkShortcutTrigger *
gtk_alternative_trigger_get_second (GtkAlternativeTrigger *self
);
Gets the second of the two alternative triggers that may
trigger self
. gtk_alternative_trigger_get_first()
will
return the other one.
gtk_never_trigger_get ()
GtkShortcutTrigger *
gtk_never_trigger_get (void
);
Gets the never trigger. This is a singleton for a trigger
that never triggers. Use this trigger instead of NULL
because it implements all virtual functions.
Types and Values
GtkShortcutTrigger
typedef struct _GtkShortcutTrigger GtkShortcutTrigger;
A trigger for a key shortcut.
GtkKeyvalTrigger
typedef struct _GtkKeyvalTrigger GtkKeyvalTrigger;
A GtkShortcutTrigger that triggers when a specific keyval and (optionally) modifiers are pressed.
GtkMnemonicTrigger
typedef struct _GtkMnemonicTrigger GtkMnemonicTrigger;
A GtkShortcutTrigger that triggers when a specific mnemonic is pressed.
GtkAlternativeTrigger
typedef struct _GtkAlternativeTrigger GtkAlternativeTrigger;
A GtkShortcutTrigger that triggers when either of two GtkShortcutTriggers trigger.
GtkNeverTrigger
typedef struct _GtkNeverTrigger GtkNeverTrigger;
A GtkShortcutTrigger that never triggers.