1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/optionmenu.h>
4 #include <gtkmm/private/optionmenu_p.h>
11 * Copyright 1998-2002 The gtkmm Development Team
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
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 * Library General Public License for more details.
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <gtkmm/menu.h>
29 #include <gtkmm/window.h>
30 #include <gtk/gtkoptionmenu.h>
36 OptionMenu::OptionMenu()
38 Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
39 Gtk::Button(Glib::ConstructParams(optionmenu_class_.init(), (char*) 0))
41 // Connect to the signal instead of overriding the on_hierarchy_changed()
42 // method because invocation of C++ default signal handlers is skipped
43 // for gtkmmproc-generated classes (a gtkmm-wide optimization).
45 signal_realize().connect(sigc::mem_fun(*this, &OptionMenu::init_accels_handler_));
48 OptionMenu::~OptionMenu()
51 //Remove the menu so that the Menu forgets about this OptionMenu.
52 //Normally the GtkOptionMenu just destroys the Menu (see gtk_option_menu_destroy),
53 //but we prevent premature destruction in general for all widgets,
54 //so the Menu would survive and remember a dead GtkOptionMenu.
60 void OptionMenu::init_accels_handler_()
64 Window *const toplevel = dynamic_cast<Window*>(get_toplevel());
65 if(toplevel && get_menu())
67 get_menu()->accelerate(*toplevel);
78 const Glib::SignalProxyInfo OptionMenu_signal_changed_info =
81 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
82 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
85 } // anonymous namespace
91 Gtk::OptionMenu* wrap(GtkOptionMenu* object, bool take_copy)
93 return dynamic_cast<Gtk::OptionMenu *> (Glib::wrap_auto ((GObject*)(object), take_copy));
96 } /* namespace Glib */
102 /* The *_Class implementation: */
104 const Glib::Class& OptionMenu_Class::init()
106 if(!gtype_) // create the GType if necessary
108 // Glib::Class has to know the class init function to clone custom types.
109 class_init_func_ = &OptionMenu_Class::class_init_function;
111 // This is actually just optimized away, apparently with no harm.
112 // Make sure that the parent type has been created.
113 //CppClassParent::CppObjectType::get_type();
115 // Create the wrapper type, with the same class/instance size as the base type.
116 register_derived_type(gtk_option_menu_get_type());
118 // Add derived versions of interfaces, if the C type implements any interfaces:
124 void OptionMenu_Class::class_init_function(void* g_class, void* class_data)
126 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
127 CppClassParent::class_init_function(klass, class_data);
129 klass->changed = &changed_callback;
133 void OptionMenu_Class::changed_callback(GtkOptionMenu* self)
135 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
136 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
138 // Non-gtkmmproc-generated custom classes implicitly call the default
139 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
140 // generated classes can use this optimisation, which avoids the unnecessary
141 // parameter conversions if there is no possibility of the virtual function
143 if(obj && obj->is_derived_())
145 try // Trap C++ exceptions which would normally be lost because this is a C callback.
147 // Call the virtual member method, which derived classes might override.
152 Glib::exception_handlers_invoke();
157 BaseClassType *const base = static_cast<BaseClassType*>(
158 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
161 // Call the original underlying C function:
162 if(base && base->changed)
163 (*base->changed)(self);
168 Glib::ObjectBase* OptionMenu_Class::wrap_new(GObject* o)
170 return manage(new OptionMenu((GtkOptionMenu*)(o)));
175 /* The implementation: */
177 OptionMenu::OptionMenu(const Glib::ConstructParams& construct_params)
179 Gtk::Button(construct_params)
183 OptionMenu::OptionMenu(GtkOptionMenu* castitem)
185 Gtk::Button((GtkButton*)(castitem))
189 OptionMenu::CppClassType OptionMenu::optionmenu_class_; // initialize static member
191 GType OptionMenu::get_type()
193 return optionmenu_class_.init().get_type();
196 GType OptionMenu::get_base_type()
198 return gtk_option_menu_get_type();
202 void OptionMenu::set_menu(Menu& menu)
204 gtk_option_menu_set_menu(gobj(), (menu).Gtk::Widget::gobj());
207 Menu* OptionMenu::get_menu()
209 return Glib::wrap((GtkMenu*)(gtk_option_menu_get_menu(gobj())));
212 const Menu* OptionMenu::get_menu() const
214 return Glib::wrap((GtkMenu*)(gtk_option_menu_get_menu(const_cast<GtkOptionMenu*>(gobj()))));
217 void OptionMenu::remove_menu()
219 gtk_option_menu_remove_menu(gobj());
222 int OptionMenu::get_history() const
224 return gtk_option_menu_get_history(const_cast<GtkOptionMenu*>(gobj()));
227 void OptionMenu::set_history(guint index)
229 gtk_option_menu_set_history(gobj(), index);
233 Glib::SignalProxy0< void > OptionMenu::signal_changed()
235 return Glib::SignalProxy0< void >(this, &OptionMenu_signal_changed_info);
239 void Gtk::OptionMenu::on_changed()
241 BaseClassType *const base = static_cast<BaseClassType*>(
242 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
245 if(base && base->changed)
246 (*base->changed)(gobj());