<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<!--ENTITY index-Objects-Grouped SYSTEM "objects_grouped.sgml"-->
<refentry id="GtkRadioButton">
<refmeta>
<refentrytitle role="top_of_page" id="GtkRadioButton.top_of_page">GtkRadioButton</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>

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

<refsynopsisdiv id="GtkRadioButton.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

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

                    <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> *radio_group_member);
<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> *radio_group_member,
                                                         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> *radio_group_member,
                                                         const <link linkend="gchar">gchar</link> *label);
#define             <link linkend="gtk-radio-button-group">gtk_radio_button_group</link>
<link linkend="void">void</link>                <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 id="GtkRadioButton.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----<link linkend="GInitiallyUnowned">GInitiallyUnowned</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 id="GtkRadioButton.implemented-interfaces" role="impl_interfaces">
<title role="impl_interfaces.title">Implemented Interfaces</title>
<para>
GtkRadioButton implements
 <link linkend="GtkActivatable">GtkActivatable</link>,  <link linkend="AtkImplementorIface">AtkImplementorIface</link> and  <link linkend="GtkBuildable">GtkBuildable</link>.</para>
</refsect1>


<refsect1 id="GtkRadioButton.properties" role="properties">
<title role="properties.title">Properties</title>
<synopsis>
  &quot;<link linkend="GtkRadioButton--group">group</link>&quot;                    <link linkend="GtkRadioButton">GtkRadioButton</link>*       : Write
</synopsis>
</refsect1>

<refsect1 id="GtkRadioButton.signals" role="signal_proto">
<title role="signal_proto.title">Signals</title>
<synopsis>
  &quot;<link linkend="GtkRadioButton-group-changed">group-changed</link>&quot;                                  : Run First
</synopsis>
</refsect1>


<refsect1 id="GtkRadioButton.description" role="desc">
<title role="desc.title">Description</title>
<para>
A single radio button performs the same basic function as a <link linkend="GtkCheckButton"><type>GtkCheckButton</type></link>,
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.</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"><type>GtkRadioButton</type></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"><function>gtk_radio_button_new()</function></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"><function>gtk_radio_button_new_with_label()</function></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"><function>gtk_radio_button_new_from_widget()</function></link> with a <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link> that already
has a group assigned to it. The convenience function
<link linkend="gtk-radio-button-new-with-label-from-widget"><function>gtk_radio_button_new_with_label_from_widget()</function></link> is also provided.
</para>
<para>
To retrieve the group a <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link> is assigned to, use
<link linkend="gtk-radio-button-get-group"><function>gtk_radio_button_get_group()</function></link>.
</para>
<para>
To remove a <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link> from one group and make it part of a new one, use <link linkend="gtk-radio-button-set-group"><function>gtk_radio_button_set_group()</function></link>.
</para>
<para>
The group list does not need to be freed, as each <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link> will remove
itself and its list item when it is destroyed.
</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>
<para>
When an unselected button in the group is clicked the clicked button
receives the "toggled" signal, as does the previously selected button.
Inside the "toggled" handler, <link linkend="gtk-toggle-button-get-active"><function>gtk_toggle_button_get_active()</function></link> can be used
to determine if the button has been selected or deselected.
</para>
</refsect1>

<refsect1 id="GtkRadioButton.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GtkRadioButton-struct" role="struct">
<title>GtkRadioButton</title>
<indexterm zone="GtkRadioButton-struct"><primary sortas="RadioButton">GtkRadioButton</primary></indexterm><programlisting>typedef struct _GtkRadioButton GtkRadioButton;</programlisting>
<para>
Contains only private data that should be read and manipulated using the
functions below.
</para></refsect2>
<refsect2 id="gtk-radio-button-new" role="function">
<title>gtk_radio_button_new ()</title>
<indexterm zone="gtk-radio-button-new"><primary sortas="radio_button_new">gtk_radio_button_new</primary></indexterm><programlisting><link linkend="GtkWidget">GtkWidget</link>*          gtk_radio_button_new                (<link linkend="GSList">GSList</link> *group);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>. To be of any practical value, a widget should
then be packed into the radio button.
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara>an existing radio button group, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if you are creating a new group.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a new radio button.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-new-from-widget" role="function">
<title>gtk_radio_button_new_from_widget ()</title>
<indexterm zone="gtk-radio-button-new-from-widget"><primary sortas="radio_button_new_from_widget">gtk_radio_button_new_from_widget</primary></indexterm><programlisting><link linkend="GtkWidget">GtkWidget</link>*          gtk_radio_button_new_from_widget    (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_group_member);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>, adding it to the same group as <parameter>radio_group_member</parameter>.
As with <link linkend="gtk-radio-button-new"><function>gtk_radio_button_new()</function></link>, a widget should be packed into the radio button.
</para><variablelist role="params">
<varlistentry><term><parameter>radio_group_member</parameter>&#160;:</term>
<listitem><simpara>an existing <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a new radio button.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-new-with-label" role="function">
<title>gtk_radio_button_new_with_label ()</title>
<indexterm zone="gtk-radio-button-new-with-label"><primary sortas="radio_button_new_with_label">gtk_radio_button_new_with_label</primary></indexterm><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"><type>GtkRadioButton</type></link> with a text label.
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara>an existing radio button group, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> if you are creating a new
group.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>label</parameter>&#160;:</term>
<listitem><simpara>the text label to display next to the radio button.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a new radio button.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-new-with-label-from-widget" role="function">
<title>gtk_radio_button_new_with_label_from_widget ()</title>
<indexterm zone="gtk-radio-button-new-with-label-from-widget"><primary sortas="radio_button_new_with_label_from_widget">gtk_radio_button_new_with_label_from_widget</primary></indexterm><programlisting><link linkend="GtkWidget">GtkWidget</link>*          gtk_radio_button_new_with_label_from_widget
                                                        (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_group_member,
                                                         const <link linkend="gchar">gchar</link> *label);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link> with a text label, adding it to the same group
as <parameter>radio_group_member</parameter>.
</para><variablelist role="params">
<varlistentry><term><parameter>radio_group_member</parameter>&#160;:</term>
<listitem><simpara>widget to get radio group from or NULL
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>label</parameter>&#160;:</term>
<listitem><simpara>a text string to display next to the radio button.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a new radio button.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-new-with-mnemonic" role="function">
<title>gtk_radio_button_new_with_mnemonic ()</title>
<indexterm zone="gtk-radio-button-new-with-mnemonic"><primary sortas="radio_button_new_with_mnemonic">gtk_radio_button_new_with_mnemonic</primary></indexterm><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"><type>GtkRadioButton</type></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"><function>gtk_label_new_with_mnemonic()</function></link>, so underscores in <parameter>label</parameter> indicate the 
mnemonic for the button.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara> the radio button group
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>label</parameter>&#160;:</term>
<listitem><simpara> the text of the button, with an underscore in front of the
        mnemonic character
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-new-with-mnemonic-from-widget" role="function">
<title>gtk_radio_button_new_with_mnemonic_from_widget ()</title>
<indexterm zone="gtk-radio-button-new-with-mnemonic-from-widget"><primary sortas="radio_button_new_with_mnemonic_from_widget">gtk_radio_button_new_with_mnemonic_from_widget</primary></indexterm><programlisting><link linkend="GtkWidget">GtkWidget</link>*          gtk_radio_button_new_with_mnemonic_from_widget
                                                        (<link linkend="GtkRadioButton">GtkRadioButton</link> *radio_group_member,
                                                         const <link linkend="gchar">gchar</link> *label);</programlisting>
<para>
Creates a new <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link> containing a label. The label
will be created using <link linkend="gtk-label-new-with-mnemonic"><function>gtk_label_new_with_mnemonic()</function></link>, so underscores
in <parameter>label</parameter> indicate the mnemonic for the button.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>radio_group_member</parameter>&#160;:</term>
<listitem><simpara> widget to get radio group from or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>label</parameter>&#160;:</term>
<listitem><simpara> the text of the button, with an underscore in front of the
        mnemonic character
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-group" role="macro" condition="deprecated:">
<title>gtk_radio_button_group</title>
<indexterm zone="gtk-radio-button-group" role="deprecated"><primary sortas="radio_button_group">gtk_radio_button_group</primary></indexterm><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"><function>gtk_radio_button_get_group()</function></link> instead.
</para></refsect2>
<refsect2 id="gtk-radio-button-set-group" role="function">
<title>gtk_radio_button_set_group ()</title>
<indexterm zone="gtk-radio-button-set-group"><primary sortas="radio_button_set_group">gtk_radio_button_set_group</primary></indexterm><programlisting><link linkend="void">void</link>                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"><type>GtkRadioButton</type></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><variablelist role="params">
<varlistentry><term><parameter>radio_button</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>group</parameter>&#160;:</term>
<listitem><simpara>an existing radio button group, such as one returned from
<link linkend="gtk-radio-button-get-group"><function>gtk_radio_button_get_group()</function></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-radio-button-get-group" role="function">
<title>gtk_radio_button_get_group ()</title>
<indexterm zone="gtk-radio-button-get-group"><primary sortas="radio_button_get_group">gtk_radio_button_get_group</primary></indexterm><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><variablelist role="params">
<varlistentry><term><parameter>radio_button</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GtkRadioButton"><type>GtkRadioButton</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a linked list containing all the radio buttons in the same group
as <parameter>radio_button</parameter>. The returned list is owned by the radio button
and must not be modified or freed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>
<refsect1 id="GtkRadioButton.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GtkRadioButton--group" role="property"><title>The <literal>&quot;group&quot;</literal> property</title>
<indexterm zone="GtkRadioButton--group"><primary sortas="RadioButton:group">GtkRadioButton:group</primary></indexterm><programlisting>  &quot;group&quot;                    <link linkend="GtkRadioButton">GtkRadioButton</link>*       : Write</programlisting>
<para>
Sets a new group for a radio button.
</para></refsect2>
</refsect1>

<refsect1 id="GtkRadioButton.signal-details" role="signals">
<title role="signals.title">Signal Details</title>
<refsect2 id="GtkRadioButton-group-changed" role="signal"><title>The <literal>&quot;group-changed&quot;</literal> signal</title>
<indexterm zone="GtkRadioButton-group-changed" role="2.4"><primary sortas="RadioButton::group-changed">GtkRadioButton::group-changed</primary></indexterm><programlisting><link linkend="void">void</link>                user_function                      (<link linkend="GtkRadioButton">GtkRadioButton</link> *style,
                                                        <link linkend="gpointer">gpointer</link>        user_data)      : Run First</programlisting>
<para>
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.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>style</parameter>&#160;:</term>
<listitem><simpara> the object which received the signal
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data set when the signal handler was connected.</simpara></listitem></varlistentry>
</variablelist><para>Since 2.4</para></refsect2>
</refsect1>


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

</refentry>
