<refentry id="GtkRadioButton">
<refmeta>
<refentrytitle>GtkRadioButton</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GtkRadioButton</refname><refpurpose>A choice from multiple check buttons.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>

#include &lt;gtk/gtk.h&gt;


struct      <link linkend="GtkRadioButton-struct">GtkRadioButton</link>;
<link linkend="GtkWidget">GtkWidget</link>*  <link linkend="gtk-radio-button-new">gtk_radio_button_new</link>            (<link linkend="GSList">GSList</link> *group);
<link linkend="GtkWidget">GtkWidget</link>*  <link linkend="gtk-radio-button-new-from-widget">gtk_radio_button_new_from_widget</link>
                                            (<link linkend="GtkRadioButton">GtkRadioButton</link> *group);
<link linkend="GtkWidget">GtkWidget</link>*  <link linkend="gtk-radio-button-new-with-label">gtk_radio_button_new_with_label</link> (<link linkend="GSList">GSList</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);
<link linkend="GtkWidget">GtkWidget</link>*  <link linkend="gtk-radio-button-new-with-label-from-widget">gtk_radio_button_new_with_label_from_widget</link>
                                            (<link linkend="GtkRadioButton">GtkRadioButton</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);
<link linkend="GtkWidget">GtkWidget</link>*  <link linkend="gtk-radio-button-new-with-mnemonic">gtk_radio_button_new_with_mnemonic</link>
                                            (<link linkend="GSList">GSList</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);
<link linkend="GtkWidget">GtkWidget</link>*  <link linkend="gtk-radio-button-new-with-mnemonic-from-widget">gtk_radio_button_new_with_mnemonic_from_widget</link>
                                            (<link linkend="GtkRadioButton">GtkRadioButton</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);
#define     <link linkend="gtk-radio-button-group">gtk_radio_button_group</link>
void        <link linkend="gtk-radio-button-set-group">gtk_radio_button_set_group</link>      (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_button,
                                             <link linkend="GSList">GSList</link> *group);
<link linkend="GSList">GSList</link>*     <link linkend="gtk-radio-button-get-group">gtk_radio_button_get_group</link>      (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_button);


</synopsis>
</refsynopsisdiv>

<refsect1>
<title>Object Hierarchy</title>
<synopsis>

  <link linkend="GObject">GObject</link>
   +----<link linkend="GtkObject">GtkObject</link>
         +----<link linkend="GtkWidget">GtkWidget</link>
               +----<link linkend="GtkContainer">GtkContainer</link>
                     +----<link linkend="GtkBin">GtkBin</link>
                           +----<link linkend="GtkButton">GtkButton</link>
                                 +----<link linkend="GtkToggleButton">GtkToggleButton</link>
                                       +----<link linkend="GtkCheckButton">GtkCheckButton</link>
                                             +----GtkRadioButton
</synopsis>

</refsect1>

<refsect1>
<title>Properties</title>
<synopsis>

  &quot;<link linkend="GtkRadioButton--group">group</link>&quot;                <link linkend="GtkRadioButton">GtkRadioButton</link>       : Write
</synopsis>
</refsect1>



<refsect1>
<title>Description</title>
<para>
A single radio button performs the same basic function as a <link linkend="GtkCheckButton">GtkCheckButton</link>,
as it's 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.</para>
<para>
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 <link linkend="GtkRadioButton">GtkRadioButton</link> is one way
of giving the user a choice from many options.
</para>
<para>
Radio button widgets are created with <link linkend="gtk-radio-button-new">gtk_radio_button_new</link>(), 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, <link linkend="gtk-radio-button-new-with-label">gtk_radio_button_new_with_label</link>() can be used if you
want a text label on the radio button.
</para>
<para>
Alternatively, when adding widgets to an existing group of radio buttons,
use <link linkend="gtk-radio-button-new-from-widget">gtk_radio_button_new_from_widget</link>() with a <link linkend="GtkRadioButton">GtkRadioButton</link> that already
has a group assigned to it. The convenience function
<link linkend="gtk-radio-button-new-with-label-from-widget">gtk_radio_button_new_with_label_from_widget</link>() is also provided.
</para>
<para>
To retrieve the group a <link linkend="GtkRadioButton">GtkRadioButton</link> is assigned to, use
<link linkend="gtk-radio-button-get-group">gtk_radio_button_get_group</link>().
</para>
<para>
To remove a <link linkend="GtkRadioButton">GtkRadioButton</link> from one group and make it part of a new one, use <link linkend="gtk-radio-button-set-group">gtk_radio_button_set_group</link>().
</para>
<para>
<example>
<title>How to create a group of two radio buttons.</title>
<programlisting>

void create_radio_buttons (void) {

   GtkWidget *window, *radio1, *radio2, *box, *entry;
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   box = gtk_vbox_new (TRUE, 2);
   
   /* 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, TRUE, TRUE, 2);
   gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
   gtk_container_add (GTK_CONTAINER (window), box);
   gtk_widget_show_all (window);
   return;
}

</programlisting>
</example>
</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="GtkRadioButton-struct">struct GtkRadioButton</title>
<programlisting>struct GtkRadioButton;</programlisting>
<para>
Contains only private data that should be read and manipulated using the
functions below.
</para></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-new">gtk_radio_button_new ()</title>
<programlisting><link linkend="GtkWidget">GtkWidget</link>*  gtk_radio_button_new            (<link linkend="GSList">GSList</link> *group);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton">GtkRadioButton</link>. To be of any practical value, a widget should
then be packed into the radio button.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry>an existing radio button group, or <literal>NULL</literal> if you are creating a new group.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a new radio button.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-new-from-widget">gtk_radio_button_new_from_widget ()</title>
<programlisting><link linkend="GtkWidget">GtkWidget</link>*  gtk_radio_button_new_from_widget
                                            (<link linkend="GtkRadioButton">GtkRadioButton</link> *group);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton">GtkRadioButton</link>, adding it to the same group as <parameter>group</parameter>. As
with <link linkend="gtk-radio-button-new">gtk_radio_button_new</link>(), a widget should be packed into the radio button.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry>an existing <link linkend="GtkRadioButton">GtkRadioButton</link>.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a new radio button.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-new-with-label">gtk_radio_button_new_with_label ()</title>
<programlisting><link linkend="GtkWidget">GtkWidget</link>*  gtk_radio_button_new_with_label (<link linkend="GSList">GSList</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton">GtkRadioButton</link> with a text label.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry>an existing radio button group, or <literal>NULL</literal> if you are creating a new
group.
</entry></row>
<row><entry align="right"><parameter>label</parameter>&nbsp;:</entry>
<entry>the text label to display next to the radio button.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a new radio button.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-new-with-label-from-widget">gtk_radio_button_new_with_label_from_widget ()</title>
<programlisting><link linkend="GtkWidget">GtkWidget</link>*  gtk_radio_button_new_with_label_from_widget
                                            (<link linkend="GtkRadioButton">GtkRadioButton</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton">GtkRadioButton</link> with a text label, adding it to the same group
as <parameter>group</parameter>.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry>an existing <link linkend="GtkRadioButton">GtkRadioButton</link>.
</entry></row>
<row><entry align="right"><parameter>label</parameter>&nbsp;:</entry>
<entry>a text string to display next to the radio button.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a new radio button.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-new-with-mnemonic">gtk_radio_button_new_with_mnemonic ()</title>
<programlisting><link linkend="GtkWidget">GtkWidget</link>*  gtk_radio_button_new_with_mnemonic
                                            (<link linkend="GSList">GSList</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton">GtkRadioButton</link> containing a label, adding it to the same 
group as <parameter>group</parameter>. The label will be created using 
<link linkend="gtk-label-new-with-mnemonic">gtk_label_new_with_mnemonic</link>(), so underscores in <parameter>label</parameter> indicate the 
mnemonic for the button.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry> the radio button group
</entry></row>
<row><entry align="right"><parameter>label</parameter>&nbsp;:</entry>
<entry> the text of the button, with an underscore in front of the
        mnemonic character
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a new <link linkend="GtkRadioButton">GtkRadioButton</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-new-with-mnemonic-from-widget">gtk_radio_button_new_with_mnemonic_from_widget ()</title>
<programlisting><link linkend="GtkWidget">GtkWidget</link>*  gtk_radio_button_new_with_mnemonic_from_widget
                                            (<link linkend="GtkRadioButton">GtkRadioButton</link> *group,
                                             const <link linkend="gchar">gchar</link> *label);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton">GtkRadioButton</link> containing a label. The label
will be created using <link linkend="gtk-label-new-with-mnemonic">gtk_label_new_with_mnemonic</link>(), so underscores
in <parameter>label</parameter> indicate the mnemonic for the button.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry> widget to get radio group from
</entry></row>
<row><entry align="right"><parameter>label</parameter>&nbsp;:</entry>
<entry> the text of the button, with an underscore in front of the
        mnemonic character
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a new <link linkend="GtkRadioButton">GtkRadioButton</link>
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-group">gtk_radio_button_group</title>
<programlisting>#define gtk_radio_button_group gtk_radio_button_get_group
</programlisting>
<warning>
<para>
<literal>gtk_radio_button_group</literal> is deprecated and should not be used in newly-written code.
</para>
</warning>
<para>
Deprecated compatibility macro. Use <link linkend="gtk-radio-button-get-group">gtk_radio_button_get_group</link>() instead.
</para></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-set-group">gtk_radio_button_set_group ()</title>
<programlisting>void        gtk_radio_button_set_group      (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_button,
                                             <link linkend="GSList">GSList</link> *group);</programlisting>
<para>
Sets a <link linkend="GtkRadioButton">GtkRadioButton</link>'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.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>radio_button</parameter>&nbsp;:</entry>
<entry>a <link linkend="GtkRadioButton">GtkRadioButton</link>.
</entry></row>
<row><entry align="right"><parameter>group</parameter>&nbsp;:</entry>
<entry>an existing radio button group, such as one returned from
<link linkend="gtk-radio-button-get-group">gtk_radio_button_get_group</link>().


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gtk-radio-button-get-group">gtk_radio_button_get_group ()</title>
<programlisting><link linkend="GSList">GSList</link>*     gtk_radio_button_get_group      (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_button);</programlisting>
<para>
Retrieves the group assigned to a radio button.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>radio_button</parameter>&nbsp;:</entry>
<entry>a <link linkend="GtkRadioButton">GtkRadioButton</link>.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a linked list containing all the radio buttons in the same group
as <parameter>radio_button</parameter>.


</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>
<refsect1>
<title>Properties</title>
<variablelist>
<varlistentry><term><anchor id="GtkRadioButton--group">&quot;<literal>group</literal>&quot; (<link linkend="GtkRadioButton">GtkRadioButton</link> : Write)</term>
<listitem>
<para>
Sets a new group for a radio button.
</para></listitem></varlistentry>

</variablelist>
</refsect1>



<refsect1>
<title>See Also</title>
<para>
<variablelist>
<varlistentry>
<term><link linkend="GtkOptionMenu">GtkOptionMenu</link></term>
<listitem><para>Another way of offering the user a single choice from
many.</para></listitem>
</varlistentry>
</variablelist>

</para>
</refsect1>

</refentry>
