Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / glibmm2 / gio / giomm / drive.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GIOMM_DRIVE_H
4 #define _GIOMM_DRIVE_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/mount.h>
29 #include <giomm/icon.h>
30 //#include <giomm/mountoperation.h>
31
32
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GDriveIface GDriveIface;
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
36
37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 typedef struct _GDrive GDrive;
39 typedef struct _GDriveClass GDriveClass;
40 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
41
42
43 namespace Gio
44 { class Drive_Class; } // namespace Gio
45 namespace Gio
46 {
47
48 /** Virtual File System drive management.
49  *
50  * This represent a piece of hardware connected to the machine. It's generally only created for removable hardware or hardware with removable media.
51  * Gio::Drive is a container class for Gio::Volume objects that stem from the same piece of media. As such, Gio::Drive abstracts a drive with 
52  * (or without) removable media and provides operations for querying whether media is available, determing whether media change is automatically 
53  * detected and ejecting the media.
54  *
55  * If the Gio::Drive reports that media isn't automatically detected, one can poll for media; typically one should not do this periodically as a 
56  * poll for media operation is potententially expensive and may spin up the drive, creating noise.
57  *
58  * @newin2p16
59  */
60
61 class Drive : public Glib::Interface
62 {
63   
64 #ifndef DOXYGEN_SHOULD_SKIP_THIS
65
66 public:
67   typedef Drive CppObjectType;
68   typedef Drive_Class CppClassType;
69   typedef GDrive BaseObjectType;
70   typedef GDriveIface BaseClassType;
71
72 private:
73   friend class Drive_Class;
74   static CppClassType drive_class_;
75
76   // noncopyable
77   Drive(const Drive&);
78   Drive& operator=(const Drive&);
79
80 protected:
81   Drive(); // you must derive from this class
82
83   /** Called by constructors of derived classes. Provide the result of 
84    * the Class init() function to ensure that it is properly 
85    * initialized.
86    * 
87    * @param interface_class The Class object for the derived type.
88    */
89   explicit Drive(const Glib::Interface_Class& interface_class);
90
91 public:
92   // This is public so that C++ wrapper instances can be
93   // created for C instances of unwrapped types.
94   // For instance, if an unexpected C type implements the C interface. 
95   explicit Drive(GDrive* castitem);
96
97 protected:
98 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
99
100 public:
101   virtual ~Drive();
102
103   static void add_interface(GType gtype_implementer);
104
105 #ifndef DOXYGEN_SHOULD_SKIP_THIS
106   static GType get_type()      G_GNUC_CONST;
107   static GType get_base_type() G_GNUC_CONST;
108 #endif
109
110   ///Provides access to the underlying C GObject.
111   GDrive*       gobj()       { return reinterpret_cast<GDrive*>(gobject_); }
112
113   ///Provides access to the underlying C GObject.  
114   const GDrive* gobj() const { return reinterpret_cast<GDrive*>(gobject_); }
115
116 private:
117
118 public:
119
120   
121   /** Gets the name of @a drive.
122    * @return A string containing @a drive's name. The returned 
123    * string should be freed when no longer needed.
124    */
125   Glib::ustring get_name() const;
126
127   
128   /** Gets the icon for @a drive.
129    * @return Icon for the @a drive.
130    */
131   Glib::RefPtr<Icon> get_icon();
132   
133   /** Gets the icon for @a drive.
134    * @return Icon for the @a drive.
135    */
136   Glib::RefPtr<const Icon> get_icon() const;
137
138   
139   /** Check if @a drive has any mountable volumes.
140    * @return <tt>true</tt> if the @a drive contains volumes, <tt>false</tt> otherwise.
141    */
142   bool has_volumes() const;
143
144  
145   /** Get a list of mountable volumes for @a drive.
146    * 
147    * The returned list should be freed with Glib::list_free(), after
148    * its elements have been unreffed with Glib::object_unref().
149    * @return List containing any Volume&lt;!----&gt;s on the given @a drive.
150    */
151   Glib::ListHandle< Glib::RefPtr<Volume> > get_volumes();
152
153   
154   /** Checks if the @a drive supports removable media.
155    * @return <tt>true</tt> if @a drive supports removable media, <tt>false</tt> otherwise.
156    */
157   bool is_media_removable() const;
158   
159   /** Checks if the @a drive has media. Note that the OS may not be polling
160    * the drive for media changes; see g_drive_is_media_check_automatic()
161    * for more details.
162    * @return <tt>true</tt> if @a drive has media, <tt>false</tt> otherwise.
163    */
164   bool has_media() const;
165   
166   /** Checks if @a drive is capabable of automatically detecting media changes.
167    * @return <tt>true</tt> if the @a drive is capabable of automatically detecting media changes, <tt>false</tt> otherwise.
168    */
169   bool is_media_check_automatic() const;
170   
171   /** Checks if a drive can be polled for media changes.
172    * @return <tt>true</tt> if the @a drive can be polled for media changes. <tt>false</tt> otherwise.
173    */
174   bool can_poll_for_media() const;
175   
176   /** Checks if a drive can be ejected.
177    * @return <tt>true</tt> if the @a drive can be ejected. <tt>false</tt> otherwise.
178    */
179   bool can_eject() const;
180
181   /** Ejects the drive.
182    * @param slot A callback which will be called when the eject is completed or canceled.
183    * @param flags Flags affecting the unmount if required for eject.
184    * @param cancellable A cancellable object which can be used to cancel the eject.
185    */
186   void eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
187
188   /** Ejects the drive.
189    * @param slot A callback which will be called when the eject is completed.
190    * @param flags Flags affecting the unmount if required for eject.
191    */
192   void eject(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
193   
194
195   /** Ejects the drive.
196    * @param slot A callback which will be called when the eject is completed.
197    * @param flags Flags affecting the unmount if required for eject.
198    */
199   void eject(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
200
201   
202   /** Finishes ejecting a drive.
203    * @param result A AsyncResult.
204    * @return <tt>true</tt> if the drive has been ejected successfully,
205    * <tt>false</tt> otherwise.
206    */
207 #ifdef GLIBMM_EXCEPTIONS_ENABLED
208   bool eject_finish(const Glib::RefPtr<AsyncResult>& result);
209 #else
210   bool eject_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
211 #endif //GLIBMM_EXCEPTIONS_ENABLED
212
213
214   /** Polls drive to see if media has been inserted or removed.
215    * @param slot A callback which will be called when the poll is completed.
216    * @param cancellable A cancellable object which can be used to cancel the operation.
217    */
218   void poll_for_media(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
219
220   /** Polls drive to see if media has been inserted or removed.
221    * @param slot A callback which will be called when the poll is completed.
222    */
223   void poll_for_media(const SlotAsyncReady& slot);
224
225   /** Polls drive to see if media has been inserted or removed.
226    */
227   void poll_for_media();
228   
229
230   /** Finishes poll_for_mediaing a drive.
231    * @param result A AsyncResult.
232    * @return <tt>true</tt> if the drive has been poll_for_mediaed successfully,
233    * <tt>false</tt> otherwise.
234    */
235 #ifdef GLIBMM_EXCEPTIONS_ENABLED
236   bool poll_for_media_finish(const Glib::RefPtr<AsyncResult>& result);
237 #else
238   bool poll_for_media_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
239 #endif //GLIBMM_EXCEPTIONS_ENABLED
240
241
242   /** Gets the identifier of the given kind for @a drive.
243    * @param kind The kind of identifier to return.
244    * @return A newly allocated string containing the
245    * requested identfier, or <tt>0</tt> if the Drive
246    * doesn't have this kind of identifier.
247    */
248   std::string get_identifier(const std::string& kind) const;
249   
250   /** Gets the kinds of identifiers that @a drive has. 
251    * Use Glib::drive_get_identifer() to obtain the identifiers
252    * themselves.
253    * @return A <tt>0</tt>-terminated array of strings containing
254    * kinds of identifiers. Use Glib::strfreev() to free.
255    */
256   Glib::StringArrayHandle enumerate_identifiers() const;
257
258   //_WRAP_VFUNC(Glib::ustring get_name() const, get_name)
259   //Careful of ref-counting: //_WRAP_VFUNC(Glib::RefPtr<Icon> get_icon() const, get_icon)
260   //_WRAP_VFUNC(bool has_volumes() const, has_volumes)
261
262
263 public:
264
265 public:
266   //C++ methods used to invoke GTK+ virtual functions:
267 #ifdef GLIBMM_VFUNCS_ENABLED
268 #endif //GLIBMM_VFUNCS_ENABLED
269
270 protected:
271   //GTK+ Virtual Functions (override these to change behaviour):
272 #ifdef GLIBMM_VFUNCS_ENABLED
273 #endif //GLIBMM_VFUNCS_ENABLED
274
275   //Default Signal Handlers::
276 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
277 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
278
279
280 };
281
282 } // namespace Gio
283
284 namespace Glib
285 {
286
287 //Pre-declare this so we can use it in TypeTrait:
288 Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy);
289
290 namespace Container_Helpers
291 {
292
293 /** This specialization of TypeTraits exists 
294  * because the default use of Glib::wrap(GObject*), 
295  * instead of a specific Glib::wrap(GSomeInterface*),
296  * would not return a wrapper for an interface.
297  */ 
298 template <>
299 struct TypeTraits< Glib::RefPtr<Gio::Drive> >
300 {
301   typedef Glib::RefPtr<Gio::Drive> CppType;
302   typedef GDrive* CType;
303   typedef GDrive* CTypeNonConst;
304
305   static CType   to_c_type      (const CppType& item)
306   { return Glib::unwrap (item); }
307
308   static CppType to_cpp_type    (const CType& item)
309   {
310     //Use a specific Glib::wrap() function, 
311     //because CType has the specific type (not just GObject):
312     return Glib::wrap(item, true /* take_copy */);
313   }
314
315   static void    release_c_type (CType item)
316   {
317     GLIBMM_DEBUG_UNREFERENCE(0, item);
318     g_object_unref(item);
319   }
320 };
321
322 } // Container_Helpers
323 } // Glib
324
325
326 namespace Glib
327 {
328   /** A Glib::wrap() method for this object.
329    * 
330    * @param object The C instance.
331    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
332    * @result A C++ instance that wraps this C instance.
333    *
334    * @relates Gio::Drive
335    */
336   Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy = false);
337
338 } // namespace Glib
339
340
341 #endif /* _GIOMM_DRIVE_H */
342