Next: , Previous: GtkUIManager, Up: Top


73 GtkActionGroup

A group of actions

73.1 Overview

Actions are organised into groups. An action group is essentially a map from names to <gtk-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 are handled by the GTK+ accelerator map. All actions are assigned an accelerator path (which normally has the form ‘<Actions>//’) 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.

73.2 Usage

— Class: <gtk-action-group>

Derives from <gtk-buildable>, <gobject>.

This class defines the following slots:

name
A name for the action group.
sensitive
Whether the action group is enabled.
visible
Whether the action group is visible.
— Signal on <gtk-action-group>: connect-proxy (arg0 <gtk-action>) (arg1 <gtk-widget>)

The connect_proxy signal is emitted after connecting a proxy to an action in the group. Note that the proxy may have been connected to a different action before.

This is intended for simple customizations for which a custom action class would be too clumsy, e.g. showing tooltips for menuitems in the statusbar.

<gtk-ui-manager> proxies the signal and provides global notification just before any action is connected to a proxy, which is probably more convenient to use.

Since 2.4

— Signal on <gtk-action-group>: disconnect-proxy (arg0 <gtk-action>) (arg1 <gtk-widget>)

The disconnect_proxy signal is emitted after disconnecting a proxy from an action in the group.

<gtk-ui-manager> proxies the signal and provides global notification just before any action is connected to a proxy, which is probably more convenient to use.

Since 2.4

— Signal on <gtk-action-group>: pre-activate (arg0 <gtk-action>)

The pre_activate signal is emitted just before the action in the action-group is activated

This is intended for <gtk-ui-manager> to proxy the signal and provide global notification just before any action is activated.

Since 2.4

— Signal on <gtk-action-group>: post-activate (arg0 <gtk-action>)

The post_activate signal is emitted just after the action in the action-group is activated

This is intended for <gtk-ui-manager> to proxy the signal and provide global notification just after any action is activated.

Since 2.4

— Function: gtk-action-group-new (name mchars) ⇒  (ret <gtk-action-group>)

Creates a new <gtk-action-group> object. The name of the action group is used when associating keybindings with the actions.

name
the name of the action group.
ret
the new <gtk-action-group>

Since 2.4

— Function: gtk-action-group-get-name (self <gtk-action-group>) ⇒  (ret mchars)
— Method: get-name

Gets the name of the action group.

action-group
the action group
ret
the name of the action group.

Since 2.4

— Function: gtk-action-group-get-sensitive (self <gtk-action-group>) ⇒  (ret bool)
— Method: get-sensitive

Returns ‘#t’ if the group is sensitive. The constituent actions can only be logically sensitive (see gtk-action-is-sensitive) if they are sensitive (see gtk-action-get-sensitive) and their group is sensitive.

action-group
the action group
ret
#t’ if the group is sensitive.

Since 2.4

— Function: gtk-action-group-set-sensitive (self <gtk-action-group>) (sensitive bool)
— Method: set-sensitive

Changes the sensitivity of action-group

action-group
the action group
sensitive
new sensitivity

Since 2.4

— Function: gtk-action-group-get-visible (self <gtk-action-group>) ⇒  (ret bool)
— Method: get-visible

Returns ‘#t’ if the group is visible. The constituent actions can only be logically visible (see gtk-action-is-visible) if they are visible (see gtk-action-get-visible) and their group is visible.

action-group
the action group
ret
#t’ if the group is visible.

Since 2.4

— Function: gtk-action-group-set-visible (self <gtk-action-group>) (visible bool)
— Method: set-visible

Changes the visible of action-group.

action-group
the action group
visible
new visiblity

Since 2.4

— Function: gtk-action-group-get-action (self <gtk-action-group>) (action_name mchars) ⇒  (ret <gtk-action>)
— Method: get-action

Looks up an action in the action group by name.

action-group
the action group
action-name
the name of the action
ret
the action, or ‘#f’ if no action by that name exists

Since 2.4

— Function: gtk-action-group-list-actions (self <gtk-action-group>) ⇒  (ret glist-of)
— Method: list-actions

Lists the actions in the action group.

action-group
the action group
ret
an allocated list of the action objects in the action group

Since 2.4

— Function: gtk-action-group-add-action (self <gtk-action-group>) (action <gtk-action>)
— Method: add-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 associated with the action. Therefore you must either set the accel path yourself with gtk-action-set-accel-path, or use ‘gtk_action_group_add_action_with_accel (..., NULL)’.

action-group
the action group
action
an action

Since 2.4

— Function: gtk-action-group-remove-action (self <gtk-action-group>) (action <gtk-action>)
— Method: remove-action

Removes an action object from the action group.

action-group
the action group
action
an action

Since 2.4

— Function: gtk-action-group-add-actions (self <gtk-action-group>) (entries scm)
— Method: add-actions

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>//’.

action-group
The action group
scm
An list of actions. The actions are of the form (name stock-id label accelerator tooltip proc?). All values are strings except the proc, which should be a procedure suitable for connecting to the activate signal on the action. stock-id, label, accelerator, tooltip, and proc may be #f.

Since 2.4

— Function: gtk-action-group-add-toggle-actions (self <gtk-action-group>) (entries scm)
— Method: add-toggle-actions

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

Since 2.4

— Function: gtk-action-group-add-radio-actions (self <gtk-action-group>) (entries scm) (value int) (on_change scm)
— Method: add-radio-actions

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

Since 2.4

— Function: gtk-action-group-translate-string (self <gtk-action-group>) (string mchars) ⇒  (ret mchars)
— Method: translate-string

Translates a string using the specified translate-func. This is mainly intended for language bindings.

action-group
a <gtk-action-group>
string
a string
ret
the translation of string

Since 2.6