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 gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (GTK_TOOL_BUTTON (button)->button), FALSE);
74 gtk_radio_tool_button_new (GSList *group)
76 GtkRadioToolButton *button;
78 button = g_object_new (GTK_TYPE_RADIO_TOOL_BUTTON,
81 gtk_radio_tool_button_set_group (button, group);
83 return GTK_TOOL_ITEM (button);
87 gtk_radio_tool_button_new_from_stock (GSList *group,
88 const gchar *stock_id)
90 GtkRadioToolButton *button;
92 g_return_val_if_fail (stock_id != NULL, NULL);
94 button = g_object_new (GTK_TYPE_RADIO_TOOL_BUTTON,
99 gtk_radio_tool_button_set_group (button, group);
101 return GTK_TOOL_ITEM (button);
105 gtk_radio_tool_button_new_from_widget (GtkWidget *group,
106 const gchar *stock_id)
110 g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (group), NULL);
113 list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
115 return gtk_radio_tool_button_new_from_stock (list, stock_id);
119 gtk_radio_tool_button_new_with_stock_from_widget (GtkWidget *group)
123 g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (group), NULL);
126 list = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (group));
128 return gtk_radio_tool_button_new (list);
132 gtk_radio_tool_button_get_group (GtkRadioToolButton *button)
134 g_return_val_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button), NULL);
136 return gtk_radio_button_get_group (GTK_RADIO_BUTTON (GTK_TOOL_BUTTON (button)->button));
140 gtk_radio_tool_button_set_group (GtkRadioToolButton *button,
143 g_return_if_fail (GTK_IS_RADIO_TOOL_BUTTON (button));
145 gtk_radio_button_set_group (GTK_RADIO_BUTTON (GTK_TOOL_BUTTON (button)->button), group);