1 // Generated by gmmproc 2.45.3 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <gtkmm/dialog.h>
7 #include <gtkmm/private/dialog_p.h>
8
9 #include <gtk/gtk.h>
10
11 // -*- c++ -*-
12 /* $Id: dialog.ccg,v 1.3 2004/11/21 20:54:20 murrayc Exp $ */
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 Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 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 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser 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 <gtk/gtk.h>
32
33 namespace Gtk
34 {
35
Dialog(const Glib::ustring & title,Gtk::Window & parent,bool modal,bool use_separator)36 Dialog::Dialog(const Glib::ustring& title, Gtk::Window& parent, bool modal, bool use_separator)
37 :
38 // Mark this class as non-derived to allow C++ vfuncs to be skipped.
39 Glib::ObjectBase(0),
40 Gtk::Window(Glib::ConstructParams(dialog_class_.init(), "title",title.c_str(), static_cast<char*>(0)))
41 {
42 construct_(modal, use_separator);
43 set_transient_for(parent);
44 }
45
Dialog(const Glib::ustring & title,bool modal,bool use_separator)46 Dialog::Dialog(const Glib::ustring& title, bool modal, bool use_separator)
47 :
48 // Mark this class as non-derived to allow C++ vfuncs to be skipped.
49 Glib::ObjectBase(0),
50 Gtk::Window(Glib::ConstructParams(dialog_class_.init(), "title",title.c_str(), static_cast<char*>(0)))
51 {
52 construct_(modal, use_separator);
53 }
54
construct_(bool modal,bool use_separator)55 void Dialog::construct_(bool modal, bool use_separator)
56 {
57 set_modal(modal);
58 set_has_separator(use_separator);
59 }
60
set_alternative_button_order_from_array(const Glib::ArrayHandle<int> & new_order)61 void Dialog::set_alternative_button_order_from_array(const Glib::ArrayHandle<int>& new_order)
62 {
63 gtk_dialog_set_alternative_button_order_from_array(gobj(), new_order.size(), const_cast<int*>(new_order.data()));
64 }
65
66 } // namespace Gtk
67
68
69 namespace
70 {
71
72
Dialog_signal_response_callback(GtkDialog * self,gint p0,void * data)73 static void Dialog_signal_response_callback(GtkDialog* self, gint p0,void* data)
74 {
75 using namespace Gtk;
76 typedef sigc::slot< void,int > SlotType;
77
78 Dialog* obj = dynamic_cast<Dialog*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
79 // Do not try to call a signal on a disassociated wrapper.
80 if(obj)
81 {
82 try
83 {
84 if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
85 (*static_cast<SlotType*>(slot))(p0
86 );
87 }
88 catch(...)
89 {
90 Glib::exception_handlers_invoke();
91 }
92 }
93 }
94
95 static const Glib::SignalProxyInfo Dialog_signal_response_info =
96 {
97 "response",
98 (GCallback) &Dialog_signal_response_callback,
99 (GCallback) &Dialog_signal_response_callback
100 };
101
102
103 } // anonymous namespace
104
105 // static
value_type()106 GType Glib::Value<Gtk::ResponseType>::value_type()
107 {
108 return gtk_response_type_get_type();
109 }
110
111
112 namespace Glib
113 {
114
wrap(GtkDialog * object,bool take_copy)115 Gtk::Dialog* wrap(GtkDialog* object, bool take_copy)
116 {
117 return dynamic_cast<Gtk::Dialog *> (Glib::wrap_auto ((GObject*)(object), take_copy));
118 }
119
120 } /* namespace Glib */
121
122 namespace Gtk
123 {
124
125
126 /* The *_Class implementation: */
127
init()128 const Glib::Class& Dialog_Class::init()
129 {
130 if(!gtype_) // create the GType if necessary
131 {
132 // Glib::Class has to know the class init function to clone custom types.
133 class_init_func_ = &Dialog_Class::class_init_function;
134
135 // This is actually just optimized away, apparently with no harm.
136 // Make sure that the parent type has been created.
137 //CppClassParent::CppObjectType::get_type();
138
139 // Create the wrapper type, with the same class/instance size as the base type.
140 register_derived_type(gtk_dialog_get_type());
141
142 // Add derived versions of interfaces, if the C type implements any interfaces:
143
144 }
145
146 return *this;
147 }
148
149
class_init_function(void * g_class,void * class_data)150 void Dialog_Class::class_init_function(void* g_class, void* class_data)
151 {
152 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
153 CppClassParent::class_init_function(klass, class_data);
154
155
156 klass->response = &response_callback;
157 }
158
159
response_callback(GtkDialog * self,gint p0)160 void Dialog_Class::response_callback(GtkDialog* self, gint p0)
161 {
162 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
163 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
164
165 // Non-gtkmmproc-generated custom classes implicitly call the default
166 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
167 // generated classes can use this optimisation, which avoids the unnecessary
168 // parameter conversions if there is no possibility of the virtual function
169 // being overridden:
170 if(obj_base && obj_base->is_derived_())
171 {
172 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
173 if(obj) // This can be NULL during destruction.
174 {
175 try // Trap C++ exceptions which would normally be lost because this is a C callback.
176 {
177 // Call the virtual member method, which derived classes might override.
178 obj->on_response(p0
179 );
180 return;
181 }
182 catch(...)
183 {
184 Glib::exception_handlers_invoke();
185 }
186 }
187 }
188
189 BaseClassType *const base = static_cast<BaseClassType*>(
190 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
191 );
192
193 // Call the original underlying C function:
194 if(base && base->response)
195 (*base->response)(self, p0);
196 }
197
198
wrap_new(GObject * o)199 Glib::ObjectBase* Dialog_Class::wrap_new(GObject* o)
200 {
201 return new Dialog((GtkDialog*)(o)); //top-level windows can not be manage()ed.
202
203 }
204
205
206 /* The implementation: */
207
Dialog(const Glib::ConstructParams & construct_params)208 Dialog::Dialog(const Glib::ConstructParams& construct_params)
209 :
210 Gtk::Window(construct_params)
211 {
212 }
213
Dialog(GtkDialog * castitem)214 Dialog::Dialog(GtkDialog* castitem)
215 :
216 Gtk::Window((GtkWindow*)(castitem))
217 {
218 }
219
~Dialog()220 Dialog::~Dialog()
221 {
222 destroy_();
223 }
224
225 Dialog::CppClassType Dialog::dialog_class_; // initialize static member
226
get_type()227 GType Dialog::get_type()
228 {
229 return dialog_class_.init().get_type();
230 }
231
232
get_base_type()233 GType Dialog::get_base_type()
234 {
235 return gtk_dialog_get_type();
236 }
237
238
Dialog()239 Dialog::Dialog()
240 :
241 // Mark this class as non-derived to allow C++ vfuncs to be skipped.
242 Glib::ObjectBase(0),
243 Gtk::Window(Glib::ConstructParams(dialog_class_.init()))
244 {
245
246
247 }
248
add_action_widget(Widget & child,int response_id)249 void Dialog::add_action_widget(Widget& child, int response_id)
250 {
251 gtk_dialog_add_action_widget(gobj(), (child).gobj(), response_id);
252 }
253
add_button(const Glib::ustring & button_text,int response_id)254 Button* Dialog::add_button(const Glib::ustring& button_text, int response_id)
255 {
256 return Glib::wrap((GtkButton*)(gtk_dialog_add_button(gobj(), button_text.c_str(), response_id)));
257 }
258
add_button(const Gtk::StockID & stock_id,int response_id)259 Button* Dialog::add_button(const Gtk::StockID& stock_id, int response_id)
260 {
261 return Glib::wrap((GtkButton*)(gtk_dialog_add_button(gobj(), (stock_id).get_c_str(), response_id)));
262 }
263
set_response_sensitive(int response_id,bool setting)264 void Dialog::set_response_sensitive(int response_id, bool setting)
265 {
266 gtk_dialog_set_response_sensitive(gobj(), response_id, static_cast<int>(setting));
267 }
268
set_default_response(int response_id)269 void Dialog::set_default_response(int response_id)
270 {
271 gtk_dialog_set_default_response(gobj(), response_id);
272 }
273
get_widget_for_response(int response_id)274 Widget* Dialog::get_widget_for_response(int response_id)
275 {
276 return Glib::wrap(gtk_dialog_get_widget_for_response(gobj(), response_id));
277 }
278
get_widget_for_response(int response_id) const279 const Widget* Dialog::get_widget_for_response(int response_id) const
280 {
281 return const_cast<Dialog*>(this)->get_widget_for_response(response_id);
282 }
283
get_response_for_widget(const Gtk::Widget & widget) const284 int Dialog::get_response_for_widget(const Gtk::Widget& widget) const
285 {
286 return gtk_dialog_get_response_for_widget(const_cast<GtkDialog*>(gobj()), const_cast<GtkWidget*>(widget.gobj()));
287 }
288
set_has_separator(bool setting)289 void Dialog::set_has_separator(bool setting)
290 {
291 gtk_dialog_set_has_separator(gobj(), static_cast<int>(setting));
292 }
293
get_has_separator() const294 bool Dialog::get_has_separator() const
295 {
296 return gtk_dialog_get_has_separator(const_cast<GtkDialog*>(gobj()));
297 }
298
alternative_button_order(const Glib::RefPtr<const Gdk::Screen> & screen)299 bool Dialog::alternative_button_order(const Glib::RefPtr<const Gdk::Screen>& screen)
300 {
301 return gtk_alternative_dialog_button_order(const_cast<GdkScreen*>(Glib::unwrap<Gdk::Screen>(screen)));
302 }
303
response(int response_id)304 void Dialog::response(int response_id)
305 {
306 gtk_dialog_response(gobj(), response_id);
307 }
308
run()309 int Dialog::run()
310 {
311 return gtk_dialog_run(gobj());
312 }
313
get_action_area()314 ButtonBox* Dialog::get_action_area()
315 {
316 return Glib::wrap((GtkButtonBox*)(gtk_dialog_get_action_area(gobj())));
317 }
318
get_action_area() const319 const ButtonBox* Dialog::get_action_area() const
320 {
321 return const_cast<Dialog*>(this)->get_action_area();
322 }
323
get_vbox()324 VBox* Dialog::get_vbox()
325 {
326 return Glib::wrap((GtkVBox*)(gtk_dialog_get_content_area(gobj())));
327 }
328
get_vbox() const329 const VBox* Dialog::get_vbox() const
330 {
331 return Glib::wrap((GtkVBox*)(gtk_dialog_get_content_area(const_cast<GtkDialog*>(gobj()))));
332 }
333
334
signal_response()335 Glib::SignalProxy1< void,int > Dialog::signal_response()
336 {
337 return Glib::SignalProxy1< void,int >(this, &Dialog_signal_response_info);
338 }
339
340
property_has_separator()341 Glib::PropertyProxy< bool > Dialog::property_has_separator()
342 {
343 return Glib::PropertyProxy< bool >(this, "has-separator");
344 }
345
property_has_separator() const346 Glib::PropertyProxy_ReadOnly< bool > Dialog::property_has_separator() const
347 {
348 return Glib::PropertyProxy_ReadOnly< bool >(this, "has-separator");
349 }
350
351
on_response(int response_id)352 void Gtk::Dialog::on_response(int response_id)
353 {
354 BaseClassType *const base = static_cast<BaseClassType*>(
355 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
356 );
357
358 if(base && base->response)
359 (*base->response)(gobj(),response_id);
360 }
361
362
363 } // namespace Gtk
364
365
366