1 // Generated by gmmproc 2.40.0 -- DO NOT MODIFY!
2 
3 
4 #include <glibmm.h>
5 
6 #include <cluttermm/script.h>
7 #include <cluttermm/private/script_p.h>
8 
9 
10 /* Copyright (C) 2007 The cluttermm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 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  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser 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 <clutter/clutter.h>
28 #include <glibmm/vectorutils.h>
29 
30 namespace Clutter
31 {
32 
33 #ifdef GLIBMM_EXCEPTIONS_ENABLED
load_from_data(const Glib::ustring & data)34 guint Script::load_from_data(const Glib::ustring& data)
35 #else
36 guint Script::load_from_data(const Glib::ustring& data, std::auto_ptr<Glib::Error>& error)
37 #endif
38 {
39   GError* gerror = 0;
40   guint result = clutter_script_load_from_data(gobj(), data.c_str(), data.bytes(), &gerror);
41 #ifdef GLIBMM_EXCEPTIONS_ENABLED
42   if(gerror)
43     ::Glib::Error::throw_exception(gerror);
44 #else
45   if(gerror)
46     error = ::Glib::Error::throw_exception(gerror);
47 #endif // GLIBMM_EXCEPTIONS_ENABLED
48 
49   return result;
50 }
51 
add_search_paths(const std::vector<std::string> & paths)52 void Script::add_search_paths(const std::vector<std::string>& paths)
53 {
54   clutter_script_add_search_paths(gobj(),
55     Glib::ArrayHandler<std::string>::vector_to_array(paths).data(), paths.size());
56 }
57 
list_objects()58 std::vector<Glib::RefPtr<Glib::Object> > Script::list_objects()
59 {
60   GList* objectList = clutter_script_list_objects(gobj());
61 
62   const guint objectCount = g_list_length(objectList);
63   std::vector<Glib::RefPtr<Glib::Object> > objectVec;
64   objectVec.reserve(objectCount);
65 
66   for(GList* objectNode = objectList; objectNode->next; objectNode = objectList->next)
67   {
68     objectVec.push_back(Glib::wrap(static_cast<GObject*>(objectNode->data), true));
69   }
70 
71   return objectVec;
72 }
73 
list_objects() const74 std::vector<Glib::RefPtr<const Glib::Object> > Script::list_objects() const
75 {
76   GList* objectList = clutter_script_list_objects(const_cast<ClutterScript*>(gobj()));
77 
78   const guint objectCount = g_list_length(objectList);
79   std::vector<Glib::RefPtr<const Glib::Object> > objectVec;
80   objectVec.reserve(objectCount);
81 
82   for(GList* objectNode = objectList; objectNode->next; objectNode = objectList->next)
83   {
84     objectVec.push_back(Glib::wrap(static_cast<GObject*>(objectNode->data), true));
85   }
86 
87   return objectVec;
88 }
89 
get_cobject(const Glib::ustring & name)90 GObject* Script::get_cobject(const Glib::ustring& name)
91 {
92   GObject *cobject = clutter_script_get_object (gobj(), name.c_str());
93   if(!cobject)
94   {
95     g_critical("cluttermm: object `%s' not found in ClutterScript file.", name.c_str());
96     return 0;
97   }
98 
99   return cobject;
100 }
101 
get_object_checked(const Glib::ustring & name,GType type)102 Glib::RefPtr<Glib::Object> Script::get_object_checked(const Glib::ustring& name, GType type)
103 {
104   // Get the widget from the ClutterScript JSON file.
105   GObject *cobject = get_cobject(name);
106   Glib::RefPtr<Glib::Object> object;
107 
108   if(!cobject)
109   {
110     g_critical("cluttermm: Glib::Object: object `%s' was not found in the ClutterScript file, or the specified part of it.",
111       name.c_str());
112     return object;
113   }
114 
115   // Check if it has the correct type.
116   if(!g_type_is_a(G_OBJECT_TYPE(cobject), type))
117   {
118     g_critical("cluttermm: object `%s' (in ClutterScript file) is of type `%s' but `%s' was expected",
119                name.c_str(), G_OBJECT_TYPE_NAME(cobject), g_type_name(type));
120     return object;
121   }
122 
123   object = Glib::wrap (cobject, true /* take ref */);
124   return object;
125 }
126 
127 #ifdef GLIBMM_VFUNCS_ENABLED
128 // Custom coded so that we can custom-code the vfunc in the ClutterScript class.
129 // This is marginally better than modifying gtkmmproc to allow this.
get_type_from_name_vfunc_callback(ClutterScript * self,const char * type_name)130 GType Script_Class::get_type_from_name_vfunc_callback(ClutterScript* self, const char* type_name)
131 {
132   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
133       Glib::ObjectBase::_get_current_wrapper((GObject*) self));
134 
135   if(obj)
136   {
137     #ifdef GLIBMM_EXCEPTIONS_ENABLED
138     try
139     {
140     #endif //GLIBMM_EXCEPTIONS_ENABLED
141       return obj->get_type_from_name_vfunc(Glib::convert_const_gchar_ptr_to_ustring(type_name));
142     #ifdef GLIBMM_EXCEPTIONS_ENABLED
143     }
144     catch(...)
145     {
146       Glib::exception_handlers_invoke();
147     }
148     #endif //GLIBMM_EXCEPTIONS_ENABLED
149   }
150   else
151   {
152     BaseClassType *const base = static_cast<BaseClassType*>(
153         g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class.
154     );
155 
156     if(base && base->get_type_from_name)
157       return (*base->get_type_from_name)(self, type_name);
158   }
159 
160   return 0;
161 }
162 #endif // GLIBMM_VFUNCS_ENABLED
163 
get_type_from_name_vfunc(const Glib::ustring & type_name)164 GType Script::get_type_from_name_vfunc(const Glib::ustring& type_name)
165 {
166   // See if there is a gtkmm version of the gclass:
167   Glib::ustring classname_prefixed ("gtkmm__"); // gtkmm uses a prefix
168   classname_prefixed += type_name;
169 
170   GType gtype = g_type_from_name(classname_prefixed.c_str());
171 
172   if(gtype == G_TYPE_INVALID) // if it's not a registered typename
173   {
174     // There's no gtkmm derived type, so just use the normal one.
175     gtype = g_type_from_name(type_name.c_str());
176   }
177 
178   return gtype;
179 }
180 
181 } //namespace Clutter
182 
183 
184 namespace
185 {
186 } // anonymous namespace
187 
188 
189 namespace Glib
190 {
191 
wrap(ClutterScript * object,bool take_copy)192 Glib::RefPtr<Clutter::Script> wrap(ClutterScript* object, bool take_copy)
193 {
194   return Glib::RefPtr<Clutter::Script>( dynamic_cast<Clutter::Script*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
195   //We use dynamic_cast<> in case of multiple inheritance.
196 }
197 
198 } /* namespace Glib */
199 
200 
201 namespace Clutter
202 {
203 
204 
205 /* The *_Class implementation: */
206 
init()207 const Glib::Class& Script_Class::init()
208 {
209   if(!gtype_) // create the GType if necessary
210   {
211     // Glib::Class has to know the class init function to clone custom types.
212     class_init_func_ = &Script_Class::class_init_function;
213 
214     // This is actually just optimized away, apparently with no harm.
215     // Make sure that the parent type has been created.
216     //CppClassParent::CppObjectType::get_type();
217 
218     // Create the wrapper type, with the same class/instance size as the base type.
219     register_derived_type(clutter_script_get_type());
220 
221     // Add derived versions of interfaces, if the C type implements any interfaces:
222 
223   }
224 
225   return *this;
226 }
227 
228 
class_init_function(void * g_class,void * class_data)229 void Script_Class::class_init_function(void* g_class, void* class_data)
230 {
231   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
232   CppClassParent::class_init_function(klass, class_data);
233 
234   klass->get_type_from_name = &get_type_from_name_vfunc_callback;
235 
236 }
237 
238 
wrap_new(GObject * object)239 Glib::ObjectBase* Script_Class::wrap_new(GObject* object)
240 {
241   return new Script((ClutterScript*)object);
242 }
243 
244 
245 /* The implementation: */
246 
gobj_copy()247 ClutterScript* Script::gobj_copy()
248 {
249   reference();
250   return gobj();
251 }
252 
Script(const Glib::ConstructParams & construct_params)253 Script::Script(const Glib::ConstructParams& construct_params)
254 :
255   Glib::Object(construct_params)
256 {
257 
258 }
259 
Script(ClutterScript * castitem)260 Script::Script(ClutterScript* castitem)
261 :
262   Glib::Object((GObject*)(castitem))
263 {}
264 
265 
~Script()266 Script::~Script()
267 {}
268 
269 
270 Script::CppClassType Script::script_class_; // initialize static member
271 
get_type()272 GType Script::get_type()
273 {
274   return script_class_.init().get_type();
275 }
276 
277 
get_base_type()278 GType Script::get_base_type()
279 {
280   return clutter_script_get_type();
281 }
282 
283 
Script()284 Script::Script()
285 :
286   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
287   Glib::ObjectBase(0),
288   Glib::Object(Glib::ConstructParams(script_class_.init()))
289 {
290 
291 
292 }
293 
create()294 Glib::RefPtr<Script> Script::create()
295 {
296   return Glib::RefPtr<Script>( new Script() );
297 }
298 
load_from_file(const std::string & filename)299 guint Script::load_from_file(const std::string& filename)
300 {
301   GError* gerror = 0;
302   guint retvalue = clutter_script_load_from_file(gobj(), filename.c_str(), &(gerror));
303   if(gerror)
304     ::Glib::Error::throw_exception(gerror);
305   return retvalue;
306 }
307 
load_from_resource(const std::string & resource_path)308 guint Script::load_from_resource(const std::string& resource_path)
309 {
310   GError* gerror = 0;
311   guint retvalue = clutter_script_load_from_resource(gobj(), resource_path.c_str(), &(gerror));
312   if(gerror)
313     ::Glib::Error::throw_exception(gerror);
314   return retvalue;
315 }
316 
get_object(const Glib::ustring & name)317 Glib::RefPtr<Glib::Object> Script::get_object(const Glib::ustring& name)
318 {
319   Glib::RefPtr<Glib::Object> retvalue = Glib::wrap(clutter_script_get_object(gobj(), name.c_str()));
320   if(retvalue)
321     retvalue->reference(); //The function does not do a ref for us.
322   return retvalue;
323 }
324 
get_object(const Glib::ustring & name) const325 Glib::RefPtr<const Glib::Object> Script::get_object(const Glib::ustring& name) const
326 {
327   return const_cast<Script*>(this)->get_object(name);
328 }
329 
lookup_filename(const std::string & filename)330 std::string Script::lookup_filename(const std::string& filename)
331 {
332   return Glib::convert_return_gchar_ptr_to_stdstring(clutter_script_lookup_filename(gobj(), filename.c_str()));
333 }
334 
unmerge_object(guint merge_id)335 void Script::unmerge_object(guint merge_id)
336 {
337   clutter_script_unmerge_objects(gobj(), merge_id);
338 }
339 
ensure_objects()340 void Script::ensure_objects()
341 {
342   clutter_script_ensure_objects(gobj());
343 }
344 
set_translation_domain(const Glib::ustring & domain)345 void Script::set_translation_domain(const Glib::ustring& domain)
346 {
347   clutter_script_set_translation_domain(gobj(), domain.c_str());
348 }
349 
get_translation_domain() const350 Glib::ustring Script::get_translation_domain() const
351 {
352   return Glib::convert_const_gchar_ptr_to_ustring(clutter_script_get_translation_domain(const_cast<ClutterScript*>(gobj())));
353 }
354 
get_script_id(const Glib::RefPtr<const Glib::Object> & object)355 std::string Script::get_script_id(const Glib::RefPtr<const Glib::Object>& object)
356 {
357   return Glib::convert_const_gchar_ptr_to_stdstring(clutter_get_script_id(const_cast<GObject*>(Glib::unwrap<Glib::Object>(object))));
358 }
359 
360 
361 #ifdef GLIBMM_PROPERTIES_ENABLED
property_filename() const362 Glib::PropertyProxy_ReadOnly< std::string > Script::property_filename() const
363 {
364   return Glib::PropertyProxy_ReadOnly< std::string >(this, "filename");
365 }
366 #endif //GLIBMM_PROPERTIES_ENABLED
367 
368 #ifdef GLIBMM_PROPERTIES_ENABLED
property_filename_set() const369 Glib::PropertyProxy_ReadOnly< bool > Script::property_filename_set() const
370 {
371   return Glib::PropertyProxy_ReadOnly< bool >(this, "filename-set");
372 }
373 #endif //GLIBMM_PROPERTIES_ENABLED
374 
375 
376 } // namespace Clutter
377 
378 
379