### Interface

# Gio ActionGroup

since: 2.0

#### Description

    interface Gio.ActionGroup : GObject.Object

`GActionGroup` 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 `GMenuModel` 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 `g_action_group_activate_action()`. Activating an action may require a `GVariant` parameter. The required type of the parameter can be inquired with `g_action_group_get_action_parameter_type()`. Actions may be disabled, see `g_action_group_get_action_enabled()`. Activating a disabled action has no effect.

Actions may optionally have a state in the form of a `GVariant`. The current state of an action can be inquired with `g_action_group_get_action_state()`. Activating a stateful action may change its state, but it is also possible to set the state by calling `g_action_group_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 `g_action_group_list_actions()` take the name of an action as an argument.

The `GActionGroup` 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 - `g_action_group_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 `GActionGroup` should provide implementations for the virtual functions `g_action_group_list_actions()` and `g_action_group_query_action()`. The other virtual functions should not be implemented - their “wrappers” are actually implemented with calls to `g_action_group_query_action()`.

Available since: 2.0

#### Prerequisite

In order to implement ActionGroup, your type must inherit from`GObject`.

#### Implementations

- GApplication
- GDBusActionGroup
- GSimpleActionGroup

#### Instance methods

###### g_action_group_action_added

Emits the `GActionGroup::action-added` signal on `action_group`.

since: 2.28

###### g_action_group_action_enabled_changed

Emits the `GActionGroup::action-enabled-changed` signal on `action_group`.

since: 2.28

###### g_action_group_action_removed

Emits the `GActionGroup::action-removed` signal on `action_group`.

since: 2.28

###### g_action_group_action_state_changed

Emits the `GActionGroup::action-state-changed` signal on `action_group`.

since: 2.28

###### g_action_group_activate_action

Activate the named action within `action_group`.

since: 2.28

###### g_action_group_change_action_state

Request for the state of the named action within `action_group` to be changed to `value`.

since: 2.28

###### g_action_group_get_action_enabled

Checks if the named action within `action_group` is currently enabled.

since: 2.28

###### g_action_group_get_action_parameter_type

Queries the type of the parameter that must be given when activating the named action within `action_group`.

since: 2.28

###### g_action_group_get_action_state

Queries the current state of the named action within `action_group`.

since: 2.28

###### g_action_group_get_action_state_hint

Requests a hint about the valid range of values for the state of the named action within `action_group`.

since: 2.28

###### g_action_group_get_action_state_type

Queries the type of the state of the named action within `action_group`.

since: 2.28

###### g_action_group_has_action

Checks if the named action exists within `action_group`.

since: 2.28

###### g_action_group_list_actions

Lists the actions contained within `action_group`.

since: 2.28

###### g_action_group_query_action

Queries all aspects of the named action within an `action_group`.

since: 2.32

#### Signals

###### Gio.ActionGroup::action-added

Signals that a new action was just added to the group. This signal is emitted after the action has been added and is now visible.

since: 2.28

###### Gio.ActionGroup::action-enabled-changed

Signals that the enabled status of the named action has changed.

since: 2.28

###### Gio.ActionGroup::action-removed

Signals that an action is just about to be removed from the group. This signal is emitted before the action is removed, so the action is still visible and can be queried from the signal handler.

since: 2.28

###### Gio.ActionGroup::action-state-changed

Signals that the state of the named action has changed.

since: 2.28

#### Interface structure

    struct GioActionGroupInterface {
      GTypeInterface g_iface;
      gboolean (* has_action) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      gchar** (* list_actions) (
        GActionGroup* action_group
      );
      gboolean (* get_action_enabled) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      const GVariantType* (* get_action_parameter_type) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      const GVariantType* (* get_action_state_type) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      GVariant* (* get_action_state_hint) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      GVariant* (* get_action_state) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      void (* change_action_state) (
        GActionGroup* action_group,
        const gchar* action_name,
        GVariant* value
      );
      void (* activate_action) (
        GActionGroup* action_group,
        const gchar* action_name,
        GVariant* parameter
      );
      void (* action_added) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      void (* action_removed) (
        GActionGroup* action_group,
        const gchar* action_name
      );
      void (* action_enabled_changed) (
        GActionGroup* action_group,
        const gchar* action_name,
        gboolean enabled
      );
      void (* action_state_changed) (
        GActionGroup* action_group,
        const gchar* action_name,
        GVariant* state
      );
      gboolean (* query_action) (
        GActionGroup* action_group,
        const gchar* action_name,
        gboolean* enabled,
        const GVariantType** parameter_type,
        const GVariantType** state_type,
        GVariant** state_hint,
        GVariant** state
      );

    }

The virtual function table for `GActionGroup`.

###### Interface members

`g_iface`

    GTypeInterface

| No description available.

`has_action`

    gboolean (* has_action) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The virtual function pointer for `g_action_group_has_action()`

`list_actions`

    gchar** (* list_actions) (
        GActionGroup* action_group
      )

| The virtual function pointer for `g_action_group_list_actions()`

`get_action_enabled`

    gboolean (* get_action_enabled) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The virtual function pointer for `g_action_group_get_action_enabled()`

`get_action_parameter_type`

    const GVariantType* (* get_action_parameter_type) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The virtual function pointer for `g_action_group_get_action_parameter_type()`

`get_action_state_type`

    const GVariantType* (* get_action_state_type) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The virtual function pointer for `g_action_group_get_action_state_type()`

`get_action_state_hint`

    GVariant* (* get_action_state_hint) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The virtual function pointer for `g_action_group_get_action_state_hint()`

`get_action_state`

    GVariant* (* get_action_state) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The virtual function pointer for `g_action_group_get_action_state()`

`change_action_state`

    void (* change_action_state) (
        GActionGroup* action_group,
        const gchar* action_name,
        GVariant* value
      )

| The virtual function pointer for `g_action_group_change_action_state()`

`activate_action`

    void (* activate_action) (
        GActionGroup* action_group,
        const gchar* action_name,
        GVariant* parameter
      )

| The virtual function pointer for `g_action_group_activate_action()`

`action_added`

    void (* action_added) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The class closure for the `GActionGroup::action-added` signal.

`action_removed`

    void (* action_removed) (
        GActionGroup* action_group,
        const gchar* action_name
      )

| The class closure for the `GActionGroup::action-removed` signal.

`action_enabled_changed`

    void (* action_enabled_changed) (
        GActionGroup* action_group,
        const gchar* action_name,
        gboolean enabled
      )

| The class closure for the `GActionGroup::action-enabled-changed` signal.

`action_state_changed`

    void (* action_state_changed) (
        GActionGroup* action_group,
        const gchar* action_name,
        GVariant* state
      )

| The class closure for the `GActionGroup::action-enabled-changed` signal.

`query_action`

    gboolean (* query_action) (
        GActionGroup* action_group,
        const gchar* action_name,
        gboolean* enabled,
        const GVariantType** parameter_type,
        const GVariantType** state_type,
        GVariant** state_hint,
        GVariant** state
      )

| The virtual function pointer for `g_action_group_query_action()`

#### Virtual methods

###### Gio.ActionGroup.action_added

Emits the `GActionGroup::action-added` signal on `action_group`.

since: 2.28

###### Gio.ActionGroup.action_enabled_changed

Emits the `GActionGroup::action-enabled-changed` signal on `action_group`.

since: 2.28

###### Gio.ActionGroup.action_removed

Emits the `GActionGroup::action-removed` signal on `action_group`.

since: 2.28

###### Gio.ActionGroup.action_state_changed

Emits the `GActionGroup::action-state-changed` signal on `action_group`.

since: 2.28

###### Gio.ActionGroup.activate_action

Activate the named action within `action_group`.

since: 2.28

###### Gio.ActionGroup.change_action_state

Request for the state of the named action within `action_group` to be changed to `value`.

since: 2.28

###### Gio.ActionGroup.get_action_enabled

Checks if the named action within `action_group` is currently enabled.

since: 2.28

###### Gio.ActionGroup.get_action_parameter_type

Queries the type of the parameter that must be given when activating the named action within `action_group`.

since: 2.28

###### Gio.ActionGroup.get_action_state

Queries the current state of the named action within `action_group`.

since: 2.28

###### Gio.ActionGroup.get_action_state_hint

Requests a hint about the valid range of values for the state of the named action within `action_group`.

since: 2.28

###### Gio.ActionGroup.get_action_state_type

Queries the type of the state of the named action within `action_group`.

since: 2.28

###### Gio.ActionGroup.has_action

Checks if the named action exists within `action_group`.

since: 2.28

###### Gio.ActionGroup.list_actions

Lists the actions contained within `action_group`.

since: 2.28

###### Gio.ActionGroup.query_action

Queries all aspects of the named action within an `action_group`.

since: 2.32