GtkShortcutAction — Tracking if shortcuts should be activated
gboolean | (*GtkShortcutFunc) () |
char * | gtk_shortcut_action_to_string () |
void | gtk_shortcut_action_print () |
GtkShortcutAction * | gtk_shortcut_action_parse_string () |
gboolean | gtk_shortcut_action_activate () |
GtkShortcutAction * | gtk_nothing_action_get () |
GtkShortcutAction * | gtk_callback_action_new () |
GtkShortcutAction * | gtk_mnemonic_action_get () |
GtkShortcutAction * | gtk_activate_action_get () |
GtkShortcutAction * | gtk_signal_action_new () |
const char * | gtk_signal_action_get_signal_name () |
GtkShortcutAction * | gtk_named_action_new () |
const char * | gtk_named_action_get_action_name () |
GObject ╰── GtkShortcutAction ├── GtkSignalAction ├── GtkNothingAction ├── GtkNamedAction ╰── GtkCallbackAction
#include <gtk/gtk.h>
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:
GtkMnemonicAction: a shortcut action that calls gtk_widget_mnemonic_activate()
GtkCallbackAction: a shortcut action that invokes a given callback
GtkSignalAction: a shortcut action that emits a given signal
GtkActivateAction: a shortcut action that calls gtk_widget_activate()
GtkNamedAction: a shortcut action that calls gtk_widget_activate_action()
GtkNothingAction: a shortcut action that does nothing
GtkShortcut
gboolean (*GtkShortcutFunc) (GtkWidget *widget
,GVariant *args
,gpointer user_data
);
Prototype for shortcuts based on user callbacks.
widget | The widget passed to the activation | |
args | The arguments passed to the activation | |
user_data | The user data provided when activating the action |
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.
self |
a new string.
[transfer full]
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.
self | ||
string | a GString to print into |
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:
nothing
, for GtkNothingAction
activate
, for GtkActivateAction
mnemonic-activate
, for GtkMnemonicAction
action(NAME)
, for a GtkNamedAction for the action named NAME
signal(NAME)
, for a GtkSignalAction for the signal NAME
[constructor]
string | the string to parse |
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.
self | ||
flags | flags to activate with | |
widget | Target of the activation | |
args | arguments to pass. | [allow-none] |
TRUE
if this action was activated successfully
GtkShortcutAction *
gtk_nothing_action_get (void
);
Gets the nothing action. This is an action that does nothing and where activating it always fails.
The nothing action.
[transfer none][type GtkNothingAction]
GtkShortcutAction * gtk_callback_action_new (GtkShortcutFunc callback
,gpointer data
,GDestroyNotify destroy
);
Create a custom action that calls the given callback
when activated.
callback | the callback to call. | [scope notified] |
data | the data to be passed to | [closure callback] |
destroy | the function to be called when the callback action is finalized. | [destroy data] |
A new shortcut action.
[transfer full][type GtkCallbackAction]
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.
The mnemonic action.
[transfer none][type GtkMnemonicAction]
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.
The activate action.
[transfer none][type GtkActivateAction]
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.
signal_name | name of the signal to emit |
const char *
gtk_signal_action_get_signal_name (GtkSignalAction *self
);
Returns the name of the signal that will be emitted.
self | a signal action |
the name of the signal to emit.
[transfer none]
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.
name | the detailed name of the action |
const char *
gtk_named_action_get_action_name (GtkNamedAction *self
);
Returns the name of the action that will be activated.
self | a named action |
the name of the action to activate
typedef struct _GtkShortcutAction GtkShortcutAction;
List of flags that can be passed to action activation. More flags may be added in the future.
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. |
typedef struct _GtkNothingAction GtkNothingAction;
A GtkShortcutAction that does nothing.
typedef struct _GtkCallbackAction GtkCallbackAction;
A GtkShortcutAction that invokes a callback.
typedef struct _GtkMnemonicAction GtkMnemonicAction;
A GtkShortcutAction that calls gtk_widget_mnemonic_activate()
.
typedef struct _GtkActivateAction GtkActivateAction;
A GtkShortcutAction that calls gtk_widget_activate()
.
typedef struct _GtkSignalAction GtkSignalAction;
A GtkShortcutAction that emits a signal.
Signals that are used in this way are referred to as keybinding signals, and they are expected to be defined with the G_SIGNAL_ACTION
flag.
typedef struct _GtkNamedAction GtkNamedAction;
A GtkShortcutAction that activates an action by name.
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkShortcutAction.html