1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef GTKMM_DISABLE_DEPRECATED
6 #include <gtkmm/optionmenu.h>
7 #include <gtkmm/private/optionmenu_p.h>
14 * Copyright 1998-2002 The gtkmm Development Team
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Library General Public
18 * License as published by the Free Software Foundation; either
19 * version 2 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Library General Public License for more details.
26 * You should have received a copy of the GNU Library General Public
27 * License along with this library; if not, write to the Free
28 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <gtkmm/menu.h>
32 #include <gtkmm/window.h>
33 #include <gtk/gtkoptionmenu.h>
39 OptionMenu::OptionMenu()
41 // Mark this class as non-derived to allow C++ vfuncs to be skipped.
43 Gtk::Button(Glib::ConstructParams(optionmenu_class_.init()))
45 // Connect to the signal instead of overriding the on_hierarchy_changed()
46 // method because invocation of C++ default signal handlers is skipped
47 // for gtkmmproc-generated classes (a gtkmm-wide optimization).
49 signal_realize().connect(sigc::mem_fun(*this, &OptionMenu::init_accels_handler_));
52 OptionMenu::~OptionMenu()
55 //Remove the menu so that the Menu forgets about this OptionMenu.
56 //Normally the GtkOptionMenu just destroys the Menu (see gtk_option_menu_destroy),
57 //but we prevent premature destruction in general for all widgets,
58 //so the Menu would survive and remember a dead GtkOptionMenu.
64 void OptionMenu::init_accels_handler_()
68 Window *const toplevel = dynamic_cast<Window*>(get_toplevel());
69 if(toplevel && get_menu())
71 get_menu()->accelerate(*toplevel);
83 static const Glib::SignalProxyInfo OptionMenu_signal_changed_info =
86 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
87 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
91 } // anonymous namespace
97 Gtk::OptionMenu* wrap(GtkOptionMenu* object, bool take_copy)
99 return dynamic_cast<Gtk::OptionMenu *> (Glib::wrap_auto ((GObject*)(object), take_copy));
102 } /* namespace Glib */
108 /* The *_Class implementation: */
110 const Glib::Class& OptionMenu_Class::init()
112 if(!gtype_) // create the GType if necessary
114 // Glib::Class has to know the class init function to clone custom types.
115 class_init_func_ = &OptionMenu_Class::class_init_function;
117 // This is actually just optimized away, apparently with no harm.
118 // Make sure that the parent type has been created.
119 //CppClassParent::CppObjectType::get_type();
121 // Create the wrapper type, with the same class/instance size as the base type.
122 register_derived_type(gtk_option_menu_get_type());
124 // Add derived versions of interfaces, if the C type implements any interfaces:
130 void OptionMenu_Class::class_init_function(void* g_class, void* class_data)
132 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
133 CppClassParent::class_init_function(klass, class_data);
135 #ifdef GLIBMM_VFUNCS_ENABLED
136 #endif //GLIBMM_VFUNCS_ENABLED
138 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
139 klass->changed = &changed_callback;
140 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
143 #ifdef GLIBMM_VFUNCS_ENABLED
144 #endif //GLIBMM_VFUNCS_ENABLED
146 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
147 void OptionMenu_Class::changed_callback(GtkOptionMenu* self)
149 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
150 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
152 // Non-gtkmmproc-generated custom classes implicitly call the default
153 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
154 // generated classes can use this optimisation, which avoids the unnecessary
155 // parameter conversions if there is no possibility of the virtual function
157 if(obj_base && obj_base->is_derived_())
159 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
160 if(obj) // This can be NULL during destruction.
162 #ifdef GLIBMM_EXCEPTIONS_ENABLED
163 try // Trap C++ exceptions which would normally be lost because this is a C callback.
165 #endif //GLIBMM_EXCEPTIONS_ENABLED
166 // Call the virtual member method, which derived classes might override.
169 #ifdef GLIBMM_EXCEPTIONS_ENABLED
173 Glib::exception_handlers_invoke();
175 #endif //GLIBMM_EXCEPTIONS_ENABLED
179 BaseClassType *const base = static_cast<BaseClassType*>(
180 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
183 // Call the original underlying C function:
184 if(base && base->changed)
185 (*base->changed)(self);
187 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
190 Glib::ObjectBase* OptionMenu_Class::wrap_new(GObject* o)
192 return manage(new OptionMenu((GtkOptionMenu*)(o)));
197 /* The implementation: */
199 OptionMenu::OptionMenu(const Glib::ConstructParams& construct_params)
201 Gtk::Button(construct_params)
205 OptionMenu::OptionMenu(GtkOptionMenu* castitem)
207 Gtk::Button((GtkButton*)(castitem))
211 OptionMenu::CppClassType OptionMenu::optionmenu_class_; // initialize static member
213 GType OptionMenu::get_type()
215 return optionmenu_class_.init().get_type();
218 GType OptionMenu::get_base_type()
220 return gtk_option_menu_get_type();
224 void OptionMenu::set_menu(Menu& menu)
226 gtk_option_menu_set_menu(gobj(), (menu).Gtk::Widget::gobj());
229 Menu* OptionMenu::get_menu()
231 return Glib::wrap((GtkMenu*)(gtk_option_menu_get_menu(gobj())));
234 const Menu* OptionMenu::get_menu() const
236 return const_cast<OptionMenu*>(this)->get_menu();
239 void OptionMenu::remove_menu()
241 gtk_option_menu_remove_menu(gobj());
244 int OptionMenu::get_history() const
246 return gtk_option_menu_get_history(const_cast<GtkOptionMenu*>(gobj()));
249 void OptionMenu::set_history(guint index)
251 gtk_option_menu_set_history(gobj(), index);
255 Glib::SignalProxy0< void > OptionMenu::signal_changed()
257 return Glib::SignalProxy0< void >(this, &OptionMenu_signal_changed_info);
261 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
262 void Gtk::OptionMenu::on_changed()
264 BaseClassType *const base = static_cast<BaseClassType*>(
265 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
268 if(base && base->changed)
269 (*base->changed)(gobj());
271 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
273 #ifdef GLIBMM_VFUNCS_ENABLED
274 #endif //GLIBMM_VFUNCS_ENABLED
279 #endif // GTKMM_DISABLE_DEPRECATED