Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / glibmm2 / gio / giomm / volume.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GIOMM_VOLUME_H
4 #define _GIOMM_VOLUME_H
5
6
7 #include <glibmm.h>
8
9 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
10
11 /* Copyright (C) 2007 The gtkmm Development Team
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Library General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library General Public
24  * License along with this library; if not, write to the Free
25  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  */
27
28 #include <giomm/file.h>
29 #include <giomm/mountoperation.h>
30 //#include <giomm/drive.h>
31 //#include <giomm/icon.h>
32
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 typedef struct _GVolumeIface GGVolumeIface;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
37
38
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 typedef struct _GVolume GVolume;
41 typedef struct _GVolumeClass GVolumeClass;
42 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
43
44
45 namespace Gio
46 { class Volume_Class; } // namespace Gio
47 namespace Gio
48 {
49
50 // Making a forward declaration here to avoid circular dependency.
51 // file.hg already includes volume.h.
52 class File;
53 class Drive;
54
55 /** The Volume interface represents user-visible objects that can be mounted.
56  * 
57  * Mounting a Volume instance is an asynchronous operation. For more information about asynchronous operations, see AsyncReady and SimpleAsyncReady. To 
58  * mount a GVolume, first call mount(), optionally providing a MountOperation object and a SlotAsyncReady callback.
59  * 
60  * Typically, you will not want to provide a MountOperation if automounting all volumes when a desktop session starts since it's not desirable to 
61  * put up a lot of dialogs asking for credentials.
62  * 
63  * The callback will be fired when the operation has resolved (either with success or failure), and a AsyncReady structure will be passed to the callback. 
64  * That callback should then call g_volume_mount_finish() with the GVolume instance and the GAsyncReady data to see if the operation was completed 
65  * successfully. If an error is present when finish() is called, then it will be filled with any error information.
66  *
67  * @newin2p16
68  */
69
70 class Volume : public Glib::Interface
71 {
72   
73 #ifndef DOXYGEN_SHOULD_SKIP_THIS
74
75 public:
76   typedef Volume CppObjectType;
77   typedef Volume_Class CppClassType;
78   typedef GVolume BaseObjectType;
79   typedef GVolumeIface BaseClassType;
80
81 private:
82   friend class Volume_Class;
83   static CppClassType volume_class_;
84
85   // noncopyable
86   Volume(const Volume&);
87   Volume& operator=(const Volume&);
88
89 protected:
90   Volume(); // you must derive from this class
91
92   /** Called by constructors of derived classes. Provide the result of 
93    * the Class init() function to ensure that it is properly 
94    * initialized.
95    * 
96    * @param interface_class The Class object for the derived type.
97    */
98   explicit Volume(const Glib::Interface_Class& interface_class);
99
100 public:
101   // This is public so that C++ wrapper instances can be
102   // created for C instances of unwrapped types.
103   // For instance, if an unexpected C type implements the C interface. 
104   explicit Volume(GVolume* castitem);
105
106 protected:
107 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
108
109 public:
110   virtual ~Volume();
111
112   static void add_interface(GType gtype_implementer);
113
114 #ifndef DOXYGEN_SHOULD_SKIP_THIS
115   static GType get_type()      G_GNUC_CONST;
116   static GType get_base_type() G_GNUC_CONST;
117 #endif
118
119   ///Provides access to the underlying C GObject.
120   GVolume*       gobj()       { return reinterpret_cast<GVolume*>(gobject_); }
121
122   ///Provides access to the underlying C GObject.  
123   const GVolume* gobj() const { return reinterpret_cast<GVolume*>(gobject_); }
124
125 private:
126
127 public:
128   
129   /** Gets the name of @a volume.
130    * @return The name for the given @a volume. The returned string should 
131    * be freed when no longer needed.
132    */
133   std::string get_name() const;
134   
135   /** Gets the UUID for the @a volume. The reference is typically based on
136    * the file system UUID for the volume in question and should be
137    * considered an opaque string. Returns <tt>0</tt> if there is no UUID
138    * available.
139    * @return The UUID for @a volume or <tt>0</tt> if no UUID can be computed.
140    */
141   std::string get_uuid() const;
142
143   
144   /** Gets the icon for @a volume.
145    * @return A Icon.
146    */
147   Glib::RefPtr<Icon> get_icon();
148   
149   /** Gets the icon for @a volume.
150    * @return A Icon.
151    */
152   Glib::RefPtr<const Icon> get_icon() const;
153
154   
155   /** Gets the drive for the @a volume.
156    * @return A Drive or <tt>0</tt> if @a volume is not associated with a drive.
157    */
158   Glib::RefPtr<Drive> get_drive();
159   
160   /** Gets the drive for the @a volume.
161    * @return A Drive or <tt>0</tt> if @a volume is not associated with a drive.
162    */
163   Glib::RefPtr<const Drive> get_drive() const;
164
165  
166   /** Gets the mount for the @a volume.
167    * @return A Mount or <tt>0</tt> if @a volume isn't mounted.
168    */
169   Glib::RefPtr<Mount> get_mount();
170   
171   /** Gets the mount for the @a volume.
172    * @return A Mount or <tt>0</tt> if @a volume isn't mounted.
173    */
174   Glib::RefPtr<const Mount> get_mount() const;
175
176   
177   /** Checks if a volume can be mounted.
178    * @return <tt>true</tt> if the @a volume can be mounted. <tt>false</tt> otherwise.
179    */
180   bool can_mount() const;
181   
182   /** Checks if a volume can be ejected.
183    * @return <tt>true</tt> if the @a volume can be ejected. <tt>false</tt> otherwise.
184    */
185   bool can_eject() const;
186   
187   /** Returns: <tt>true</tt> if the volume should be automatically mounted.
188    * @return <tt>true</tt> if the volume should be automatically mounted.
189    */
190   bool should_automount() const;
191
192   /** Mounts a volume.
193    * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
194    *
195    * @param slot A callback which will be called when the operation is completed or canceled.
196    * @param cancellable A cancellable object which can be used to cancel the operation.
197    * @param mount_operation A mount operation.
198    */
199   void mount(const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountMountFlags flags = MOUNT_MOUNT_NONE);
200
201   /** Mounts a volume.
202    * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
203    *
204    * @param slot A callback which will be called when the operation is completed or canceled.
205    * @param mount_operation A mount operation.
206    */
207   void mount(const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags = MOUNT_MOUNT_NONE);
208
209   /** Mounts a volume.
210    * 
211    * @param mount_operation A mount operation.
212    */
213   void mount(const Glib::RefPtr<MountOperation>& mount_operation, MountMountFlags flags = MOUNT_MOUNT_NONE);
214
215   /** Mounts a volume.
216    */
217   void mount(MountMountFlags flags = MOUNT_MOUNT_NONE);
218
219   
220   /** Finishes mounting a volume.
221    * @param result A AsyncResult.
222    * @return <tt>true</tt>, <tt>false</tt> if operation failed.
223    */
224 #ifdef GLIBMM_EXCEPTIONS_ENABLED
225   bool mount_finish(const Glib::RefPtr<AsyncResult>& result);
226 #else
227   bool mount_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
228 #endif //GLIBMM_EXCEPTIONS_ENABLED
229
230
231   /** Ejects a volume. 
232    * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
233    *
234    * @param slot A callback which will be called when the operation is completed or canceled.
235    * @param cancellable A cancellable object which can be used to cancel the operation.
236    * @param flags Flags affecting the unmount if required for eject.
237    */
238   void eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
239
240   /** Ejects a volume. 
241    * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
242    *
243    * @param slot A callback which will be called when the operation is completed or canceled.
244    * @param flags Flags affecting the unmount if required for eject.
245    */
246   void eject(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
247
248   /** Ejects a volume. 
249    * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
250    *
251    * @param flags Flags affecting the unmount if required for eject.
252    */
253   void eject(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
254   
255
256   /** Finishes ejecting a volume.
257    * @param result A AsyncResult.
258    * @return <tt>true</tt>, <tt>false</tt> if operation failed.
259    */
260 #ifdef GLIBMM_EXCEPTIONS_ENABLED
261   bool eject_finish(const Glib::RefPtr<AsyncResult>& result);
262 #else
263   bool eject_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
264 #endif //GLIBMM_EXCEPTIONS_ENABLED
265
266
267   /** Gets the identifier of the given kind for @a volume. 
268    * See the introduction
269    * for more information about volume identifiers.
270    * @param kind The kind of identifier to return.
271    * @return A newly allocated string containing the
272    * requested identfier, or <tt>0</tt> if the Volume
273    * doesn't have this kind of identifier.
274    */
275   std::string get_identifier(const std::string& kind) const;
276
277   
278   /** Gets the kinds of identifiers
279    * that @a volume has. Use Glib::volume_get_identifer() to obtain 
280    * the identifiers themselves.
281    * @return A <tt>0</tt>-terminated array of strings containing
282    * kinds of identifiers. Use Glib::strfreev() to free.
283    */
284   Glib::StringArrayHandle enumerate_identifiers() const;
285
286   
287   Glib::RefPtr<File> get_activation_root();
288   
289   Glib::RefPtr<const File> get_activation_root() const;
290
291   
292   /**
293    * @par Prototype:
294    * <tt>void on_my_%changed()</tt>
295    */
296
297   Glib::SignalProxy0< void > signal_changed();
298
299   
300   /**
301    * @par Prototype:
302    * <tt>void on_my_%removed()</tt>
303    */
304
305   Glib::SignalProxy0< void > signal_removed();
306
307
308   //_WRAP_VFUNC(std::string get_name(), get_name)
309   //_WRAP_VFUNC(Glib::RefPtr<Icon> get_icon(), get_icon)
310   //_WRAP_VFUNC(std::string get_uuid(), get_uuid)
311
312  
313   //_WRAP_VFUNC(Glib::RefPtr<Drive> get_drive(), get_drive)
314
315  
316   //_WRAP_VFUNC(Glib::RefPtr<Mount> get_mount(), get_mount)
317
318   //_WRAP_VFUNC(bool can_mount(), can_mount)
319   //_WRAP_VFUNC(bool can_eject(), can_eject)
320   //_WRAP_VFUNC(void mount_fn(GMountMountFlags flags, GMountOperation* mount_operation, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data), mount_fn) //TODO: Rename to mount()?       
321   //_WRAP_VFUNC(bool mount_finish(GAsyncResult* result, GError** error), mount_finish)
322   //_WRAP_VFUNC(void eject(GMountUnmountFlags flags, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data), eject)
323   //_WRAP_VFUNC(bool eject_finish(GAsyncResult* result, GError** error), eject_finish)
324   
325   //_WRAP_VFUNC(std::string get_identifier(const std::string& kind), get_identifier)
326
327   //TODO: Use an ArrayHandle.
328   //_WRAP_VFUNC(char** enumerate_identifiers(), enumerate_identifiers)
329
330   //_WRAP_VFUNC(bool should_automount(), should_automount)
331
332
333 public:
334
335 public:
336   //C++ methods used to invoke GTK+ virtual functions:
337 #ifdef GLIBMM_VFUNCS_ENABLED
338 #endif //GLIBMM_VFUNCS_ENABLED
339
340 protected:
341   //GTK+ Virtual Functions (override these to change behaviour):
342 #ifdef GLIBMM_VFUNCS_ENABLED
343 #endif //GLIBMM_VFUNCS_ENABLED
344
345   //Default Signal Handlers::
346 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
347   virtual void on_changed();
348   virtual void on_removed();
349 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
350
351
352 };
353
354 } // namespace Gio
355
356 namespace Glib
357 {
358
359 //Pre-declare this so we can use it in TypeTrait:
360 Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy);
361
362 namespace Container_Helpers
363 {
364
365 /** This specialization of TypeTraits exists 
366  * because the default use of Glib::wrap(GObject*), 
367  * instead of a specific Glib::wrap(GSomeInterface*),
368  * would not return a wrapper for an interface.
369  */ 
370 template <>
371 struct TypeTraits< Glib::RefPtr<Gio::Volume> >
372 {
373   typedef Glib::RefPtr<Gio::Volume> CppType;
374   typedef GVolume* CType;
375   typedef GVolume* CTypeNonConst;
376
377   static CType   to_c_type      (const CppType& item)
378   { return Glib::unwrap (item); }
379
380   static CppType to_cpp_type    (const CType& item)
381   {
382     //Use a specific Glib::wrap() function, 
383     //because CType has the specific type (not just GObject):
384     return Glib::wrap(item, true /* take_copy */);
385   }
386
387   static void    release_c_type (CType item)
388   {
389     GLIBMM_DEBUG_UNREFERENCE(0, item);
390     g_object_unref(item);
391   }
392 };
393
394 } // Container_Helpers
395 } // Glib
396
397
398 namespace Glib
399 {
400   /** A Glib::wrap() method for this object.
401    * 
402    * @param object The C instance.
403    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
404    * @result A C++ instance that wraps this C instance.
405    *
406    * @relates Gio::Volume
407    */
408   Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy = false);
409
410 } // namespace Glib
411
412
413 #endif /* _GIOMM_VOLUME_H */
414