2 // Generated by gtkmmproc -- DO NOT MODIFY!
9 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
11 /* Copyright (C) 2007 The gtkmm Development Team
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.
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.
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.
28 #include <giomm/mount.h>
29 #include <giomm/icon.h>
30 //#include <giomm/mountoperation.h>
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GDriveIface GDriveIface;
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 typedef struct _GDrive GDrive;
39 typedef struct _GDriveClass GDriveClass;
40 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
44 { class Drive_Class; } // namespace Gio
48 /** Virtual File System drive management.
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.
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.
61 class Drive : public Glib::Interface
64 #ifndef DOXYGEN_SHOULD_SKIP_THIS
67 typedef Drive CppObjectType;
68 typedef Drive_Class CppClassType;
69 typedef GDrive BaseObjectType;
70 typedef GDriveIface BaseClassType;
73 friend class Drive_Class;
74 static CppClassType drive_class_;
78 Drive& operator=(const Drive&);
81 Drive(); // you must derive from this class
83 /** Called by constructors of derived classes. Provide the result of
84 * the Class init() function to ensure that it is properly
87 * @param interface_class The Class object for the derived type.
89 explicit Drive(const Glib::Interface_Class& interface_class);
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);
98 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
103 static void add_interface(GType gtype_implementer);
105 #ifndef DOXYGEN_SHOULD_SKIP_THIS
106 static GType get_type() G_GNUC_CONST;
107 static GType get_base_type() G_GNUC_CONST;
110 ///Provides access to the underlying C GObject.
111 GDrive* gobj() { return reinterpret_cast<GDrive*>(gobject_); }
113 ///Provides access to the underlying C GObject.
114 const GDrive* gobj() const { return reinterpret_cast<GDrive*>(gobject_); }
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.
125 Glib::ustring get_name() const;
128 /** Gets the icon for @a drive.
129 * @return Icon for the @a drive.
131 Glib::RefPtr<Icon> get_icon();
133 /** Gets the icon for @a drive.
134 * @return Icon for the @a drive.
136 Glib::RefPtr<const Icon> get_icon() const;
139 /** Check if @a drive has any mountable volumes.
140 * @return <tt>true</tt> if the @a drive contains volumes, <tt>false</tt> otherwise.
142 bool has_volumes() const;
145 /** Get a list of mountable volumes for @a drive.
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<!---->s on the given @a drive.
151 Glib::ListHandle< Glib::RefPtr<Volume> > get_volumes();
154 /** Checks if the @a drive supports removable media.
155 * @return <tt>true</tt> if @a drive supports removable media, <tt>false</tt> otherwise.
157 bool is_media_removable() const;
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()
162 * @return <tt>true</tt> if @a drive has media, <tt>false</tt> otherwise.
164 bool has_media() const;
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.
169 bool is_media_check_automatic() const;
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.
174 bool can_poll_for_media() const;
176 /** Checks if a drive can be ejected.
177 * @return <tt>true</tt> if the @a drive can be ejected. <tt>false</tt> otherwise.
179 bool can_eject() const;
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.
186 void eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
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.
192 void eject(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
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.
199 void eject(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
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.
207 #ifdef GLIBMM_EXCEPTIONS_ENABLED
208 bool eject_finish(const Glib::RefPtr<AsyncResult>& result);
210 bool eject_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
211 #endif //GLIBMM_EXCEPTIONS_ENABLED
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.
218 void poll_for_media(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
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.
223 void poll_for_media(const SlotAsyncReady& slot);
225 /** Polls drive to see if media has been inserted or removed.
227 void poll_for_media();
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.
235 #ifdef GLIBMM_EXCEPTIONS_ENABLED
236 bool poll_for_media_finish(const Glib::RefPtr<AsyncResult>& result);
238 bool poll_for_media_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
239 #endif //GLIBMM_EXCEPTIONS_ENABLED
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.
248 std::string get_identifier(const std::string& kind) const;
250 /** Gets the kinds of identifiers that @a drive has.
251 * Use Glib::drive_get_identifer() to obtain the identifiers
253 * @return A <tt>0</tt>-terminated array of strings containing
254 * kinds of identifiers. Use Glib::strfreev() to free.
256 Glib::StringArrayHandle enumerate_identifiers() const;
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)
266 //C++ methods used to invoke GTK+ virtual functions:
267 #ifdef GLIBMM_VFUNCS_ENABLED
268 #endif //GLIBMM_VFUNCS_ENABLED
271 //GTK+ Virtual Functions (override these to change behaviour):
272 #ifdef GLIBMM_VFUNCS_ENABLED
273 #endif //GLIBMM_VFUNCS_ENABLED
275 //Default Signal Handlers::
276 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
277 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
287 //Pre-declare this so we can use it in TypeTrait:
288 Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy);
290 namespace Container_Helpers
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.
299 struct TypeTraits< Glib::RefPtr<Gio::Drive> >
301 typedef Glib::RefPtr<Gio::Drive> CppType;
302 typedef GDrive* CType;
303 typedef GDrive* CTypeNonConst;
305 static CType to_c_type (const CppType& item)
306 { return Glib::unwrap (item); }
308 static CppType to_cpp_type (const CType& item)
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 */);
315 static void release_c_type (CType item)
317 GLIBMM_DEBUG_UNREFERENCE(0, item);
318 g_object_unref(item);
322 } // Container_Helpers
328 /** A Glib::wrap() method for this object.
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.
334 * @relates Gio::Drive
336 Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy = false);
341 #endif /* _GIOMM_DRIVE_H */