1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/action.h>
4 #include <gtkmm/private/action_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/gtkaction.h>
28 #include <gtkmm/menuitem.h>
29 #include <gtkmm/toolitem.h>
30 #include <gtkmm/image.h>
35 Action::Action(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label, const Glib::ustring& tooltip)
37 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
38 Glib::Object(Glib::ConstructParams(action_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))
41 Glib::RefPtr<Action> Action::create(const Glib::ustring& name, const Glib::ustring& label, const Glib::ustring& tooltip)
43 return Glib::RefPtr<Action>( new Action(name, Gtk::StockID(), label, tooltip) );
46 Glib::RefPtr<Action> Action::create(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label, const Glib::ustring& tooltip)
48 return Glib::RefPtr<Action>( new Action(name, stock_id, label, tooltip) );
52 void Action::set_tooltip(const Glib::ustring& tooltip)
54 property_tooltip() = tooltip;
64 const Glib::SignalProxyInfo Action_signal_activate_info =
67 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
68 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
71 } // anonymous namespace
77 Glib::RefPtr<Gtk::Action> wrap(GtkAction* object, bool take_copy)
79 return Glib::RefPtr<Gtk::Action>( dynamic_cast<Gtk::Action*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
80 //We use dynamic_cast<> in case of multiple inheritance.
83 } /* namespace Glib */
90 /* The *_Class implementation: */
92 const Glib::Class& Action_Class::init()
94 if(!gtype_) // create the GType if necessary
96 // Glib::Class has to know the class init function to clone custom types.
97 class_init_func_ = &Action_Class::class_init_function;
99 // This is actually just optimized away, apparently with no harm.
100 // Make sure that the parent type has been created.
101 //CppClassParent::CppObjectType::get_type();
103 // Create the wrapper type, with the same class/instance size as the base type.
104 register_derived_type(gtk_action_get_type());
106 // Add derived versions of interfaces, if the C type implements any interfaces:
112 void Action_Class::class_init_function(void* g_class, void* class_data)
114 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
115 CppClassParent::class_init_function(klass, class_data);
117 klass->create_menu_item = &create_menu_item_vfunc_callback;
118 klass->create_tool_item = &create_tool_item_vfunc_callback;
119 klass->connect_proxy = &connect_proxy_vfunc_callback;
120 klass->disconnect_proxy = &disconnect_proxy_vfunc_callback;
121 klass->activate = &activate_callback;
124 GtkWidget* Action_Class::create_menu_item_vfunc_callback(GtkAction* self)
126 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
127 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
129 // Non-gtkmmproc-generated custom classes implicitly call the default
130 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
131 // generated classes can use this optimisation, which avoids the unnecessary
132 // parameter conversions if there is no possibility of the virtual function
134 if(obj && obj->is_derived_())
136 try // Trap C++ exceptions which would normally be lost because this is a C callback.
138 // Call the virtual member method, which derived classes might override.
139 return (GtkWidget*)Glib::unwrap(obj->create_menu_item_vfunc());
143 Glib::exception_handlers_invoke();
148 BaseClassType *const base = static_cast<BaseClassType*>(
149 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
152 // Call the original underlying C function:
153 if(base && base->create_menu_item)
154 return (*base->create_menu_item)(self);
157 typedef GtkWidget* RType;
161 GtkWidget* Action_Class::create_tool_item_vfunc_callback(GtkAction* self)
163 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
164 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
166 // Non-gtkmmproc-generated custom classes implicitly call the default
167 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
168 // generated classes can use this optimisation, which avoids the unnecessary
169 // parameter conversions if there is no possibility of the virtual function
171 if(obj && obj->is_derived_())
173 try // Trap C++ exceptions which would normally be lost because this is a C callback.
175 // Call the virtual member method, which derived classes might override.
176 return (GtkWidget*)Glib::unwrap(obj->create_tool_item_vfunc());
180 Glib::exception_handlers_invoke();
185 BaseClassType *const base = static_cast<BaseClassType*>(
186 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
189 // Call the original underlying C function:
190 if(base && base->create_tool_item)
191 return (*base->create_tool_item)(self);
194 typedef GtkWidget* RType;
198 void Action_Class::connect_proxy_vfunc_callback(GtkAction* self, GtkWidget* proxy)
200 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
201 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
203 // Non-gtkmmproc-generated custom classes implicitly call the default
204 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
205 // generated classes can use this optimisation, which avoids the unnecessary
206 // parameter conversions if there is no possibility of the virtual function
208 if(obj && obj->is_derived_())
210 try // Trap C++ exceptions which would normally be lost because this is a C callback.
212 // Call the virtual member method, which derived classes might override.
213 obj->connect_proxy_vfunc(Glib::wrap(proxy)
218 Glib::exception_handlers_invoke();
223 BaseClassType *const base = static_cast<BaseClassType*>(
224 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
227 // Call the original underlying C function:
228 if(base && base->connect_proxy)
229 (*base->connect_proxy)(self, proxy);
233 void Action_Class::disconnect_proxy_vfunc_callback(GtkAction* self, GtkWidget* proxy)
235 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
236 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
238 // Non-gtkmmproc-generated custom classes implicitly call the default
239 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
240 // generated classes can use this optimisation, which avoids the unnecessary
241 // parameter conversions if there is no possibility of the virtual function
243 if(obj && obj->is_derived_())
245 try // Trap C++ exceptions which would normally be lost because this is a C callback.
247 // Call the virtual member method, which derived classes might override.
248 obj->disconnect_proxy_vfunc(Glib::wrap(proxy)
253 Glib::exception_handlers_invoke();
258 BaseClassType *const base = static_cast<BaseClassType*>(
259 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
262 // Call the original underlying C function:
263 if(base && base->disconnect_proxy)
264 (*base->disconnect_proxy)(self, proxy);
269 void Action_Class::activate_callback(GtkAction* self)
271 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
272 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
274 // Non-gtkmmproc-generated custom classes implicitly call the default
275 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
276 // generated classes can use this optimisation, which avoids the unnecessary
277 // parameter conversions if there is no possibility of the virtual function
279 if(obj && obj->is_derived_())
281 try // Trap C++ exceptions which would normally be lost because this is a C callback.
283 // Call the virtual member method, which derived classes might override.
288 Glib::exception_handlers_invoke();
293 BaseClassType *const base = static_cast<BaseClassType*>(
294 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
297 // Call the original underlying C function:
298 if(base && base->activate)
299 (*base->activate)(self);
304 Glib::ObjectBase* Action_Class::wrap_new(GObject* object)
306 return new Action((GtkAction*)object);
310 /* The implementation: */
312 GtkAction* Action::gobj_copy()
318 Action::Action(const Glib::ConstructParams& construct_params)
320 Glib::Object(construct_params)
323 Action::Action(GtkAction* castitem)
325 Glib::Object((GObject*)(castitem))
332 Action::CppClassType Action::action_class_; // initialize static member
334 GType Action::get_type()
336 return action_class_.init().get_type();
339 GType Action::get_base_type()
341 return gtk_action_get_type();
347 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
348 Glib::Object(Glib::ConstructParams(action_class_.init()))
352 Glib::RefPtr<Action> Action::create()
354 return Glib::RefPtr<Action>( new Action() );
356 Glib::ustring Action::get_name() const
358 return Glib::convert_const_gchar_ptr_to_ustring(gtk_action_get_name(const_cast<GtkAction*>(gobj())));
361 bool Action::is_sensitive() const
363 return gtk_action_is_sensitive(const_cast<GtkAction*>(gobj()));
366 bool Action::get_sensitive() const
368 return gtk_action_get_sensitive(const_cast<GtkAction*>(gobj()));
371 void Action::set_sensitive(bool sensitive)
373 gtk_action_set_sensitive(gobj(), static_cast<int>(sensitive));
376 bool Action::is_visible() const
378 return gtk_action_is_visible(const_cast<GtkAction*>(gobj()));
381 bool Action::get_visible() const
383 return gtk_action_get_visible(const_cast<GtkAction*>(gobj()));
386 void Action::set_visible(bool visible)
388 gtk_action_set_visible(gobj(), static_cast<int>(visible));
391 void Action::activate()
393 gtk_action_activate(gobj());
396 Image* Action::create_icon(IconSize icon_size)
398 return Glib::wrap((GtkImage*)(gtk_action_create_icon(gobj(), static_cast<GtkIconSize>(int(icon_size)))));
401 MenuItem* Action::create_menu_item()
403 return Glib::wrap((GtkMenuItem*)(gtk_action_create_menu_item(gobj())));
406 ToolItem* Action::create_tool_item()
408 return Glib::wrap((GtkToolItem*)(gtk_action_create_tool_item(gobj())));
411 void Action::connect_proxy(Widget& proxy)
413 gtk_action_connect_proxy(gobj(), (proxy).gobj());
416 void Action::disconnect_proxy(Widget& proxy)
418 gtk_action_disconnect_proxy(gobj(), (proxy).gobj());
421 Glib::SListHandle<Widget*> Action::get_proxies()
423 return Glib::SListHandle<Widget*>(gtk_action_get_proxies(gobj()), Glib::OWNERSHIP_SHALLOW);
426 Glib::SListHandle<const Widget*> Action::get_proxies() const
428 return Glib::SListHandle<const Widget*>(gtk_action_get_proxies(const_cast<GtkAction*>(gobj())), Glib::OWNERSHIP_SHALLOW);
431 void Action::connect_accelerator()
433 gtk_action_connect_accelerator(gobj());
436 void Action::disconnect_accelerator()
438 gtk_action_disconnect_accelerator(gobj());
441 Glib::ustring Action::get_accel_path() const
443 return Glib::convert_const_gchar_ptr_to_ustring(gtk_action_get_accel_path(const_cast<GtkAction*>(gobj())));
446 void Action::set_accel_path(const Glib::ustring& accel_path)
448 gtk_action_set_accel_path(gobj(), accel_path.c_str());
451 void Action::set_accel_group(const Glib::RefPtr<AccelGroup>& accel_group)
453 gtk_action_set_accel_group(gobj(), Glib::unwrap(accel_group));
456 void Action::block_activate_from(Widget& proxy)
458 gtk_action_block_activate_from(gobj(), (proxy).gobj());
461 void Action::unblock_activate_from(Widget& proxy)
463 gtk_action_unblock_activate_from(gobj(), (proxy).gobj());
467 Glib::SignalProxy0< void > Action::signal_activate()
469 return Glib::SignalProxy0< void >(this, &Action_signal_activate_info);
473 Glib::PropertyProxy_ReadOnly<Glib::ustring> Action::property_name() const
475 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "name");
478 Glib::PropertyProxy<Glib::ustring> Action::property_label()
480 return Glib::PropertyProxy<Glib::ustring>(this, "label");
483 Glib::PropertyProxy_ReadOnly<Glib::ustring> Action::property_label() const
485 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "label");
488 Glib::PropertyProxy<Glib::ustring> Action::property_short_label()
490 return Glib::PropertyProxy<Glib::ustring>(this, "short-label");
493 Glib::PropertyProxy_ReadOnly<Glib::ustring> Action::property_short_label() const
495 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "short-label");
498 Glib::PropertyProxy<Glib::ustring> Action::property_tooltip()
500 return Glib::PropertyProxy<Glib::ustring>(this, "tooltip");
503 Glib::PropertyProxy_ReadOnly<Glib::ustring> Action::property_tooltip() const
505 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "tooltip");
508 Glib::PropertyProxy<StockID> Action::property_stock_id()
510 return Glib::PropertyProxy<StockID>(this, "stock-id");
513 Glib::PropertyProxy_ReadOnly<StockID> Action::property_stock_id() const
515 return Glib::PropertyProxy_ReadOnly<StockID>(this, "stock-id");
518 Glib::PropertyProxy<bool> Action::property_visible_horizontal()
520 return Glib::PropertyProxy<bool>(this, "visible-horizontal");
523 Glib::PropertyProxy_ReadOnly<bool> Action::property_visible_horizontal() const
525 return Glib::PropertyProxy_ReadOnly<bool>(this, "visible-horizontal");
528 Glib::PropertyProxy<bool> Action::property_visible_vertical()
530 return Glib::PropertyProxy<bool>(this, "visible-vertical");
533 Glib::PropertyProxy_ReadOnly<bool> Action::property_visible_vertical() const
535 return Glib::PropertyProxy_ReadOnly<bool>(this, "visible-vertical");
538 Glib::PropertyProxy<bool> Action::property_is_important()
540 return Glib::PropertyProxy<bool>(this, "is-important");
543 Glib::PropertyProxy_ReadOnly<bool> Action::property_is_important() const
545 return Glib::PropertyProxy_ReadOnly<bool>(this, "is-important");
548 Glib::PropertyProxy<bool> Action::property_hide_if_empty()
550 return Glib::PropertyProxy<bool>(this, "hide-if-empty");
553 Glib::PropertyProxy_ReadOnly<bool> Action::property_hide_if_empty() const
555 return Glib::PropertyProxy_ReadOnly<bool>(this, "hide-if-empty");
558 Glib::PropertyProxy<bool> Action::property_sensitive()
560 return Glib::PropertyProxy<bool>(this, "sensitive");
563 Glib::PropertyProxy_ReadOnly<bool> Action::property_sensitive() const
565 return Glib::PropertyProxy_ReadOnly<bool>(this, "sensitive");
568 Glib::PropertyProxy<bool> Action::property_visible()
570 return Glib::PropertyProxy<bool>(this, "visible");
573 Glib::PropertyProxy_ReadOnly<bool> Action::property_visible() const
575 return Glib::PropertyProxy_ReadOnly<bool>(this, "visible");
579 void Gtk::Action::on_activate()
581 BaseClassType *const base = static_cast<BaseClassType*>(
582 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
585 if(base && base->activate)
586 (*base->activate)(gobj());
590 Widget* Gtk::Action::create_menu_item_vfunc()
592 BaseClassType *const base = static_cast<BaseClassType*>(
593 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
596 if(base && base->create_menu_item)
597 return Glib::wrap((*base->create_menu_item)(gobj()));
599 typedef Widget* RType;
603 Widget* Gtk::Action::create_tool_item_vfunc()
605 BaseClassType *const base = static_cast<BaseClassType*>(
606 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
609 if(base && base->create_tool_item)
610 return Glib::wrap((*base->create_tool_item)(gobj()));
612 typedef Widget* RType;
616 void Gtk::Action::connect_proxy_vfunc(Widget* proxy)
618 BaseClassType *const base = static_cast<BaseClassType*>(
619 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
622 if(base && base->connect_proxy)
623 (*base->connect_proxy)(gobj(),(GtkWidget*)Glib::unwrap(proxy));
626 void Gtk::Action::disconnect_proxy_vfunc(Widget* proxy)
628 BaseClassType *const base = static_cast<BaseClassType*>(
629 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
632 if(base && base->disconnect_proxy)
633 (*base->disconnect_proxy)(gobj(),(GtkWidget*)Glib::unwrap(proxy));