Gtk.Radio_Button

Entities

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

A single radio button performs the same basic function as a Gtk.Check_Button.Gtk_Check_Button, as its position in the object hierarchy reflects. It is only when multiple radio buttons are grouped together that they become a different user interface component in their own right.

Every radio button is a member of some group of radio buttons. When one is selected, all other radio buttons in the same group are deselected. A Gtk.Radio_Button.Gtk_Radio_Button is one way of giving the user a choice from many options.

Radio button widgets are created with gtk_radio_button_new, passing null as the argument if this is the first radio button in a group. In subsequent calls, the group you wish to add this button to should be passed as an argument. Optionally, Gtk.Radio_Button.Gtk_New can be used if you want a text label on the radio button.

Alternatively, when adding widgets to an existing group of radio buttons, use gtk_radio_button_new_from_widget with a Gtk.Radio_Button.Gtk_Radio_Button that already has a group assigned to it. The convenience function Gtk.Radio_Button.Gtk_New is also provided.

To retrieve the group a Gtk.Radio_Button.Gtk_Radio_Button is assigned to, use Gtk.Radio_Button.Get_Group.

To remove a Gtk.Radio_Button.Gtk_Radio_Button from one group and make it part of a new one, use Gtk.Radio_Button.Set_Group.

The group list does not need to be freed, as each Gtk.Radio_Button.Gtk_Radio_Button will remove itself and its list item when it is destroyed.

# CSS nodes

radiobutton
├── radio
╰── <child>

A GtkRadioButton with indicator (see Gtk.Toggle_Button.Set_Mode) has a main CSS node with name radiobutton and a subnode with name radio.

button.radio
├── radio
╰── <child>

A GtkRadioButton without indicator changes the name of its main node to button and adds a .radio style class to it. The subnode is invisible in this case.

## How to create a group of two radio buttons.

void create_radio_buttons (void) {

   GtkWidget *window, *radio1, *radio2, *box, *entry;
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
   gtk_box_set_homogeneous (GTK_BOX (box), TRUE);

   // Create a radio button with a GtkEntry widget
   radio1 = gtk_radio_button_new (NULL);
   entry = gtk_entry_new ();
   gtk_container_add (GTK_CONTAINER (radio1), entry);

   // Create a radio button with a label
   radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
                                                         "I'm the second radio button.");

   // Pack them into a box, then show all the widgets
   gtk_box_pack_start (GTK_BOX (box), radio1);
   gtk_box_pack_start (GTK_BOX (box), radio2);
   gtk_container_add (GTK_CONTAINER (window), box);
   gtk_widget_show_all (window);
   return;
}

When an unselected button in the group is clicked the clicked button receives the Gtk.Toggle_Button.Gtk_Toggle_Button::toggled signal, as does the previously selected button. Inside the Gtk.Toggle_Button.Gtk_Toggle_Button::toggled handler, Gtk.Toggle_Button.Get_Active can be used to determine if the button has been selected or deselected.

<screenshot>gtk-radio_button</screenshot> <group>Buttons and Toggles</group> <testgtk>create_radio_button.adb</testgtk>

"+"

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

"+"

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

"+"

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

"-"

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

"-"

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

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Radio_Button
Parameters
Interf
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_Radio_Button_Void

type Cb_Gtk_Radio_Button_Void is not null access procedure
  (Self : access Gtk_Radio_Button_Record'Class);
Parameters
Self

Do_Set_Related_Action

procedure Do_Set_Related_Action
   (Self   : not null access Gtk_Radio_Button_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_Radio_Button_Record) return UTF8_String
Parameters
Self
Return Value

Get_Action_Target_Value

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

Get_Group

function Get_Group
   (Radio_Button : not null access Gtk_Radio_Button_Record)
    return Gtk.Widget.Widget_SList.GSlist

Retrieves the group assigned to a radio button.

Parameters
Radio_Button
Return Value

Get_Related_Action

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

Get_Type

function Get_Type return Glib.GType
Return Value

Get_Use_Action_Appearance

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

Group_Property

Group_Property : constant Glib.Properties.Property_Object;

Type: Gtk_Radio_Button Flags: write Sets a new group for a radio button.

Gtk_New

procedure Gtk_New
   (Radio_Button : out Gtk_Radio_Button;
    Group        : access Gtk_Radio_Button_Record'Class;
    Label        : UTF8_String := "")

Creates a new Gtk.Radio_Button.Gtk_Radio_Button with a text label, adding it to the same group as Radio_Group_Member. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

widget to get radio group from or null

Label

a text string to display next to the radio button.

Gtk_New

procedure Gtk_New
   (Radio_Button : out Gtk_Radio_Button;
    Group        : Gtk.Widget.Widget_SList.GSlist := Widget_SList.Null_List;
    Label        : UTF8_String := "")

Creates or initializes a new radio button, belonging to Group. If Label is left as the empty string, then the button will not have any child and you are free to put any thing you want in it, including a pixmap. To initialize the group (when creating the first button), leave Group to the Null_List. You can later get the new group that is created with a call to the Get_Group subprogram below. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

an existing radio button group, or null if you are creating a new group.

Label

the text label to display next to the radio button.

Gtk_New_With_Mnemonic

procedure Gtk_New_With_Mnemonic
   (Radio_Button : out Gtk_Radio_Button;
    Group        : access Gtk_Radio_Button_Record'Class;
    Label        : UTF8_String)

Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate the mnemonic for the button. To initialize a new group (when creating the first button), you should pass it null or a button that has not been created with Gtk_New, as in the example below. Initialize_With_Mnemonic does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

widget to get radio group from or null

Label

the text of the button, with an underscore in front of the mnemonic character

Gtk_New_With_Mnemonic

procedure Gtk_New_With_Mnemonic
   (Radio_Button : out Gtk_Radio_Button;
    Group        : Gtk.Widget.Widget_SList.GSlist := Widget_SList.Null_List;
    Label        : UTF8_String)

Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label, adding it to the same group as Group. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate the mnemonic for the button. Initialize_With_Mnemonic does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

the radio button group, or null

Label

the text of the button, with an underscore in front of the mnemonic character

Gtk_Radio_Button

type Gtk_Radio_Button is access all Gtk_Radio_Button_Record'Class;

Gtk_Radio_Button_New_With_Label

function Gtk_Radio_Button_New_With_Label
   (Group : Gtk.Widget.Widget_SList.GSlist := Widget_SList.Null_List;
    Label : UTF8_String := "") return Gtk_Radio_Button

Creates or initializes a new radio button, belonging to Group. If Label is left as the empty string, then the button will not have any child and you are free to put any thing you want in it, including a pixmap. To initialize the group (when creating the first button), leave Group to the Null_List. You can later get the new group that is created with a call to the Get_Group subprogram below.

Parameters
Group

an existing radio button group, or null if you are creating a new group.

Label

the text label to display next to the radio button.

Return Value

Gtk_Radio_Button_New_With_Label_From_Widget

function Gtk_Radio_Button_New_With_Label_From_Widget
   (Group : access Gtk_Radio_Button_Record'Class;
    Label : UTF8_String := "") return Gtk_Radio_Button

Creates a new Gtk.Radio_Button.Gtk_Radio_Button with a text label, adding it to the same group as Radio_Group_Member.

Parameters
Group

widget to get radio group from or null

Label

a text string to display next to the radio button.

Return Value

Gtk_Radio_Button_New_With_Mnemonic

function Gtk_Radio_Button_New_With_Mnemonic
   (Group : Gtk.Widget.Widget_SList.GSlist := Widget_SList.Null_List;
    Label : UTF8_String) return Gtk_Radio_Button

Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label, adding it to the same group as Group. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate the mnemonic for the button.

Parameters
Group

the radio button group, or null

Label

the text of the button, with an underscore in front of the mnemonic character

Return Value

Gtk_Radio_Button_New_With_Mnemonic_From_Widget

function Gtk_Radio_Button_New_With_Mnemonic_From_Widget
   (Group : access Gtk_Radio_Button_Record'Class;
    Label : UTF8_String) return Gtk_Radio_Button

Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate the mnemonic for the button. To initialize a new group (when creating the first button), you should pass it null or a button that has not been created with Gtk_New, as in the example below.

Parameters
Group

widget to get radio group from or null

Label

the text of the button, with an underscore in front of the mnemonic character

Return Value

Gtk_Radio_Button_Record

type Gtk_Radio_Button_Record is new Gtk_Check_Button_Record with null record;

Implements_Gtk_Actionable

package Implements_Gtk_Actionable is new Glib.Types.Implements
  (Gtk.Actionable.Gtk_Actionable, Gtk_Radio_Button_Record, Gtk_Radio_Button);

Implements_Gtk_Activatable

package Implements_Gtk_Activatable is new Glib.Types.Implements
  (Gtk.Activatable.Gtk_Activatable, Gtk_Radio_Button_Record, Gtk_Radio_Button);

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Button_Record, Gtk_Radio_Button);

Initialize

procedure Initialize
   (Radio_Button : not null access Gtk_Radio_Button_Record'Class;
    Group        : access Gtk_Radio_Button_Record'Class;
    Label        : UTF8_String := "")

Creates a new Gtk.Radio_Button.Gtk_Radio_Button with a text label, adding it to the same group as Radio_Group_Member. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

widget to get radio group from or null

Label

a text string to display next to the radio button.

Initialize

procedure Initialize
   (Radio_Button : not null access Gtk_Radio_Button_Record'Class;
    Group        : Gtk.Widget.Widget_SList.GSlist := Widget_SList.Null_List;
    Label        : UTF8_String := "")

Creates or initializes a new radio button, belonging to Group. If Label is left as the empty string, then the button will not have any child and you are free to put any thing you want in it, including a pixmap. To initialize the group (when creating the first button), leave Group to the Null_List. You can later get the new group that is created with a call to the Get_Group subprogram below. Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

an existing radio button group, or null if you are creating a new group.

Label

the text label to display next to the radio button.

Initialize_With_Mnemonic

procedure Initialize_With_Mnemonic
   (Radio_Button : not null access Gtk_Radio_Button_Record'Class;
    Group        : access Gtk_Radio_Button_Record'Class;
    Label        : UTF8_String)

Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate the mnemonic for the button. To initialize a new group (when creating the first button), you should pass it null or a button that has not been created with Gtk_New, as in the example below. Initialize_With_Mnemonic does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

widget to get radio group from or null

Label

the text of the button, with an underscore in front of the mnemonic character

Initialize_With_Mnemonic

procedure Initialize_With_Mnemonic
   (Radio_Button : not null access Gtk_Radio_Button_Record'Class;
    Group        : Gtk.Widget.Widget_SList.GSlist := Widget_SList.Null_List;
    Label        : UTF8_String)

Creates a new Gtk.Radio_Button.Gtk_Radio_Button containing a label, adding it to the same group as Group. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, so underscores in Label indicate the mnemonic for the button. Initialize_With_Mnemonic does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Radio_Button
Group

the radio button group, or null

Label

the text of the button, with an underscore in front of the mnemonic character

Join_Group

procedure Join_Group
   (Radio_Button : not null access Gtk_Radio_Button_Record;
    Group_Source : access Gtk_Radio_Button_Record'Class)

Joins a Gtk.Radio_Button.Gtk_Radio_Button object to the group of another Gtk.Radio_Button.Gtk_Radio_Button object Use this in language bindings instead of the Gtk.Radio_Button.Get_Group and Gtk.Radio_Button.Set_Group methods A common way to set up a group of radio buttons is the following:

GtkRadioButton *radio_button;
GtkRadioButton *last_button;

while (some_condition)
  {
     radio_button = gtk_radio_button_new (NULL);

     gtk_radio_button_join_group (radio_button, last_button);
     last_button = radio_button;
  }

Since: gtk+ 3.0

Parameters
Radio_Button
Group_Source

a radio button object whos group we are joining, or null to remove the radio button from its group

On_Group_Changed

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

Emitted when the group of radio buttons that a radio button belongs to changes. This is emitted when a radio button switches from being alone to being part of a group of 2 or more buttons, or vice-versa, and when a button is moved from one group of 2 or more buttons to a different one, but not when the composition of the group that a button belongs to changes.

Parameters
Self
Call
Slot
After

On_Group_Changed

procedure On_Group_Changed
   (Self  : not null access Gtk_Radio_Button_Record;
    Call  : Cb_Gtk_Radio_Button_Void;
    After : Boolean := False)

Emitted when the group of radio buttons that a radio button belongs to changes. This is emitted when a radio button switches from being alone to being part of a group of 2 or more buttons, or vice-versa, and when a button is moved from one group of 2 or more buttons to a different one, but not when the composition of the group that a button belongs to changes.

Parameters
Self
Call
After

Set_Action_Name

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

Set_Action_Target_Value

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

Set_Detailed_Action_Name

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

Set_Group

procedure Set_Group
   (Radio_Button : not null access Gtk_Radio_Button_Record;
    Group        : Gtk.Widget.Widget_SList.GSlist)

Sets a Gtk.Radio_Button.Gtk_Radio_Button's group. It should be noted that this does not change the layout of your interface in any way, so if you are changing the group, it is likely you will need to re-arrange the user interface to reflect these changes.

Parameters
Radio_Button
Group

an existing radio button group, such as one returned from Gtk.Radio_Button.Get_Group, or null.

Set_Related_Action

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

Set_Use_Action_Appearance

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

Signal_Group_Changed

Signal_Group_Changed : constant Glib.Signal_Name := "group-changed";

Emitted when the group of radio buttons that a radio button belongs to changes. This is emitted when a radio button switches from being alone to being part of a group of 2 or more buttons, or vice-versa, and when a button is moved from one group of 2 or more buttons to a different one, but not when the composition of the group that a button belongs to changes.

Sync_Action_Properties

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