A Glib.Simple_Action.Gsimple_Action is the obvious simple implementation of the Glib.Action.Gaction interface. This is the easiest way to create an action for purposes of adding it to a Glib.Simple_Action_Group.Gsimple_Action_Group.
See also Gtk.Action.Gtk_Action.
function "+"
(Widget : access Gsimple_Action_Record'Class)
return Glib.Action.Gaction
function "-"
(Interf : Glib.Action.Gaction)
return Gsimple_Action
procedure Activate
(Self : not null access Gsimple_Action_Record;
Parameter : Glib.Variant.Gvariant)
type Cb_GObject_Gvariant_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class;
Parameter : Glib.Variant.Gvariant);
type Cb_Gsimple_Action_Gvariant_Void is not null access procedure
(Self : access Gsimple_Action_Record'Class;
Parameter : Glib.Variant.Gvariant);
procedure Change_State
(Self : not null access Gsimple_Action_Record;
Value : Glib.Variant.Gvariant)
Enabled_Property : constant Glib.Properties.Property_Boolean;
If Action is currently enabled.
If the action is disabled then calls to Glib.Action.Activate and Glib.Action.Change_State have no effect.
procedure G_New
(Self : out Gsimple_Action;
Name : UTF8_String;
Parameter_Type : Glib.Variant.Gvariant_Type)
Creates a new action. The created action is stateless. See Glib.Simple_Action.G_New_Stateful to create an action that has state. Since: gtk+ 2.28
the name of the action
the type of parameter that will be passed to handlers for the Glib.Simple_Action.Gsimple_Action::activate signal, or null for no parameter
procedure G_New_Stateful
(Self : out Gsimple_Action;
Name : UTF8_String;
Parameter_Type : Glib.Variant.Gvariant_Type;
State : Glib.Variant.Gvariant)
Creates a new stateful action. All future state values must have the same Glib.Variant.Gvariant_Type as the initial State. If the State Glib.Variant.Gvariant is floating, it is consumed. Since: gtk+ 2.28
the name of the action
the type of the parameter that will be passed to handlers for the Glib.Simple_Action.Gsimple_Action::activate signal, or null for no parameter
the initial state of the action
function Get_Enabled
(Self : not null access Gsimple_Action_Record) return Boolean
function Get_Name
(Self : not null access Gsimple_Action_Record) return UTF8_String
function Get_Parameter_Type
(Self : not null access Gsimple_Action_Record)
return Glib.Variant.Gvariant_Type
function Get_State
(Self : not null access Gsimple_Action_Record)
return Glib.Variant.Gvariant
function Get_State_Hint
(Self : not null access Gsimple_Action_Record)
return Glib.Variant.Gvariant
function Get_State_Type
(Self : not null access Gsimple_Action_Record)
return Glib.Variant.Gvariant_Type
function Get_Type return Glib.GType
type Gsimple_Action is access all Gsimple_Action_Record'Class;
function Gsimple_Action_New
(Name : UTF8_String;
Parameter_Type : Glib.Variant.Gvariant_Type) return Gsimple_Action
Creates a new action. The created action is stateless. See Glib.Simple_Action.G_New_Stateful to create an action that has state. Since: gtk+ 2.28
the name of the action
the type of parameter that will be passed to handlers for the Glib.Simple_Action.Gsimple_Action::activate signal, or null for no parameter
function Gsimple_Action_New_Stateful
(Name : UTF8_String;
Parameter_Type : Glib.Variant.Gvariant_Type;
State : Glib.Variant.Gvariant) return Gsimple_Action
Creates a new stateful action. All future state values must have the same Glib.Variant.Gvariant_Type as the initial State. If the State Glib.Variant.Gvariant is floating, it is consumed. Since: gtk+ 2.28
the name of the action
the type of the parameter that will be passed to handlers for the Glib.Simple_Action.Gsimple_Action::activate signal, or null for no parameter
the initial state of the action
type Gsimple_Action_Record is new GObject_Record with null record;
package Implements_Gaction is new Glib.Types.Implements
(Glib.Action.Gaction, Gsimple_Action_Record, Gsimple_Action);
procedure Initialize
(Self : not null access Gsimple_Action_Record'Class;
Name : UTF8_String;
Parameter_Type : Glib.Variant.Gvariant_Type)
Creates a new action. The created action is stateless. See Glib.Simple_Action.G_New_Stateful to create an action that has state. Since: gtk+ 2.28 Initialize does nothing if the object was already created with another call to Initialize* or G_New.
the name of the action
the type of parameter that will be passed to handlers for the Glib.Simple_Action.Gsimple_Action::activate signal, or null for no parameter
procedure Initialize_Stateful
(Self : not null access Gsimple_Action_Record'Class;
Name : UTF8_String;
Parameter_Type : Glib.Variant.Gvariant_Type;
State : Glib.Variant.Gvariant)
Creates a new stateful action. All future state values must have the same Glib.Variant.Gvariant_Type as the initial State. If the State Glib.Variant.Gvariant is floating, it is consumed. Since: gtk+ 2.28 Initialize_Stateful does nothing if the object was already created with another call to Initialize* or G_New.
the name of the action
the type of the parameter that will be passed to handlers for the Glib.Simple_Action.Gsimple_Action::activate signal, or null for no parameter
the initial state of the action
Name_Property : constant Glib.Properties.Property_String;
The name of the action. This is mostly meaningful for identifying the action once it has been added to a Glib.Simple_Action_Group.Gsimple_Action_Group.
procedure On_Activate
(Self : not null access Gsimple_Action_Record;
Call : Cb_GObject_Gvariant_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
Indicates that the action was just activated.
Parameter will always be of the expected type, i.e. the parameter type specified when the action was created. If an incorrect type is given when activating the action, this signal is not emitted.
Since GLib 2.40, if no handler is connected to this signal then the default behaviour for boolean-stated actions with a null parameter type is to toggle them via the Glib.Simple_Action.Gsimple_Action::change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to Glib.Simple_Action.Gsimple_Action::change-state. This should allow almost all users of Glib.Simple_Action.Gsimple_Action to connect only one handler or the other.
procedure On_Activate
(Self : not null access Gsimple_Action_Record;
Call : Cb_Gsimple_Action_Gvariant_Void;
After : Boolean := False)
Indicates that the action was just activated.
Parameter will always be of the expected type, i.e. the parameter type specified when the action was created. If an incorrect type is given when activating the action, this signal is not emitted.
Since GLib 2.40, if no handler is connected to this signal then the default behaviour for boolean-stated actions with a null parameter type is to toggle them via the Glib.Simple_Action.Gsimple_Action::change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to Glib.Simple_Action.Gsimple_Action::change-state. This should allow almost all users of Glib.Simple_Action.Gsimple_Action to connect only one handler or the other.
procedure On_Change_State
(Self : not null access Gsimple_Action_Record;
Call : Cb_GObject_Gvariant_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
Indicates that the action just received a request to change its state.
Value will always be of the correct state type, i.e. the type of the initial state passed to Glib.Simple_Action.G_New_Stateful. If an incorrect type is given when requesting to change the state, this signal is not emitted.
If no handler is connected to this signal then the default behaviour is to call Glib.Simple_Action.Set_State to set the state to the requested value. If you connect a signal handler then no default action is taken. If the state should change then you must call Glib.Simple_Action.Set_State from the handler.
An example of a 'change-state' handler:
static void
change_volume_state (GSimpleAction *action,
GVariant *value,
gpointer user_data)
{
gint requested;
requested = g_variant_get_int32 (value);
// Volume only goes from 0 to 10
if (0 <= requested && requested <= 10)
g_simple_action_set_state (action, value);
}
The handler need not set the state to the requested value. It could set it to any value at all, or take some other action.
procedure On_Change_State
(Self : not null access Gsimple_Action_Record;
Call : Cb_Gsimple_Action_Gvariant_Void;
After : Boolean := False)
Indicates that the action just received a request to change its state.
Value will always be of the correct state type, i.e. the type of the initial state passed to Glib.Simple_Action.G_New_Stateful. If an incorrect type is given when requesting to change the state, this signal is not emitted.
If no handler is connected to this signal then the default behaviour is to call Glib.Simple_Action.Set_State to set the state to the requested value. If you connect a signal handler then no default action is taken. If the state should change then you must call Glib.Simple_Action.Set_State from the handler.
An example of a 'change-state' handler:
static void
change_volume_state (GSimpleAction *action,
GVariant *value,
gpointer user_data)
{
gint requested;
requested = g_variant_get_int32 (value);
// Volume only goes from 0 to 10
if (0 <= requested && requested <= 10)
g_simple_action_set_state (action, value);
}
The handler need not set the state to the requested value. It could set it to any value at all, or take some other action.
Parameter_Type_Property : constant Glib.Properties.Property_Boxed;
Type: GLib.Variant_Type The type of the parameter that must be given when activating the action.
procedure Set_Enabled
(Self : not null access Gsimple_Action_Record;
Enabled : Boolean)
Sets the action as enabled or not. An action must be enabled in order to be activated or in order to have its state changed from outside callers. This should only be called by the implementor of the action. Users of the action should not attempt to modify its enabled flag. Since: gtk+ 2.28
whether the action is enabled
procedure Set_State
(Self : not null access Gsimple_Action_Record;
Value : Glib.Variant.Gvariant)
Sets the state of the action. This directly updates the 'state' property to the given value. This should only be called by the implementor of the action. Users of the action should not attempt to directly modify the 'state' property. Instead, they should call Glib.Action.Change_State to request the change. If the Value GVariant is floating, it is consumed. Since: gtk+ 2.30
the new Glib.Variant.Gvariant for the state
procedure Set_State_Hint
(Self : not null access Gsimple_Action_Record;
State_Hint : Glib.Variant.Gvariant)
Sets the state hint for the action. See Glib.Action.Get_State_Hint for more information about action state hints. Since: gtk+ 2.44
a Glib.Variant.Gvariant representing the state hint
Signal_Activate : constant Glib.Signal_Name := "activate";
Indicates that the action was just activated.
Parameter will always be of the expected type, i.e. the parameter type specified when the action was created. If an incorrect type is given when activating the action, this signal is not emitted.
Since GLib 2.40, if no handler is connected to this signal then the default behaviour for boolean-stated actions with a null parameter type is to toggle them via the Glib.Simple_Action.Gsimple_Action::change-state signal. For stateful actions where the state type is equal to the parameter type, the default is to forward them directly to Glib.Simple_Action.Gsimple_Action::change-state. This should allow almost all users of Glib.Simple_Action.Gsimple_Action to connect only one handler or the other.
Signal_Change_State : constant Glib.Signal_Name := "change-state";
Indicates that the action just received a request to change its state.
Value will always be of the correct state type, i.e. the type of the initial state passed to Glib.Simple_Action.G_New_Stateful. If an incorrect type is given when requesting to change the state, this signal is not emitted.
If no handler is connected to this signal then the default behaviour is to call Glib.Simple_Action.Set_State to set the state to the requested value. If you connect a signal handler then no default action is taken. If the state should change then you must call Glib.Simple_Action.Set_State from the handler.
An example of a 'change-state' handler:
static void
change_volume_state (GSimpleAction *action,
GVariant *value,
gpointer user_data)
{
gint requested;
requested = g_variant_get_int32 (value);
// Volume only goes from 0 to 10
if (0 <= requested && requested <= 10)
g_simple_action_set_state (action, value);
}
The handler need not set the state to the requested value. It could set it to any value at all, or take some other action.
State_Property : constant Glib.Properties.Property_Object;
Type: Glib.Variant.Gvariant The state of the action, or null if the action is stateless.
State_Type_Property : constant Glib.Properties.Property_Boxed;
Type: GLib.Variant_Type The Glib.Variant.Gvariant_Type of the state that the action has, or null if the action is stateless.