Synopsis#include <gio/gio.h> GVolume; GVolumeIface; char* g_volume_get_name (GVolume *volume); char* g_volume_get_uuid (GVolume *volume); GIcon* g_volume_get_icon (GVolume *volume); GDrive* g_volume_get_drive (GVolume *volume); GMount* g_volume_get_mount (GVolume *volume); gboolean g_volume_can_mount (GVolume *volume); gboolean g_volume_should_automount (GVolume *volume); GFile* g_volume_get_activation_root (GVolume *volume); void g_volume_mount (GVolume *volume, GMountMountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean g_volume_mount_finish (GVolume *volume, GAsyncResult *result, GError **error); gboolean g_volume_can_eject (GVolume *volume); void g_volume_eject (GVolume *volume, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean g_volume_eject_finish (GVolume *volume, GAsyncResult *result, GError **error); #define G_VOLUME_IDENTIFIER_KIND_HAL_UDI #define G_VOLUME_IDENTIFIER_KIND_LABEL #define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT #define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE #define G_VOLUME_IDENTIFIER_KIND_UUID char** g_volume_enumerate_identifiers (GVolume *volume); char* g_volume_get_identifier (GVolume *volume, const char *kind); DescriptionThe GVolume interface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS, GVolume is the moral equivalent of GnomeVFSDrive.
Mounting a GVolume instance is an asynchronous operation. For more
information about asynchronous operations, see GAsyncReady and
GSimpleAsyncReady. To mount a GVolume, first call
Typically, one will only want to pass
The callback will be fired when the operation has resolved (either
with success or failure), and a GAsyncReady structure will be
passed to the callback. That callback should then call
It is sometimes necessary to directly access the underlying
operating system object behind a volume (e.g. for passing a volume
to an application via the commandline). For this purpose, GIO
allows to obtain an 'identifier' for the volume. There can be
different kinds of identifiers, such as Hal UDIs, filesystem labels,
traditional Unix devices (e.g.
DetailsGVolumeIfacetypedef struct { GTypeInterface g_iface; /* signals */ void (* changed) (GVolume *volume); void (* removed) (GVolume *volume); /* Virtual Table */ char * (* get_name) (GVolume *volume); GIcon * (* get_icon) (GVolume *volume); char * (* get_uuid) (GVolume *volume); GDrive * (* get_drive) (GVolume *volume); GMount * (* get_mount) (GVolume *volume); gboolean (* can_mount) (GVolume *volume); gboolean (* can_eject) (GVolume *volume); void (* mount_fn) (GVolume *volume, GMountMountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean (* mount_finish) (GVolume *volume, GAsyncResult *result, GError **error); void (* eject) (GVolume *volume, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean (* eject_finish) (GVolume *volume, GAsyncResult *result, GError **error); char * (* get_identifier) (GVolume *volume, const char *kind); char ** (* enumerate_identifiers) (GVolume *volume); gboolean (* should_automount) (GVolume *volume); GFile * (* get_activation_root) (GVolume *volume); } GVolumeIface; Interface for implementing operations for mountable volumes.
g_volume_get_name ()char* g_volume_get_name (GVolume *volume);
Gets the name of
g_volume_get_uuid ()char* g_volume_get_uuid (GVolume *volume);
Gets the UUID for the
g_volume_can_mount ()gboolean g_volume_can_mount (GVolume *volume); Checks if a volume can be mounted.
g_volume_should_automount ()gboolean g_volume_should_automount (GVolume *volume); Returns whether the volume should be automatically mounted.
g_volume_get_activation_root ()GFile* g_volume_get_activation_root (GVolume *volume);
Gets the activation root for a GVolume if it is known ahead of
mount time. Returns
GMount *mount; GFile *mount_root GFile *volume_activation_root; mount = g_volume_get_mount (volume); /* mounted, so never NULL */ mount_root = g_mount_get_root (mount); volume_activation_root = g_volume_get_activation_root(volume); /* assume not NULL */
then the expression
(g_file_has_prefix (volume_activation_root, mount_root) || g_file_equal (volume_activation_root, mount_root))
will always be There is a number of possible uses of this function.
First, implementations of GVolumeMonitor can use this method to
determine if a GMount should be adopted in the implementation of
Second, applications such as a file manager can use this to
navigate to the correct root in response to the user navigating to
a server. Now suppose there is a volume monitor for networked
servers that creates GVolume objects corresponding to the
"favorite servers" (e.g. set up by the user via some "Connect to
Server" dialog). Suppose also that one of the favorite servers is
named "public_html @ fd.o" and the URI is
Now, due to the way GIO works, when the corresponding GVolume is
mounted then a GMount (typically adopted by the volume monitor)
will appear with the mount root (e.g. the result of
All this means that a file manager can use the latter URI for navigating when the user clicks an icon representing the GVolume (e.g. clicking an icon with the name "public_html @ fd.o" or similar).
Since 2.18 g_volume_mount ()void g_volume_mount (GVolume *volume, GMountMountFlags flags, GMountOperation *mount_operation, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
Mounts a volume. This is an asynchronous operation, and is
finished by calling
g_volume_mount_finish ()gboolean g_volume_mount_finish (GVolume *volume, GAsyncResult *result, GError **error);
Finishes mounting a volume. If any errors occured during the operation,
If the mount operation succeeded,
g_volume_can_eject ()gboolean g_volume_can_eject (GVolume *volume); Checks if a volume can be ejected.
g_volume_eject ()void g_volume_eject (GVolume *volume, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
Ejects a volume. This is an asynchronous operation, and is
finished by calling
g_volume_eject_finish ()gboolean g_volume_eject_finish (GVolume *volume, GAsyncResult *result, GError **error);
Finishes ejecting a volume. If any errors occured during the operation,
G_VOLUME_IDENTIFIER_KIND_HAL_UDI#define G_VOLUME_IDENTIFIER_KIND_HAL_UDI "hal-udi"
The string used to obtain a Hal UDI with
G_VOLUME_IDENTIFIER_KIND_LABEL#define G_VOLUME_IDENTIFIER_KIND_LABEL "label"
The string used to obtain a filesystem label with
G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT#define G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT "nfs-mount"
The string used to obtain a NFS mount with
G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE#define G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE "unix-device"
The string used to obtain a Unix device path with
G_VOLUME_IDENTIFIER_KIND_UUID#define G_VOLUME_IDENTIFIER_KIND_UUID "uuid"
The string used to obtain a UUID with
g_volume_enumerate_identifiers ()char** g_volume_enumerate_identifiers (GVolume *volume);
Gets the kinds of identifiers
that
g_volume_get_identifier ()char* g_volume_get_identifier (GVolume *volume, const char *kind);
Gets the identifier of the given kind for
Signal DetailsThe
|
|
user data set when the signal handler was connected. |
"removed"
signalvoid user_function (GVolume *arg0, gpointer user_data) : Run Last
This signal is emitted when the GVolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
|
user data set when the signal handler was connected. |