add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / optionmenu.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #ifndef GTKMM_DISABLE_DEPRECATED
4
5
6 #include <gtkmm/optionmenu.h>
7 #include <gtkmm/private/optionmenu_p.h>
8
9 // -*- c++ -*-
10 /* $Id$ */
11
12 /* 
13  *
14  * Copyright 1998-2002 The gtkmm Development Team
15  *
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.
20  *
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.
25  *
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.
29  */
30
31 #include <gtkmm/menu.h>
32 #include <gtkmm/window.h>
33 #include <gtk/gtkoptionmenu.h>
34
35 namespace Gtk
36 {
37
38
39 OptionMenu::OptionMenu()
40 :
41   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
42   Glib::ObjectBase(0),
43   Gtk::Button(Glib::ConstructParams(optionmenu_class_.init()))
44 {
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).
48
49   signal_realize().connect(sigc::mem_fun(*this, &OptionMenu::init_accels_handler_));
50 }
51
52 OptionMenu::~OptionMenu()
53 {
54   //GTKMM_LIFECYCLE
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.
59   remove_menu();
60
61   destroy_();
62 }
63
64 void OptionMenu::init_accels_handler_()
65 {
66   if(gobj())
67   {
68     Window *const toplevel = dynamic_cast<Window*>(get_toplevel());
69     if(toplevel && get_menu())
70     {
71       get_menu()->accelerate(*toplevel);
72     }
73   }
74 }
75
76 } /* namespace Gtk */
77
78
79 namespace
80 {
81
82
83 static const Glib::SignalProxyInfo OptionMenu_signal_changed_info =
84 {
85   "changed",
86   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
87   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
88 };
89
90
91 } // anonymous namespace
92
93
94 namespace Glib
95 {
96
97 Gtk::OptionMenu* wrap(GtkOptionMenu* object, bool take_copy)
98 {
99   return dynamic_cast<Gtk::OptionMenu *> (Glib::wrap_auto ((GObject*)(object), take_copy));
100 }
101
102 } /* namespace Glib */
103
104 namespace Gtk
105 {
106
107
108 /* The *_Class implementation: */
109
110 const Glib::Class& OptionMenu_Class::init()
111 {
112   if(!gtype_) // create the GType if necessary
113   {
114     // Glib::Class has to know the class init function to clone custom types.
115     class_init_func_ = &OptionMenu_Class::class_init_function;
116
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();
120
121     // Create the wrapper type, with the same class/instance size as the base type.
122     register_derived_type(gtk_option_menu_get_type());
123
124     // Add derived versions of interfaces, if the C type implements any interfaces:
125   }
126
127   return *this;
128 }
129
130 void OptionMenu_Class::class_init_function(void* g_class, void* class_data)
131 {
132   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
133   CppClassParent::class_init_function(klass, class_data);
134
135 #ifdef GLIBMM_VFUNCS_ENABLED
136 #endif //GLIBMM_VFUNCS_ENABLED
137
138 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
139   klass->changed = &changed_callback;
140 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
141 }
142
143 #ifdef GLIBMM_VFUNCS_ENABLED
144 #endif //GLIBMM_VFUNCS_ENABLED
145
146 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
147 void OptionMenu_Class::changed_callback(GtkOptionMenu* self)
148 {
149   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
150       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
151
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
156   // being overridden:
157   if(obj_base && obj_base->is_derived_())
158   {
159     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
160     if(obj) // This can be NULL during destruction.
161     {
162       #ifdef GLIBMM_EXCEPTIONS_ENABLED
163       try // Trap C++ exceptions which would normally be lost because this is a C callback.
164       {
165       #endif //GLIBMM_EXCEPTIONS_ENABLED
166         // Call the virtual member method, which derived classes might override.
167         obj->on_changed();
168         return;
169       #ifdef GLIBMM_EXCEPTIONS_ENABLED
170       }
171       catch(...)
172       {
173         Glib::exception_handlers_invoke();
174       }
175       #endif //GLIBMM_EXCEPTIONS_ENABLED
176     }
177   }
178   
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).
181     );
182
183   // Call the original underlying C function:
184   if(base && base->changed)
185     (*base->changed)(self);
186 }
187 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
188
189
190 Glib::ObjectBase* OptionMenu_Class::wrap_new(GObject* o)
191 {
192   return manage(new OptionMenu((GtkOptionMenu*)(o)));
193
194 }
195
196
197 /* The implementation: */
198
199 OptionMenu::OptionMenu(const Glib::ConstructParams& construct_params)
200 :
201   Gtk::Button(construct_params)
202 {
203   }
204
205 OptionMenu::OptionMenu(GtkOptionMenu* castitem)
206 :
207   Gtk::Button((GtkButton*)(castitem))
208 {
209   }
210
211 OptionMenu::CppClassType OptionMenu::optionmenu_class_; // initialize static member
212
213 GType OptionMenu::get_type()
214 {
215   return optionmenu_class_.init().get_type();
216 }
217
218 GType OptionMenu::get_base_type()
219 {
220   return gtk_option_menu_get_type();
221 }
222
223
224 void OptionMenu::set_menu(Menu& menu)
225 {
226 gtk_option_menu_set_menu(gobj(), (menu).Gtk::Widget::gobj()); 
227 }
228
229 Menu* OptionMenu::get_menu()
230 {
231   return Glib::wrap((GtkMenu*)(gtk_option_menu_get_menu(gobj())));
232 }
233
234 const Menu* OptionMenu::get_menu() const
235 {
236   return const_cast<OptionMenu*>(this)->get_menu();
237 }
238
239 void OptionMenu::remove_menu()
240 {
241 gtk_option_menu_remove_menu(gobj()); 
242 }
243
244 int OptionMenu::get_history() const
245 {
246   return gtk_option_menu_get_history(const_cast<GtkOptionMenu*>(gobj()));
247 }
248
249 void OptionMenu::set_history(guint index)
250 {
251 gtk_option_menu_set_history(gobj(), index); 
252 }
253
254
255 Glib::SignalProxy0< void > OptionMenu::signal_changed()
256 {
257   return Glib::SignalProxy0< void >(this, &OptionMenu_signal_changed_info);
258 }
259
260
261 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
262 void Gtk::OptionMenu::on_changed()
263 {
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).
266   );
267
268   if(base && base->changed)
269     (*base->changed)(gobj());
270 }
271 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
272
273 #ifdef GLIBMM_VFUNCS_ENABLED
274 #endif //GLIBMM_VFUNCS_ENABLED
275
276
277 } // namespace Gtk
278
279 #endif // GTKMM_DISABLE_DEPRECATED
280
281