GtkShortcutTrigger — Triggers to track if shortcuts should be activated
GObject ╰── GtkShortcutTrigger ├── GtkKeyvalTrigger ├── GtkNeverTrigger ╰── GtkAlternativeTrigger
#include <gtk/gtk.h>
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.
GdkKeyMatch gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self
,GdkEvent *event
,gboolean enable_mnemonics
);
Checks if the given event
triggers self
.
self | ||
event | the event to check | |
enable_mnemonics |
|
Whether the event triggered the shortcut
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.
trigger | [type GtkShortcutTrigger] |
a hash value corresponding to trigger
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.
trigger1 | [type GtkShortcutTrigger] | |
trigger2 | [type GtkShortcutTrigger] |
TRUE
if trigger1
and trigger2
are equal
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.
trigger1 | [type GtkShortcutTrigger] | |
trigger2 | [type GtkShortcutTrigger] |
An integer less than, equal to, or greater than zero if trigger1
is found, respectively, to be less than, to match, or be greater than trigger2
.
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.
self |
a new string.
[transfer full]
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.
self | ||
string | a GString to print into |
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.
self | ||
display | GdkDisplay to print for |
a new string.
[transfer full]
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.
self | ||
display | GdkDisplay to print for | |
string | a GString to print into |
TRUE
if something was printed or FALSE
if the trigger did not have a textual representation suitable for end users.
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 GtkNeverTrigger
a 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]
string | the string to parse |
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.
keyval | The keyval to trigger for | |
modifiers | the modifiers that need to be present |
A new GtkShortcutTrigger
GdkModifierType
gtk_keyval_trigger_get_modifiers (GtkKeyvalTrigger *self
);
Gets the modifiers that must be present to succeed triggering self
.
self | a keyval GtkShortcutTrigger |
the modifiers
guint
gtk_keyval_trigger_get_keyval (GtkKeyvalTrigger *self
);
Gets the keyval that must be pressed to succeed triggering self
.
self | a keyval GtkShortcutTrigger |
the keyval
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.
keyval | The keyval to trigger for |
guint
gtk_mnemonic_trigger_get_keyval (GtkMnemonicTrigger *self
);
Gets the keyval that must be pressed to succeed triggering self
.
self | a mnemonic GtkShortcutTrigger |
the keyval
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.
first | The first trigger that may trigger. | [transfer full] |
second | The second trigger that may trigger. | [transfer full] |
a new GtkShortcutTrigger
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.
self | an alternative GtkShortcutTrigger |
the first alternative trigger.
[transfer none]
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.
self | an alternative GtkShortcutTrigger |
the second alternative trigger.
[transfer none]
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.
The never trigger.
[type GtkNeverTrigger][transfer none]
typedef struct _GtkShortcutTrigger GtkShortcutTrigger;
A trigger for a key shortcut.
typedef struct _GtkKeyvalTrigger GtkKeyvalTrigger;
A GtkShortcutTrigger that triggers when a specific keyval and (optionally) modifiers are pressed.
typedef struct _GtkMnemonicTrigger GtkMnemonicTrigger;
A GtkShortcutTrigger that triggers when a specific mnemonic is pressed.
typedef struct _GtkAlternativeTrigger GtkAlternativeTrigger;
A GtkShortcutTrigger that triggers when either of two GtkShortcutTriggers trigger.
typedef struct _GtkNeverTrigger GtkNeverTrigger;
A GtkShortcutTrigger that never triggers.
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkShortcutTrigger.html