Class: Gtk::ShortcutTrigger

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Gtk::ShortcutTrigger

Tries to parse the given string into a trigger.

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

Parameters:

  • string (String)

    the string to parse

Instance Method Details

#compare(trigger2) ⇒ Integer

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:

Returns:

  • (Integer)

    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.

#equal(trigger2) ⇒ Boolean

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:

Returns:

  • (Boolean)

    true if trigger1 and trigger2 are equal

#hashInteger

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.

Returns:

  • (Integer)

    a hash value corresponding to trigger

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:

  • string (GLib::String)

    a GString to print into

Returns:

  • (nil)

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:

  • display (Gdk::Display)

    GdkDisplay to print for

  • string (GLib::String)

    a GString to print into

Returns:

  • (Boolean)

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

#to_label(display) ⇒ String

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:

  • display (Gdk::Display)

    GdkDisplay to print for

Returns:

  • (String)

    a new string

#to_stringString

Prints the given trigger into a human-readable string.

This is a small wrapper around [methodGtk.ShortcutTrigger.print] to help when debugging.

Returns:

  • (String)

    a new string

#trigger(event, enable_mnemonics) ⇒ Gdk::KeyMatch

Checks if the given event triggers self.

Parameters:

  • event (Gdk::Event)

    the event to check

  • enable_mnemonics (Boolean)

    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:

  • (Gdk::KeyMatch)

    Whether the event triggered the shortcut