dzl-shortcut-controller: Dazzle Reference Manual

## dzl-shortcut-controller dzl-shortcut-controller |

## Functions

DzlShortcutController * | dzl_shortcut_controller_new ()
DzlShortcutManager * | dzl_shortcut_controller_get_manager ()
void | dzl_shortcut_controller_set_manager ()
DzlShortcutController * | dzl_shortcut_controller_find ()
DzlShortcutController * | dzl_shortcut_controller_try_find ()
DzlShortcutContext * | dzl_shortcut_controller_get_context ()
void | dzl_shortcut_controller_set_context_by_name ()
DzlShortcutContext * | dzl_shortcut_controller_get_context_for_phase ()
gboolean | dzl_shortcut_controller_execute_command ()
const DzlShortcutChord * | dzl_shortcut_controller_get_current_chord ()
void | dzl_shortcut_controller_add_command_action ()
void | dzl_shortcut_controller_add_command_callback ()
void | dzl_shortcut_controller_add_command_signal ()

## Properties

DzlShortcutContext * | context | Read
DzlShortcutChord * | current-chord | Read
DzlShortcutManager * | manager | Read / Write
GtkWidget * | widget | Read / Write / Construct Only

## Signals

void | reset | Action
void | set-context-named | Action

## Types and Values

#define | DZL_TYPE_SHORTCUT_CONTROLLER
| DzlShortcutController

## Object Hierarchy

        GObject
        ╰── DzlShortcutController

## Description

## Functions

### dzl_shortcut_controller_new ()

    DzlShortcutController *
    dzl_shortcut_controller_new (GtkWidget *widget);

### dzl_shortcut_controller_get_manager ()

    DzlShortcutManager *
    dzl_shortcut_controller_get_manager (DzlShortcutController *self);

Gets the DzlShortcutManager associated with this controller.

Generally, this will look for the root controller's manager as mixing and matching managers in a single window hierarchy is not supported.

#### Parameters

self | a DzlShortcutController |

#### Returns

A DzlShortcutManager.

[not nullable][transfer none]

### dzl_shortcut_controller_set_manager ()

    void
    dzl_shortcut_controller_set_manager (DzlShortcutController *self,
                                         DzlShortcutManager *manager);

Sets the “manager” property.

If you set this to `NULL`, it will revert to the default DzlShortcutManager for the process.

#### Parameters

self | a DzlShortcutController |
manager | A DzlShortcutManager or `NULL`. | [nullable]

### dzl_shortcut_controller_find ()

    DzlShortcutController *
    dzl_shortcut_controller_find (GtkWidget *widget);

Finds the registered DzlShortcutController for a widget.

The controller is created if it does not already exist.

#### Returns

An DzlShortcutController or `NULL`.

[not nullable][transfer none]

### dzl_shortcut_controller_try_find ()

    DzlShortcutController *
    dzl_shortcut_controller_try_find (GtkWidget *widget);

Finds the registered DzlShortcutController for a widget.

If no controller is found, `NULL` is returned.

#### Returns

An DzlShortcutController or `NULL`.

[nullable][transfer none]

### dzl_shortcut_controller_get_context ()

    DzlShortcutContext *
    dzl_shortcut_controller_get_context (DzlShortcutController *self);

This function gets the “context” property, which is the current context to dispatch events to. An DzlShortcutContext is a group of keybindings that may be activated in response to a single or series of GdkEventKey.

#### Parameters

self | An DzlShortcutController |

#### Returns

A DzlShortcutContext or `NULL`.

[transfer none][nullable]

Since: 3.26

### dzl_shortcut_controller_set_context_by_name ()

    void
    dzl_shortcut_controller_set_context_by_name
                                   (DzlShortcutController *self,
                                    const gchar *name);

Changes the context for the controller to the context matching `name` .

Contexts are resolved at runtime through the current theme (and possibly a parent theme if it inherits from one).

#### Parameters

self | a DzlShortcutController |
name | The name of the context. | [nullable]

Since: 3.26

### dzl_shortcut_controller_get_context_for_phase ()

    DzlShortcutContext *
    dzl_shortcut_controller_get_context_for_phase
                                   (DzlShortcutController *self,
                                    DzlShortcutPhase phase);

Controllers can have a different context for a particular phase, which allows them to activate different keybindings depending if the event in capture, bubble, or dispatch.

#### Parameters

self | a DzlShortcutController |
phase | the phase for the shorcut delivery |

#### Returns

A DzlShortcutContext or `NULL`.

[transfer none][nullable]

Since: 3.26

### dzl_shortcut_controller_execute_command ()

    gboolean
    dzl_shortcut_controller_execute_command
                                   (DzlShortcutController *self,
                                    const gchar *command);

This method will locate and execute the command matching the id `command` .

If the command is not found, `FALSE` is returned.

#### Parameters

self | a DzlShortcutController |
command | the id of the command |

#### Returns

`TRUE` if the command was found and executed.

### dzl_shortcut_controller_get_current_chord ()

    const DzlShortcutChord *
    dzl_shortcut_controller_get_current_chord
                                   (DzlShortcutController *self);

This method gets the “current-chord” property. This is useful if you want to monitor in-progress chord building.

Note that this value will only be valid on the controller for the toplevel widget (a GtkWindow). Chords are not tracked at the individual widget controller level.

#### Parameters

self | a DzlShortcutController |

#### Returns

A DzlShortcutChord or `NULL`.

[transfer none][nullable]

### dzl_shortcut_controller_add_command_action ()

    void
    dzl_shortcut_controller_add_command_action
                                   (DzlShortcutController *self,
                                    const gchar *command_id,
                                    const gchar *default_accel,
                                    DzlShortcutPhase phase,
                                    const gchar *action);

### dzl_shortcut_controller_add_command_callback ()

    void
    dzl_shortcut_controller_add_command_callback
                                   (DzlShortcutController *self,
                                    const gchar *command_id,
                                    const gchar *default_accel,
                                    DzlShortcutPhase phase,
                                    GtkCallback callback,
                                    gpointer callback_data,
                                    GDestroyNotify callback_data_destroy);

### dzl_shortcut_controller_add_command_signal ()

    void
    dzl_shortcut_controller_add_command_signal
                                   (DzlShortcutController *self,
                                    const gchar *command_id,
                                    const gchar *default_accel,
                                    DzlShortcutPhase phase,
                                    const gchar *signal_name,
                                    guint n_args,
                                    ...);

## Types and Values

### DZL_TYPE_SHORTCUT_CONTROLLER

    #define DZL_TYPE_SHORTCUT_CONTROLLER (dzl_shortcut_controller_get_type())

### DzlShortcutController

    typedef struct _DzlShortcutController DzlShortcutController;

## Property Details

### The `“context”` property

      “context”                  DzlShortcutContext *

The current context of the controller, for dispatch phase.

Flags: Read

### The `“current-chord”` property

      “current-chord”            DzlShortcutChord *

The current chord for the controller.

Flags: Read

### The `“manager”` property

      “manager”                  DzlShortcutManager *

The shortcut manager.

Flags: Read / Write

### The `“widget”` property

      “widget”                   GtkWidget *

The widget for which the controller attached.

Flags: Read / Write / Construct Only

## Signal Details

### The `“reset”` signal

    void
    user_function (DzlShortcutController *dzlshortcutcontroller,
                   gpointer               user_data)

This signal is emitted when the shortcut controller is requesting the widget to reset any state it may have regarding the shortcut controller. Such an example might be a modal system that lives outside the controller whose state should be cleared in response to the controller changing modes.

#### Parameters

user_data | user data set when the signal handler was connected. |

Flags: Action

### The `“set-context-named”` signal

    void
    user_function (DzlShortcutController *self,
                   gchar                 *name,
                   gpointer               user_data)

This changes the current context on the DzlShortcutController to be the context matching `name` . This is found by looking up the context by name in the active DzlShortcutTheme.

#### Parameters

self | An DzlShortcutController |
name | The name of the context |
user_data | user data set when the signal handler was connected. |

Flags: Action