gtk.action_group

Module for [ActionGroup] class

Types 3

Actions are organised into groups. An action group is essentially a map from names to #GtkAction 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 ## {#Action-Accel}

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 # {#GtkActionGroup-BUILDER-UI}

The #GtkActionGroup implementation of the #GtkBuildable interface accepts #GtkAction 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 #GtkWidget, the main difference is that it doesn’t allow you to specify a signal.

A #GtkDialog 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>

Methods
GType _gType() @property
ActionGroup self()Returns `this`, for use in `with` statements.
ActionGroupGidBuilder builder()Get builder for [gtk.action_group.ActionGroup] Returns: New builder object
gtk.accel_group.AccelGroup accelGroup() @propertyGet `accelGroup` property. Returns: The accelerator group the actions of this group should use.
void accelGroup(gtk.accel_group.AccelGroup propval) @propertySet `accelGroup` property. Params: propval = The accelerator group the actions of this group should use.
string name() @propertyGet `name` property. Returns: A name for the action.
bool sensitive() @propertyGet `sensitive` property. Returns: Whether the action group is enabled.
void sensitive(bool propval) @propertySet `sensitive` property. Params: propval = Whether the action group is enabled.
bool visible() @propertyGet `visible` property. Returns: Whether the action group is visible.
void visible(bool propval) @propertySet `visible` property. Params: propval = Whether the action group is visible.
void addAction(gtk.action.Action action)Adds an action object to the action group. Note that this function does not set up the accel path of the action, which can lead to problems if a user tries to modify the accelerator of a menuitem a...
void addActionWithAccel(gtk.action.Action action, string accelerator = null)Adds an action object to the action group and sets up the accelerator.
gtk.accel_group.AccelGroup getAccelGroup()Gets the accelerator group. Returns: the accelerator group associated with this action group or null if there is none.
gtk.action.Action getAction(string actionName)Looks up an action in the action group by name.
string getName()Gets the name of the action group. Returns: the name of the action group.
bool getSensitive()Returns true if the group is sensitive. The constituent actions can only be logically sensitive (see [gtk.action.Action.isSensitive]) if they are sensitive (see [gtk.action.Action.getSensitive]) a...
bool getVisible()Returns true if the group is visible. The constituent actions can only be logically visible (see [gtk.action.Action.isVisible]) if they are visible (see [gtk.action.Action.getVisible]) and their g...
gtk.action.Action[] listActions()Lists the actions in the action group. Returns: an allocated list of the action objects in the action group
void removeAction(gtk.action.Action action)Removes an action object from the action group.
void setAccelGroup(gtk.accel_group.AccelGroup accelGroup = null)Sets the accelerator group to be used by every action in this group.
void setSensitive(bool sensitive)Changes the sensitivity of action_group
void setTranslateFunc(gtk.types.TranslateFunc func)Sets a function to be used for translating the label and tooltip of #GtkActionEntrys added by [gtk.action_group.ActionGroup.addActions].
void setTranslationDomain(string domain = null)Sets the translation domain and uses [glib.global.dgettext] for translating the label and tooltip of #GtkActionEntrys added by [gtk.action_group.ActionGroup.addActions].
void setVisible(bool visible)Changes the visible of action_group.
string translateString(string string_)Translates a string using the function set with [gtk.action_group.ActionGroup.setTranslateFunc]. This is mainly intended for language bindings.
gulong connectConnectProxy(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.action.Action))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.widget.Widget))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.action_group.ActionGroup))) && Parameters!T.length < 4)Connect to `ConnectProxy` signal.
gulong connectDisconnectProxy(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.action.Action))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.widget.Widget))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.action_group.ActionGroup))) && Parameters!T.length < 4)Connect to `DisconnectProxy` signal.
gulong connectPostActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.action.Action))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.action_group.ActionGroup))) && Parameters!T.length < 3)Connect to `PostActivate` signal.
gulong connectPreActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.action.Action))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.action_group.ActionGroup))) && Parameters!T.length < 3)Connect to `PreActivate` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(string name)Creates a new #GtkActionGroup object. The name of the action group is used when associating [keybindings][Action-Accel] with the actions.
Methods
T accelGroup(gtk.accel_group.AccelGroup propval)Set `accelGroup` property. Params: propval = The accelerator group the actions of this group should use. Returns: Builder instance for fluent chaining
T name(string propval)Set `name` property. Params: propval = A name for the action. Returns: Builder instance for fluent chaining
T sensitive(bool propval)Set `sensitive` property. Params: propval = Whether the action group is enabled. Returns: Builder instance for fluent chaining
T visible(bool propval)Set `visible` property. Params: propval = Whether the action group is visible. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.action_group.ActionGroup]