gtk.action
Module for [Action] class
Types 3
In GTK+ 3.10, GtkAction has been deprecated. Use #GActioninstead, and associate actions with #GtkActionable widgets. Use #GMenuModel for creating menus with [gtk.menu.Menu.newFromModel].
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:
- 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)
The action will also have some state information:
- visible (shown/hidden)
- sensitive (enabled/disabled)
Apart from regular actions, there are [toggle actions][GtkToggleAction], which can be toggled between two states and [radio actions][GtkRadioAction], of which only one in a group can be in the “active” state. Other actions can be implemented as #GtkAction subclasses.
Each action can have one or more proxy widgets. To act as an action proxy, widget needs to implement #GtkActivatable interface. Proxies mirror the state of the action and should change when the action’s state changes. Properties that are always mirrored by proxies are #GtkAction:sensitive and #GtkAction:visible. #GtkAction:gicon, #GtkAction:icon-name, #GtkAction:label, #GtkAction:short-label and #GtkAction:stock-id properties are only mirorred if proxy widget has #GtkActivatable:use-action-appearance property set to true.
When the proxy is activated, it should activate its action.
ActionGidBuilder builder()Get builder for [gtk.action.Action] Returns: New builder objectgtk.action_group.ActionGroup actionGroup() @propertyGet `actionGroup` property. Returns: The GtkActionGroup this GtkAction is associated with, or NULL (for internal use).void actionGroup(gtk.action_group.ActionGroup propval) @propertySet `actionGroup` property. Params: propval = The GtkActionGroup this GtkAction is associated with, or NULL (for internal use).bool alwaysShowImage() @propertyGet `alwaysShowImage` property. Returns: If true, the action's menu item proxies will ignore the #GtkSettings:gtk-menu-images setting and always show their image, if available.void alwaysShowImage(bool propval) @propertySet `alwaysShowImage` property. Params: propval = If true, the action's menu item proxies will ignore the #GtkSettings:gtk-menu-images setting and always show their image, if available.gio.icon.Icon gicon() @propertyGet `gicon` property. Returns: The #GIcon displayed in the #GtkAction.void gicon(gio.icon.Icon propval) @propertySet `gicon` property. Params: propval = The #GIcon displayed in the #GtkAction.bool hideIfEmpty() @propertyGet `hideIfEmpty` property. Returns: When TRUE, empty menu proxies for this action are hidden.void hideIfEmpty(bool propval) @propertySet `hideIfEmpty` property. Params: propval = When TRUE, empty menu proxies for this action are hidden.string iconName() @propertyGet `iconName` property. Returns: The name of the icon from the icon theme.void iconName(string propval) @propertySet `iconName` property. Params: propval = The name of the icon from the icon theme.bool isImportant() @propertyGet `isImportant` property. Returns: Whether the action is considered important. When TRUE, toolitem proxies for this action show text in GTKTOOLBARBOTH_HORIZ mode.void isImportant(bool propval) @propertySet `isImportant` property. Params: propval = Whether the action is considered important. When TRUE, toolitem proxies for this action show text in GTKTOOLBARBOTH_HORIZ mode.string label() @propertyGet `label` property. Returns: The label used for menu items and buttons that activate this action. If the label is null, GTK+ uses the stock label specified via the stock-id property.void label(string propval) @propertySet `label` property. Params: propval = The label used for menu items and buttons that activate this action. If the label is null, GTK+ uses the stock label specified via the stock-id property.void sensitive(bool propval) @propertySet `sensitive` property. Params: propval = Whether the action is enabled.string shortLabel() @propertyGet `shortLabel` property. Returns: A shorter label that may be used on toolbar buttons.void shortLabel(string propval) @propertySet `shortLabel` property. Params: propval = A shorter label that may be used on toolbar buttons.string stockId() @propertyGet `stockId` property. Returns: The stock icon displayed in widgets representing this action.void stockId(string propval) @propertySet `stockId` property. Params: propval = The stock icon displayed in widgets representing this action.void tooltip(string propval) @propertySet `tooltip` property. Params: propval = A tooltip for this action.void visible(bool propval) @propertySet `visible` property. Params: propval = Whether the action is visible.bool visibleHorizontal() @propertyGet `visibleHorizontal` property. Returns: Whether the toolbar item is visible when the toolbar is in a horizontal orientation.void visibleHorizontal(bool propval) @propertySet `visibleHorizontal` property. Params: propval = Whether the toolbar item is visible when the toolbar is in a horizontal orientation.bool visibleOverflown() @propertyGet `visibleOverflown` property. Returns: When true, toolitem proxies for this action are represented in the toolbar overflow menu.void visibleOverflown(bool propval) @propertySet `visibleOverflown` property. Params: propval = When true, toolitem proxies for this action are represented in the toolbar overflow menu.bool visibleVertical() @propertyGet `visibleVertical` property. Returns: Whether the toolbar item is visible when the toolbar is in a vertical orientation.void visibleVertical(bool propval) @propertySet `visibleVertical` property. Params: propval = Whether the toolbar item is visible when the toolbar is in a vertical orientation.void activate()Emits the “activate” signal on the specified action, if it isn't insensitive. This gets called by the proxy widgets when they get activated.void blockActivate()Disable activation signals from the actionvoid connectAccelerator()Installs the accelerator for action if action has an accel path and group. See [gtk.action.Action.setAccelPath] and [gtk.action.Action.setAccelGroup]gtk.widget.Widget createIcon(gtk.types.IconSize iconSize)This function is intended for use by action implementations to create icons displayed in the proxy widgets.gtk.widget.Widget createMenu()If action provides a #GtkMenu widget as a submenu for the menu item or the toolbar item it creates, this function returns an instance of that menu. Returns: the menu item provided by the action, or...gtk.widget.Widget createMenuItem()Creates a menu item widget that proxies for the given action. Returns: a menu item connected to the action.gtk.widget.Widget createToolItem()Creates a toolbar item widget that proxies for the given action. Returns: a toolbar item connected to the action.void disconnectAccelerator()Undoes the effect of one call to [gtk.action.Action.connectAccelerator].gobject.closure.Closure getAccelClosure()Returns the accel closure for this action. Returns: the accel closure for this action. The returned closure is owned by GTK+ and must not be unreffed or modified.string getAccelPath()Returns the accel path for this action. Returns: the accel path for this action, or null if none is set. The returned string is owned by GTK+ and must not be freed or modified.bool getAlwaysShowImage()Returns whether action's menu item proxies will always show their image, if available. Returns: true if the menu item proxies will always show their imagegio.icon.Icon getGicon()Gets the gicon of action. Returns: The action’s #GIcon if one is set.string getIconName()Gets the icon name of action. Returns: the icon namebool getIsImportant()Checks whether action is important or not Returns: whether action is importantstring getLabel()Gets the label text of action. Returns: the label textstring getName()Returns the name of the action. Returns: the name of the action. The string belongs to GTK+ and should not be freed.gtk.widget.Widget[] getProxies()Returns the proxy widgets for an action. See also [gtk.activatable.Activatable.getRelatedAction]. Returns: a #GSList of proxy widgets. The list is owned by GTK+ and must not be modified.bool getSensitive()Returns whether the action itself is sensitive. Note that this doesn’t necessarily mean effective sensitivity. See [gtk.action.Action.isSensitive] for that. Returns: true if the action itself is ...string getShortLabel()Gets the short label text of action. Returns: the short label text.string getStockId()Gets the stock id of action. Returns: the stock idstring getTooltip()Gets the tooltip text of action. Returns: the tooltip textbool getVisible()Returns whether the action itself is visible. Note that this doesn’t necessarily mean effective visibility. See [gtk.action.Action.isSensitive] for that. Returns: true if the action itself is vis...bool getVisibleHorizontal()Checks whether action is visible when horizontal Returns: whether action is visible when horizontalbool getVisibleVertical()Checks whether action is visible when horizontal Returns: whether action is visible when horizontalbool isSensitive()Returns whether the action is effectively sensitive. Returns: true if the action and its associated action group are both sensitive.bool isVisible()Returns whether the action is effectively visible. Returns: true if the action and its associated action group are both visible.void setAccelGroup(gtk.accel_group.AccelGroup accelGroup = null)Sets the #GtkAccelGroup in which the accelerator for this action will be installed.void setAccelPath(string accelPath)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.void setAlwaysShowImage(bool alwaysShow)Sets whether action's menu item proxies will ignore the #GtkSettings:gtk-menu-images setting and always show their image, if available.void setGicon(gio.icon.Icon icon)Sets the icon of action.void setIconName(string iconName)Sets the icon name on actionvoid setIsImportant(bool isImportant)Sets whether the action is important, this attribute is used primarily by toolbar items to decide whether to show a label or not.void setLabel(string label)Sets the label of action.void setSensitive(bool sensitive)Sets the :sensitive property of the action to sensitive. Note that this doesn’t necessarily mean effective sensitivity. See [gtk.action.Action.isSensitive] for that.void setShortLabel(string shortLabel)Sets a shorter label text on action.void setStockId(string stockId)Sets the stock id on actionvoid setTooltip(string tooltip)Sets the tooltip text on actionvoid setVisible(bool visible)Sets the :visible property of the action to visible. Note that this doesn’t necessarily mean effective visibility. See [gtk.action.Action.isVisible] for that.void setVisibleHorizontal(bool visibleHorizontal)Sets whether action is visible when horizontalvoid setVisibleVertical(bool visibleVertical)Sets whether action is visible when verticalvoid unblockActivate()Reenable activation signals from the actiongulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.action.Action)))
&& Parameters!T.length < 2)Connect to `Activate` signal.this(string name, string label = null, string tooltip = null, string stockId = null)Creates a new #GtkAction object. To add the action to a #GtkActionGroup and set the accelerator for the action, call [gtk.action_group.ActionGroup.addActionWithAccel]. See the [UI Definition sectio...T actionGroup(gtk.action_group.ActionGroup propval)Set `actionGroup` property. Params: propval = The GtkActionGroup this GtkAction is associated with, or NULL (for internal use). Returns: Builder instance for fluent chainingT alwaysShowImage(bool propval)Set `alwaysShowImage` property. Params: propval = If true, the action's menu item proxies will ignore the #GtkSettings:gtk-menu-images setting and always show their image, if available.T gicon(gio.icon.Icon propval)Set `gicon` property. Params: propval = The #GIcon displayed in the #GtkAction.T hideIfEmpty(bool propval)Set `hideIfEmpty` property. Params: propval = When TRUE, empty menu proxies for this action are hidden. Returns: Builder instance for fluent chainingT iconName(string propval)Set `iconName` property. Params: propval = The name of the icon from the icon theme.T isImportant(bool propval)Set `isImportant` property. Params: propval = Whether the action is considered important. When TRUE, toolitem proxies for this action show text in GTKTOOLBARBOTH_HORIZ mode. Returns: Builder instan...T label(string propval)Set `label` property. Params: propval = The label used for menu items and buttons that activate this action. If the label is null, GTK+ uses the stock label specified via the stock-id property.T name(string propval)Set `name` property. Params: propval = A unique name for the action. Returns: Builder instance for fluent chainingT sensitive(bool propval)Set `sensitive` property. Params: propval = Whether the action is enabled. Returns: Builder instance for fluent chainingT shortLabel(string propval)Set `shortLabel` property. Params: propval = A shorter label that may be used on toolbar buttons.T stockId(string propval)Set `stockId` property. Params: propval = The stock icon displayed in widgets representing this action.T tooltip(string propval)Set `tooltip` property. Params: propval = A tooltip for this action. Returns: Builder instance for fluent chainingT visible(bool propval)Set `visible` property. Params: propval = Whether the action is visible. Returns: Builder instance for fluent chainingT visibleHorizontal(bool propval)Set `visibleHorizontal` property. Params: propval = Whether the toolbar item is visible when the toolbar is in a horizontal orientation. Returns: Builder instance for fluent chainingT visibleOverflown(bool propval)Set `visibleOverflown` property. Params: propval = When true, toolitem proxies for this action are represented in the toolbar overflow menu. Returns: Builder instance for fluent chainingT visibleVertical(bool propval)Set `visibleVertical` property. Params: propval = Whether the toolbar item is visible when the toolbar is in a vertical orientation. Returns: Builder instance for fluent chaining