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