1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/toggleaction.h>
4 #include <gtkmm/private/toggleaction_p.h>
9 /* Copyright 2003 The gtkmm Development Team
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.
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.
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.
26 #include <gtk/gtktoggleaction.h>
32 ToggleAction::ToggleAction(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label, const Glib::ustring& tooltip, bool is_active)
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))
37 set_active(is_active);
40 Glib::RefPtr<ToggleAction> ToggleAction::create(const Glib::ustring& name, const Glib::ustring& label, const Glib::ustring& tooltip, bool is_active)
42 return Glib::RefPtr<ToggleAction>( new ToggleAction(name, Gtk::StockID(), label, tooltip, is_active) );
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)
47 return Glib::RefPtr<ToggleAction>( new ToggleAction(name, stock_id, label, tooltip, is_active) );
57 const Glib::SignalProxyInfo ToggleAction_signal_toggled_info =
60 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
61 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
64 } // anonymous namespace
70 Glib::RefPtr<Gtk::ToggleAction> wrap(GtkToggleAction* object, bool take_copy)
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.
76 } /* namespace Glib */
83 /* The *_Class implementation: */
85 const Glib::Class& ToggleAction_Class::init()
87 if(!gtype_) // create the GType if necessary
89 // Glib::Class has to know the class init function to clone custom types.
90 class_init_func_ = &ToggleAction_Class::class_init_function;
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();
96 // Create the wrapper type, with the same class/instance size as the base type.
97 register_derived_type(gtk_toggle_action_get_type());
99 // Add derived versions of interfaces, if the C type implements any interfaces:
105 void ToggleAction_Class::class_init_function(void* g_class, void* class_data)
107 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
108 CppClassParent::class_init_function(klass, class_data);
110 klass->toggled = &toggled_callback;
114 void ToggleAction_Class::toggled_callback(GtkToggleAction* self)
116 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
117 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
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
124 if(obj && obj->is_derived_())
126 try // Trap C++ exceptions which would normally be lost because this is a C callback.
128 // Call the virtual member method, which derived classes might override.
133 Glib::exception_handlers_invoke();
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).
142 // Call the original underlying C function:
143 if(base && base->toggled)
144 (*base->toggled)(self);
149 Glib::ObjectBase* ToggleAction_Class::wrap_new(GObject* object)
151 return new ToggleAction((GtkToggleAction*)object);
155 /* The implementation: */
157 GtkToggleAction* ToggleAction::gobj_copy()
163 ToggleAction::ToggleAction(const Glib::ConstructParams& construct_params)
165 Gtk::Action(construct_params)
168 ToggleAction::ToggleAction(GtkToggleAction* castitem)
170 Gtk::Action((GtkAction*)(castitem))
173 ToggleAction::~ToggleAction()
177 ToggleAction::CppClassType ToggleAction::toggleaction_class_; // initialize static member
179 GType ToggleAction::get_type()
181 return toggleaction_class_.init().get_type();
184 GType ToggleAction::get_base_type()
186 return gtk_toggle_action_get_type();
190 ToggleAction::ToggleAction()
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()))
197 Glib::RefPtr<ToggleAction> ToggleAction::create()
199 return Glib::RefPtr<ToggleAction>( new ToggleAction() );
201 void ToggleAction::toggled()
203 gtk_toggle_action_toggled(gobj());
206 void ToggleAction::set_active(bool is_active)
208 gtk_toggle_action_set_active(gobj(), static_cast<int>(is_active));
211 bool ToggleAction::get_active() const
213 return gtk_toggle_action_get_active(const_cast<GtkToggleAction*>(gobj()));
216 void ToggleAction::set_draw_as_radio(bool draw_as_radio)
218 gtk_toggle_action_set_draw_as_radio(gobj(), static_cast<int>(draw_as_radio));
221 bool ToggleAction::get_draw_as_radio() const
223 return gtk_toggle_action_get_draw_as_radio(const_cast<GtkToggleAction*>(gobj()));
227 Glib::SignalProxy0< void > ToggleAction::signal_toggled()
229 return Glib::SignalProxy0< void >(this, &ToggleAction_signal_toggled_info);
233 Glib::PropertyProxy<bool> ToggleAction::property_draw_as_radio()
235 return Glib::PropertyProxy<bool>(this, "draw-as-radio");
238 Glib::PropertyProxy_ReadOnly<bool> ToggleAction::property_draw_as_radio() const
240 return Glib::PropertyProxy_ReadOnly<bool>(this, "draw-as-radio");
244 void Gtk::ToggleAction::on_toggled()
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).
250 if(base && base->toggled)
251 (*base->toggled)(gobj());