Warning: ActionGroup is deprecated since 3.10.
Actions are organised into groups.
An action group is essentially a map from names to Action objects.
All actions that would make sense to use in a particular context should be in a single group. Multiple action groups may be used for a
particular user interface. In fact, it is expected that most nontrivial applications will make use of multiple groups. For example, in an
application that can edit multiple documents, one group holding global actions (e.g. quit, about, new), and one group per document holding
actions that act on that document (eg. save, cut/copy/paste, etc). Each window’s menus would be constructed from a combination of two
action groups.
Accelerators
Accelerators are handled by the GTK+ accelerator map. All actions are assigned an accelerator path (which normally has the form `<
Actions>/group-name/action-name`) and a shortcut is associated with this accelerator path. All menuitems and toolitems take on this
accelerator path. The GTK+ accelerator map code makes sure that the correct shortcut is displayed next to the menu item.
GtkActionGroup as GtkBuildable
The ActionGroup implementation of the Buildable interface
accepts Action objects as `<child>` elements in UI definitions.
Note that it is probably more common to define actions and action groups in the code, since they are directly related to what the code
can do.
The GtkActionGroup implementation of the GtkBuildable interface supports a custom `<accelerator>` element, which has attributes
named “key“ and “modifiers“ and allows to specify accelerators. This is similar to the `<accelerator>` element of
Widget, the main difference is that it doesn’t allow you to specify a signal.
A Dialog UI definition fragment.
<object class="GtkActionGroup" id="actiongroup">
<child>
<object class="GtkAction" id="About">
<property name="name">About</property>
<property name="stock_id">gtk-about</property>
<signal handler="about_activate" name="activate"/>
</object>
<accelerator key="F1" modifiers="GDK_CONTROL_MASK | GDK_SHIFT_MASK"/>
</child>
</object>
- public void add_action (Action action)
Adds an action object to the action group.
- public void add_action_with_accel (Action action, string? accelerator)
Adds an action object to the action group and sets up the accelerator.
- public void add_actions (ActionEntry[] entries, void* user_data)
This is a convenience function to create a number of actions and add
them to the action group.
- public void add_actions_full (ActionEntry[] entries, void* user_data, DestroyNotify? destroy)
This variant of
add_actions adds a DestroyNotify callback
for user_data
.
- public void add_radio_actions (RadioActionEntry[] entries, int value, RadioActionCallback on_change)
This is a convenience routine to create a group of radio actions and
add them to the action group.
- public void add_radio_actions_full (RadioActionEntry[] entries, int value, owned RadioActionCallback on_change)
- public void add_toggle_actions (ToggleActionEntry[] entries, void* user_data)
This is a convenience function to create a number of toggle actions
and add them to the action group.
- public void add_toggle_actions_full (ToggleActionEntry[] entries, void* user_data, DestroyNotify? destroy)
- public unowned AccelGroup get_accel_group ()
Gets the accelerator group.
- public virtual unowned Action get_action (string action_name)
Looks up an action in the action group by name.
- public bool get_sensitive ()
Returns true if the group is
sensitive.
- public bool get_visible ()
Returns true if the group is
visible.
- public List<unowned Action> list_actions ()
Lists the actions in the action group.
- public void remove_action (Action action)
Removes an action object from the action group.
- public void set_accel_group (AccelGroup? accel_group)
Sets the accelerator group to be used by every action in this group.
- public void set_sensitive (bool sensitive)
Changes the sensitivity of this
- public void set_translate_func (owned TranslateFunc func)
- public void set_translation_domain (string? domain)
Sets the translation domain and uses dgettext
for translating the label
and tooltip
of ActionEntry
s added by add_actions.
- public void set_visible (bool visible)
Changes the visible of this.
- public unowned string translate_string (string str)