module Gio::ActionGroup

Overview

#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().

Direct including types

Defined in:

lib/gi-crystal/src/auto/gio-2.0/action_group.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.cast(obj : GObject::Object) : self #

Cast a GObject::Object to self, throws a TypeCastError if the cast can't be made.


[View source]

Class Method Detail

def self.cast?(obj : GObject::Object) : self | Nil #

[View source]
def self.g_type : UInt64 #

[View source]

Instance Method Detail

def action_added(action_name : String) : Nil #

[View source]
def action_added_signal #

[View source]
def action_enabled(action_name : String) : Bool #

[View source]
def action_enabled_changed(action_name : String, enabled : Bool) : Nil #

[View source]
def action_enabled_changed_signal #

[View source]
def action_parameter_type(action_name : String) : GLib::VariantType | Nil #

[View source]
def action_removed(action_name : String) : Nil #

[View source]
def action_removed_signal #

[View source]
def action_state(action_name : String) : GLib::Variant | Nil #

[View source]
def action_state_changed(action_name : String, state : _) : Nil #

[View source]
def action_state_changed_signal #

[View source]
def action_state_hint(action_name : String) : GLib::Variant | Nil #

[View source]
def action_state_type(action_name : String) : GLib::VariantType | Nil #

[View source]
def activate_action(action_name : String, parameter : _ | Nil) : Nil #

[View source]
def change_action_state(action_name : String, value : _) : Nil #

[View source]
def has_action(action_name : String) : Bool #

[View source]
def list_actions : Enumerable(String) #

[View source]
def query_action(action_name : String, enabled : Bool) : Bool #

[View source]
abstract def to_unsafe #

[View source]