add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / radiobutton.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <gtkmm/radiobutton.h>
5 #include <gtkmm/private/radiobutton_p.h>
6
7 // -*- c++ -*-
8 /* $Id$ */
9
10 /* 
11  *
12  * Copyright 1998-2002 The gtkmm Development Team
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Library General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * Library General Public License for more details.
23  *
24  * You should have received a copy of the GNU Library General Public
25  * License along with this library; if not, write to the Free
26  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  */
28
29 #include <gtk/gtkradiobutton.h>
30
31 typedef Gtk::RadioButton::Group Group; //So that the generate get_group return type is parsed.
32
33 namespace Gtk
34 {
35
36 RadioButton::RadioButton()
37 :
38   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
39   Glib::ObjectBase(0),
40   Gtk::CheckButton(Glib::ConstructParams(radiobutton_class_.init()))
41 {}
42
43 RadioButton::RadioButton(const Glib::ustring& label, bool mnemonic)
44 :
45   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
46   Glib::ObjectBase(0),
47   Gtk::CheckButton(Glib::ConstructParams(radiobutton_class_.init(), "label",label.c_str(),"use_underline",gboolean(mnemonic), static_cast<char*>(0)))
48 {}
49
50 RadioButton::RadioButton(Group& group)
51 :
52   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
53   Glib::ObjectBase(0),
54   Gtk::CheckButton(Glib::ConstructParams(radiobutton_class_.init()))
55 {
56   group.add(*this);
57 }
58
59 RadioButton::RadioButton(Group& group, const Glib::ustring& label, bool mnemonic)
60 :
61   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
62   Glib::ObjectBase(0),
63   Gtk::CheckButton(Glib::ConstructParams(radiobutton_class_.init(), "label",label.c_str(),"use_underline",gboolean(mnemonic), static_cast<char*>(0)))
64 {
65   group.add(*this);
66 }
67
68 void RadioButton::set_group(Group& group)
69 {
70   gtk_radio_button_set_group(gobj(), group.group_);
71
72   //The group will be updated, ready for use with the next radiobutton:
73   group = get_group();
74 }
75
76 void RadioButton::reset_group()
77 {
78   gtk_radio_button_set_group(gobj(), 0);
79 }
80
81 } //namespace Gtk
82
83
84 namespace
85 {
86
87
88 static const Glib::SignalProxyInfo RadioButton_signal_group_changed_info =
89 {
90   "group_changed",
91   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
92   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
93 };
94
95
96 } // anonymous namespace
97
98
99 namespace Glib
100 {
101
102 Gtk::RadioButton* wrap(GtkRadioButton* object, bool take_copy)
103 {
104   return dynamic_cast<Gtk::RadioButton *> (Glib::wrap_auto ((GObject*)(object), take_copy));
105 }
106
107 } /* namespace Glib */
108
109 namespace Gtk
110 {
111
112
113 /* The *_Class implementation: */
114
115 const Glib::Class& RadioButton_Class::init()
116 {
117   if(!gtype_) // create the GType if necessary
118   {
119     // Glib::Class has to know the class init function to clone custom types.
120     class_init_func_ = &RadioButton_Class::class_init_function;
121
122     // This is actually just optimized away, apparently with no harm.
123     // Make sure that the parent type has been created.
124     //CppClassParent::CppObjectType::get_type();
125
126     // Create the wrapper type, with the same class/instance size as the base type.
127     register_derived_type(gtk_radio_button_get_type());
128
129     // Add derived versions of interfaces, if the C type implements any interfaces:
130   }
131
132   return *this;
133 }
134
135 void RadioButton_Class::class_init_function(void* g_class, void* class_data)
136 {
137   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
138   CppClassParent::class_init_function(klass, class_data);
139
140 #ifdef GLIBMM_VFUNCS_ENABLED
141 #endif //GLIBMM_VFUNCS_ENABLED
142
143 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
144   klass->group_changed = &group_changed_callback;
145 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
146 }
147
148 #ifdef GLIBMM_VFUNCS_ENABLED
149 #endif //GLIBMM_VFUNCS_ENABLED
150
151 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
152 void RadioButton_Class::group_changed_callback(GtkRadioButton* self)
153 {
154   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
155       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
156
157   // Non-gtkmmproc-generated custom classes implicitly call the default
158   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
159   // generated classes can use this optimisation, which avoids the unnecessary
160   // parameter conversions if there is no possibility of the virtual function
161   // being overridden:
162   if(obj_base && obj_base->is_derived_())
163   {
164     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
165     if(obj) // This can be NULL during destruction.
166     {
167       #ifdef GLIBMM_EXCEPTIONS_ENABLED
168       try // Trap C++ exceptions which would normally be lost because this is a C callback.
169       {
170       #endif //GLIBMM_EXCEPTIONS_ENABLED
171         // Call the virtual member method, which derived classes might override.
172         obj->on_group_changed();
173         return;
174       #ifdef GLIBMM_EXCEPTIONS_ENABLED
175       }
176       catch(...)
177       {
178         Glib::exception_handlers_invoke();
179       }
180       #endif //GLIBMM_EXCEPTIONS_ENABLED
181     }
182   }
183   
184   BaseClassType *const base = static_cast<BaseClassType*>(
185         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
186     );
187
188   // Call the original underlying C function:
189   if(base && base->group_changed)
190     (*base->group_changed)(self);
191 }
192 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
193
194
195 Glib::ObjectBase* RadioButton_Class::wrap_new(GObject* o)
196 {
197   return manage(new RadioButton((GtkRadioButton*)(o)));
198
199 }
200
201
202 /* The implementation: */
203
204 RadioButton::RadioButton(const Glib::ConstructParams& construct_params)
205 :
206   Gtk::CheckButton(construct_params)
207 {
208   }
209
210 RadioButton::RadioButton(GtkRadioButton* castitem)
211 :
212   Gtk::CheckButton((GtkCheckButton*)(castitem))
213 {
214   }
215
216 RadioButton::~RadioButton()
217 {
218   destroy_();
219 }
220
221 RadioButton::CppClassType RadioButton::radiobutton_class_; // initialize static member
222
223 GType RadioButton::get_type()
224 {
225   return radiobutton_class_.init().get_type();
226 }
227
228 GType RadioButton::get_base_type()
229 {
230   return gtk_radio_button_get_type();
231 }
232
233
234 Group RadioButton::get_group()
235 {
236   return Group(gtk_radio_button_get_group(gobj()));
237 }
238
239
240 Glib::SignalProxy0< void > RadioButton::signal_group_changed()
241 {
242   return Glib::SignalProxy0< void >(this, &RadioButton_signal_group_changed_info);
243 }
244
245
246 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
247 void Gtk::RadioButton::on_group_changed()
248 {
249   BaseClassType *const base = static_cast<BaseClassType*>(
250       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
251   );
252
253   if(base && base->group_changed)
254     (*base->group_changed)(gobj());
255 }
256 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
257
258 #ifdef GLIBMM_VFUNCS_ENABLED
259 #endif //GLIBMM_VFUNCS_ENABLED
260
261
262 } // namespace Gtk
263
264