Gtk.Action¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
The |
||
r/w/c |
Whether the image will always be shown |
||
r/w |
The |
||
r/w |
When |
||
r/w |
The name of the icon from the icon theme |
||
r/w |
Whether the action is considered important. When |
||
r/w |
The label used for menu items and buttons that activate this action. |
||
r/w/co |
A unique name for the action. |
||
r/w |
Whether the action is enabled. |
||
r/w |
A shorter label that may be used on toolbar buttons. |
||
r/w |
The stock icon displayed in widgets representing this action. |
||
r/w |
A tooltip for this action. |
||
r/w |
Whether the action is visible. |
||
r/w |
Whether the toolbar item is visible when the toolbar is in a horizontal orientation. |
||
r/w |
When |
||
r/w |
Whether the toolbar item is visible when the toolbar is in a vertical orientation. |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The “activate” signal is emitted when the action is activated. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
object |
r |
Class Details¶
- class Gtk.Action(*args, **kwargs)¶
- Bases:
- Abstract:
No
- Structure:
In GTK+ 3.10,
Gtk.Action
has been deprecated. UseGio.Action
instead, and associate actions withGtk.Actionable
widgets. UseGio.MenuModel
for creating menus withGtk.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 asGtk.Action
subclasses.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 areGtk.Action
:sensitive
andGtk.Action
:visible
.Gtk.Action
:gicon
,Gtk.Action
:icon-name
,Gtk.Action
:label
,Gtk.Action
:short-label
andGtk.Action
:stock-id
properties are only mirorred if proxy widget hasGtk.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:
- 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, callGtk.ActionGroup.add_action_with_accel
(). See the UI Definition section for information on allowed action names.New in version 2.4.
Deprecated since version 3.10: Use
Gio.Action
instead, associating it to a widget withGtk.Actionable
or creating aGtk.Menu
withGtk.Menu.new_from_model
()
- activate()[source]¶
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.
Deprecated since version 3.10: Use
Gio.ActionGroup.activate_action
() on aGio.Action
instead
- block_activate()[source]¶
Disable activation signals from the action
This is needed when updating the state of your proxy
Gtk.Activatable
widget could result in callingGtk.Action.activate
(), this is a convenience function to avoid recursing in those cases (updating toggle state for instance).New in version 2.16.
Deprecated since version 3.10: Use
Gio.SimpleAction.set_enabled
() to disable theGio.SimpleAction
instead
- 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 until
Gtk.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 associatedGtk.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.
Deprecated since version 3.10: Use
Gio.MenuItem.set_icon
() to set an icon on aGio.MenuItem
, orGtk.Container.add
() to add aGtk.Image
to aGtk.Button
- 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.
Deprecated since version 3.10: Use
Gio.Action
andGio.MenuModel
instead, and create aGtk.Menu
withGtk.Menu.new_from_model
()
- 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.
Deprecated since version 3.10: Use
Gio.MenuItem.new
() and associate it with aGio.Action
instead.
- create_tool_item()[source]¶
- 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.
Deprecated since version 3.10: Use a
Gtk.ToolItem
and associate it with aGio.Action
usingGtk.Actionable.set_action_name
() instead
- 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 associatedGtk.Menu
instead
- get_accel_closure()[source]¶
- 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
andGtk.Menu
instead, which have no equivalent for getting the accel closure
- get_accel_path()[source]¶
- Returns:
the accel path for this action, or
None
if 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 associatedGtk.Menu
instead
- get_always_show_image()[source]¶
-
Returns whether self's menu item proxies will always show their image, if available.
New in version 2.20.
Deprecated since version 3.10: Use
Gio.MenuItem.get_attribute_value
() on aGio.MenuItem
instead
- get_gicon()[source]¶
-
Gets the gicon of self.
New in version 2.16.
Deprecated since version 3.10: Use
Gio.Action
instead, andGio.MenuItem.get_attribute_value
() to get an icon from aGio.MenuItem
associated with aGio.Action
- get_icon_name()[source]¶
- Returns:
the icon name
- Return type:
Gets the icon name of self.
New in version 2.16.
Deprecated since version 3.10: Use
Gio.Action
instead, andGio.MenuItem.get_attribute_value
() to get an icon from aGio.MenuItem
associated with aGio.Action
- get_is_important()[source]¶
- 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
- get_label()[source]¶
- Returns:
the label text
- Return type:
Gets the label text of self.
New in version 2.16.
Deprecated since version 3.10: Use
Gio.Action
instead, and get a label from a menu item withGio.MenuItem.get_attribute_value
(). ForGtk.Actionable
widgets, use the widget-specific API to get a label
- get_name()[source]¶
- 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.
Deprecated since version 3.10: Use
Gio.Action.get_name
() on aGio.Action
instead
- get_proxies()[source]¶
- 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.
- get_sensitive()[source]¶
-
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.
Deprecated since version 3.10: Use
Gio.Action.get_enabled
() on aGio.Action
instead
- get_short_label()[source]¶
- 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
- get_stock_id()[source]¶
- 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
- get_tooltip()[source]¶
- Returns:
the tooltip text
- Return type:
Gets the tooltip text of self.
New in version 2.16.
Deprecated since version 3.10: Use
Gio.Action
instead, and get tooltips from associatedGtk.Actionable
widgets withGtk.Widget.get_tooltip_text
()
- get_visible()[source]¶
-
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 ofGtk.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
- is_sensitive()[source]¶
-
Returns whether the action is effectively sensitive.
New in version 2.4.
Deprecated since version 3.10: Use
Gio.Action.get_enabled
() on aGio.Action
instead
- is_visible()[source]¶
-
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 ofGtk.Actionable
widgets directly
- set_accel_group(accel_group)[source]¶
- Parameters:
accel_group (
Gtk.AccelGroup
orNone
) – aGtk.AccelGroup
orNone
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 associatedGtk.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 with
GLib.intern_static_string
().New in version 2.4.
Deprecated since version 3.10: Use
Gio.Action
and the accelerator path on an associatedGtk.Menu
instead
- set_always_show_image(always_show)[source]¶
-
Sets whether self's menu item proxies will ignore the
Gtk.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.
Deprecated since version 3.10: Use
Gio.MenuItem.set_icon
() on aGio.MenuItem
instead, if the item should have an image
- set_gicon(icon)[source]¶
-
Sets the icon of self.
New in version 2.16.
Deprecated since version 3.10: Use
Gio.Action
instead, andGio.MenuItem.set_icon
() to set an icon on aGio.MenuItem
associated with aGio.Action
, orGtk.Container.add
() to add aGtk.Image
to aGtk.Button
- 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.
Deprecated since version 3.10: Use
Gio.Action
instead, andGio.MenuItem.set_icon
() to set an icon on aGio.MenuItem
associated with aGio.Action
, orGtk.Container.add
() to add aGtk.Image
to aGtk.Button
- set_is_important(is_important)[source]¶
-
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
- set_label(label)[source]¶
- 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 withGio.MenuItem.set_label
(). ForGtk.Actionable
widgets, use the widget-specific API to set a label
- set_sensitive(sensitive)[source]¶
-
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.
Deprecated since version 3.10: Use
Gio.SimpleAction.set_enabled
() on aGio.SimpleAction
instead
- 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
- set_tooltip(tooltip)[source]¶
- Parameters:
tooltip (
str
) – the tooltip text
Sets the tooltip text on self
New in version 2.16.
Deprecated since version 3.10: Use
Gio.Action
instead, and set tooltips on associatedGtk.Actionable
widgets withGtk.Widget.set_tooltip_text
()
- set_visible(visible)[source]¶
-
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 ofGtk.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
- unblock_activate()[source]¶
Reenable activation signals from the action
New in version 2.16.
Deprecated since version 3.10: Use
Gio.SimpleAction.set_enabled
() to enable theGio.SimpleAction
instead
- 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.
Deprecated since version 3.10: Use
Gio.ActionGroup.activate_action
() on aGio.Action
instead
- 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.
Deprecated since version 3.10: Use
Gio.Action
andGio.MenuModel
instead, and create aGtk.Menu
withGtk.Menu.new_from_model
()
- 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.
Deprecated since version 3.10: Use
Gio.MenuItem.new
() and associate it with aGio.Action
instead.
- 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.
Deprecated since version 3.10: Use a
Gtk.ToolItem
and associate it with aGio.Action
usingGtk.Actionable.set_action_name
() instead
- 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.
Deprecated since version 3.10: Use
Gio.SimpleAction
::activate
instead
Property Details¶
- Gtk.Action.props.action_group¶
- Name:
action-group
- Type:
- Default Value:
- Flags:
The
Gtk.ActionGroup
thisGtk.Action
is associated with, orNone
(for internal use).Deprecated since version 3.10: Lookup the
Gio.Action
usingGio.ActionMap.lookup_action
() instead
- Gtk.Action.props.always_show_image¶
-
If
True
, the action’s menu item proxies will ignore theGtk.Settings
:gtk-menu-images
setting 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¶
-
The
Gio.Icon
displayed in theGtk.Action
.Note that the stock icon is preferred, if the
Gtk.Action
:stock-id
property holds the id of an existing stock icon.This is an appearance property and thus only applies if
Gtk.Activatable
:use-action-appearance
isTrue
.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¶
-
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¶
-
The name of the icon from the icon theme.
Note that the stock icon is preferred, if the
Gtk.Action
:stock-id
property holds the id of an existing stock icon, and theGio.Icon
is preferred if theGtk.Action
:gicon
property is set.This is an appearance property and thus only applies if
Gtk.Activatable
:use-action-appearance
isTrue
.New in version 2.10.
Deprecated since version 3.10: Use the “icon” attribute on a
Gio.MenuItem
instead
- Gtk.Action.props.is_important¶
-
Whether the action is considered important. When
True
, toolitem proxies for this action show text inGtk.ToolbarStyle.BOTH_HORIZ
mode.Deprecated since version 3.10: There is no corresponding replacement when using
Gio.Action
- Gtk.Action.props.label¶
-
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 if
Gtk.Activatable
:use-action-appearance
isTrue
.Deprecated since version 3.10: Use the “label” attribute on
Gio.MenuItem
instead
- Gtk.Action.props.name¶
- Name:
name
- Type:
- Default Value:
- Flags:
A unique name for the action.
Deprecated since version 3.10: Use
Gio.Action
:name
instead
- Gtk.Action.props.sensitive¶
-
Whether the action is enabled.
Deprecated since version 3.10: Use
Gio.Action
:enabled
andGio.SimpleAction
:enabled
instead
- Gtk.Action.props.short_label¶
-
A shorter label that may be used on toolbar buttons.
This is an appearance property and thus only applies if
Gtk.Activatable
:use-action-appearance
isTrue
.Deprecated since version 3.10: There is no corresponding replacement when using
Gio.Action
- Gtk.Action.props.stock_id¶
-
The stock icon displayed in widgets representing this action.
This is an appearance property and thus only applies if
Gtk.Activatable
:use-action-appearance
isTrue
.Deprecated since version 3.10: There is no corresponding replacement when using
Gio.Action
- Gtk.Action.props.tooltip¶
-
A tooltip for this action.
Deprecated since version 3.10: Use
Gtk.Widget.set_tooltip_text
() instead
- Gtk.Action.props.visible¶
-
Whether the action is visible.
Deprecated since version 3.10: There is no corresponding replacement when using
Gio.Action
- Gtk.Action.props.visible_horizontal¶
-
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¶
-
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