MIDI branch becomes trunk
[ardour.git] / libs / gtkmm2 / atk / atkmm / document.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <atkmm/document.h>
4 #include <atkmm/private/document_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright 2003 The gtkmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free
23  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 #include <atkmm/object.h>
27 #include <atk/atkdocument.h>
28
29
30 namespace Atk
31 {
32
33
34 } // namespace Atk
35
36
37 namespace
38 {
39 } // anonymous namespace
40
41
42 namespace Glib
43 {
44
45 Glib::RefPtr<Atk::Document> wrap(AtkDocument* object, bool take_copy)
46 {
47   return Glib::RefPtr<Atk::Document>( dynamic_cast<Atk::Document*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
48   //We use dynamic_cast<> in case of multiple inheritance.
49 }
50
51 } // namespace Glib
52
53
54 namespace Atk
55 {
56
57
58 /* The *_Class implementation: */
59
60 const Glib::Interface_Class& Document_Class::init()
61 {
62   if(!gtype_) // create the GType if necessary
63   {
64     // Glib::Interface_Class has to know the interface init function
65     // in order to add interfaces to implementing types.
66     class_init_func_ = &Document_Class::iface_init_function;
67
68     // We can not derive from another interface, and it is not necessary anyway.
69     gtype_ = atk_document_get_type();
70   }
71
72   return *this;
73 }
74
75 void Document_Class::iface_init_function(void* g_iface, void*)
76 {
77   BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
78
79   //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
80   //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
81   g_assert(klass != 0); 
82
83   klass->get_document_type = &get_document_type_vfunc_callback;
84   klass->get_document = &get_document_vfunc_callback;
85 }
86
87 const gchar* Document_Class::get_document_type_vfunc_callback(AtkDocument* self)
88 {
89   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
90       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
91
92   // Non-gtkmmproc-generated custom classes implicitly call the default
93   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
94   // generated classes can use this optimisation, which avoids the unnecessary
95   // parameter conversions if there is no possibility of the virtual function
96   // being overridden:
97   if(obj && obj->is_derived_())
98   {
99     try // Trap C++ exceptions which would normally be lost because this is a C callback.
100     {
101       // Call the virtual member method, which derived classes might override.
102       return obj->get_document_type_vfunc();
103     }
104     catch(...)
105     {
106       Glib::exception_handlers_invoke();
107     }
108   }
109   else
110   {
111     BaseClassType *const base = static_cast<BaseClassType*>(
112         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
113 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
114 )    );
115
116     // Call the original underlying C function:
117     if(base && base->get_document_type)
118       return (*base->get_document_type)(self);
119   }
120
121   typedef const gchar* RType;
122   return RType();
123 }
124
125 gpointer Document_Class::get_document_vfunc_callback(AtkDocument* self)
126 {
127   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
128       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
129
130   // Non-gtkmmproc-generated custom classes implicitly call the default
131   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
132   // generated classes can use this optimisation, which avoids the unnecessary
133   // parameter conversions if there is no possibility of the virtual function
134   // being overridden:
135   if(obj && obj->is_derived_())
136   {
137     try // Trap C++ exceptions which would normally be lost because this is a C callback.
138     {
139       // Call the virtual member method, which derived classes might override.
140       return obj->get_document_vfunc();
141     }
142     catch(...)
143     {
144       Glib::exception_handlers_invoke();
145     }
146   }
147   else
148   {
149     BaseClassType *const base = static_cast<BaseClassType*>(
150         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
151 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
152 )    );
153
154     // Call the original underlying C function:
155     if(base && base->get_document)
156       return (*base->get_document)(self);
157   }
158
159   typedef gpointer RType;
160   return RType();
161 }
162
163
164 Glib::ObjectBase* Document_Class::wrap_new(GObject* object)
165 {
166   return new Document((AtkDocument*)(object));
167 }
168
169
170 /* The implementation: */
171
172 Document::Document()
173 :
174   Glib::Interface(document_class_.init())
175 {}
176
177 Document::Document(AtkDocument* castitem)
178 :
179   Glib::Interface((GObject*)(castitem))
180 {}
181
182 Document::~Document()
183 {}
184
185 // static
186 void Document::add_interface(GType gtype_implementer)
187 {
188   document_class_.init().add_interface(gtype_implementer);
189 }
190
191 Document::CppClassType Document::document_class_; // initialize static member
192
193 GType Document::get_type()
194 {
195   return document_class_.init().get_type();
196 }
197
198 GType Document::get_base_type()
199 {
200   return atk_document_get_type();
201 }
202
203
204 Glib::ustring Document::get_document_type() const
205 {
206   return Glib::convert_const_gchar_ptr_to_ustring(atk_document_get_document_type(const_cast<AtkDocument*>(gobj())));
207 }
208
209 gpointer Document::get_document()
210 {
211   return atk_document_get_document(gobj());
212 }
213
214
215 const gchar* Atk::Document::get_document_type_vfunc() 
216 {
217   BaseClassType *const base = static_cast<BaseClassType*>(
218       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
219 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
220 )  );
221
222   if(base && base->get_document_type)
223     return (*base->get_document_type)(gobj());
224
225   typedef const gchar* RType;
226   return RType();
227 }
228
229 gpointer Atk::Document::get_document_vfunc() const
230 {
231   BaseClassType *const base = static_cast<BaseClassType*>(
232       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
233 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
234 )  );
235
236   if(base && base->get_document)
237     return (*base->get_document)(const_cast<AtkDocument*>(gobj()));
238
239   typedef gpointer RType;
240   return RType();
241 }
242
243
244 } // namespace Atk
245
246