1 // Generated by gmmproc 2.60.0 -- DO NOT MODIFY!
2 
3 
4 #include <glibmm.h>
5 
6 #include <gtkmm/switch.h>
7 #include <gtkmm/private/switch_p.h>
8 
9 
10 /*
11  * Copyright 1998-2002 The gtkmm Development Team
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26  */
27 
28 #include <gtk/gtk.h>
29 
30 namespace Gtk
31 {
32 
33 } // namespace Gtk
34 
35 
36 namespace
37 {
38 
39 
Switch_signal_state_set_callback(GtkSwitch * self,gboolean p0,void * data)40 static gboolean Switch_signal_state_set_callback(GtkSwitch* self, gboolean p0,void* data)
41 {
42   using namespace Gtk;
43   using SlotType = sigc::slot< bool,bool >;
44 
45   auto obj = dynamic_cast<Switch*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
46   // Do not try to call a signal on a disassociated wrapper.
47   if(obj)
48   {
49     try
50     {
51       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
52         return static_cast<int>((*static_cast<SlotType*>(slot))(p0
53 ));
54     }
55     catch(...)
56     {
57        Glib::exception_handlers_invoke();
58     }
59   }
60 
61   using RType = gboolean;
62   return RType();
63 }
64 
Switch_signal_state_set_notify_callback(GtkSwitch * self,gboolean p0,void * data)65 static gboolean Switch_signal_state_set_notify_callback(GtkSwitch* self, gboolean p0, void* data)
66 {
67   using namespace Gtk;
68   using SlotType = sigc::slot< void,bool >;
69 
70   auto obj = dynamic_cast<Switch*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
71   // Do not try to call a signal on a disassociated wrapper.
72   if(obj)
73   {
74     try
75     {
76       if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
77         (*static_cast<SlotType*>(slot))(p0
78 );
79     }
80     catch(...)
81     {
82       Glib::exception_handlers_invoke();
83     }
84   }
85 
86   using RType = gboolean;
87   return RType();
88 }
89 
90 static const Glib::SignalProxyInfo Switch_signal_state_set_info =
91 {
92   "state-set",
93   (GCallback) &Switch_signal_state_set_callback,
94   (GCallback) &Switch_signal_state_set_notify_callback
95 };
96 
97 
98 } // anonymous namespace
99 
100 
101 namespace Glib
102 {
103 
wrap(GtkSwitch * object,bool take_copy)104 Gtk::Switch* wrap(GtkSwitch* object, bool take_copy)
105 {
106   return dynamic_cast<Gtk::Switch *> (Glib::wrap_auto ((GObject*)(object), take_copy));
107 }
108 
109 } /* namespace Glib */
110 
111 namespace Gtk
112 {
113 
114 
115 /* The *_Class implementation: */
116 
init()117 const Glib::Class& Switch_Class::init()
118 {
119   if(!gtype_) // create the GType if necessary
120   {
121     // Glib::Class has to know the class init function to clone custom types.
122     class_init_func_ = &Switch_Class::class_init_function;
123 
124     // This is actually just optimized away, apparently with no harm.
125     // Make sure that the parent type has been created.
126     //CppClassParent::CppObjectType::get_type();
127 
128     // Create the wrapper type, with the same class/instance size as the base type.
129     register_derived_type(gtk_switch_get_type());
130 
131     // Add derived versions of interfaces, if the C type implements any interfaces:
132   Activatable::add_interface(get_type());
133 
134   }
135 
136   return *this;
137 }
138 
139 
class_init_function(void * g_class,void * class_data)140 void Switch_Class::class_init_function(void* g_class, void* class_data)
141 {
142   const auto klass = static_cast<BaseClassType*>(g_class);
143   CppClassParent::class_init_function(klass, class_data);
144 
145 
146   klass->state_set = &state_set_callback;
147 }
148 
149 
state_set_callback(GtkSwitch * self,gboolean p0)150 gboolean Switch_Class::state_set_callback(GtkSwitch* self, gboolean p0)
151 {
152   const auto obj_base = static_cast<Glib::ObjectBase*>(
153       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
154 
155   // Non-gtkmmproc-generated custom classes implicitly call the default
156   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
157   // generated classes can use this optimisation, which avoids the unnecessary
158   // parameter conversions if there is no possibility of the virtual function
159   // being overridden:
160   if(obj_base && obj_base->is_derived_())
161   {
162     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
163     if(obj) // This can be NULL during destruction.
164     {
165       try // Trap C++ exceptions which would normally be lost because this is a C callback.
166       {
167         // Call the virtual member method, which derived classes might override.
168         return static_cast<int>(obj->on_state_set(p0
169 ));
170       }
171       catch(...)
172       {
173         Glib::exception_handlers_invoke();
174       }
175     }
176   }
177 
178   const auto base = static_cast<BaseClassType*>(
179         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
180     );
181 
182   // Call the original underlying C function:
183   if(base && base->state_set)
184     return (*base->state_set)(self, p0);
185 
186   using RType = gboolean;
187   return RType();
188 }
189 
190 
wrap_new(GObject * o)191 Glib::ObjectBase* Switch_Class::wrap_new(GObject* o)
192 {
193   return manage(new Switch((GtkSwitch*)(o)));
194 
195 }
196 
197 
198 /* The implementation: */
199 
Switch(const Glib::ConstructParams & construct_params)200 Switch::Switch(const Glib::ConstructParams& construct_params)
201 :
202   Gtk::Widget(construct_params)
203 {
204   }
205 
Switch(GtkSwitch * castitem)206 Switch::Switch(GtkSwitch* castitem)
207 :
208   Gtk::Widget((GtkWidget*)(castitem))
209 {
210   }
211 
212 
Switch(Switch && src)213 Switch::Switch(Switch&& src) noexcept
214 : Gtk::Widget(std::move(src))
215   , Activatable(std::move(src))
216 {}
217 
operator =(Switch && src)218 Switch& Switch::operator=(Switch&& src) noexcept
219 {
220   Gtk::Widget::operator=(std::move(src));
221   Activatable::operator=(std::move(src));
222   return *this;
223 }
224 
~Switch()225 Switch::~Switch() noexcept
226 {
227   destroy_();
228 }
229 
230 Switch::CppClassType Switch::switch_class_; // initialize static member
231 
get_type()232 GType Switch::get_type()
233 {
234   return switch_class_.init().get_type();
235 }
236 
237 
get_base_type()238 GType Switch::get_base_type()
239 {
240   return gtk_switch_get_type();
241 }
242 
243 
Switch()244 Switch::Switch()
245 :
246   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
247   Glib::ObjectBase(nullptr),
248   Gtk::Widget(Glib::ConstructParams(switch_class_.init()))
249 {
250 
251 
252 }
253 
set_active(bool is_active)254 void Switch::set_active(bool is_active)
255 {
256   gtk_switch_set_active(gobj(), static_cast<int>(is_active));
257 }
258 
get_active() const259 bool Switch::get_active() const
260 {
261   return gtk_switch_get_active(const_cast<GtkSwitch*>(gobj()));
262 }
263 
set_state(bool state)264 void Switch::set_state(bool state)
265 {
266   gtk_switch_set_state(gobj(), static_cast<int>(state));
267 }
268 
get_state() const269 bool Switch::get_state() const
270 {
271   return gtk_switch_get_state(const_cast<GtkSwitch*>(gobj()));
272 }
273 
274 
signal_state_set()275 Glib::SignalProxy< bool,bool > Switch::signal_state_set()
276 {
277   return Glib::SignalProxy< bool,bool >(this, &Switch_signal_state_set_info);
278 }
279 
280 
property_active()281 Glib::PropertyProxy< bool > Switch::property_active()
282 {
283   return Glib::PropertyProxy< bool >(this, "active");
284 }
285 
property_active() const286 Glib::PropertyProxy_ReadOnly< bool > Switch::property_active() const
287 {
288   return Glib::PropertyProxy_ReadOnly< bool >(this, "active");
289 }
290 
property_state()291 Glib::PropertyProxy< bool > Switch::property_state()
292 {
293   return Glib::PropertyProxy< bool >(this, "state");
294 }
295 
property_state() const296 Glib::PropertyProxy_ReadOnly< bool > Switch::property_state() const
297 {
298   return Glib::PropertyProxy_ReadOnly< bool >(this, "state");
299 }
300 
301 
on_state_set(bool state)302 bool Gtk::Switch::on_state_set(bool state)
303 {
304   const auto base = static_cast<BaseClassType*>(
305       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
306   );
307 
308   if(base && base->state_set)
309     return (*base->state_set)(gobj(),static_cast<int>(state));
310 
311   using RType = bool;
312   return RType();
313 }
314 
315 
316 } // namespace Gtk
317 
318 
319