Gio.ActionGroup
const Gio = imports.gi.Gio; let action_group = new Gio.ActionGroup();
Gio.ActionGroup represents a group of actions. Actions can be used to expose functionality in a structured way, either from one part of a program to another, or to the outside world. Action groups are often used together with a Gio.MenuModel that provides additional representation data for displaying the actions to the user, e.g. in a menu.
The main way to interact with the actions in a GActionGroup is to activate them with Gio.ActionGroup.prototype.activate_action. Activating an action may require a GLib.Variant parameter. The required type of the parameter can be inquired with Gio.ActionGroup.prototype.get_action_parameter_type. Actions may be disabled, see Gio.ActionGroup.prototype.get_action_enabled. Activating a disabled action has no effect.
Actions may optionally have a state in the form of a GLib.Variant. The current state of an action can be inquired with Gio.ActionGroup.prototype.get_action_state. Activating a stateful action may change its state, but it is also possible to set the state by calling Gio.ActionGroup.prototype.change_action_state.
As typical example, consider a text editing application which has an option to change the current font to 'bold'. A good way to represent this would be a stateful action, with a boolean state. Activating the action would toggle the state.
Each action in the group has a unique name (which is a string). All method calls, except Gio.ActionGroup.prototype.list_actions take the name of an action as an argument.
The Gio.ActionGroup API is meant to be the 'public' API to the action group. The calls here are exactly the interaction that 'external forces' (eg: UI, incoming D-Bus messages, etc.) are supposed to have with actions. 'Internal' APIs (ie: ones meant only to be accessed by the action group implementation) are found on subclasses. This is why you will find - for example - Gio.ActionGroup.prototype.get_action_enabled but not an equivalent set() call.
Signals are emitted on the action group in response to state changes on individual actions.
Implementations of Gio.ActionGroup should provide implementations for the virtual functions Gio.ActionGroup.prototype.list_actions and Gio.ActionGroup.prototype.query_action. The other virtual functions should not be implemented - their "wrappers" are actually implemented with calls to Gio.ActionGroup.prototype.query_action.
Prerequisites
ActionGroup requires GObject.Object
Known Implementations
ActionGroup is implemented by Application, DBusActionGroup and SimpleActionGroup
Methods
- Gio.ActionGroup.prototype.action_added
- Gio.ActionGroup.prototype.action_enabled_changed
- Gio.ActionGroup.prototype.action_removed
- Gio.ActionGroup.prototype.action_state_changed
- Gio.ActionGroup.prototype.activate_action
- Gio.ActionGroup.prototype.change_action_state
- Gio.ActionGroup.prototype.get_action_enabled
- Gio.ActionGroup.prototype.get_action_parameter_type
- Gio.ActionGroup.prototype.get_action_state
- Gio.ActionGroup.prototype.get_action_state_hint
- Gio.ActionGroup.prototype.get_action_state_type
- Gio.ActionGroup.prototype.has_action
- Gio.ActionGroup.prototype.list_actions
- Gio.ActionGroup.prototype.query_action
Virtual functions
- Gio.ActionGroup::action_added
- Gio.ActionGroup::action_enabled_changed
- Gio.ActionGroup::action_removed
- Gio.ActionGroup::action_state_changed
- Gio.ActionGroup::activate_action
- Gio.ActionGroup::change_action_state
- Gio.ActionGroup::get_action_enabled
- Gio.ActionGroup::get_action_parameter_type
- Gio.ActionGroup::get_action_state
- Gio.ActionGroup::get_action_state_hint
- Gio.ActionGroup::get_action_state_type
- Gio.ActionGroup::has_action
- Gio.ActionGroup::list_actions
- Gio.ActionGroup::query_action