Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / dialog.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/dialog.h>
4 #include <gtkmm/private/dialog_p.h>
5
6 #include <gtk/gtktypebuiltins.h>
7 // -*- c++ -*-
8 /* $Id$ */
9
10 /* Copyright 1998-2002 The gtkmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include <gtk/gtkdialog.h>
28
29 namespace Gtk
30 {
31
32 Dialog::Dialog(const Glib::ustring& title, Gtk::Window& parent, bool modal, bool use_separator)
33 :
34   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
35   Gtk::Window(Glib::ConstructParams(dialog_class_.init(), "title",title.c_str(), (char*) 0))
36 {
37   construct_(modal, use_separator);
38   set_transient_for(parent);
39 }
40
41 Dialog::Dialog(const Glib::ustring& title, bool modal, bool use_separator)
42 :
43   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
44   Gtk::Window(Glib::ConstructParams(dialog_class_.init(), "title",title.c_str(), (char*) 0))
45 {
46   construct_(modal, use_separator);
47 }
48
49 void Dialog::construct_(bool modal, bool use_separator)
50 {
51   set_modal(modal);
52   set_has_separator(use_separator);
53 }
54
55 void Dialog::set_alternative_button_order_from_array(const Glib::ArrayHandle<int>& new_order)
56 {
57   gtk_dialog_set_alternative_button_order_from_array(gobj(), new_order.size(), const_cast<int*>(new_order.data()));
58 }
59
60 } // namespace Gtk
61
62
63 namespace
64 {
65
66 void Dialog_signal_response_callback(GtkDialog* self, gint p0,void* data)
67 {
68   using namespace Gtk;
69   typedef sigc::slot< void,int > SlotType;
70
71   // Do not try to call a signal on a disassociated wrapper.
72   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
73   {
74     try
75     {
76       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
77         (*static_cast<SlotType*>(slot))(p0
78 );
79     }
80     catch(...)
81     {
82       Glib::exception_handlers_invoke();
83     }
84   }
85 }
86
87 const Glib::SignalProxyInfo Dialog_signal_response_info =
88 {
89   "response",
90   (GCallback) &Dialog_signal_response_callback,
91   (GCallback) &Dialog_signal_response_callback
92 };
93
94 } // anonymous namespace
95
96 // static
97 GType Glib::Value<Gtk::ResponseType>::value_type()
98 {
99   return gtk_response_type_get_type();
100 }
101
102
103 namespace Glib
104 {
105
106 Gtk::Dialog* wrap(GtkDialog* object, bool take_copy)
107 {
108   return dynamic_cast<Gtk::Dialog *> (Glib::wrap_auto ((GObject*)(object), take_copy));
109 }
110
111 } /* namespace Glib */
112
113 namespace Gtk
114 {
115
116
117 /* The *_Class implementation: */
118
119 const Glib::Class& Dialog_Class::init()
120 {
121   if(!gtype_) // create the GType if necessary
122   {
123     // Glib::Class has to know the class init function to clone custom types.
124     class_init_func_ = &Dialog_Class::class_init_function;
125
126     // This is actually just optimized away, apparently with no harm.
127     // Make sure that the parent type has been created.
128     //CppClassParent::CppObjectType::get_type();
129
130     // Create the wrapper type, with the same class/instance size as the base type.
131     register_derived_type(gtk_dialog_get_type());
132
133     // Add derived versions of interfaces, if the C type implements any interfaces:
134   }
135
136   return *this;
137 }
138
139 void Dialog_Class::class_init_function(void* g_class, void* class_data)
140 {
141   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
142   CppClassParent::class_init_function(klass, class_data);
143
144   klass->response = &response_callback;
145 }
146
147
148 void Dialog_Class::response_callback(GtkDialog* self, gint p0)
149 {
150   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
151       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
152
153   // Non-gtkmmproc-generated custom classes implicitly call the default
154   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
155   // generated classes can use this optimisation, which avoids the unnecessary
156   // parameter conversions if there is no possibility of the virtual function
157   // being overridden:
158   if(obj && obj->is_derived_())
159   {
160     try // Trap C++ exceptions which would normally be lost because this is a C callback.
161     {
162       // Call the virtual member method, which derived classes might override.
163       obj->on_response(p0
164 );
165     }
166     catch(...)
167     {
168       Glib::exception_handlers_invoke();
169     }
170   }
171   else
172   {
173     BaseClassType *const base = static_cast<BaseClassType*>(
174         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
175     );
176
177     // Call the original underlying C function:
178     if(base && base->response)
179       (*base->response)(self, p0);
180   }
181 }
182
183
184 Glib::ObjectBase* Dialog_Class::wrap_new(GObject* o)
185 {
186   return new Dialog((GtkDialog*)(o)); //top-level windows can not be manage()ed.
187
188 }
189
190
191 /* The implementation: */
192
193 Dialog::Dialog(const Glib::ConstructParams& construct_params)
194 :
195   Gtk::Window(construct_params)
196 {
197   }
198
199 Dialog::Dialog(GtkDialog* castitem)
200 :
201   Gtk::Window((GtkWindow*)(castitem))
202 {
203   }
204
205 Dialog::~Dialog()
206 {
207   destroy_();
208 }
209
210 Dialog::CppClassType Dialog::dialog_class_; // initialize static member
211
212 GType Dialog::get_type()
213 {
214   return dialog_class_.init().get_type();
215 }
216
217 GType Dialog::get_base_type()
218 {
219   return gtk_dialog_get_type();
220 }
221
222
223 Dialog::Dialog()
224 :
225   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
226   Gtk::Window(Glib::ConstructParams(dialog_class_.init()))
227 {
228   }
229
230 void Dialog::add_action_widget(Widget& child, int response_id)
231 {
232   gtk_dialog_add_action_widget(gobj(), (child).gobj(), response_id);
233 }
234
235 Button* Dialog::add_button(const Glib::ustring& button_text, int response_id)
236 {
237   return Glib::wrap((GtkButton*)(gtk_dialog_add_button(gobj(), button_text.c_str(), response_id)));
238 }
239
240 Button* Dialog::add_button(const Gtk::StockID& stock_id, int response_id)
241 {
242   return Glib::wrap((GtkButton*)(gtk_dialog_add_button(gobj(), (stock_id).get_c_str(), response_id)));
243 }
244
245 void Dialog::set_response_sensitive(int response_id, bool setting)
246 {
247   gtk_dialog_set_response_sensitive(gobj(), response_id, static_cast<int>(setting));
248 }
249
250 void Dialog::set_default_response(int response_id)
251 {
252   gtk_dialog_set_default_response(gobj(), response_id);
253 }
254
255 void Dialog::set_has_separator(bool setting)
256 {
257   gtk_dialog_set_has_separator(gobj(), static_cast<int>(setting));
258 }
259
260 bool Dialog::get_has_separator() const
261 {
262   return gtk_dialog_get_has_separator(const_cast<GtkDialog*>(gobj()));
263 }
264
265 bool Dialog::alternative_button_order(const Glib::RefPtr<const Gdk::Screen>& screen)
266 {
267   return gtk_alternative_dialog_button_order(const_cast<GdkScreen*>(Glib::unwrap<Gdk::Screen>(screen)));
268 }
269
270 void Dialog::response(int response_id)
271 {
272   gtk_dialog_response(gobj(), response_id);
273 }
274
275 int Dialog::run()
276 {
277   return gtk_dialog_run(gobj());
278 }
279
280 VBox* Dialog::get_vbox()
281 {
282   return Glib::wrap((GtkVBox*)(gobj()->vbox));
283 }
284
285 const VBox* Dialog::get_vbox() const
286 {
287   return Glib::wrap((GtkVBox*)(gobj()->vbox));
288 }
289
290 HButtonBox* Dialog::get_action_area()
291 {
292   return Glib::wrap((GtkHButtonBox*)(gobj()->action_area));
293 }
294
295 const HButtonBox* Dialog::get_action_area() const
296 {
297   return Glib::wrap((GtkHButtonBox*)(gobj()->action_area));
298 }
299
300
301 Glib::SignalProxy1< void,int > Dialog::signal_response()
302 {
303   return Glib::SignalProxy1< void,int >(this, &Dialog_signal_response_info);
304 }
305
306
307 Glib::PropertyProxy<bool> Dialog::property_has_separator() 
308 {
309   return Glib::PropertyProxy<bool>(this, "has-separator");
310 }
311
312 Glib::PropertyProxy_ReadOnly<bool> Dialog::property_has_separator() const
313 {
314   return Glib::PropertyProxy_ReadOnly<bool>(this, "has-separator");
315 }
316
317
318 void Gtk::Dialog::on_response(int response_id)
319 {
320   BaseClassType *const base = static_cast<BaseClassType*>(
321       g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
322   );
323
324   if(base && base->response)
325     (*base->response)(gobj(),response_id);
326 }
327
328
329 } // namespace Gtk
330
331