1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
<!-- ##### SECTION Title ##### -->
GtkToggleButton
<!-- ##### SECTION Short_Description ##### -->
create buttons which retain their state.
<!-- ##### SECTION Long_Description ##### -->
<para>
A #GtkToggleButton is a #GtkButton which will remain 'pressed-in' when
clicked. Clicking again will cause the toggle button to return to its
normal state.
</para>
<para>
A toggle button is created by calling either gtk_toggle_button_new() or
gtk_toggle_button_new_with_label(). If using the former, it is advisable to
pack a widget, (such as a #GtkLabel and/or a #GtkPixmap), into the toggle
button's container. (See #GtkButton for more information).
</para>
<para>
The state of a #GtkToggleButton can be set specifically using
gtk_toggle_button_set_active(), and retrieved using
gtk_toggle_button_get_active().
</para>
<para>
To simply switch the state of a toggle button, use gtk_toggle_button_toggled.
</para>
<example>
<title>Creating two <structname>GtkToggleButton</structname> widgets.</title>
<programlisting>
void make_toggles (void) {
GtkWidget *dialog, *toggle1, *toggle2;
dialog = gtk_dialog_new (<!-- -->);
toggle1 = gtk_toggle_button_new_with_label ("Hi, i'm a toggle button.");
/* Makes this toggle button invisible */
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle1), TRUE);
g_signal_connect (toggle1, "toggled",
G_CALLBACK (output_state), NULL);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
toggle1, FALSE, FALSE, 2);
toggle2 = gtk_toggle_button_new_with_label ("Hi, i'm another toggle button.");
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2), FALSE);
g_signal_connect (toggle2, "toggled",
G_CALLBACK (output_state), NULL);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
toggle2, FALSE, FALSE, 2);
gtk_widget_show_all (dialog);
}
</programlisting>
</example>
<!-- ##### SECTION See_Also ##### -->
<para>
<variablelist>
<varlistentry>
<term>#GtkButton</term>
<listitem><para>a more general button.</para></listitem>
</varlistentry>
<varlistentry>
<term>#GtkCheckButton</term>
<listitem><para>another way of presenting a toggle option.</para></listitem>
</varlistentry>
<varlistentry>
<term>#GtkCheckMenuItem</term>
<listitem><para>a #GtkToggleButton as a menu item.</para></listitem>
</varlistentry>
</variablelist>
</para>
<!-- ##### STRUCT GtkToggleButton ##### -->
<para>
The #GtkToggleButton struct contains private data only, and should be manipulated using the functions below.
</para>
<!-- ##### SIGNAL GtkToggleButton::toggled ##### -->
<para>
Should be connected if you wish to perform an action whenever the
#GtkToggleButton's state is changed.
</para>
@togglebutton: the object which received the signal.
<!-- ##### ARG GtkToggleButton:active ##### -->
<para>
</para>
<!-- ##### ARG GtkToggleButton:draw-indicator ##### -->
<para>
</para>
<!-- ##### ARG GtkToggleButton:inconsistent ##### -->
<para>
</para>
<!-- ##### FUNCTION gtk_toggle_button_new ##### -->
<para>
Creates a new toggle button. A widget should be packed into the button, as in gtk_button_new().
</para>
@Returns: a new toggle button.
<!-- ##### FUNCTION gtk_toggle_button_new_with_label ##### -->
<para>
Creates a new toggle button with a text label.
</para>
@label: a string containing the message to be placed in the toggle button.
@Returns: a new toggle button.
<!-- ##### FUNCTION gtk_toggle_button_new_with_mnemonic ##### -->
<para>
</para>
@label:
@Returns:
<!-- ##### FUNCTION gtk_toggle_button_set_mode ##### -->
<para>
</para>
@toggle_button:
@draw_indicator:
<!-- ##### FUNCTION gtk_toggle_button_get_mode ##### -->
<para>
</para>
@toggle_button:
@Returns:
<!-- ##### MACRO gtk_toggle_button_set_state ##### -->
<para>
This is a deprecated macro, and is only maintained for compatibility reasons.
</para>
<!-- ##### FUNCTION gtk_toggle_button_toggled ##### -->
<para>
Emits the <link linkend="GtkToggleButton-toggled">toggled</link>
signal on the #GtkToggleButton. There is no good reason for an
application ever to call this function.
</para>
@toggle_button: a #GtkToggleButton.
<!-- ##### FUNCTION gtk_toggle_button_get_active ##### -->
<para>
Queries a #GtkToggleButton and returns its current state. Returns %TRUE if
the toggle button is pressed in and %FALSE if it is raised.
</para>
@toggle_button: a #GtkToggleButton.
@Returns: a #gboolean value.
<!-- ##### FUNCTION gtk_toggle_button_set_active ##### -->
<para>
Sets the status of the toggle button. Set to %TRUE if you want the
GtkToggleButton to be 'pressed in', and %FALSE to raise it.
This action causes the toggled signal to be emitted.
</para>
@toggle_button: a #GtkToggleButton.
@is_active: %TRUE or %FALSE.
<!-- ##### FUNCTION gtk_toggle_button_get_inconsistent ##### -->
<para>
</para>
@toggle_button:
@Returns:
<!-- ##### FUNCTION gtk_toggle_button_set_inconsistent ##### -->
<para>
</para>
@toggle_button:
@setting:
|