Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / glibmm2 / gio / giomm / appinfo.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <giomm/appinfo.h>
5 #include <giomm/private/appinfo_p.h>
6
7 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
8
9 /* Copyright (C) 2007 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 <gio/gio.h>
27 #include <giomm/file.h>
28
29 namespace Gio
30 {
31
32 #ifdef GLIBMM_EXCEPTIONS_ENABLED
33 Glib::RefPtr<AppInfo>
34 AppInfo::create_from_commandline(const std::string& commandline,
35                                  const std::string& application_name,
36                                  AppInfoCreateFlags flags)
37 #else
38 Glib::RefPtr<AppInfo>
39 AppInfo::create_from_commandline(const std::string& commandline,
40                                  const std::string& application_name,
41                                  AppInfoCreateFlags flags,
42                                  std::auto_ptr<Glib::Error>& error)
43 #endif // GLIBMM_EXCEPTIONS_ENABLED
44 {
45   GAppInfo* capp_info = 0;
46   GError* gerror = 0;
47
48   capp_info = g_app_info_create_from_commandline(commandline.c_str(),
49                                                  application_name.c_str(),
50                                                  static_cast<GAppInfoCreateFlags>(flags),
51                                                  &gerror);
52
53   if (gerror)
54 #ifdef GLIBMM_EXCEPTIONS_ENABLED
55     ::Glib::Error::throw_exception(gerror);
56 #else
57     error = ::Glib::Error::throw_exception(gerror);
58 #endif //GLIBMM_EXCEPTIONS_ENABLED
59
60   return Glib::wrap(capp_info);
61 }
62
63 Glib::ListHandle< Glib::RefPtr<AppInfo> > AppInfo::get_all()
64 {
65   return Glib::ListHandle< Glib::RefPtr<AppInfo> >(g_app_info_get_all(), Glib::OWNERSHIP_SHALLOW);
66 }
67
68 Glib::ListHandle< Glib::RefPtr<AppInfo> > AppInfo::get_all_for_type(const std::string& content_type)
69 {
70   return Glib::ListHandle< Glib::RefPtr<AppInfo> >(
71     g_app_info_get_all_for_type(content_type.c_str()), Glib::OWNERSHIP_SHALLOW);
72 }
73
74 Glib::RefPtr<AppInfo> AppInfo::get_default_for_type(const std::string& content_type,
75                                                     bool must_support_uris)
76 {
77   GAppInfo* cinfo = 0;
78   cinfo = g_app_info_get_default_for_type(content_type.c_str(),
79                                           static_cast<gboolean>(must_support_uris));
80   return Glib::wrap(cinfo);
81 }
82
83 Glib::RefPtr<AppInfo> AppInfo::get_default_for_uri_scheme(const std::string& uri_scheme)
84 {
85   GAppInfo* cinfo = 0;
86   cinfo = g_app_info_get_default_for_uri_scheme(uri_scheme.c_str());
87   return Glib::wrap(cinfo);
88 }
89
90 } // namespace Gio
91
92 namespace
93 {
94 } // anonymous namespace
95
96
97 namespace Glib
98 {
99
100 Glib::RefPtr<Gio::AppLaunchContext> wrap(GAppLaunchContext* object, bool take_copy)
101 {
102   return Glib::RefPtr<Gio::AppLaunchContext>( dynamic_cast<Gio::AppLaunchContext*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
103   //We use dynamic_cast<> in case of multiple inheritance.
104 }
105
106 } /* namespace Glib */
107
108
109 namespace Gio
110 {
111
112
113 /* The *_Class implementation: */
114
115 const Glib::Class& AppLaunchContext_Class::init()
116 {
117   if(!gtype_) // create the GType if necessary
118   {
119     // Glib::Class has to know the class init function to clone custom types.
120     class_init_func_ = &AppLaunchContext_Class::class_init_function;
121
122     // This is actually just optimized away, apparently with no harm.
123     // Make sure that the parent type has been created.
124     //CppClassParent::CppObjectType::get_type();
125
126     // Create the wrapper type, with the same class/instance size as the base type.
127     register_derived_type(g_app_launch_context_get_type());
128
129     // Add derived versions of interfaces, if the C type implements any interfaces:
130
131   }
132
133   return *this;
134 }
135
136 void AppLaunchContext_Class::class_init_function(void* g_class, void* class_data)
137 {
138   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
139   CppClassParent::class_init_function(klass, class_data);
140
141 #ifdef GLIBMM_VFUNCS_ENABLED
142 #endif //GLIBMM_VFUNCS_ENABLED
143
144 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
145 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
146 }
147
148 #ifdef GLIBMM_VFUNCS_ENABLED
149 #endif //GLIBMM_VFUNCS_ENABLED
150
151 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
152 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
153
154
155 Glib::ObjectBase* AppLaunchContext_Class::wrap_new(GObject* object)
156 {
157   return new AppLaunchContext((GAppLaunchContext*)object);
158 }
159
160
161 /* The implementation: */
162
163 GAppLaunchContext* AppLaunchContext::gobj_copy()
164 {
165   reference();
166   return gobj();
167 }
168
169 AppLaunchContext::AppLaunchContext(const Glib::ConstructParams& construct_params)
170 :
171   Glib::Object(construct_params)
172 {
173
174 }
175
176 AppLaunchContext::AppLaunchContext(GAppLaunchContext* castitem)
177 :
178   Glib::Object((GObject*)(castitem))
179 {}
180
181
182 AppLaunchContext::~AppLaunchContext()
183 {}
184
185
186 AppLaunchContext::CppClassType AppLaunchContext::applaunchcontext_class_; // initialize static member
187
188 GType AppLaunchContext::get_type()
189 {
190   return applaunchcontext_class_.init().get_type();
191 }
192
193 GType AppLaunchContext::get_base_type()
194 {
195   return g_app_launch_context_get_type();
196 }
197
198
199 AppLaunchContext::AppLaunchContext()
200 :
201   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
202   Glib::ObjectBase(0),
203   Glib::Object(Glib::ConstructParams(applaunchcontext_class_.init()))
204 {
205   
206
207 }
208
209 Glib::RefPtr<AppLaunchContext> AppLaunchContext::create()
210 {
211   return Glib::RefPtr<AppLaunchContext>( new AppLaunchContext() );
212 }
213 std::string AppLaunchContext::get_display(const Glib::RefPtr<AppInfo>& info, const Glib::ListHandle< Glib::RefPtr<Gio::File> >& files)
214 {
215   return Glib::convert_return_gchar_ptr_to_stdstring(g_app_launch_context_get_display(gobj(), Glib::unwrap(info), files.data()));
216 }
217
218 std::string AppLaunchContext::get_startup_notify_id(const Glib::RefPtr<AppInfo>& info, const Glib::ListHandle< Glib::RefPtr<Gio::File> >& files)
219 {
220   return Glib::convert_return_gchar_ptr_to_stdstring(g_app_launch_context_get_startup_notify_id(gobj(), Glib::unwrap(info), files.data()));
221 }
222
223 void AppLaunchContext::launch_failed(const std::string& startup_notify_id)
224 {
225 g_app_launch_context_launch_failed(gobj(), startup_notify_id.c_str()); 
226 }
227
228
229 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
230 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
231
232 #ifdef GLIBMM_VFUNCS_ENABLED
233 #endif //GLIBMM_VFUNCS_ENABLED
234
235
236 } // namespace Gio
237
238
239 namespace Glib
240 {
241
242 Glib::RefPtr<Gio::AppInfo> wrap(GAppInfo* object, bool take_copy)
243 {
244   return Glib::RefPtr<Gio::AppInfo>( dynamic_cast<Gio::AppInfo*> (Glib::wrap_auto_interface<Gio::AppInfo> ((GObject*)(object), take_copy)) );
245   //We use dynamic_cast<> in case of multiple inheritance.
246 }
247
248 } // namespace Glib
249
250
251 namespace Gio
252 {
253
254
255 /* The *_Class implementation: */
256
257 const Glib::Interface_Class& AppInfo_Class::init()
258 {
259   if(!gtype_) // create the GType if necessary
260   {
261     // Glib::Interface_Class has to know the interface init function
262     // in order to add interfaces to implementing types.
263     class_init_func_ = &AppInfo_Class::iface_init_function;
264
265     // We can not derive from another interface, and it is not necessary anyway.
266     gtype_ = g_app_info_get_type();
267   }
268
269   return *this;
270 }
271
272 void AppInfo_Class::iface_init_function(void* g_iface, void*)
273 {
274   BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
275
276   //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
277   //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
278   g_assert(klass != 0); 
279
280 #ifdef GLIBMM_VFUNCS_ENABLED
281 #endif //GLIBMM_VFUNCS_ENABLED
282
283 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
284 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
285 }
286
287 #ifdef GLIBMM_VFUNCS_ENABLED
288 #endif //GLIBMM_VFUNCS_ENABLED
289
290 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
291 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
292
293
294 Glib::ObjectBase* AppInfo_Class::wrap_new(GObject* object)
295 {
296   return new AppInfo((GAppInfo*)(object));
297 }
298
299
300 /* The implementation: */
301
302 AppInfo::AppInfo()
303 :
304   Glib::Interface(appinfo_class_.init())
305 {}
306
307 AppInfo::AppInfo(GAppInfo* castitem)
308 :
309   Glib::Interface((GObject*)(castitem))
310 {}
311
312 AppInfo::AppInfo(const Glib::Interface_Class& interface_class)
313 : Glib::Interface(interface_class)
314 {
315 }
316
317 AppInfo::~AppInfo()
318 {}
319
320 // static
321 void AppInfo::add_interface(GType gtype_implementer)
322 {
323   appinfo_class_.init().add_interface(gtype_implementer);
324 }
325
326 AppInfo::CppClassType AppInfo::appinfo_class_; // initialize static member
327
328 GType AppInfo::get_type()
329 {
330   return appinfo_class_.init().get_type();
331 }
332
333 GType AppInfo::get_base_type()
334 {
335   return g_app_info_get_type();
336 }
337
338 bool AppInfo::equal(const Glib::RefPtr<AppInfo>& other) const
339 {
340   return g_app_info_equal(const_cast<GAppInfo*>(gobj()), Glib::unwrap(other));
341 }
342
343 std::string AppInfo::get_id() const
344 {
345   return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_id(const_cast<GAppInfo*>(gobj())));
346 }
347
348 std::string AppInfo::get_name() const
349 {
350   return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_name(const_cast<GAppInfo*>(gobj())));
351 }
352
353 std::string AppInfo::get_description() const
354 {
355   return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_description(const_cast<GAppInfo*>(gobj())));
356 }
357
358 std::string AppInfo::get_executable() const
359 {
360   return Glib::convert_const_gchar_ptr_to_stdstring(g_app_info_get_executable(const_cast<GAppInfo*>(gobj())));
361 }
362
363 Glib::RefPtr<Icon> AppInfo::get_icon()
364 {
365
366   Glib::RefPtr<Icon> retvalue = Glib::wrap(g_app_info_get_icon(gobj()));
367   if(retvalue)
368     retvalue->reference(); //The function does not do a ref for us.
369   return retvalue;
370
371 }
372
373 const Glib::RefPtr<const Icon> AppInfo::get_icon() const
374 {
375   return const_cast<AppInfo*>(this)->get_icon();
376 }
377
378 #ifdef GLIBMM_EXCEPTIONS_ENABLED
379 bool AppInfo::launch(const Glib::ListHandle<std::string>& files, const Glib::RefPtr<AppLaunchContext>& launch_context)
380 #else
381 bool AppInfo::launch(const Glib::ListHandle<std::string>& files, const Glib::RefPtr<AppLaunchContext>& launch_context, std::auto_ptr<Glib::Error>& error)
382 #endif //GLIBMM_EXCEPTIONS_ENABLED
383 {
384   GError* gerror = 0;
385   bool retvalue = g_app_info_launch(gobj(), files.data(), Glib::unwrap(launch_context), &(gerror));
386 #ifdef GLIBMM_EXCEPTIONS_ENABLED
387   if(gerror)
388     ::Glib::Error::throw_exception(gerror);
389 #else
390   if(gerror)
391     error = ::Glib::Error::throw_exception(gerror);
392 #endif //GLIBMM_EXCEPTIONS_ENABLED
393
394   return retvalue;
395
396 }
397
398 bool AppInfo::supports_uris() const
399 {
400   return g_app_info_supports_uris(const_cast<GAppInfo*>(gobj()));
401 }
402
403 bool AppInfo::supports_files() const
404 {
405   return g_app_info_supports_files(const_cast<GAppInfo*>(gobj()));
406 }
407
408 #ifdef GLIBMM_EXCEPTIONS_ENABLED
409 bool AppInfo::launch_uris(const Glib::ListHandle<std::string>& uris, GAppLaunchContext* launch_context)
410 #else
411 bool AppInfo::launch_uris(const Glib::ListHandle<std::string>& uris, GAppLaunchContext* launch_context, std::auto_ptr<Glib::Error>& error)
412 #endif //GLIBMM_EXCEPTIONS_ENABLED
413 {
414   GError* gerror = 0;
415   bool retvalue = g_app_info_launch_uris(gobj(), uris.data(), launch_context, &(gerror));
416 #ifdef GLIBMM_EXCEPTIONS_ENABLED
417   if(gerror)
418     ::Glib::Error::throw_exception(gerror);
419 #else
420   if(gerror)
421     error = ::Glib::Error::throw_exception(gerror);
422 #endif //GLIBMM_EXCEPTIONS_ENABLED
423
424   return retvalue;
425
426 }
427
428 bool AppInfo::should_show() const
429 {
430   return g_app_info_should_show(const_cast<GAppInfo*>(gobj()));
431 }
432
433 #ifdef GLIBMM_EXCEPTIONS_ENABLED
434 bool AppInfo::set_as_default_for_type(const std::string& content_type)
435 #else
436 bool AppInfo::set_as_default_for_type(const std::string& content_type, std::auto_ptr<Glib::Error>& error)
437 #endif //GLIBMM_EXCEPTIONS_ENABLED
438 {
439   GError* gerror = 0;
440   bool retvalue = g_app_info_set_as_default_for_type(gobj(), content_type.c_str(), &(gerror));
441 #ifdef GLIBMM_EXCEPTIONS_ENABLED
442   if(gerror)
443     ::Glib::Error::throw_exception(gerror);
444 #else
445   if(gerror)
446     error = ::Glib::Error::throw_exception(gerror);
447 #endif //GLIBMM_EXCEPTIONS_ENABLED
448
449   return retvalue;
450
451 }
452
453 #ifdef GLIBMM_EXCEPTIONS_ENABLED
454 bool AppInfo::set_as_default_for_extension(const std::string& extension)
455 #else
456 bool AppInfo::set_as_default_for_extension(const std::string& extension, std::auto_ptr<Glib::Error>& error)
457 #endif //GLIBMM_EXCEPTIONS_ENABLED
458 {
459   GError* gerror = 0;
460   bool retvalue = g_app_info_set_as_default_for_extension(gobj(), extension.c_str(), &(gerror));
461 #ifdef GLIBMM_EXCEPTIONS_ENABLED
462   if(gerror)
463     ::Glib::Error::throw_exception(gerror);
464 #else
465   if(gerror)
466     error = ::Glib::Error::throw_exception(gerror);
467 #endif //GLIBMM_EXCEPTIONS_ENABLED
468
469   return retvalue;
470
471 }
472
473 #ifdef GLIBMM_EXCEPTIONS_ENABLED
474 bool AppInfo::add_supports_type(const std::string& content_type)
475 #else
476 bool AppInfo::add_supports_type(const std::string& content_type, std::auto_ptr<Glib::Error>& error)
477 #endif //GLIBMM_EXCEPTIONS_ENABLED
478 {
479   GError* gerror = 0;
480   bool retvalue = g_app_info_add_supports_type(gobj(), content_type.c_str(), &(gerror));
481 #ifdef GLIBMM_EXCEPTIONS_ENABLED
482   if(gerror)
483     ::Glib::Error::throw_exception(gerror);
484 #else
485   if(gerror)
486     error = ::Glib::Error::throw_exception(gerror);
487 #endif //GLIBMM_EXCEPTIONS_ENABLED
488
489   return retvalue;
490
491 }
492
493 bool AppInfo::can_remove_supports_type() const
494 {
495   return g_app_info_can_remove_supports_type(const_cast<GAppInfo*>(gobj()));
496 }
497
498 #ifdef GLIBMM_EXCEPTIONS_ENABLED
499 bool AppInfo::remove_supports_type(const std::string& content_type)
500 #else
501 bool AppInfo::remove_supports_type(const std::string& content_type, std::auto_ptr<Glib::Error>& error)
502 #endif //GLIBMM_EXCEPTIONS_ENABLED
503 {
504   GError* gerror = 0;
505   bool retvalue = g_app_info_remove_supports_type(gobj(), content_type.c_str(), &(gerror));
506 #ifdef GLIBMM_EXCEPTIONS_ENABLED
507   if(gerror)
508     ::Glib::Error::throw_exception(gerror);
509 #else
510   if(gerror)
511     error = ::Glib::Error::throw_exception(gerror);
512 #endif //GLIBMM_EXCEPTIONS_ENABLED
513
514   return retvalue;
515
516 }
517
518
519 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
520 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
521
522 #ifdef GLIBMM_VFUNCS_ENABLED
523 #endif //GLIBMM_VFUNCS_ENABLED
524
525
526 } // namespace Gio
527
528