Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / glibmm2 / gio / giomm / mount.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <giomm/mount.h>
5 #include <giomm/private/mount_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 <giomm/drive.h>
27 #include <giomm/volume.h>
28 #include <gio/gio.h>
29 #include "slot_async.h"
30
31 namespace Gio
32 {
33
34 void Mount::unmount(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags)
35 {
36   // Create a copy of the slot.
37   // A pointer to it will be passed through the callback's data parameter
38   // and deleted in the callback.
39   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
40
41   g_mount_unmount(gobj(),
42                   GMountUnmountFlags(flags),
43                   cancellable->gobj(), 
44                   &SignalProxy_async_callback,
45                   slot_copy);
46 }
47
48 void Mount::unmount(const SlotAsyncReady& slot, MountUnmountFlags flags)
49 {
50   // Create a copy of the slot.
51   // A pointer to it will be passed through the callback's data parameter
52   // and deleted in the callback.
53   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
54
55   g_mount_unmount(gobj(),
56                   GMountUnmountFlags(flags),
57                   NULL, 
58                   &SignalProxy_async_callback,
59                   slot_copy);
60 }
61
62 void Mount::unmount(MountUnmountFlags flags)
63 {
64   g_mount_unmount(gobj(),
65                   GMountUnmountFlags(flags),
66                   NULL, 
67                   NULL,
68                   NULL);
69 }
70
71
72 void Mount::remount(const Glib::RefPtr<MountOperation>& operation, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountMountFlags flags)
73 {
74   // Create a copy of the slot.
75   // A pointer to it will be passed through the callback's data parameter
76   // and deleted in the callback.
77   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
78
79   g_mount_remount(gobj(),
80                   static_cast<GMountMountFlags>(flags),
81                   operation->gobj(),
82                   cancellable->gobj(), 
83                   &SignalProxy_async_callback,
84                   slot_copy);
85 }
86
87 void Mount::remount(const Glib::RefPtr<MountOperation>& operation, const SlotAsyncReady& slot, MountMountFlags flags)
88 {
89   // Create a copy of the slot.
90   // A pointer to it will be passed through the callback's data parameter
91   // and deleted in the callback.
92   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
93
94   g_mount_remount(gobj(),
95                   static_cast<GMountMountFlags>(flags),
96                   operation->gobj(),
97                   NULL, 
98                   &SignalProxy_async_callback,
99                   slot_copy);
100 }
101
102 void Mount::remount(const Glib::RefPtr<MountOperation>& operation, MountMountFlags flags)
103 {
104   g_mount_remount(gobj(),
105                   static_cast<GMountMountFlags>(flags),
106                   operation->gobj(),
107                   NULL, 
108                   NULL,
109                   NULL);
110 }
111
112 void Mount::remount(MountMountFlags flags)
113 {
114   g_mount_remount(gobj(),
115                   static_cast<GMountMountFlags>(flags),
116                   NULL,
117                   NULL, 
118                   NULL,
119                   NULL);
120 }
121
122 void Mount::eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags)
123 {
124   // Create a copy of the slot.
125   // A pointer to it will be passed through the callback's data parameter
126   // and deleted in the callback.
127   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
128
129   g_mount_eject(gobj(),
130                   GMountUnmountFlags(flags),
131                   cancellable->gobj(), 
132                   &SignalProxy_async_callback,
133                   slot_copy);
134 }
135
136 void Mount::eject(const SlotAsyncReady& slot, MountUnmountFlags flags)
137 {
138   // Create a copy of the slot.
139   // A pointer to it will be passed through the callback's data parameter
140   // and deleted in the callback.
141   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
142
143   g_mount_eject(gobj(),
144                   GMountUnmountFlags(flags),
145                   NULL, 
146                   &SignalProxy_async_callback,
147                   slot_copy);
148 }
149
150 void Mount::eject(MountUnmountFlags flags)
151 {
152   g_mount_eject(gobj(),
153                   GMountUnmountFlags(flags),
154                   NULL, 
155                   NULL,
156                   NULL);
157 }
158
159
160 void Mount::guess_content_type(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, bool force_rescan)
161 {
162   // Create a copy of the slot.
163   // A pointer to it will be passed through the callback's data parameter
164   // and deleted in the callback.
165   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
166
167   g_mount_guess_content_type(gobj(),
168                   force_rescan,
169                   cancellable->gobj(), 
170                   &SignalProxy_async_callback,
171                   slot_copy);
172 }
173
174 void Mount::guess_content_type(const SlotAsyncReady& slot, bool force_rescan)
175 {
176   // Create a copy of the slot.
177   // A pointer to it will be passed through the callback's data parameter
178   // and deleted in the callback.
179   SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
180
181   g_mount_guess_content_type(gobj(),
182                   force_rescan,
183                   NULL, 
184                   &SignalProxy_async_callback,
185                   slot_copy);
186 }
187
188 void Mount::guess_content_type(bool force_rescan)
189 {
190   g_mount_guess_content_type(gobj(),
191                   force_rescan,
192                   NULL, 
193                   NULL,
194                   NULL);
195 }
196
197
198 } // namespace Gio
199
200
201 namespace
202 {
203
204
205 static const Glib::SignalProxyInfo Mount_signal_changed_info =
206 {
207   "changed",
208   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
209   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
210 };
211
212
213 static const Glib::SignalProxyInfo Mount_signal_unmounted_info =
214 {
215   "unmounted",
216   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
217   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
218 };
219
220
221 } // anonymous namespace
222
223
224 namespace Glib
225 {
226
227 Glib::RefPtr<Gio::Mount> wrap(GMount* object, bool take_copy)
228 {
229   return Glib::RefPtr<Gio::Mount>( dynamic_cast<Gio::Mount*> (Glib::wrap_auto_interface<Gio::Mount> ((GObject*)(object), take_copy)) );
230   //We use dynamic_cast<> in case of multiple inheritance.
231 }
232
233 } // namespace Glib
234
235
236 namespace Gio
237 {
238
239
240 /* The *_Class implementation: */
241
242 const Glib::Interface_Class& Mount_Class::init()
243 {
244   if(!gtype_) // create the GType if necessary
245   {
246     // Glib::Interface_Class has to know the interface init function
247     // in order to add interfaces to implementing types.
248     class_init_func_ = &Mount_Class::iface_init_function;
249
250     // We can not derive from another interface, and it is not necessary anyway.
251     gtype_ = g_mount_get_type();
252   }
253
254   return *this;
255 }
256
257 void Mount_Class::iface_init_function(void* g_iface, void*)
258 {
259   BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
260
261   //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
262   //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
263   g_assert(klass != 0); 
264
265 #ifdef GLIBMM_VFUNCS_ENABLED
266 #endif //GLIBMM_VFUNCS_ENABLED
267
268 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
269   klass->changed = &changed_callback;
270   klass->unmounted = &unmounted_callback;
271 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
272 }
273
274 #ifdef GLIBMM_VFUNCS_ENABLED
275 #endif //GLIBMM_VFUNCS_ENABLED
276
277 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
278 void Mount_Class::changed_callback(GMount* self)
279 {
280   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
281       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
282
283   // Non-gtkmmproc-generated custom classes implicitly call the default
284   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
285   // generated classes can use this optimisation, which avoids the unnecessary
286   // parameter conversions if there is no possibility of the virtual function
287   // being overridden:
288   if(obj_base && obj_base->is_derived_())
289   {
290     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
291     if(obj) // This can be NULL during destruction.
292     {
293       #ifdef GLIBMM_EXCEPTIONS_ENABLED
294       try // Trap C++ exceptions which would normally be lost because this is a C callback.
295       {
296       #endif //GLIBMM_EXCEPTIONS_ENABLED
297         // Call the virtual member method, which derived classes might override.
298         obj->on_changed();
299         return;
300       #ifdef GLIBMM_EXCEPTIONS_ENABLED
301       }
302       catch(...)
303       {
304         Glib::exception_handlers_invoke();
305       }
306       #endif //GLIBMM_EXCEPTIONS_ENABLED
307     }
308   }
309   
310   BaseClassType *const base = static_cast<BaseClassType*>(
311         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
312 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
313 )    );
314
315   // Call the original underlying C function:
316   if(base && base->changed)
317     (*base->changed)(self);
318 }
319 void Mount_Class::unmounted_callback(GMount* self)
320 {
321   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
322       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
323
324   // Non-gtkmmproc-generated custom classes implicitly call the default
325   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
326   // generated classes can use this optimisation, which avoids the unnecessary
327   // parameter conversions if there is no possibility of the virtual function
328   // being overridden:
329   if(obj_base && obj_base->is_derived_())
330   {
331     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
332     if(obj) // This can be NULL during destruction.
333     {
334       #ifdef GLIBMM_EXCEPTIONS_ENABLED
335       try // Trap C++ exceptions which would normally be lost because this is a C callback.
336       {
337       #endif //GLIBMM_EXCEPTIONS_ENABLED
338         // Call the virtual member method, which derived classes might override.
339         obj->on_unmounted();
340         return;
341       #ifdef GLIBMM_EXCEPTIONS_ENABLED
342       }
343       catch(...)
344       {
345         Glib::exception_handlers_invoke();
346       }
347       #endif //GLIBMM_EXCEPTIONS_ENABLED
348     }
349   }
350   
351   BaseClassType *const base = static_cast<BaseClassType*>(
352         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
353 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
354 )    );
355
356   // Call the original underlying C function:
357   if(base && base->unmounted)
358     (*base->unmounted)(self);
359 }
360 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
361
362
363 Glib::ObjectBase* Mount_Class::wrap_new(GObject* object)
364 {
365   return new Mount((GMount*)(object));
366 }
367
368
369 /* The implementation: */
370
371 Mount::Mount()
372 :
373   Glib::Interface(mount_class_.init())
374 {}
375
376 Mount::Mount(GMount* castitem)
377 :
378   Glib::Interface((GObject*)(castitem))
379 {}
380
381 Mount::Mount(const Glib::Interface_Class& interface_class)
382 : Glib::Interface(interface_class)
383 {
384 }
385
386 Mount::~Mount()
387 {}
388
389 // static
390 void Mount::add_interface(GType gtype_implementer)
391 {
392   mount_class_.init().add_interface(gtype_implementer);
393 }
394
395 Mount::CppClassType Mount::mount_class_; // initialize static member
396
397 GType Mount::get_type()
398 {
399   return mount_class_.init().get_type();
400 }
401
402 GType Mount::get_base_type()
403 {
404   return g_mount_get_type();
405 }
406
407
408 Glib::RefPtr<File> Mount::get_root()
409 {
410
411   Glib::RefPtr<File> retvalue = Glib::wrap(g_mount_get_root(gobj()));
412   if(retvalue)
413     retvalue->reference(); //The function does not do a ref for us.
414   return retvalue;
415
416 }
417
418 Glib::RefPtr<const File> Mount::get_root() const
419 {
420   return const_cast<Mount*>(this)->get_root();
421 }
422
423 std::string Mount::get_name() const
424 {
425   return Glib::convert_return_gchar_ptr_to_stdstring(g_mount_get_name(const_cast<GMount*>(gobj())));
426 }
427
428 Glib::RefPtr<Icon> Mount::get_icon()
429 {
430
431   Glib::RefPtr<Icon> retvalue = Glib::wrap(g_mount_get_icon(gobj()));
432   if(retvalue)
433     retvalue->reference(); //The function does not do a ref for us.
434   return retvalue;
435
436 }
437
438 Glib::RefPtr<const Icon> Mount::get_icon() const
439 {
440   return const_cast<Mount*>(this)->get_icon();
441 }
442
443 std::string Mount::get_uuid() const
444 {
445   return Glib::convert_return_gchar_ptr_to_stdstring(g_mount_get_uuid(const_cast<GMount*>(gobj())));
446 }
447
448 Glib::RefPtr<Volume> Mount::get_volume()
449 {
450
451   Glib::RefPtr<Volume> retvalue = Glib::wrap(g_mount_get_volume(gobj()));
452   if(retvalue)
453     retvalue->reference(); //The function does not do a ref for us.
454   return retvalue;
455
456 }
457
458 Glib::RefPtr<const Volume> Mount::get_volume() const
459 {
460   return const_cast<Mount*>(this)->get_volume();
461 }
462
463 Glib::RefPtr<Drive> Mount::get_drive()
464 {
465
466   Glib::RefPtr<Drive> retvalue = Glib::wrap(g_mount_get_drive(gobj()));
467   if(retvalue)
468     retvalue->reference(); //The function does not do a ref for us.
469   return retvalue;
470
471 }
472
473 Glib::RefPtr<const Drive> Mount::get_drive() const
474 {
475   return const_cast<Mount*>(this)->get_drive();
476 }
477
478 bool Mount::can_unmount() const
479 {
480   return g_mount_can_unmount(const_cast<GMount*>(gobj()));
481 }
482
483 bool Mount::can_eject() const
484 {
485   return g_mount_can_eject(const_cast<GMount*>(gobj()));
486 }
487
488 #ifdef GLIBMM_EXCEPTIONS_ENABLED
489 bool Mount::unmount_finish(const Glib::RefPtr<AsyncResult>& result)
490 #else
491 bool Mount::unmount_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error)
492 #endif //GLIBMM_EXCEPTIONS_ENABLED
493 {
494   GError* gerror = 0;
495   bool retvalue = g_mount_unmount_finish(gobj(), Glib::unwrap(result), &(gerror));
496 #ifdef GLIBMM_EXCEPTIONS_ENABLED
497   if(gerror)
498     ::Glib::Error::throw_exception(gerror);
499 #else
500   if(gerror)
501     error = ::Glib::Error::throw_exception(gerror);
502 #endif //GLIBMM_EXCEPTIONS_ENABLED
503
504   return retvalue;
505
506 }
507
508 #ifdef GLIBMM_EXCEPTIONS_ENABLED
509 bool Mount::remount_finish(const Glib::RefPtr<AsyncResult>& result)
510 #else
511 bool Mount::remount_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error)
512 #endif //GLIBMM_EXCEPTIONS_ENABLED
513 {
514   GError* gerror = 0;
515   bool retvalue = g_mount_remount_finish(gobj(), Glib::unwrap(result), &(gerror));
516 #ifdef GLIBMM_EXCEPTIONS_ENABLED
517   if(gerror)
518     ::Glib::Error::throw_exception(gerror);
519 #else
520   if(gerror)
521     error = ::Glib::Error::throw_exception(gerror);
522 #endif //GLIBMM_EXCEPTIONS_ENABLED
523
524   return retvalue;
525
526 }
527
528 #ifdef GLIBMM_EXCEPTIONS_ENABLED
529 bool Mount::eject_finish(const Glib::RefPtr<AsyncResult>& result)
530 #else
531 bool Mount::eject_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error)
532 #endif //GLIBMM_EXCEPTIONS_ENABLED
533 {
534   GError* gerror = 0;
535   bool retvalue = g_mount_eject_finish(gobj(), Glib::unwrap(result), &(gerror));
536 #ifdef GLIBMM_EXCEPTIONS_ENABLED
537   if(gerror)
538     ::Glib::Error::throw_exception(gerror);
539 #else
540   if(gerror)
541     error = ::Glib::Error::throw_exception(gerror);
542 #endif //GLIBMM_EXCEPTIONS_ENABLED
543
544   return retvalue;
545
546 }
547
548 #ifdef GLIBMM_EXCEPTIONS_ENABLED
549 Glib::StringArrayHandle Mount::guess_content_type_finish(const Glib::RefPtr<AsyncResult>& result)
550 #else
551 Glib::StringArrayHandle Mount::guess_content_type_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error)
552 #endif //GLIBMM_EXCEPTIONS_ENABLED
553 {
554   GError* gerror = 0;
555   Glib::StringArrayHandle retvalue = Glib::StringArrayHandle(g_mount_guess_content_type_finish(gobj(), Glib::unwrap(result), &(gerror)), Glib::OWNERSHIP_DEEP);
556 #ifdef GLIBMM_EXCEPTIONS_ENABLED
557   if(gerror)
558     ::Glib::Error::throw_exception(gerror);
559 #else
560   if(gerror)
561     error = ::Glib::Error::throw_exception(gerror);
562 #endif //GLIBMM_EXCEPTIONS_ENABLED
563
564   return retvalue;
565
566 }
567
568
569 Glib::SignalProxy0< void > Mount::signal_changed()
570 {
571   return Glib::SignalProxy0< void >(this, &Mount_signal_changed_info);
572 }
573
574
575 Glib::SignalProxy0< void > Mount::signal_unmounted()
576 {
577   return Glib::SignalProxy0< void >(this, &Mount_signal_unmounted_info);
578 }
579
580
581 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
582 void Gio::Mount::on_changed()
583 {
584   BaseClassType *const base = static_cast<BaseClassType*>(
585       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
586 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
587 )  );
588
589   if(base && base->changed)
590     (*base->changed)(gobj());
591 }
592 void Gio::Mount::on_unmounted()
593 {
594   BaseClassType *const base = static_cast<BaseClassType*>(
595       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
596 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
597 )  );
598
599   if(base && base->unmounted)
600     (*base->unmounted)(gobj());
601 }
602 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
603
604 #ifdef GLIBMM_VFUNCS_ENABLED
605 #endif //GLIBMM_VFUNCS_ENABLED
606
607
608 } // namespace Gio
609
610