An action which can be triggered by a menu or toolbar item
Actions represent operations that the user can be perform, along with some information how it should be presented in the interface. Each action provides methods to create icons, menu items and toolbar items representing itself.
As well as the callback that is called when the action gets activated, the following also gets associated with the action: The action will also have some state information:
a name (not translated, for path lookup)
a label (translated, for display)
an accelerator
whether label indicates a stock id
a tooltip (optional, translated)
a toolbar label (optional, shorter than label)
visible (shown/hidden)
sensitive (enabled/disabled)
Apart from regular actions, there are toggle actions, which can be toggled
between two states and radio actions, of which only one in a group can be in the
"active" state. Other actions can be implemented as <gtk-action>
subclasses.
Each action can have one or more proxy menu item, toolbar button or other proxy widgets. Proxies mirror the state of the action (text label, tooltip, icon, visible, sensitive, etc), and should change when the action's state changes. When the proxy is activated, it should activate its action.
Derives from
<gtk-buildable>
,<gobject>
.This class defines the following slots:
name
- A unique name for the action.
label
- The label used for menu items and buttons that activate this action.
short-label
- A shorter label that may be used on toolbar buttons.
tooltip
- A tooltip for this action.
stock-id
- The stock icon displayed in widgets representing this action.
icon-name
- The name of the icon from the icon theme
visible-horizontal
- Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
visible-vertical
- Whether the toolbar item is visible when the toolbar is in a vertical orientation.
visible-overflown
- When TRUE, toolitem proxies for this action are represented in the toolbar overflow menu.
is-important
- Whether the action is considered important. When TRUE, toolitem proxies for this action show text in GTK_TOOLBAR_BOTH_HORIZ mode.
hide-if-empty
- When TRUE, empty menu proxies for this action are hidden.
sensitive
- Whether the action is enabled.
visible
- Whether the action is visible.
action-group
- The GtkActionGroup this GtkAction is associated with, or NULL (for internal use).
The "activate" signal is emitted when the action is activated.
Since 2.4
mchars
) (label mchars
) (tooltip mchars
) (stock_id mchars
) ⇒ (ret <gtk-action>
)Creates a new
<gtk-action>
object. To add the action to a<gtk-action-group>
and set the accelerator for the action, callgtk-action-group-add-action-with-accel
. See (the missing figure, XML-UI for information on allowed action names.
- name
- A unique name for the action
- label
- the label displayed in menu items and on buttons
- tooltip
- a tooltip for the action
- stock-id
- the stock icon to display in widgets representing the action
- ret
- a new
<gtk-action>
Since 2.4
<gtk-action>
) ⇒ (ret mchars
)Returns the name of the action.
- action
- the action object
- ret
- the name of the action. The string belongs to GTK+ and should not be freed.
Since 2.4
<gtk-action>
) ⇒ (ret bool
)Returns whether the action is effectively sensitive.
- action
- the action object
- ret
- ‘
#t
’ if the action and its associated action group are both sensitive.Since 2.4
<gtk-action>
) ⇒ (ret bool
)Returns whether the action itself is sensitive. Note that this doesn't necessarily mean effective sensitivity. See
gtk-action-is-sensitive
for that.
- action
- the action object
- ret
- ‘
#t
’ if the action itself is sensitive.Since 2.4
<gtk-action>
) (sensitive bool
)Sets the ::sensitive property of the action to sensitive. Note that this doesn't necessarily mean effective sensitivity. See
gtk-action-is-sensitive
for that.
- action
- the action object
- sensitive
- ‘
#t
’ to make the action sensitiveSince 2.6
<gtk-action>
) ⇒ (ret bool
)Returns whether the action is effectively visible.
- action
- the action object
- ret
- ‘
#t
’ if the action and its associated action group are both visible.Since 2.4
<gtk-action>
) ⇒ (ret bool
)Returns whether the action itself is visible. Note that this doesn't necessarily mean effective visibility. See
gtk-action-is-sensitive
for that.
- action
- the action object
- ret
- ‘
#t
’ if the action itself is visible.Since 2.4
<gtk-action>
) (visible bool
)Sets the ::visible property of the action to visible. Note that this doesn't necessarily mean effective visibility. See
gtk-action-is-visible
for that.
- action
- the action object
- visible
- ‘
#t
’ to make the action visibleSince 2.6
<gtk-action>
)Emits the "activate" signal on the specified action, if it isn't insensitive. This gets called by the proxy widgets when they get activated.
It can also be used to manually activate an action.
- action
- the action object
Since 2.4
<gtk-action>
) (icon_size <gtk-icon-size>
) ⇒ (ret <gtk-widget>
)This function is intended for use by action implementations to create icons displayed in the proxy widgets.
- action
- the action object
- icon-size
- the size of the icon that should be created.
- ret
- a widget that displays the icon for this action.
Since 2.4
<gtk-action>
) ⇒ (ret <gtk-widget>
)Creates a menu item widget that proxies for the given action.
- action
- the action object
- ret
- a menu item connected to the action.
Since 2.4
<gtk-action>
) ⇒ (ret <gtk-widget>
)Creates a toolbar item widget that proxies for the given action.
- action
- the action object
- ret
- a toolbar item connected to the action.
Since 2.4
<gtk-action>
) (proxy <gtk-widget>
)Connects a widget to an action object as a proxy. Synchronises various properties of the action with the widget (such as label text, icon, tooltip, etc), and attaches a callback so that the action gets activated when the proxy widget does.
If the widget is already connected to an action, it is disconnected first.
- action
- the action object
- proxy
- the proxy widget
Since 2.4
<gtk-action>
) (proxy <gtk-widget>
)Disconnects a proxy widget from an action. Does not destroy the widget, however.
- action
- the action object
- proxy
- the proxy widget
Since 2.4
<gtk-action>
) ⇒ (ret gslist-of
)Returns the proxy widgets for an action. See also
gtk-widget-get-action
.
- action
- the action object
- ret
- a
<gs-list>
of proxy widgets. The list is owned by GTK+ and must not be modified.Since 2.4
<gtk-action>
)Installs the accelerator for action if action has an accel path and group. See
gtk-action-set-accel-path
andgtk-action-set-accel-group
Since multiple proxies may independently trigger the installation of the accelerator, the action counts the number of times this function has been called and doesn't remove the accelerator until
gtk-action-disconnect-accelerator
has been called as many times.
- action
- a
<gtk-action>
Since 2.4
<gtk-action>
)Undoes the effect of one call to
gtk-action-connect-accelerator
.
- action
- a
<gtk-action>
Since 2.4
<gtk-action>
) (proxy <gtk-widget>
)Disables calls to the
gtk-action-activate
function by signals on the given proxy widget. This is used to break notification loops for things like check or radio actions.This function is intended for use by action implementations.
- action
- the action object
- proxy
- a proxy widget
Since 2.4
<gtk-action>
) (proxy <gtk-widget>
)Re-enables calls to the
gtk-action-activate
function by signals on the given proxy widget. This undoes the blocking done bygtk-action-block-activate-from
.This function is intended for use by action implementations.
- action
- the action object
- proxy
- a proxy widget
Since 2.4
<gtk-action>
) ⇒ (ret mchars
)Returns the accel path for this action.
- action
- the action object
- ret
- the accel path for this action, or ‘
#f
’ if none is set. The returned string is owned by GTK+ and must not be freed or modified.Since 2.6
<gtk-action>
) (accel_path mchars
)Sets the accel path for this action. All proxy widgets associated with the action will have this accel path, so that their accelerators are consistent.
- action
- the action object
- accel-path
- the accelerator path
Since 2.4