2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GIOMM_VOLUME_H
4 #define _GIOMM_VOLUME_H
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/file.h>
29 #include <giomm/mountoperation.h>
30 //#include <giomm/drive.h>
31 //#include <giomm/icon.h>
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 typedef struct _GVolumeIface GGVolumeIface;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 typedef struct _GVolume GVolume;
41 typedef struct _GVolumeClass GVolumeClass;
42 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
46 { class Volume_Class; } // namespace Gio
50 // Making a forward declaration here to avoid circular dependency.
51 // file.hg already includes volume.h.
55 /** The Volume interface represents user-visible objects that can be mounted.
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.
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.
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.
70 class Volume : public Glib::Interface
73 #ifndef DOXYGEN_SHOULD_SKIP_THIS
76 typedef Volume CppObjectType;
77 typedef Volume_Class CppClassType;
78 typedef GVolume BaseObjectType;
79 typedef GVolumeIface BaseClassType;
82 friend class Volume_Class;
83 static CppClassType volume_class_;
86 Volume(const Volume&);
87 Volume& operator=(const Volume&);
90 Volume(); // you must derive from this class
92 /** Called by constructors of derived classes. Provide the result of
93 * the Class init() function to ensure that it is properly
96 * @param interface_class The Class object for the derived type.
98 explicit Volume(const Glib::Interface_Class& interface_class);
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);
107 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
112 static void add_interface(GType gtype_implementer);
114 #ifndef DOXYGEN_SHOULD_SKIP_THIS
115 static GType get_type() G_GNUC_CONST;
116 static GType get_base_type() G_GNUC_CONST;
119 ///Provides access to the underlying C GObject.
120 GVolume* gobj() { return reinterpret_cast<GVolume*>(gobject_); }
122 ///Provides access to the underlying C GObject.
123 const GVolume* gobj() const { return reinterpret_cast<GVolume*>(gobject_); }
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.
133 std::string get_name() const;
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
139 * @return The UUID for @a volume or <tt>0</tt> if no UUID can be computed.
141 std::string get_uuid() const;
144 /** Gets the icon for @a volume.
147 Glib::RefPtr<Icon> get_icon();
149 /** Gets the icon for @a volume.
152 Glib::RefPtr<const Icon> get_icon() const;
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.
158 Glib::RefPtr<Drive> get_drive();
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.
163 Glib::RefPtr<const Drive> get_drive() const;
166 /** Gets the mount for the @a volume.
167 * @return A Mount or <tt>0</tt> if @a volume isn't mounted.
169 Glib::RefPtr<Mount> get_mount();
171 /** Gets the mount for the @a volume.
172 * @return A Mount or <tt>0</tt> if @a volume isn't mounted.
174 Glib::RefPtr<const Mount> get_mount() const;
177 /** Checks if a volume can be mounted.
178 * @return <tt>true</tt> if the @a volume can be mounted. <tt>false</tt> otherwise.
180 bool can_mount() const;
182 /** Checks if a volume can be ejected.
183 * @return <tt>true</tt> if the @a volume can be ejected. <tt>false</tt> otherwise.
185 bool can_eject() const;
187 /** Returns: <tt>true</tt> if the volume should be automatically mounted.
188 * @return <tt>true</tt> if the volume should be automatically mounted.
190 bool should_automount() const;
193 * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
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.
199 void mount(const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountMountFlags flags = MOUNT_MOUNT_NONE);
202 * This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.
204 * @param slot A callback which will be called when the operation is completed or canceled.
205 * @param mount_operation A mount operation.
207 void mount(const Glib::RefPtr<MountOperation>& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags = MOUNT_MOUNT_NONE);
211 * @param mount_operation A mount operation.
213 void mount(const Glib::RefPtr<MountOperation>& mount_operation, MountMountFlags flags = MOUNT_MOUNT_NONE);
217 void mount(MountMountFlags flags = MOUNT_MOUNT_NONE);
220 /** Finishes mounting a volume.
221 * @param result A AsyncResult.
222 * @return <tt>true</tt>, <tt>false</tt> if operation failed.
224 #ifdef GLIBMM_EXCEPTIONS_ENABLED
225 bool mount_finish(const Glib::RefPtr<AsyncResult>& result);
227 bool mount_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
228 #endif //GLIBMM_EXCEPTIONS_ENABLED
232 * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
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.
238 void eject(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
241 * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
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.
246 void eject(const SlotAsyncReady& slot, MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
249 * This is an asynchronous operation, and is finished by calling eject_finish() with the AsyncResult data returned in the callback slot.
251 * @param flags Flags affecting the unmount if required for eject.
253 void eject(MountUnmountFlags flags = MOUNT_UNMOUNT_NONE);
256 /** Finishes ejecting a volume.
257 * @param result A AsyncResult.
258 * @return <tt>true</tt>, <tt>false</tt> if operation failed.
260 #ifdef GLIBMM_EXCEPTIONS_ENABLED
261 bool eject_finish(const Glib::RefPtr<AsyncResult>& result);
263 bool eject_finish(const Glib::RefPtr<AsyncResult>& result, std::auto_ptr<Glib::Error>& error);
264 #endif //GLIBMM_EXCEPTIONS_ENABLED
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.
275 std::string get_identifier(const std::string& kind) const;
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.
284 Glib::StringArrayHandle enumerate_identifiers() const;
287 Glib::RefPtr<File> get_activation_root();
289 Glib::RefPtr<const File> get_activation_root() const;
294 * <tt>void on_my_%changed()</tt>
297 Glib::SignalProxy0< void > signal_changed();
302 * <tt>void on_my_%removed()</tt>
305 Glib::SignalProxy0< void > signal_removed();
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)
313 //_WRAP_VFUNC(Glib::RefPtr<Drive> get_drive(), get_drive)
316 //_WRAP_VFUNC(Glib::RefPtr<Mount> get_mount(), get_mount)
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)
325 //_WRAP_VFUNC(std::string get_identifier(const std::string& kind), get_identifier)
327 //TODO: Use an ArrayHandle.
328 //_WRAP_VFUNC(char** enumerate_identifiers(), enumerate_identifiers)
330 //_WRAP_VFUNC(bool should_automount(), should_automount)
336 //C++ methods used to invoke GTK+ virtual functions:
337 #ifdef GLIBMM_VFUNCS_ENABLED
338 #endif //GLIBMM_VFUNCS_ENABLED
341 //GTK+ Virtual Functions (override these to change behaviour):
342 #ifdef GLIBMM_VFUNCS_ENABLED
343 #endif //GLIBMM_VFUNCS_ENABLED
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
359 //Pre-declare this so we can use it in TypeTrait:
360 Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy);
362 namespace Container_Helpers
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.
371 struct TypeTraits< Glib::RefPtr<Gio::Volume> >
373 typedef Glib::RefPtr<Gio::Volume> CppType;
374 typedef GVolume* CType;
375 typedef GVolume* CTypeNonConst;
377 static CType to_c_type (const CppType& item)
378 { return Glib::unwrap (item); }
380 static CppType to_cpp_type (const CType& item)
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 */);
387 static void release_c_type (CType item)
389 GLIBMM_DEBUG_UNREFERENCE(0, item);
390 g_object_unref(item);
394 } // Container_Helpers
400 /** A Glib::wrap() method for this object.
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.
406 * @relates Gio::Volume
408 Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy = false);
413 #endif /* _GIOMM_VOLUME_H */