Gtk.Action - Classes - Gtk 3.0 (original) (raw)
g GObject.GInterface GObject.GInterface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.Object GObject.Object Gtk.Action Gtk.Action GObject.Object->Gtk.Action Gtk.Buildable->Gtk.Action
Subclasses:
Gtk.RecentAction, Gtk.ToggleAction
Methods¶
Inherited:
GObject.Object (37), Gtk.Buildable (10)
Structs:
class | new (name, label, tooltip, stock_id) |
---|---|
activate () | |
block_activate () | |
connect_accelerator () | |
create_icon (icon_size) | |
create_menu () | |
create_menu_item () | |
create_tool_item () | |
disconnect_accelerator () | |
get_accel_closure () | |
get_accel_path () | |
get_always_show_image () | |
get_gicon () | |
get_icon_name () | |
get_is_important () | |
get_label () | |
get_name () | |
get_proxies () | |
get_sensitive () | |
get_short_label () | |
get_stock_id () | |
get_tooltip () | |
get_visible () | |
get_visible_horizontal () | |
get_visible_vertical () | |
is_sensitive () | |
is_visible () | |
set_accel_group (accel_group) | |
set_accel_path (accel_path) | |
set_always_show_image (always_show) | |
set_gicon (icon) | |
set_icon_name (icon_name) | |
set_is_important (is_important) | |
set_label (label) | |
set_sensitive (sensitive) | |
set_short_label (short_label) | |
set_stock_id (stock_id) | |
set_tooltip (tooltip) | |
set_visible (visible) | |
set_visible_horizontal (visible_horizontal) | |
set_visible_vertical (visible_vertical) | |
unblock_activate () |
Virtual Methods¶
Inherited:
GObject.Object (7), Gtk.Buildable (10)
do_activate () |
---|
do_connect_proxy (proxy) |
do_create_menu () |
do_create_menu_item () |
do_create_tool_item () |
do_disconnect_proxy (proxy) |
Properties¶
Name | Type | Flags | Short Description |
---|---|---|---|
action-group | Gtk.ActionGroup | r/w | The Gtk.ActionGroup this Gtk.Action is associated with, or None (for internal use). deprecated |
always-show-image | bool | r/w/c | Whether the image will always be shown deprecated |
gicon | Gio.Icon | r/w | The Gio.Icon being displayed deprecated |
hide-if-empty | bool | r/w | When True, empty menu proxies for this action are hidden. deprecated |
icon-name | str | r/w | The name of the icon from the icon theme deprecated |
is-important | bool | r/w | Whether the action is considered important. When True, toolitem proxies for this action show text in Gtk.ToolbarStyle.BOTH_HORIZ mode. deprecated |
label | str | r/w | The label used for menu items and buttons that activate this action. deprecated |
name | str | r/w/co | A unique name for the action. deprecated |
sensitive | bool | r/w | Whether the action is enabled. deprecated |
short-label | str | r/w | A shorter label that may be used on toolbar buttons. deprecated |
stock-id | str | r/w | The stock icon displayed in widgets representing this action. deprecated |
tooltip | str | r/w | A tooltip for this action. deprecated |
visible | bool | r/w | Whether the action is visible. deprecated |
visible-horizontal | bool | r/w | Whether the toolbar item is visible when the toolbar is in a horizontal orientation. deprecated |
visible-overflown | bool | r/w | When True, toolitem proxies for this action are represented in the toolbar overflow menu. deprecated |
visible-vertical | bool | r/w | Whether the toolbar item is visible when the toolbar is in a vertical orientation. deprecated |
Signals¶
Inherited:
Name | Short Description |
---|---|
activate | The “activate” signal is emitted when the action is activated. deprecated |
Fields¶
Inherited:
Name | Type | Access | Description |
---|---|---|---|
object | GObject.Object | r |
Class Details¶
class Gtk.Action(*args, **kwargs)¶
Bases:
Abstract:
No
Structure:
In GTK+ 3.10, Gtk.Action has been deprecated. Use Gio.Actioninstead, and associate actions with Gtk.Actionable widgets. UseGio.MenuModel for creating menus with Gtk.Menu.new_from_model().
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, which can be toggled between two states andradio actions, of which only one in a group can be in the “active” state. Other actions can be implemented as Gtk.Actionsubclasses.
Each action can have one or more proxy widgets. To act as an action proxy, widget needs to implement Gtk.Activatable 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 Gtk.Action :sensitive andGtk.Action :visible. Gtk.Action :gicon, Gtk.Action :icon-name, Gtk.Action :label,Gtk.Action :short-label and Gtk.Action :stock-id properties are only mirorred if proxy widget has Gtk.Activatable :use-action-appearance property set toTrue.
When the proxy is activated, it should activate its action.
classmethod new(name, label, tooltip, stock_id)[source]¶
Parameters:
- name (str) – A unique name for the action
- label (str or None) – the label displayed in menu items and on buttons, or None
- tooltip (str or None) – a tooltip for the action, or None
- stock_id (str or None) – the stock icon to display in widgets representing the action, or None
Returns:
a new Gtk.Action
Return type:
Creates a new Gtk.Action object. To add the action to aGtk.ActionGroup and set the accelerator for the action, call Gtk.ActionGroup.add_action_with_accel(). See the UI Definition section for information on allowed action names.
New in version 2.4.
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.
New in version 2.4.
Disable activation signals from the action
This is needed when updating the state of your proxyGtk.Activatable widget could result in calling Gtk.Action.activate(), this is a convenience function to avoid recursing in those cases (updating toggle state for instance).
New in version 2.16.
connect_accelerator()[source]¶
Installs the accelerator for self if self 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 self counts the number of times this function has been called and doesn’t remove the accelerator untilGtk.Action.disconnect_accelerator() has been called as many times.
New in version 2.4.
Deprecated since version 3.10: Use Gio.Action and the accelerator group on an associated Gtk.Menu instead
create_icon(icon_size)[source]¶
Parameters:
icon_size (int) – the size of the icon (Gtk.IconSize) that should be created.
Returns:
a widget that displays the icon for this action.
Return type:
This function is intended for use by action implementations to create icons displayed in the proxy widgets.
New in version 2.4.
Returns:
the menu item provided by the action, or None.
Return type:
If self provides a Gtk.Menu widget as a submenu for the menu item or the toolbar item it creates, this function returns an instance of that menu.
New in version 2.12.
Returns:
a menu item connected to the action.
Return type:
Creates a menu item widget that proxies for the given action.
New in version 2.4.
Returns:
a toolbar item connected to the action.
Return type:
Creates a toolbar item widget that proxies for the given action.
New in version 2.4.
disconnect_accelerator()[source]¶
Undoes the effect of one call to Gtk.Action.connect_accelerator().
New in version 2.4.
Deprecated since version 3.10: Use Gio.Action and the accelerator group on an associated Gtk.Menu instead
Returns:
the accel closure for this action. The returned closure is owned by GTK+ and must not be unreffed or modified.
Return type:
Returns the accel closure for this action.
New in version 2.8.
Deprecated since version 3.10: Use Gio.Action and Gtk.Menu instead, which have no equivalent for getting the accel closure
Returns:
the accel path for this action, or Noneif none is set. The returned string is owned by GTK+ and must not be freed or modified.
Return type:
Returns the accel path for this action.
New in version 2.6.
Deprecated since version 3.10: Use Gio.Action and the accelerator path on an associated Gtk.Menu instead
get_always_show_image()[source]¶
Returns:
True if the menu item proxies will always show their image
Return type:
Returns whether self's menu item proxies will always show their image, if available.
New in version 2.20.
Returns:
The action’s Gio.Icon if one is set.
Return type:
Gets the gicon of self.
New in version 2.16.
Returns:
the icon name
Return type:
Gets the icon name of self.
New in version 2.16.
Returns:
whether self is important
Return type:
Checks whether self is important or not
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor whether labels are shown directly
Returns:
the label text
Return type:
Gets the label text of self.
New in version 2.16.
Returns:
the name of the action. The string belongs to GTK+ and should not be freed.
Return type:
Returns the name of the action.
New in version 2.4.
Returns:
a GLib.SList of proxy widgets. The list is owned by GTK+ and must not be modified.
Return type:
Returns the proxy widgets for an action. See also Gtk.Activatable.get_related_action().
New in version 2.4.
Deprecated since version 3.10.
Returns:
True if the action itself is sensitive.
Return type:
Returns whether the action itself is sensitive. Note that this doesn’t necessarily mean effective sensitivity. See Gtk.Action.is_sensitive() for that.
New in version 2.4.
Returns:
the short label text.
Return type:
Gets the short label text of self.
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, which has no equivalent of short labels
Returns:
the stock id
Return type:
Gets the stock id of self.
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, which has no equivalent of stock items
Returns:
the tooltip text
Return type:
Gets the tooltip text of self.
New in version 2.16.
Returns:
True if the action itself is visible.
Return type:
Returns whether the action itself is visible. Note that this doesn’t necessarily mean effective visibility. See Gtk.Action.is_sensitive() for that.
New in version 2.4.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the state of Gtk.Actionable widgets directly
get_visible_horizontal()[source]¶
Returns:
whether self is visible when horizontal
Return type:
Checks whether self is visible when horizontal
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the visibility of associated widgets and menu items directly
get_visible_vertical()[source]¶
Returns:
whether self is visible when horizontal
Return type:
Checks whether self is visible when horizontal
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the visibility of associated widgets and menu items directly
Returns:
True if the action and its associated action group are both sensitive.
Return type:
Returns whether the action is effectively sensitive.
New in version 2.4.
Returns:
True if the action and its associated action group are both visible.
Return type:
Returns whether the action is effectively visible.
New in version 2.4.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the state of Gtk.Actionable widgets directly
set_accel_group(accel_group)[source]¶
Parameters:
accel_group (Gtk.AccelGroup or None) – a Gtk.AccelGroup or None
Sets the Gtk.AccelGroup in which the accelerator for this action will be installed.
New in version 2.4.
Deprecated since version 3.10: Use Gio.Action and the accelerator group on an associated Gtk.Menu instead
set_accel_path(accel_path)[source]¶
Parameters:
accel_path (str) – the accelerator path
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.
Note that accel_path string will be stored in a #GQuark. Therefore, if you pass a static string, you can save some memory by interning it first withGLib.intern_static_string().
New in version 2.4.
Deprecated since version 3.10: Use Gio.Action and the accelerator path on an associated Gtk.Menu instead
set_always_show_image(always_show)[source]¶
Parameters:
always_show (bool) – True if menuitem proxies should always show their image
Sets whether self's menu item proxies will ignore theGtk.Settings :gtk-menu-images setting and always show their image, if available.
Use this if the menu item would be useless or hard to use without their image.
New in version 2.20.
Parameters:
icon (Gio.Icon) – the Gio.Icon to set
Sets the icon of self.
New in version 2.16.
set_icon_name(icon_name)[source]¶
Parameters:
icon_name (str) – the icon name to set
Sets the icon name on self
New in version 2.16.
set_is_important(is_important)[source]¶
Parameters:
is_important (bool) – True to make the action important
Sets whether the action is important, this attribute is used primarily by toolbar items to decide whether to show a label or not.
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor whether labels are shown directly
Parameters:
label (str) – the label text to set
Sets the label of self.
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and set a label on a menu item with Gio.MenuItem.set_label(). For Gtk.Actionable widgets, use the widget-specific API to set a label
set_sensitive(sensitive)[source]¶
Parameters:
sensitive (bool) – True to make the action sensitive
Sets the :sensitive property of the action to sensitive. Note that this doesn’t necessarily mean effective sensitivity. SeeGtk.Action.is_sensitive() for that.
New in version 2.6.
set_short_label(short_label)[source]¶
Parameters:
short_label (str) – the label text to set
Sets a shorter label text on self.
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, which has no equivalent of short labels
set_stock_id(stock_id)[source]¶
Parameters:
stock_id (str) – the stock id
Sets the stock id on self
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, which has no equivalent of stock items
Parameters:
tooltip (str) – the tooltip text
Sets the tooltip text on self
New in version 2.16.
Parameters:
visible (bool) – True to make the action visible
Sets the :visible property of the action to visible. Note that this doesn’t necessarily mean effective visibility. SeeGtk.Action.is_visible() for that.
New in version 2.6.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the state of Gtk.Actionable widgets directly
set_visible_horizontal(visible_horizontal)[source]¶
Parameters:
visible_horizontal (bool) – whether the action is visible horizontally
Sets whether self is visible when horizontal
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the visibility of associated widgets and menu items directly
set_visible_vertical(visible_vertical)[source]¶
Parameters:
visible_vertical (bool) – whether the action is visible vertically
Sets whether self is visible when vertical
New in version 2.16.
Deprecated since version 3.10: Use Gio.Action instead, and control and monitor the visibility of associated widgets and menu items directly
Reenable activation signals from the action
New in version 2.16.
do_activate() virtual¶
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.
New in version 2.4.
do_connect_proxy(proxy) virtual¶
Parameters:
proxy (Gtk.Widget) –
Returns:
the menu item provided by the action, or None.
Return type:
If action provides a Gtk.Menu widget as a submenu for the menu item or the toolbar item it creates, this function returns an instance of that menu.
New in version 2.12.
Returns:
a menu item connected to the action.
Return type:
Creates a menu item widget that proxies for the given action.
New in version 2.4.
do_create_tool_item() virtual¶
Returns:
a toolbar item connected to the action.
Return type:
Creates a toolbar item widget that proxies for the given action.
New in version 2.4.
do_disconnect_proxy(proxy) virtual¶
Parameters:
proxy (Gtk.Widget) –
Signal Details¶
Gtk.Action.signals.activate(action)¶
Signal Name:
activate
Flags:
Parameters:
action (Gtk.Action) – The object which received the signal
The “activate” signal is emitted when the action is activated.
New in version 2.4.
Property Details¶
Gtk.Action.props.action_group¶
Name:
action-group
Type:
Default Value:
Flags:
The Gtk.ActionGroup this Gtk.Action is associated with, or None(for internal use).
Gtk.Action.props.always_show_image¶
Name:
always-show-image
Type:
Default Value:
Flags:
If True, the action’s menu item proxies will ignore the Gtk.Settings :gtk-menu-imagessetting and always show their image, if available.
Use this property if the menu item would be useless or hard to use without their image.
New in version 2.20.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.gicon¶
Name:
gicon
Type:
Default Value:
Flags:
The Gio.Icon displayed in the Gtk.Action.
Note that the stock icon is preferred, if the Gtk.Action :stock-idproperty holds the id of an existing stock icon.
This is an appearance property and thus only applies ifGtk.Activatable :use-action-appearance is True.
New in version 2.16.
Deprecated since version 3.10: Use the “icon” attribute on a Gio.MenuItem instead
Gtk.Action.props.hide_if_empty¶
Name:
hide-if-empty
Type:
Default Value:
Flags:
When True, empty menu proxies for this action are hidden.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.icon_name¶
Name:
icon-name
Type:
Default Value:
Flags:
The name of the icon from the icon theme.
Note that the stock icon is preferred, if the Gtk.Action :stock-idproperty holds the id of an existing stock icon, and the Gio.Icon is preferred if the Gtk.Action :gicon property is set.
This is an appearance property and thus only applies ifGtk.Activatable :use-action-appearance is True.
New in version 2.10.
Deprecated since version 3.10: Use the “icon” attribute on a Gio.MenuItem instead
Gtk.Action.props.is_important¶
Name:
is-important
Type:
Default Value:
Flags:
Whether the action is considered important. When True, toolitem proxies for this action show text in Gtk.ToolbarStyle.BOTH_HORIZ mode.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.label¶
Name:
label
Type:
Default Value:
Flags:
The label used for menu items and buttons that activate this action. If the label is None, GTK+ uses the stock label specified via the stock-id property.
This is an appearance property and thus only applies ifGtk.Activatable :use-action-appearance is True.
Deprecated since version 3.10: Use the “label” attribute on Gio.MenuItem instead
Gtk.Action.props.name¶
Name:
name
Type:
Default Value:
Flags:
READABLE, WRITABLE, CONSTRUCT_ONLY
A unique name for the action.
Gtk.Action.props.sensitive¶
Name:
sensitive
Type:
Default Value:
Flags:
Whether the action is enabled.
Gtk.Action.props.short_label¶
Name:
short-label
Type:
Default Value:
Flags:
A shorter label that may be used on toolbar buttons.
This is an appearance property and thus only applies ifGtk.Activatable :use-action-appearance is True.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.stock_id¶
Name:
stock-id
Type:
Default Value:
Flags:
The stock icon displayed in widgets representing this action.
This is an appearance property and thus only applies ifGtk.Activatable :use-action-appearance is True.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.tooltip¶
Name:
tooltip
Type:
Default Value:
Flags:
A tooltip for this action.
Gtk.Action.props.visible¶
Name:
visible
Type:
Default Value:
Flags:
Whether the action is visible.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.visible_horizontal¶
Name:
visible-horizontal
Type:
Default Value:
Flags:
Whether the toolbar item is visible when the toolbar is in a horizontal orientation.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.visible_overflown¶
Name:
visible-overflown
Type:
Default Value:
Flags:
When True, toolitem proxies for this action are represented in the toolbar overflow menu.
New in version 2.6.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action
Gtk.Action.props.visible_vertical¶
Name:
visible-vertical
Type:
Default Value:
Flags:
Whether the toolbar item is visible when the toolbar is in a vertical orientation.
Deprecated since version 3.10: There is no corresponding replacement when using Gio.Action