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