Gtk.Switch

Entities

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

Gtk.Switch.Gtk_Switch is a widget that has two states: on or off. The user can control which state should be active by clicking the empty area, or by dragging the handle.

GtkSwitch can also handle situations where the underlying state changes with a delay. See Gtk.Switch.Gtk_Switch::state-set for details.

# CSS nodes

switch
╰── slider

GtkSwitch has two css nodes, the main node with the name switch and a subnode named slider. Neither of them is using any style classes.

"+"

function "+"
  (Widget : access Gtk_Switch_Record'Class)
return Gtk.Actionable.Gtk_Actionable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Switch_Record'Class)
return Gtk.Activatable.Gtk_Activatable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Switch_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Actionable.Gtk_Actionable)
return Gtk_Switch
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Activatable.Gtk_Activatable)
return Gtk_Switch
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Switch
Parameters
Interf
Return Value

Active_Property

Active_Property : constant Glib.Properties.Property_Boolean;

Whether the Gtk.Switch.Gtk_Switch widget is in its on or off state.

Cb_GObject_Boolean_Boolean

type Cb_GObject_Boolean_Boolean is not null access function
  (Self  : access Glib.Object.GObject_Record'Class;
   State : Boolean) return Boolean;
Parameters
Self
State
Return Value

Cb_GObject_Void

type Cb_GObject_Void is not null access procedure
  (Self : access Glib.Object.GObject_Record'Class);
Parameters
Self

Cb_Gtk_Switch_Boolean_Boolean

type Cb_Gtk_Switch_Boolean_Boolean is not null access function
  (Self  : access Gtk_Switch_Record'Class;
   State : Boolean) return Boolean;
Parameters
Self
State
Return Value

Cb_Gtk_Switch_Void

type Cb_Gtk_Switch_Void is not null access procedure (Self : access Gtk_Switch_Record'Class);
Parameters
Self

Do_Set_Related_Action

procedure Do_Set_Related_Action
   (Self   : not null access Gtk_Switch_Record;
    Action : not null access Gtk.Action.Gtk_Action_Record'Class)
Parameters
Self
Action

Get_Action_Name

function Get_Action_Name
   (Self : not null access Gtk_Switch_Record) return UTF8_String
Parameters
Self
Return Value

Get_Action_Target_Value

function Get_Action_Target_Value
   (Self : not null access Gtk_Switch_Record)
    return Glib.Variant.Gvariant
Parameters
Self
Return Value

Get_Active

function Get_Active
   (Self : not null access Gtk_Switch_Record) return Boolean

Gets whether the Gtk.Switch.Gtk_Switch is in its "on" or "off" state. Since: gtk+ 3.0

Parameters
Self
Return Value

True if the Gtk.Switch.Gtk_Switch is active, and False otherwise

Get_Related_Action

function Get_Related_Action
   (Self : not null access Gtk_Switch_Record)
    return Gtk.Action.Gtk_Action
Parameters
Self
Return Value

Get_State

function Get_State
   (Self : not null access Gtk_Switch_Record) return Boolean

Gets the underlying state of the Gtk.Switch.Gtk_Switch. Since: gtk+ 3.14

Parameters
Self
Return Value

the underlying state

Get_Type

function Get_Type return Glib.GType
Return Value

Get_Use_Action_Appearance

function Get_Use_Action_Appearance
   (Self : not null access Gtk_Switch_Record) return Boolean
Parameters
Self
Return Value

Gtk_New

procedure Gtk_New (Self : out Gtk_Switch)

Creates a new Gtk.Switch.Gtk_Switch widget. Since: gtk+ 3.0 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Gtk_Switch

type Gtk_Switch is access all Gtk_Switch_Record'Class;

Gtk_Switch_New

function Gtk_Switch_New return Gtk_Switch

Creates a new Gtk.Switch.Gtk_Switch widget. Since: gtk+ 3.0

Return Value

Gtk_Switch_Record

type Gtk_Switch_Record is new Gtk_Widget_Record with null record;

Implements_Gtk_Actionable

package Implements_Gtk_Actionable is new Glib.Types.Implements
  (Gtk.Actionable.Gtk_Actionable, Gtk_Switch_Record, Gtk_Switch);

Implements_Gtk_Activatable

package Implements_Gtk_Activatable is new Glib.Types.Implements
  (Gtk.Activatable.Gtk_Activatable, Gtk_Switch_Record, Gtk_Switch);

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Switch_Record, Gtk_Switch);

Initialize

procedure Initialize (Self : not null access Gtk_Switch_Record'Class)

Creates a new Gtk.Switch.Gtk_Switch widget. Since: gtk+ 3.0 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

On_Activate

procedure On_Activate
   (Self  : not null access Gtk_Switch_Record;
    Call  : Cb_GObject_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

The ::activate signal on GtkSwitch is an action signal and emitting it causes the switch to animate. Applications should never connect to this signal, but use the notify::active signal.

Parameters
Self
Call
Slot
After

On_Activate

procedure On_Activate
   (Self  : not null access Gtk_Switch_Record;
    Call  : Cb_Gtk_Switch_Void;
    After : Boolean := False)

The ::activate signal on GtkSwitch is an action signal and emitting it causes the switch to animate. Applications should never connect to this signal, but use the notify::active signal.

Parameters
Self
Call
After

On_State_Set

procedure On_State_Set
   (Self  : not null access Gtk_Switch_Record;
    Call  : Cb_GObject_Boolean_Boolean;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)

The ::state-set signal on GtkSwitch is emitted to change the underlying state. It is emitted when the user changes the switch position. The default handler keeps the state in sync with the Gtk.Switch.Gtk_Switch:active property.

To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call Gtk.Switch.Set_State when the underlying state change is complete. The signal handler should return True to prevent the default handler from running.

Visually, the underlying state is represented by the trough color of the switch, while the Gtk.Switch.Gtk_Switch:active property is represented by the position of the switch.

Callback parameters: -- @param State the new state of the switch

Parameters
Self
Call
Slot
After

On_State_Set

procedure On_State_Set
   (Self  : not null access Gtk_Switch_Record;
    Call  : Cb_Gtk_Switch_Boolean_Boolean;
    After : Boolean := False)

The ::state-set signal on GtkSwitch is emitted to change the underlying state. It is emitted when the user changes the switch position. The default handler keeps the state in sync with the Gtk.Switch.Gtk_Switch:active property.

To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call Gtk.Switch.Set_State when the underlying state change is complete. The signal handler should return True to prevent the default handler from running.

Visually, the underlying state is represented by the trough color of the switch, while the Gtk.Switch.Gtk_Switch:active property is represented by the position of the switch.

Callback parameters: -- @param State the new state of the switch

Parameters
Self
Call
After

Set_Action_Name

procedure Set_Action_Name
   (Self        : not null access Gtk_Switch_Record;
    Action_Name : UTF8_String := "")
Parameters
Self
Action_Name

Set_Action_Target_Value

procedure Set_Action_Target_Value
   (Self         : not null access Gtk_Switch_Record;
    Target_Value : Glib.Variant.Gvariant)
Parameters
Self
Target_Value

Set_Active

procedure Set_Active
   (Self      : not null access Gtk_Switch_Record;
    Is_Active : Boolean)

Changes the state of Sw to the desired one. Since: gtk+ 3.0

Parameters
Self
Is_Active

True if Sw should be active, and False otherwise

Set_Detailed_Action_Name

procedure Set_Detailed_Action_Name
   (Self                 : not null access Gtk_Switch_Record;
    Detailed_Action_Name : UTF8_String)
Parameters
Self
Detailed_Action_Name

Set_Related_Action

procedure Set_Related_Action
   (Self   : not null access Gtk_Switch_Record;
    Action : not null access Gtk.Action.Gtk_Action_Record'Class)
Parameters
Self
Action

Set_State

procedure Set_State
   (Self  : not null access Gtk_Switch_Record;
    State : Boolean)

Sets the underlying state of the Gtk.Switch.Gtk_Switch. Normally, this is the same as Gtk.Switch.Gtk_Switch:active, unless the switch is set up for delayed state changes. This function is typically called from a Gtk.Switch.Gtk_Switch::state-set signal handler. See Gtk.Switch.Gtk_Switch::state-set for details. Since: gtk+ 3.14

Parameters
Self
State

the new state

Set_Use_Action_Appearance

procedure Set_Use_Action_Appearance
   (Self           : not null access Gtk_Switch_Record;
    Use_Appearance : Boolean)
Parameters
Self
Use_Appearance

Signal_Activate

Signal_Activate : constant Glib.Signal_Name := "activate";

The ::activate signal on GtkSwitch is an action signal and emitting it causes the switch to animate. Applications should never connect to this signal, but use the notify::active signal.

Signal_State_Set

Signal_State_Set : constant Glib.Signal_Name := "state-set";

The ::state-set signal on GtkSwitch is emitted to change the underlying state. It is emitted when the user changes the switch position. The default handler keeps the state in sync with the Gtk.Switch.Gtk_Switch:active property.

To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call Gtk.Switch.Set_State when the underlying state change is complete. The signal handler should return True to prevent the default handler from running.

Visually, the underlying state is represented by the trough color of the switch, while the Gtk.Switch.Gtk_Switch:active property is represented by the position of the switch.

Callback parameters: -- @param State the new state of the switch

State_Property

State_Property : constant Glib.Properties.Property_Boolean;

The backend state that is controlled by the switch. See Gtk.Switch.Gtk_Switch::state-set for details.

Sync_Action_Properties

procedure Sync_Action_Properties
   (Self   : not null access Gtk_Switch_Record;
    Action : access Gtk.Action.Gtk_Action_Record'Class)
Parameters
Self
Action