The <GVolume> interface represents user-visible
objects that can be mounted. For example, a file system partition on a
USB flash drive, or an optical disc inserted into a disc drive.
If a <GVolume> is currently mounted, the
corresponding <GMount> can be retrieved using
volume:get-mount.
Mounting a <GVolume> instance is an asynchronous
operation. For more information about asynchronous operations, see
<GAsyncResult> and <GTask>.
To mount a <GVolume>, first call volume:mount with (at least) the <GVolume>
instance, optionally a <GMountOperation>
object and a GAsyncReadyCallback.
Typically, one will only want to pass NULL for the
<GMountOperation> if automounting all
volumes when a desktop session starts since it’s not desirable to put up
a lot of dialogs asking for credentials.
The callback will be fired when the operation has resolved (either with
success or failure), and a <GAsyncResult>
instance will be passed to the callback. That callback should then call
volume:mount-finish? with the
<GVolume> instance and the
<GAsyncResult> data to see if the operation
was completed successfully. If a <GError> is
present when volume:mount-finish? is
called, then it will be filled with any error information.
Note, when porting from GnomeVFS, <GVolume> is the
moral equivalent of GnomeVFSDrive.
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 command line). 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. /dev/sda2), UUIDs. GIO uses predefined strings as
names for the different kinds of identifiers:
G_VOLUME_IDENTIFIER_KIND_UUID,
G_VOLUME_IDENTIFIER_KIND_LABEL, etc. Use volume:get-identifier to obtain an identifier for a
volume.
Note that G_VOLUME_IDENTIFIER_KIND_HAL_UDI will only be available
when the GVFS hal volume monitor is in use. Other volume monitors will
generally be able to provide the
G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE identifier, which can be
used to obtain a hal device by means of
libhal_manager_find_device_string_match().
Checks if a volume can be ejected.
Checks if a volume can be mounted.
Ejects a volume. This is an asynchronous operation, and is finished by
calling volume:eject-finish? with the
self and <GAsyncResult> returned in the
callback.
Passed: a <GVolume>.
Passed: a <GMountUnmountFlags>, or a
list of its symbols, or one of them.
flags affecting the unmount if required for eject
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback, or #f
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
user data that gets passed to callback
Finishes ejecting a volume. If any errors occurred during the
operation, error will be set to contain the errors and #f
will be returned.
Passed: a <GVolume>.
pointer to a <GVolume>
Passed: a <GAsyncResult>.
Returned: a boolean.
#t, #f if operation failed
Ejects a volume. This is an asynchronous operation, and is finished by
calling volume:eject-with-operation-finish? with
the self and <GAsyncResult> data
returned in the callback.
Passed: a <GVolume>.
Passed: a <GMountUnmountFlags>, or a
list of its symbols, or one of them.
flags affecting the unmount if required for eject
Passed, or left out: a <GMountOperation>,
or #f.
a <GMountOperation> or #f to avoid
user interaction
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback, or #f
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
user data passed to callback
Finishes ejecting a volume. If any errors occurred during the
operation, error will be set to contain the errors and #f
will be returned.
Passed: a <GVolume>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t if the volume was successfully ejected. #f otherwise
Gets the kinds of identifiers that self has. Use
volume:get-identifier to obtain the
identifiers themselves.
Gets the activation root for a <GVolume> if it is
known ahead of mount time. Returns #f otherwise. If not
#f and if self is mounted, then the result of
mount:get-root on the
<GMount> object obtained from volume:get-mount will always either be equal or a prefix of
what this function returns. In other words, in code
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 #t.
Activation roots are typically used in
<GVolumeMonitor> implementations to find the
underlying mount to shadow, see mount:is-shadowed? for more details.
Passed: a <GVolume>.
Returned: a <GFile>, or #f.
the activation root of self or #f. Use object:unref to free.
Gets the drive for the self.
Passed: a <GVolume>.
Returned: a <GDrive>, or #f.
a <GDrive> or #f if self is not
associated with a drive. The returned object should be unreffed with
object:unref when no longer needed.
Gets the icon for self.
Passed: a <GVolume>.
Returned: a <GIcon>.
a <GIcon>. The returned object should be unreffed
with object:unref when no longer
needed.
Gets the identifier of the given kind for self. See the introduction for more information about volume identifiers.
Gets the mount for the self.
Passed: a <GVolume>.
Returned: a <GMount>, or #f.
a <GMount> or #f if self isn’t mounted.
The returned object should be unreffed with object:unref when no longer needed.
Gets the name of self.
Passed: a <GVolume>.
Returned: a string.
the name for the given self. The returned string should be freed
with byte-array:free when no longer needed.
Gets the sort key for self, if any.
Gets the symbolic icon for self.
Passed: a <GVolume>.
Returned: a <GIcon>.
a <GIcon>. The returned object should be unreffed
with object:unref when no longer
needed.
Gets the UUID for the self. The reference is typically based on
the file system UUID for the volume in question and should be considered
an opaque string. Returns #f if there is no UUID available.
Passed: a <GVolume>.
Returned: a string, or #f.
the UUID for self or #f if no UUID can be computed. The
returned string should be freed with
byte-array:free when no longer needed.
Mounts a volume. This is an asynchronous operation, and is finished by
calling volume:mount-finish? with the
self and <GAsyncResult> returned in the
callback.
Passed: a <GVolume>.
Passed: a <GMountMountFlags>, or a list of
its symbols, or one of them.
flags affecting the operation
Passed, or left out: a <GMountOperation>,
or #f.
a <GMountOperation> or #f to avoid
user interaction
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback, or #f
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
user data that gets passed to callback
Finishes mounting a volume. If any errors occurred during the
operation, error will be set to contain the errors and #f
will be returned.
If the mount operation succeeded, volume:get-mount on self is guaranteed to return the
mount right after calling this function; there’s no need to listen for
the ’mount-added’ signal on
<GVolumeMonitor>.
Passed: a <GVolume>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t, #f if operation failed
Returns whether the volume should be automatically mounted.
Connect a handler with (connect object volume:changed handler).
It is called as (handler self).
Emitted when the volume has been changed.
Passed: a <GVolume>.
Connect a handler with (connect object volume:removed handler).
It is called as (handler self).
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.
Passed: a <GVolume>.
Checks if a volume can be ejected.
To override it in a new class, give register-type #:vfuncs
`((can-eject . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Checks if a volume can be mounted.
To override it in a new class, give register-type #:vfuncs
`((can-mount . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Changed signal that is emitted when the volume’s state has changed.
To override it in a new class, give register-type #:vfuncs
`((changed . ,procedure)). The procedure is called as
(procedure self).
Ejects a volume. This is an asynchronous operation, and is finished by
calling volume:eject-finish? with the
self and <GAsyncResult> returned in the
callback.
To override it in a new class, give register-type #:vfuncs
`((eject . ,procedure)). The procedure is called as (procedure
self flags cancellable callback user-data).
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Passed: a <GMountUnmountFlags>, or a
list of its symbols, or one of them.
flags affecting the unmount if required for eject
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback, or #f
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
user data that gets passed to callback
Finishes ejecting a volume. If any errors occurred during the
operation, error will be set to contain the errors and #f
will be returned.
To override it in a new class, give register-type #:vfuncs
`((eject-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
pointer to a <GVolume>
Passed: a <GAsyncResult>.
Returned: a boolean.
#t, #f if operation failed
Ejects a volume. This is an asynchronous operation, and is finished by
calling volume:eject-with-operation-finish? with
the self and <GAsyncResult> data
returned in the callback.
To override it in a new class, give register-type #:vfuncs
`((eject-with-operation . ,procedure)). The procedure is called as
(procedure self flags mount-operation cancellable callback
user-data).
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Passed: a <GMountUnmountFlags>, or a
list of its symbols, or one of them.
flags affecting the unmount if required for eject
Passed, or left out: a <GMountOperation>,
or #f.
a <GMountOperation> or #f to avoid
user interaction
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback, or #f
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
user data passed to callback
Finishes ejecting a volume. If any errors occurred during the
operation, error will be set to contain the errors and #f
will be returned.
To override it in a new class, give register-type #:vfuncs
`((eject-with-operation-finish . ,procedure)). The procedure is
called as (procedure self result) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t if the volume was successfully ejected. #f otherwise
Gets the kinds of identifiers that self has. Use
volume:get-identifier to obtain the
identifiers themselves.
To override it in a new class, give register-type #:vfuncs
`((enumerate-identifiers . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Gets the activation root for a <GVolume> if it is
known ahead of mount time. Returns #f otherwise. If not
#f and if self is mounted, then the result of
mount:get-root on the
<GMount> object obtained from volume:get-mount will always either be equal or a prefix of
what this function returns. In other words, in code
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 #t.
Activation roots are typically used in
<GVolumeMonitor> implementations to find the
underlying mount to shadow, see mount:is-shadowed? for more details.
To override it in a new class, give register-type #:vfuncs
`((get-activation-root . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Returned: a <GFile>, or #f.
the activation root of self or #f. Use object:unref to free.
Gets the drive for the self.
To override it in a new class, give register-type #:vfuncs
`((get-drive . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Returned: a <GDrive>, or #f.
a <GDrive> or #f if self is not
associated with a drive. The returned object should be unreffed with
object:unref when no longer needed.
Gets the icon for self.
To override it in a new class, give register-type #:vfuncs
`((get-icon . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Gets the identifier of the given kind for self. See the introduction for more information about volume identifiers.
To override it in a new class, give register-type #:vfuncs
`((get-identifier . ,procedure)). The procedure is called as
(procedure self kind) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Passed: a string.
the kind of identifier to return
Returned: a string, or #f.
a newly allocated string containing the requested identifier, or
#f if the <GVolume> doesn’t have this kind
of identifier
Gets the mount for the self.
To override it in a new class, give register-type #:vfuncs
`((get-mount . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Returned: a <GMount>, or #f.
a <GMount> or #f if self isn’t mounted.
The returned object should be unreffed with object:unref when no longer needed.
Gets the name of self.
To override it in a new class, give register-type #:vfuncs
`((get-name . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Returned: a string.
the name for the given self. The returned string should be freed
with byte-array:free when no longer needed.
Gets the sort key for self, if any.
To override it in a new class, give register-type #:vfuncs
`((get-sort-key . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Gets the symbolic icon for self.
To override it in a new class, give register-type #:vfuncs
`((get-symbolic-icon . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Gets the UUID for the self. The reference is typically based on
the file system UUID for the volume in question and should be considered
an opaque string. Returns #f if there is no UUID available.
To override it in a new class, give register-type #:vfuncs
`((get-uuid . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Returned: a string, or #f.
the UUID for self or #f if no UUID can be computed. The
returned string should be freed with
byte-array:free when no longer needed.
Finishes mounting a volume. If any errors occurred during the
operation, error will be set to contain the errors and #f
will be returned.
If the mount operation succeeded, volume:get-mount on self is guaranteed to return the
mount right after calling this function; there’s no need to listen for
the ’mount-added’ signal on
<GVolumeMonitor>.
To override it in a new class, give register-type #:vfuncs
`((mount-finish . ,procedure)). The procedure is called as
(procedure self result) ⇒ %return.
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Passed: a <GAsyncResult>.
Returned: a boolean.
#t, #f if operation failed
Mounts a volume. This is an asynchronous operation, and is finished by
calling volume:mount-finish? with the
self and <GAsyncResult> returned in the
callback.
To override it in a new class, give register-type #:vfuncs
`((mount-fn . ,procedure)). The procedure is called as
(procedure self flags mount-operation cancellable callback
user-data).
Passed: the class whose implementation to call: a class that implements
<GVolume>, or its GType number.
Passed: a <GVolume>.
Passed: a <GMountMountFlags>, or a list of
its symbols, or one of them.
flags affecting the operation
Passed, or left out: a <GMountOperation>,
or #f.
a <GMountOperation> or #f to avoid
user interaction
Passed, or left out: a <GCancellable>, or
#f.
optional <GCancellable> object, #f to
ignore
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback, or #f
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
user data that gets passed to callback
The removed signal that 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.
To override it in a new class, give register-type #:vfuncs
`((removed . ,procedure)). The procedure is called as
(procedure self).
Returns whether the volume should be automatically mounted.
To override it in a new class, give register-type #:vfuncs
`((should-automount . ,procedure)). The procedure is called as
(procedure self) ⇒ %return.