2.37 <GVolume>

Interface: <GVolume>

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.

Volume Identifiers

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().

Procedures

Method: volume:can-eject? self ⇒ %return
Method: can-eject? self ⇒ %return

Checks if a volume can be ejected.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a boolean.

#t if the self can be ejected. #f otherwise

Method: volume:can-mount? self ⇒ %return
Method: can-mount? self ⇒ %return

Checks if a volume can be mounted.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a boolean.

#t if the self can be mounted. #f otherwise

Method: volume:eject self flags [cancellable] [callback]
Method: eject self flags [cancellable] [callback]

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.

self

Passed: a <GVolume>.

a <GVolume>

flags

Passed: a <GMountUnmountFlags>, or a list of its symbols, or one of them.

flags affecting the unmount if required for eject

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback, or #f

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

user data that gets passed to callback

Method: volume:eject-finish? self result ⇒ %return
Method: eject-finish? self result ⇒ %return

Finishes ejecting a volume. If any errors occurred during the operation, error will be set to contain the errors and #f will be returned.

self

Passed: a <GVolume>.

pointer to a <GVolume>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t, #f if operation failed

Method: volume:eject-with-operation self flags [mount-operation] [cancellable] [callback]
Method: eject-with-operation self flags [mount-operation] [cancellable] [callback]

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.

self

Passed: a <GVolume>.

a <GVolume>

flags

Passed: a <GMountUnmountFlags>, or a list of its symbols, or one of them.

flags affecting the unmount if required for eject

mount-operation

Passed, or left out: a <GMountOperation>, or #f.

a <GMountOperation> or #f to avoid user interaction

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback, or #f

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

user data passed to callback

Method: volume:eject-with-operation-finish? self result ⇒ %return
Method: eject-with-operation-finish? self result ⇒ %return

Finishes ejecting a volume. If any errors occurred during the operation, error will be set to contain the errors and #f will be returned.

self

Passed: a <GVolume>.

a <GVolume>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t if the volume was successfully ejected. #f otherwise

Method: volume:enumerate-identifiers self ⇒ %return
Method: enumerate-identifiers self ⇒ %return

Gets the kinds of identifiers that self has. Use volume:get-identifier to obtain the identifiers themselves.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a vector, each a string.

a #f-terminated array of strings containing kinds of identifiers. Use strfreev to free.

Method: volume:get-activation-root self ⇒ %return
Method: get-activation-root 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.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a <GFile>, or #f.

the activation root of self or #f. Use object:unref to free.

Method: volume:get-drive self ⇒ %return
Method: get-drive self ⇒ %return

Gets the drive for the self.

self

Passed: a <GVolume>.

a <GVolume>

%return

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.

Method: volume:get-icon self ⇒ %return
Method: get-icon self ⇒ %return

Gets the icon for self.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a <GIcon>.

a <GIcon>. The returned object should be unreffed with object:unref when no longer needed.

Method: volume:get-identifier self kind ⇒ %return
Method: get-identifier self kind ⇒ %return

Gets the identifier of the given kind for self. See the introduction for more information about volume identifiers.

self

Passed: a <GVolume>.

a <GVolume>

kind

Passed: a string.

the kind of identifier to return

%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

Method: volume:get-mount self ⇒ %return
Method: get-mount self ⇒ %return

Gets the mount for the self.

self

Passed: a <GVolume>.

a <GVolume>

%return

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.

Method: volume:get-name self ⇒ %return
Method: get-name self ⇒ %return

Gets the name of self.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a string.

the name for the given self. The returned string should be freed with byte-array:free when no longer needed.

Method: volume:get-sort-key self ⇒ %return
Method: get-sort-key self ⇒ %return

Gets the sort key for self, if any.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a string, or #f.

Sorting key for self or #f if no such key is available

Method: volume:get-symbolic-icon self ⇒ %return
Method: get-symbolic-icon self ⇒ %return

Gets the symbolic icon for self.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a <GIcon>.

a <GIcon>. The returned object should be unreffed with object:unref when no longer needed.

Method: volume:get-uuid self ⇒ %return
Method: get-uuid 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.

self

Passed: a <GVolume>.

a <GVolume>

%return

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.

Method: volume:mount self flags [mount-operation] [cancellable] [callback]
Method: mount self flags [mount-operation] [cancellable] [callback]

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.

self

Passed: a <GVolume>.

a <GVolume>

flags

Passed: a <GMountMountFlags>, or a list of its symbols, or one of them.

flags affecting the operation

mount-operation

Passed, or left out: a <GMountOperation>, or #f.

a <GMountOperation> or #f to avoid user interaction

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback, or #f

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

user data that gets passed to callback

Method: volume:mount-finish? self result ⇒ %return
Method: mount-finish? self result ⇒ %return

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>.

self

Passed: a <GVolume>.

a <GVolume>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t, #f if operation failed

Method: volume:should-automount? self ⇒ %return
Method: should-automount? self ⇒ %return

Returns whether the volume should be automatically mounted.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a boolean.

#t if the volume should be automatically mounted

Signals

Signal: volume:changed

Connect a handler with (connect object volume:changed handler). It is called as (handler self).

Emitted when the volume has been changed.

self

Passed: a <GVolume>.

Signal: volume:removed

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.

self

Passed: a <GVolume>.

Virtual methods

Virtual method: volume:do-can-eject implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a boolean.

#t if the self can be ejected. #f otherwise

Virtual method: volume:do-can-mount implementor 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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a boolean.

#t if the self can be mounted. #f otherwise

Virtual method: volume:do-changed implementor self

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).

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

Virtual method: volume:do-eject implementor self flags [cancellable] [callback]

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).

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

flags

Passed: a <GMountUnmountFlags>, or a list of its symbols, or one of them.

flags affecting the unmount if required for eject

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback, or #f

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

user data that gets passed to callback

Virtual method: volume:do-eject-finish implementor self result ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

pointer to a <GVolume>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t, #f if operation failed

Virtual method: volume:do-eject-with-operation implementor self flags [mount-operation] [cancellable] [callback]

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).

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

flags

Passed: a <GMountUnmountFlags>, or a list of its symbols, or one of them.

flags affecting the unmount if required for eject

mount-operation

Passed, or left out: a <GMountOperation>, or #f.

a <GMountOperation> or #f to avoid user interaction

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback, or #f

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

user data passed to callback

Virtual method: volume:do-eject-with-operation-finish implementor self result ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t if the volume was successfully ejected. #f otherwise

Virtual method: volume:do-enumerate-identifiers implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a vector, each a string.

a #f-terminated array of strings containing kinds of identifiers. Use strfreev to free.

Virtual method: volume:do-get-activation-root implementor 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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a <GFile>, or #f.

the activation root of self or #f. Use object:unref to free.

Virtual method: volume:do-get-drive implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

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.

Virtual method: volume:do-get-icon implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a <GIcon>.

a <GIcon>. The returned object should be unreffed with object:unref when no longer needed.

Virtual method: volume:do-get-identifier implementor self kind ⇒ %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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

kind

Passed: a string.

the kind of identifier to return

%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

Virtual method: volume:do-get-mount implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

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.

Virtual method: volume:do-get-name implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a string.

the name for the given self. The returned string should be freed with byte-array:free when no longer needed.

Virtual method: volume:do-get-sort-key implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a string, or #f.

Sorting key for self or #f if no such key is available

Virtual method: volume:do-get-symbolic-icon implementor 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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a <GIcon>.

a <GIcon>. The returned object should be unreffed with object:unref when no longer needed.

Virtual method: volume:do-get-uuid implementor 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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

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.

Virtual method: volume:do-mount-finish implementor self result ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a boolean.

#t, #f if operation failed

Virtual method: volume:do-mount-fn implementor self flags [mount-operation] [cancellable] [callback]

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).

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

flags

Passed: a <GMountMountFlags>, or a list of its symbols, or one of them.

flags affecting the operation

mount-operation

Passed, or left out: a <GMountOperation>, or #f.

a <GMountOperation> or #f to avoid user interaction

cancellable

Passed, or left out: a <GCancellable>, or #f.

optional <GCancellable> object, #f to ignore

callback

Passed, or left out: a procedure, or #f.

a GAsyncReadyCallback, or #f

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

user data that gets passed to callback

Virtual method: volume:do-removed implementor self

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).

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

Virtual method: volume:do-should-automount implementor self ⇒ %return

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.

implementor

Passed: the class whose implementation to call: a class that implements <GVolume>, or its GType number.

self

Passed: a <GVolume>.

a <GVolume>

%return

Returned: a boolean.

#t if the volume should be automatically mounted