1 /* gtkradiotoolbutton.c
3 * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
4 * Copyright (C) 2002 James Henstridge <james@daa.com.au>
5 * Copyright (C) 2003 Soeren Sandmann <sandmann@daimi.au.dk>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #include "gtkradiotoolbutton.h"
24 #include "gtkradiobutton.h"
27 static void gtk_radio_tool_button_init (GtkRadioToolButton *button);
28 static void gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass);
31 gtk_radio_tool_button_get_type (void)
33 static GType type = 0;
37 static const GTypeInfo type_info =
39 sizeof (GtkRadioToolButtonClass),
41 (GBaseFinalizeFunc) NULL,
42 (GClassInitFunc) gtk_radio_tool_button_class_init,
43 (GClassFinalizeFunc) NULL,
45 sizeof (GtkRadioToolButton),
47 (GInstanceInitFunc) gtk_radio_tool_button_init
50 type = g_type_register_static (GTK_TYPE_TOGGLE_TOOL_BUTTON,
51 "GtkRadioToolButton", &type_info, 0);
58 gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass)
60 GtkToolButtonClass *toolbutton_class;
62 toolbutton_class = (GtkToolButtonClass *)klass;
64 toolbutton_class->button_type = GTK_TYPE_RADIO_BUTTON;
68 gtk_radio_tool_button_init (GtkRadioToolButton *button)
70 GtkToolButton *tool_button = GTK_TOOL_BUTTON (button);
71 gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)), FALSE);
75 * gtk_radio_tool_button_new:
76 * @group: An existing radio button group, or %NULL if you are creating a new group
78 * Creates a new #GtkRadioToolButton, adding it to @group.
80 * Return value: The new #GtkRadioToolButton
85 gtk_radio_tool_button_new (GSList *group)
87 GtkRadioToolButton *button;
89 button = g_object_new (GTK_TYPE_RADIO_TOOL_BUTTON,
92 gtk_radio_tool_button_set_group (button, group);
94 return GTK_TOOL_ITEM (button);
98 * gtk_radio_tool_button_new_from_stock:
99 * @group: an existing radio button group, or %NULL if you are creating a new group
100 * @stock_id: the name of a stock item
102 * Creates a new #GtkRadioToolButton, adding it to @group.
103 * The new #GtkRadioToolButton will contain an icon and label from the
104 * stock item indicated by @stock_id.
106 * Return value: The new #GtkRadioToolItem
111 gtk_radio_tool_button_new_from_stock (GSList *group,
112 const gchar *stock_id)
114 GtkRadioToolButton *button;
116 g_return_val_if_fail (stock_id != NULL, NULL);
118 button = g_object_new (GTK_TYPE_RADIO_TOOL_BUTTON,
119 "stock_id", stock_id,
123 gtk_radio_tool_button_set_group (button, group);
125 return GTK_TOOL_ITEM (button);
129 * gtk_radio_tool_button_new_from_widget:
130 * @group: An existing #GtkRadioToolButton
132 * Creates a new #GtkRadioToolButton adding it to the same group as @gruup
134 * Return value: The new #GtkRadioToolButton
139 gtk_radio_tool_button_new_from_widget (GtkWidget *group)
143 g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (group), NULL);
146 list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
148 return gtk_radio_tool_button_new (list);
152 * gtk_radio_tool_button_new_with_stock_from_widget:
153 * @group: An existing #GtkRadioToolButton.
154 * @stock_id: the name of a stock item
156 * Creates a new #GtkRadioToolButton adding it to the same group as @group.
157 * The new #GtkRadioToolButton will contain an icon and label from the
158 * stock item indicated by @stock_id.
160 * Return value: A new #GtkRadioToolButton
165 gtk_radio_tool_button_new_with_stock_from_widget (GtkWidget *group,
166 const gchar *stock_id)
170 g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (group), NULL);
173 list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
175 return gtk_radio_tool_button_new_from_stock (list, stock_id);
178 static GtkRadioButton *
179 get_radio_button (GtkRadioToolButton *button)
181 return GTK_RADIO_BUTTON (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button)));
185 * gtk_radio_tool_button_get_group:
186 * @button: a #GtkRadioToolButton
188 * Returns the radio button group @button belongs to.
190 * Return value: The group @button belongs to.
195 gtk_radio_tool_button_get_group (GtkRadioToolButton *button)
197 g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button), NULL);
199 return gtk_radio_button_get_group (get_radio_button (button));
203 * gtk_radio_tool_button_set_group:
204 * @button: a #GtkRadioToolButton
205 * @group: an existing radio button group
207 * Adds @button to @group, removing it from the group it belonged to before.
212 gtk_radio_tool_button_set_group (GtkRadioToolButton *button,
215 g_return_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button));
217 gtk_radio_button_set_group (get_radio_button (button), group);