GtkShortcutTrigger

GtkShortcutTrigger — Triggers to track if shortcuts should be activated

Object Hierarchy

    GObject
    ╰── GtkShortcutTrigger
        ├── GtkKeyvalTrigger
        ├── GtkNeverTrigger
        ╰── GtkAlternativeTrigger

Includes

#include <gtk/gtk.h>

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 .

Parameters

self

a GtkShortcutTrigger

 

event

the event to check

 

enable_mnemonics

TRUE if mnemonics should trigger. Usually the value of this property is determined by checking that the passed in event is a Key event and has the right modifiers set.

 

Returns

Whether the event triggered the shortcut


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.

Parameters

trigger

a GtkShortcutTrigger.

[type GtkShortcutTrigger]

Returns

a hash value corresponding to trigger


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.

Parameters

trigger1

a GtkShortcutTrigger.

[type GtkShortcutTrigger]

trigger2

a GtkShortcutTrigger.

[type GtkShortcutTrigger]

Returns

TRUE if trigger1 and trigger2 are equal


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.

Parameters

trigger1

a GtkShortcutTrigger.

[type GtkShortcutTrigger]

trigger2

a GtkShortcutTrigger.

[type GtkShortcutTrigger]

Returns

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 .


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.

Parameters

self

a GtkShortcutTrigger

 

Returns

a new string.

[transfer full]


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.

Parameters

self

a GtkShortcutTrigger

 

string

a GString to print into

 

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.

Parameters

self

a GtkShortcutTrigger

 

display

GdkDisplay to print for

 

Returns

a new string.

[transfer full]


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.

Parameters

self

a GtkShortcutTrigger

 

display

GdkDisplay to print for

 

string

a GString to print into

 

Returns

TRUE if something was printed or FALSE if the trigger did not have a textual representation suitable for end users.


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:

Note that you will have to escape the < and &gt; characters when specifying triggers in XML files, such as GtkBuilder ui files. Use &lt; instead of < and &gt; instead of &gt;.

[constructor]

Parameters

string

the string to parse

 

Returns

a new GtkShortcutTrigger or NULL on error.

[nullable][transfer full]


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.

Parameters

keyval

The keyval to trigger for

 

modifiers

the modifiers that need to be present

 

Returns

A new GtkShortcutTrigger


gtk_keyval_trigger_get_modifiers ()

GdkModifierType
gtk_keyval_trigger_get_modifiers (GtkKeyvalTrigger *self);

Gets the modifiers that must be present to succeed triggering self .

Parameters

self

a keyval GtkShortcutTrigger

 

Returns

the modifiers


gtk_keyval_trigger_get_keyval ()

guint
gtk_keyval_trigger_get_keyval (GtkKeyvalTrigger *self);

Gets the keyval that must be pressed to succeed triggering self .

Parameters

self

a keyval GtkShortcutTrigger

 

Returns

the keyval


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.

Parameters

keyval

The keyval to trigger for

 

Returns

A new GtkShortcutTrigger.

[transfer full][type GtkMnemonicTrigger]


gtk_mnemonic_trigger_get_keyval ()

guint
gtk_mnemonic_trigger_get_keyval (GtkMnemonicTrigger *self);

Gets the keyval that must be pressed to succeed triggering self .

Parameters

self

a mnemonic GtkShortcutTrigger

 

Returns

the keyval


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.

Parameters

first

The first trigger that may trigger.

[transfer full]

second

The second trigger that may trigger.

[transfer full]

Returns

a new GtkShortcutTrigger


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.

Parameters

self

an alternative GtkShortcutTrigger

 

Returns

the first alternative trigger.

[transfer none]


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.

Parameters

self

an alternative GtkShortcutTrigger

 

Returns

the second alternative trigger.

[transfer none]


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.

Returns

The never trigger.

[type GtkNeverTrigger][transfer none]

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.

See Also

GtkShortcut