W Wrapl, The Programming Language

Libraries:Gtk:Gtk:ActionGroup

Types

T

Inherits from:

Actions are organised into groups. An action group is essentially a map from names to Gtk.Gtk.Action.T 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 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 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.

Example 38. A GtkDialog UI definition fragment.

1
2
3
4
5
6
7
8
9
10
<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>




Constants

Nil : T

Functions

GetType() : Gtk.GObject.Type.T



New(name @ Std.String.T) : Gtk.Gtk.ActionGroup.T

Creates a new T object. The name of the action group is used when associating keybindings with the actions.

name the name of the action group.
Returns the new T


Methods

:AddAction(self @ T, action @ Gtk.Gtk.Action.T) : Std.Object.T

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 associated with the action. Therefore you must either set the accel path yourself with Gtk.Gtk.Action.SetAccelPath, or use gtk_action_group_add_action_with_accel (..., NULL).

action_group the action group
action an action


:AddActionWithAccel(self @ T, action @ Gtk.Gtk.Action.T, accelerator @ Std.String.T) : Std.Object.T

Adds an action object to the action group and sets up the accelerator.

If accelerator is NULL, attempts to use the accelerator associated with the stock_id of the action.

Accel paths are set to <Actions>/group-name/action-name.

action_group the action group
action the action to add
accelerator the accelerator for the action, in the format understood by Gtk.Gtk.Accelerator.Parse, or "" for no accelerator, or NULL to use the stock accelerator. [allow-none]


:AddActions(self @ T, entries @ Gtk.Gtk.ActionEntry.T, n_entries @ Std.Integer.SmallT, user_data) : Std.Object.T

This is a convenience function to create a number of actions and add them to the action group.

The "activate" signals of the actions are connected to the callbacks and their accel paths are set to <Actions>/group-name/action-name.

action_group the action group
entries an array of action descriptions
n_entries the number of entries
user_data data to pass to the action callbacks


:AddActionsFull(self @ T, entries @ Gtk.Gtk.ActionEntry.T, n_entries @ Std.Integer.SmallT, user_data, destroy @ Std.Function.T) : Std.Object.T

This variant of AddActions adds a GDestroyNotify callback for user_data.

action_group the action group
entries an array of action descriptions
n_entries the number of entries
user_data data to pass to the action callbacks
destroy destroy notification callback for user_data


:AddRadioActions(self @ T, entries @ Gtk.Gtk.RadioActionEntry.T, n_entries @ Std.Integer.SmallT, value @ Std.Integer.SmallT, on_change @ Std.Object.T, user_data) : Std.Object.T

This is a convenience routine to create a group of radio actions and add them to the action group.

The "changed" signal of the first radio action is connected to the on_change callback and the accel paths of the actions are set to <Actions>/group-name/action-name.

action_group the action group
entries an array of radio action descriptions
n_entries the number of entries
value the value of the action to activate initially, or -1 if no action should be activated
on_change the callback to connect to the changed signal
user_data data to pass to the action callbacks


:AddRadioActionsFull(self @ T, entries @ Gtk.Gtk.RadioActionEntry.T, n_entries @ Std.Integer.SmallT, value @ Std.Integer.SmallT, on_change @ Std.Object.T, user_data, destroy @ Std.Function.T) : Std.Object.T

This variant of AddRadioActions adds a GDestroyNotify callback for user_data.

action_group the action group
entries an array of radio action descriptions
n_entries the number of entries
value the value of the action to activate initially, or -1 if no action should be activated
on_change the callback to connect to the changed signal
user_data data to pass to the action callbacks
destroy destroy notification callback for user_data


:AddToggleActions(self @ T, entries @ Gtk.Gtk.ToggleActionEntry.T, n_entries @ Std.Integer.SmallT, user_data) : Std.Object.T

This is a convenience function to create a number of toggle actions and add them to the action group.

The "activate" signals of the actions are connected to the callbacks and their accel paths are set to <Actions>/group-name/action-name.

action_group the action group
entries an array of toggle action descriptions
n_entries the number of entries
user_data data to pass to the action callbacks


:AddToggleActionsFull(self @ T, entries @ Gtk.Gtk.ToggleActionEntry.T, n_entries @ Std.Integer.SmallT, user_data, destroy @ Std.Function.T) : Std.Object.T

This variant of AddToggleActions adds a GDestroyNotify callback for user_data.

action_group the action group
entries an array of toggle action descriptions
n_entries the number of entries
user_data data to pass to the action callbacks
destroy destroy notification callback for user_data


:GetAction(self @ T, action_name @ Std.String.T) : Gtk.Gtk.Action.T

Looks up an action in the action group by name.

action_group the action group
action_name the name of the action
Returns the action, or NULL if no action by that name exists. [transfer none]


:GetName(self @ T) : Std.String.T

Gets the name of the action group.

action_group the action group
Returns the name of the action group.


:GetSensitive(self @ T) : Std.Symbol.T

Returns TRUE if the group is sensitive. The constituent actions can only be logically sensitive (see Gtk.Gtk.Action.IsSensitive) if they are sensitive (see Gtk.Gtk.Action.GetSensitive) and their group is sensitive.

action_group the action group
Returns TRUE if the group is sensitive.


:GetVisible(self @ T) : Std.Symbol.T

Returns TRUE if the group is visible. The constituent actions can only be logically visible (see Gtk.Gtk.Action.IsVisible) if they are visible (see Gtk.Gtk.Action.GetVisible) and their group is visible.

action_group the action group
Returns TRUE if the group is visible.


:ListActions(self @ T) : Std.Object.T

Lists the actions in the action group.

action_group the action group
Returns an allocated list of the action objects in the action group. [element-type GtkAction][transfer container]


:RemoveAction(self @ T, action @ Gtk.Gtk.Action.T) : Std.Object.T

Removes an action object from the action group.

action_group the action group
action an action


:SetSensitive(self @ T, sensitive @ Std.Symbol.T) : Std.Object.T

Changes the sensitivity of action_group

action_group the action group
sensitive new sensitivity


:SetTranslateFunc(self @ T, func @ Std.Function.T, data @ Std.Address.T, notify @ Std.Function.T) : Std.Object.T

Sets a function to be used for translating the label and tooltip of GtkActionGroupEntrys added by AddActions.

If you're using gettext(), it is enough to set the translation domain with SetTranslationDomain.

action_group a T
func a Gtk.Gtk.TranslateFunc
data data to be passed to func and notify
notify a GDestroyNotify function to be called when action_group is destroyed and when the translation function is changed again


:SetTranslationDomain(self @ T, domain @ Std.String.T) : Std.Object.T

Sets the translation domain and uses g_dgettext() for translating the label and tooltip of Gtk.Gtk.ActionEntry.Ts added by AddActions.

If you're not using gettext() for localization, see SetTranslateFunc.

action_group a T
domain the translation domain to use for g_dgettext() calls


:SetVisible(self @ T, visible @ Std.Symbol.T) : Std.Object.T

Changes the visible of action_group.

action_group the action group
visible new visiblity


:TranslateString(self @ T, string @ Std.String.T) : Std.String.T

Translates a string using the specified translate_func(). This is mainly intended for language bindings.

action_group a T
string a string
Returns the translation of string