GtkShortcutAction

GtkShortcutAction — Tracking if shortcuts should be activated

Object Hierarchy

    GObject
    ╰── GtkShortcutAction
        ├── GtkSignalAction
        ├── GtkNothingAction
        ├── GtkNamedAction
        ╰── GtkCallbackAction

Includes

#include <gtk/gtk.h>

Description

GtkShortcutAction is the object used to describe what a GtkShortcut should do when triggered. To activate a GtkShortcutAction manually, gtk_shortcut_action_activate() can be called.

GtkShortcutActions contain functions that allow easy presentation to end users as well as being printed for debugging.

All GtkShortcutActions are immutable, you can only specify their properties during construction. If you want to change a action, you have to replace it with a new one. If you need to pass arguments to an action, these are specified by the higher-level GtkShortcut object.

GTK provides various actions:

GtkShortcutAction as GtkBuildable

GtkShortcut

Functions

GtkShortcutFunc ()

gboolean
(*GtkShortcutFunc) (GtkWidget *widget,
                    GVariant *args,
                    gpointer user_data);

Prototype for shortcuts based on user callbacks.

Parameters

widget

The widget passed to the activation

 

args

The arguments passed to the activation

 

user_data

The user data provided when activating the action

 

gtk_shortcut_action_to_string ()

char *
gtk_shortcut_action_to_string (GtkShortcutAction *self);

Prints the given action into a human-readable string. This is a small wrapper around gtk_shortcut_action_print() to help when debugging.

Parameters

self

a GtkShortcutAction

 

Returns

a new string.

[transfer full]


gtk_shortcut_action_print ()

void
gtk_shortcut_action_print (GtkShortcutAction *self,
                           GString *string);

Prints the given action 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 GtkShortcutAction

 

string

a GString to print into

 

gtk_shortcut_action_parse_string ()

GtkShortcutAction *
gtk_shortcut_action_parse_string (const char *string);

Tries to parse the given string into an action. On success, the parsed action is returned. When parsing failed, NULL is returned.

The accepted strings are:

[constructor]

Parameters

string

the string to parse

 

Returns

a new GtkShortcutAction or NULL on error.

[nullable][transfer full]


gtk_shortcut_action_activate ()

gboolean
gtk_shortcut_action_activate (GtkShortcutAction *self,
                              GtkShortcutActionFlags flags,
                              GtkWidget *widget,
                              GVariant *args);

Activates the action on the widget with the given args .

Note that some actions ignore the passed in flags , widget or args .

Activation of an action can fail for various reasons. If the action is not supported by the widget , if the args don't match the action or if the activation otherwise had no effect, FALSE will be returned.

Parameters

self

a GtkShortcutAction

 

flags

flags to activate with

 

widget

Target of the activation

 

args

arguments to pass.

[allow-none]

Returns

TRUE if this action was activated successfully


gtk_nothing_action_get ()

GtkShortcutAction *
gtk_nothing_action_get (void);

Gets the nothing action. This is an action that does nothing and where activating it always fails.

Returns

The nothing action.

[transfer none]


gtk_callback_action_new ()

GtkShortcutAction *
gtk_callback_action_new (GtkShortcutFunc callback,
                         gpointer data,
                         GDestroyNotify destroy);

Create a custom action that calls the given callback when activated.

Parameters

callback

the callback to call.

[scope notified]

data

the data to be passed to callback .

[closure callback]

destroy

the function to be called when the callback action is finalized.

[destroy data]

Returns

A new shortcut action.

[transfer full]


gtk_mnemonic_action_get ()

GtkShortcutAction *
gtk_mnemonic_action_get (void);

Gets the mnemonic action. This is an action that calls gtk_widget_mnemonic_activate() on the given widget upon activation.

Returns

The mnemonic action.

[transfer none]


gtk_activate_action_get ()

GtkShortcutAction *
gtk_activate_action_get (void);

Gets the activate action. This is an action that calls gtk_widget_activate() on the given widget upon activation.

Returns

The activate action.

[transfer none]


gtk_signal_action_new ()

GtkShortcutAction *
gtk_signal_action_new (const char *signal_name);

Creates an action that when activated, emits the given action signal on the provided widget unpacking the given args into arguments passed to the signal.

Parameters

signal_name

name of the signal to emit

 

Returns

a new GtkShortcutAction.

[transfer full][type GtkSignalAction]


gtk_signal_action_get_signal_name ()

const char *
gtk_signal_action_get_signal_name (GtkSignalAction *self);

Returns the name of the signal that will be emitted.

Parameters

self

a signal action

 

Returns

the name of the signal to emit.

[transfer none]


gtk_named_action_new ()

GtkShortcutAction *
gtk_named_action_new (const char *name);

Creates an action that when activated, activates the action given by the detailed name on the widget passing the given arguments to it.

See gtk_widget_insert_action_group() for how to add actions to widgets.

Parameters

name

the detailed name of the action

 

Returns

a new GtkShortcutAction.

[transfer full][type GtkNamedAction]


gtk_named_action_get_action_name ()

const char *
gtk_named_action_get_action_name (GtkNamedAction *self);

Returns the name of the action that will be activated.

Parameters

self

a named action

 

Returns

the name of the action to activate

Types and Values

GtkShortcutAction

typedef struct _GtkShortcutAction GtkShortcutAction;

enum GtkShortcutActionFlags

List of flags that can be passed to action activation. More flags may be added in the future.

Members

GTK_SHORTCUT_ACTION_EXCLUSIVE

The action is the only action that can be activated. If this flag is not set, a future activation may select a different action.

 

GtkNothingAction

typedef struct _GtkNothingAction GtkNothingAction;

A GtkShortcutAction that does nothing.


GtkCallbackAction

typedef struct _GtkCallbackAction GtkCallbackAction;

A GtkShortcutAction that invokes a callback.


GtkMnemonicAction

typedef struct _GtkMnemonicAction GtkMnemonicAction;

A GtkShortcutAction that calls gtk_widget_mnemonic_activate().


GtkActivateAction

typedef struct _GtkActivateAction GtkActivateAction;

A GtkShortcutAction that calls gtk_widget_activate().


GtkSignalAction

typedef struct _GtkSignalAction GtkSignalAction;

A GtkShortcutAction that emits a signal.


GtkNamedAction

typedef struct _GtkNamedAction GtkNamedAction;

A GtkShortcutAction that activates an action by name.

See Also

GtkShortcut