Gtk.ShortcutTrigger

g GObject.Object GObject.Object Gtk.ShortcutTrigger Gtk.ShortcutTrigger GObject.Object->Gtk.ShortcutTrigger

Subclasses:

Gtk.AlternativeTrigger, Gtk.KeyvalTrigger, Gtk.MnemonicTrigger, Gtk.NeverTrigger

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

parse_string (string)

compare (trigger2)

equal (trigger2)

hash ()

print_ (string)

print_label (display, string)

to_label (display)

to_string ()

trigger (event, enable_mnemonics)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.ShortcutTrigger(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gtk.ShortcutTriggerClass

GtkShortcutTrigger tracks how a GtkShortcut should be activated.

To find out if a GtkShortcutTrigger triggers, you can call [method`Gtk`.ShortcutTrigger.trigger] 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.

classmethod parse_string(string)[source]
Parameters:

string (str) – the string to parse

Returns:

a new GtkShortcutTrigger

Return type:

Gtk.ShortcutTrigger or None

Tries to parse the given string into a trigger.

On success, the parsed trigger is returned. When parsing failed, None 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 GtkMnemonicTrigger, 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 Gtk.Builder ui files. Use &lt; instead of < and &gt; instead of >.

compare(trigger2)[source]
Parameters:

trigger2 (Gtk.ShortcutTrigger) – a GtkShortcutTrigger

Returns:

An integer less than, equal to, or greater than zero if self is found, respectively, to be less than, to match, or be greater than trigger2.

Return type:

int

The types of self and trigger2 are gconstpointer only to allow use of this function as a GCompareFunc.

They must each be a GtkShortcutTrigger.

equal(trigger2)[source]
Parameters:

trigger2 (Gtk.ShortcutTrigger) – a GtkShortcutTrigger

Returns:

True if self and trigger2 are equal

Return type:

bool

Checks if self 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.

hash()[source]
Returns:

a hash value corresponding to self

Return type:

int

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 self is gconstpointer only to allow use of this function with GHashTable. They must each be a GtkShortcutTrigger.

print_(string)[source]
Parameters:

string (GLib.String) – a GString to print into

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.

print_label(display, string)[source]
Parameters:
Returns:

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

Return type:

bool

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.

to_label(display)[source]
Parameters:

display (Gdk.Display) – GdkDisplay to print for

Returns:

a new string

Return type:

str

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.

to_string()[source]
Returns:

a new string

Return type:

str

Prints the given trigger into a human-readable string.

This is a small wrapper around [method`Gtk`.ShortcutTrigger.print] to help when debugging.

trigger(event, enable_mnemonics)[source]
Parameters:
  • event (Gdk.Event) – the event to check

  • enable_mnemonics (bool) – 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

Return type:

Gdk.KeyMatch

Checks if the given event triggers self.