An action which can be triggered by a menu or toolbar item
Class GtkAction( name, [label],[tooltip],[stock_id] )
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 |
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)
The action will also have some state information:
- visible (shown/hidden)
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 GtkAction 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.
Methods | |
activate | Emits the "activate" signal on the specified action, if it isn't insensitive. |
block_activate | Disable activation signals from the action |
connect_accelerator | Installs the accelerator for action if action has an accel path and group. |
create_icon | This function is intended for use by action implementations to create icons displayed in the proxy widgets. |
create_menu | 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. |
create_menu_item | Creates a menu item widget that proxies for the given action. |
create_tool_item | Creates a toolbar item widget that proxies for the given action. |
disconnect_accelerator | Undoes the effect of one call to connect_accelerator(). |
get_accel_path | Returns the accel path for this action. |
get_always_show_image | Returns whether action's menu item proxies will ignore the "gtk-menu-images" setting and always show their image, if available. |
get_icon_name | Gets the icon name of action. |
get_is_important | Checks whether action is important or not |
get_label | Gets the label text of action. |
get_name | Returns the name of the action. |
get_proxies | Returns the proxy widgets for an action. |
get_sensitive | Returns whether the action itself is sensitive. |
get_short_label | Gets the short label text of action. |
get_stock_id | Gets the stock id of action. |
get_tooltip | Gets the tooltip text of action. |
get_visible | Returns whether the action itself is visible. |
get_visible_horizontal | Checks whether action is visible when horizontal |
get_visible_vertical | Checks whether action is visible when horizontal |
is_sensitive | Returns whether the action is effectively sensitive. |
is_visible | Returns whether the action is effectively visible. |
set_accel_path | Sets the accel path for this action. |
set_always_show_image | Sets whether action's menu item proxies will ignore the "gtk-menu-images" setting and always show their image, if available. |
set_icon_name | Sets the icon name on action |
set_is_important | Sets whether the action is important. |
set_label | Sets the label of action. |
set_sensitive | Sets the sensitive property of the action to sensitive. |
set_short_label | Sets a shorter label text on action. |
set_stock_id | Sets the stock id on action |
set_tooltip | Sets the tooltip text on action |
set_visible | Sets the visible property of the action to visible. |
set_visible_horizontal | Sets whether action is visible when horizontal |
set_visible_vertical | Sets whether action is visible when vertical |
signal_activate | The "activate" signal is emitted when the action is activated. |
unblock_activate | Reenable activation signals from the action |
Emits the "activate" signal on the specified action, if it isn't insensitive.
GtkAction.activate()
This gets called by the proxy widgets when they get activated.
It can also be used to manually activate an action.
Disable activation signals from the action
GtkAction.block_activate()
This is needed when updating the state of your proxy GtkActivatable widget could result in calling gtk_action_activate(), this is a convenience function to avoid recursing in those cases (updating toggle state for instance).
Installs the accelerator for action if action has an accel path and group.
GtkAction.connect_accelerator()
See set_accel_path() and 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 disconnect_accelerator() has been called as many times.
This function is intended for use by action implementations to create icons displayed in the proxy widgets.
GtkAction.create_icon( icon_size )
icon_size | the size of the icon that should be created (GtkIconSize). |
Return | a widget that displays the icon for this action (GtkImage). |
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.
GtkAction.create_menu()
Return | the menu item provided by the action (GtkMenu), or nil. |
Creates a menu item widget that proxies for the given action.
GtkAction.create_menu_item()
Return | a menu item connected to the action (GtkMenuItem). |
Creates a toolbar item widget that proxies for the given action.
GtkAction.create_tool_item()
Return | a toolbar item connected to the action (GtkToolItem). |
Undoes the effect of one call to connect_accelerator().
GtkAction.disconnect_accelerator()
Returns the accel path for this action.
GtkAction.get_accel_path()
Return | the accel path for this action, or nil if none is set. |
Returns whether action's menu item proxies will ignore the "gtk-menu-images" setting and always show their image, if available.
GtkAction.get_always_show_image()
Return | true if the menu item proxies will always show their image |
Gets the icon name of action.
GtkAction.get_icon_name()
Return | the icon name. |
Checks whether action is important or not
GtkAction.get_is_important()
Return | whether action is important |
Gets the label text of action.
GtkAction.get_label()
Return | the label text |
Returns the name of the action.
GtkAction.get_name()
Return | the name of the action |
Returns the proxy widgets for an action.
GtkAction.get_proxies()
Return | an array of proxy widgets (GtkWidget). |
See also gtk_widget_get_action().
Returns whether the action itself is sensitive.
GtkAction.get_sensitive()
Return | true if the action itself is sensitive. |
Note that this doesn't necessarily mean effective sensitivity. See is_sensitive() for that.
Gets the short label text of action.
GtkAction.get_short_label()
Return | the short label text |
Gets the stock id of action.
GtkAction.get_stock_id()
Return | the stock id |
Gets the tooltip text of action.
GtkAction.get_tooltip()
Return | the tooltip text |
Returns whether the action itself is visible.
GtkAction.get_visible()
Return | true if the action itself is visible. |
Note that this doesn't necessarily mean effective visibility. See is_sensitive() for that.
Checks whether action is visible when horizontal
GtkAction.get_visible_horizontal()
Return | whether action is visible when horizontal |
Checks whether action is visible when horizontal
GtkAction.get_visible_vertical()
Return | whether action is visible when horizontal |
Returns whether the action is effectively sensitive.
GtkAction.is_sensitive()
Return | true if the action and its associated action group are both sensitive. |
Returns whether the action is effectively visible.
GtkAction.is_visible()
Return | true if the action and its associated action group are both visible. |
Sets the accel path for this action.
GtkAction.set_accel_path( accel_path )
accel_path | the accelerator path (string) |
All proxy widgets associated with the action will have this accel path, so that their accelerators are consistent.
Sets whether action's menu item proxies will ignore the "gtk-menu-images" setting and always show their image, if available.
GtkAction.set_always_show_image()
Use this if the menu item would be useless or hard to use without their image.
Sets the icon name on action
GtkAction.set_icon_name( icon_name )
icon_name | the icon name to set |
Sets whether the action is important.
GtkAction.set_is_important( is_important )
is_important | TRUE to make the action important |
This attribute is used primarily by toolbar items to decide whether to show a label or not.
Sets the label of action.
GtkAction.set_label( label )
label | the label text to set |
Sets the sensitive property of the action to sensitive.
GtkAction.set_sensitive( sensitive )
sensitive | true to make the action sensitive |
Note that this doesn't necessarily mean effective sensitivity. See is_sensitive() for that.
Sets a shorter label text on action.
GtkAction.set_short_label( short_label )
short_label | the label text to set |
Sets the stock id on action
GtkAction.set_stock_id( stock_id )
stock_id | the stock id |
Sets the tooltip text on action
GtkAction.set_tooltip( tooltip )
tooltip | the tooltip text |
Sets the visible property of the action to visible.
GtkAction.set_visible( true )
true | to make the action visible |
Note that this doesn't necessarily mean effective visibility. See is_visible() for that.
Sets whether action is visible when horizontal
GtkAction.set_visible_horizontal( visible_horizontal )
visible_horizontal | whether the action is visible horizontally |
Sets whether action is visible when vertical
GtkAction.set_visible_vertical( visible_vertical )
visible_vertical | whether the action is visible vertically |
The "activate" signal is emitted when the action is activated.
GtkAction.signal_activate()
Reenable activation signals from the action
GtkAction.unblock_activate()