]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkradiobutton.sgml
Make 3.0 parallel-installable to 2.x
[~andy/gtk] / docs / reference / gtk / tmpl / gtkradiobutton.sgml
1 <!-- ##### SECTION Title ##### -->
2 GtkRadioButton
3
4 <!-- ##### SECTION Short_Description ##### -->
5 A choice from multiple check buttons
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 A single radio button performs the same basic function as a #GtkCheckButton,
10 as its position in the object hierarchy reflects. It is only when multiple
11 radio buttons are grouped together that they become a different user
12 interface component in their own right.</para>
13 <para>
14 Every radio button is a member of some group of radio buttons. When one is selected, all other
15 radio buttons in the same group are deselected. A #GtkRadioButton is one way
16 of giving the user a choice from many options.
17 </para>
18 <para>
19 Radio button widgets are created with gtk_radio_button_new(), passing NULL
20 as the argument if this is the first radio button in a group. In subsequent
21 calls, the group you wish to add this button to should be passed as an
22 argument. Optionally, gtk_radio_button_new_with_label() can be used if you
23 want a text label on the radio button.
24 </para>
25 <para>
26 Alternatively, when adding widgets to an existing group of radio buttons,
27 use gtk_radio_button_new_from_widget() with a #GtkRadioButton that already
28 has a group assigned to it. The convenience function
29 gtk_radio_button_new_with_label_from_widget() is also provided.
30 </para>
31 <para>
32 To retrieve the group a #GtkRadioButton is assigned to, use
33 gtk_radio_button_get_group().
34 </para>
35 <para>
36 To remove a #GtkRadioButton from one group and make it part of a new one, use gtk_radio_button_set_group().
37 </para>
38 <para>
39 The group list does not need to be freed, as each #GtkRadioButton will remove
40 itself and its list item when it is destroyed.
41 </para>
42 <para>
43 <example>
44 <title>How to create a group of two radio buttons.</title>
45 <programlisting>
46
47 void create_radio_buttons (void) {
48
49    GtkWidget *window, *radio1, *radio2, *box, *entry;
50    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
51    box = gtk_vbox_new (TRUE, 2);
52    
53    /* Create a radio button with a GtkEntry widget */
54    radio1 = gtk_radio_button_new (NULL);
55    entry = gtk_entry_new (<!-- -->);
56    gtk_container_add (GTK_CONTAINER (radio1), entry);
57    
58    
59    /* Create a radio button with a label */
60    radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
61                                                         "I'm the second radio button.");
62    
63    /* Pack them into a box, then show all the widgets */
64    gtk_box_pack_start (GTK_BOX (box), radio1, TRUE, TRUE, 2);
65    gtk_box_pack_start (GTK_BOX (box), radio2, TRUE, TRUE, 2);
66    gtk_container_add (GTK_CONTAINER (window), box);
67    gtk_widget_show_all (window);
68    return;
69 }
70
71 </programlisting>
72 </example>
73 </para>
74 <para>
75 When an unselected button in the group is clicked the clicked button
76 receives the "toggled" signal, as does the previously selected button.
77 Inside the "toggled" handler, gtk_toggle_button_get_active() can be used 
78 to determine if the button has been selected or deselected.
79 </para>
80
81 <!-- ##### SECTION See_Also ##### -->
82 <para>
83 <variablelist>
84 <varlistentry>
85 <term>#GtkOptionMenu</term>
86 <listitem><para>Another way of offering the user a single choice from
87 many.</para></listitem>
88 </varlistentry>
89 </variablelist>
90
91 </para>
92
93 <!-- ##### SECTION Stability_Level ##### -->
94
95
96 <!-- ##### SECTION Image ##### -->
97
98
99 <!-- ##### STRUCT GtkRadioButton ##### -->
100 <para>
101 Contains only private data that should be read and manipulated using the
102 functions below.
103 </para>
104
105
106 <!-- ##### SIGNAL GtkRadioButton::group-changed ##### -->
107 <para>
108
109 </para>
110
111 @radiobutton: the object which received the signal.
112
113 <!-- ##### ARG GtkRadioButton:group ##### -->
114 <para>
115 Sets a new group for a radio button.
116 </para>
117
118 <!-- ##### FUNCTION gtk_radio_button_new ##### -->
119 <para>
120 Creates a new #GtkRadioButton. To be of any practical value, a widget should
121 then be packed into the radio button.
122 </para>
123
124 @group: an existing radio button group, or %NULL if you are creating a new group.
125 @Returns: a new radio button.
126
127
128 <!-- ##### FUNCTION gtk_radio_button_new_from_widget ##### -->
129 <para>
130 Creates a new #GtkRadioButton, adding it to the same group as @radio_group_member.
131 As with gtk_radio_button_new(), a widget should be packed into the radio button.
132 </para>
133
134 @radio_group_member: an existing #GtkRadioButton.
135 @Returns: a new radio button.
136
137
138 <!-- ##### FUNCTION gtk_radio_button_new_with_label ##### -->
139 <para>
140 Creates a new #GtkRadioButton with a text label.
141 </para>
142
143 @group: an existing radio button group, or %NULL if you are creating a new
144 group.
145 @label: the text label to display next to the radio button.
146 @Returns: a new radio button.
147
148
149 <!-- ##### FUNCTION gtk_radio_button_new_with_label_from_widget ##### -->
150 <para>
151 Creates a new #GtkRadioButton with a text label, adding it to the same group
152 as @radio_group_member.
153 </para>
154
155 @radio_group_member: widget to get radio group from or NULL
156 @label: a text string to display next to the radio button.
157 @Returns: a new radio button.
158 <!-- # Unused Parameters # -->
159 @group: an existing #GtkRadioButton.
160
161
162 <!-- ##### FUNCTION gtk_radio_button_new_with_mnemonic ##### -->
163 <para>
164
165 </para>
166
167 @group: 
168 @label: 
169 @Returns: 
170
171
172 <!-- ##### FUNCTION gtk_radio_button_new_with_mnemonic_from_widget ##### -->
173 <para>
174
175 </para>
176
177 @radio_group_member: 
178 @label: 
179 @Returns: 
180
181
182 <!-- ##### FUNCTION gtk_radio_button_set_group ##### -->
183 <para>
184 Sets a #GtkRadioButton's group. It should be noted that this does not change
185 the layout of your interface in any way, so if you are changing the group,
186 it is likely you will need to re-arrange the user interface to reflect these
187 changes.
188 </para>
189
190 @radio_button: a #GtkRadioButton.
191 @group: an existing radio button group, such as one returned from
192 gtk_radio_button_get_group().
193
194
195 <!-- ##### FUNCTION gtk_radio_button_get_group ##### -->
196
197
198 @radio_button: 
199 @Returns: 
200
201