Gio.Volume¶
| Implementations: | |
|---|---|
| None | |
Methods¶
can_eject () |
|
can_mount () |
|
eject (flags, cancellable, callback, *user_data) |
|
eject_finish (result) |
|
eject_with_operation (flags, mount_operation, cancellable, callback, *user_data) |
|
eject_with_operation_finish (result) |
|
enumerate_identifiers () |
|
get_activation_root () |
|
get_drive () |
|
get_icon () |
|
get_identifier (kind) |
|
get_mount () |
|
get_name () |
|
get_sort_key () |
|
get_symbolic_icon () |
|
get_uuid () |
|
mount (flags, mount_operation, cancellable, callback, *user_data) |
|
mount_finish (result) |
|
should_automount () |
Virtual Methods¶
do_can_eject () |
|
do_can_mount () |
|
do_changed () |
|
do_eject (flags, cancellable, callback, *user_data) |
|
do_eject_finish (result) |
|
do_eject_with_operation (flags, mount_operation, cancellable, callback, *user_data) |
|
do_eject_with_operation_finish (result) |
|
do_enumerate_identifiers () |
|
do_get_activation_root () |
|
do_get_drive () |
|
do_get_icon () |
|
do_get_identifier (kind) |
|
do_get_mount () |
|
do_get_name () |
|
do_get_sort_key () |
|
do_get_symbolic_icon () |
|
do_get_uuid () |
|
do_mount_finish (result) |
|
do_mount_fn (flags, mount_operation, cancellable, callback, *user_data) |
|
do_removed () |
|
do_should_automount () |
Properties¶
None
Signals¶
| Name | Short Description |
|---|---|
changed |
Emitted when the volume has been changed. |
removed |
This signal is emitted when the Gio.Volume have been removed. |
Fields¶
None
Class Details¶
-
class
Gio.Volume¶ Bases: GObject.GInterfaceStructure: Gio.VolumeIfaceThe
Gio.Volumeinterface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS,Gio.Volumeis the moral equivalent of #GnomeVFSDrive.Mounting a
Gio.Volumeinstance is an asynchronous operation. For more information about asynchronous operations, seeGio.AsyncResultandGio.Task. To mount aGio.Volume, first callGio.Volume.mount() with (at least) theGio.Volumeinstance, optionally aGio.MountOperationobject and aGio.AsyncReadyCallback.Typically, one will only want to pass
Nonefor theGio.MountOperationif 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
Gio.AsyncResultinstance will be passed to the callback. That callback should then callGio.Volume.mount_finish() with theGio.Volumeinstance and theGio.AsyncResultdata to see if the operation was completed successfully. If an error is present whenGio.Volume.mount_finish() is called, then it will be filled with any error information.- 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 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.
/dev/sda2), UUIDs. GIO uses predefined strings as names for the different kinds of identifiers:Gio.VOLUME_IDENTIFIER_KIND_UUID,Gio.VOLUME_IDENTIFIER_KIND_LABEL, etc. UseGio.Volume.get_identifier() to obtain an identifier for a volume.Note that
Gio.VOLUME_IDENTIFIER_KIND_HAL_UDIwill only be available when the gvfs hal volume monitor is in use. Other volume monitors will generally be able to provide theGio.VOLUME_IDENTIFIER_KIND_UNIX_DEVICEidentifier, which can be used to obtain a hal device by means of libhal_manager_find_device_string_match().-
can_eject()[source]¶ Returns: Trueif the self can be ejected.FalseotherwiseReturn type: boolChecks if a volume can be ejected.
-
can_mount()[source]¶ Returns: Trueif the self can be mounted.FalseotherwiseReturn type: boolChecks if a volume can be mounted.
-
eject(flags, cancellable, callback, *user_data)[source]¶ Parameters: - flags (
Gio.MountUnmountFlags) – flags affecting the unmount if required for eject - cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback, orNone - user_data (
objectorNone) – user data that gets passed to callback
Ejects a volume. This is an asynchronous operation, and is finished by calling
Gio.Volume.eject_finish() with the self andGio.AsyncResultreturned in the callback.Deprecated since version 2.22: Use
Gio.Volume.eject_with_operation() instead.- flags (
-
eject_finish(result)[source]¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultRaises: GLib.ErrorReturns: True,Falseif operation failedReturn type: boolFinishes ejecting a volume. If any errors occurred during the operation, error will be set to contain the errors and
Falsewill be returned.Deprecated since version 2.22: Use
Gio.Volume.eject_with_operation_finish() instead.
-
eject_with_operation(flags, mount_operation, cancellable, callback, *user_data)[source]¶ Parameters: - flags (
Gio.MountUnmountFlags) – flags affecting the unmount if required for eject - mount_operation (
Gio.MountOperationorNone) – aGio.MountOperationorNoneto avoid user interaction - cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback, orNone - user_data (
objectorNone) – user data passed to callback
Ejects a volume. This is an asynchronous operation, and is finished by calling
Gio.Volume.eject_with_operation_finish() with the self andGio.AsyncResultdata returned in the callback.New in version 2.22.
- flags (
-
eject_with_operation_finish(result)[source]¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultRaises: GLib.ErrorReturns: Trueif the volume was successfully ejected.FalseotherwiseReturn type: boolFinishes ejecting a volume. If any errors occurred during the operation, error will be set to contain the errors and
Falsewill be returned.New in version 2.22.
-
enumerate_identifiers()[source]¶ Returns: a None-terminated array of strings containing kinds of identifiers. UseGLib.strfreev() to free.Return type: [ str]Gets the kinds of identifiers that self has. Use
Gio.Volume.get_identifier() to obtain the identifiers themselves.
-
get_activation_root()[source]¶ Returns: the activation root of self or None. UseGObject.Object.unref() to free.Return type: Gio.FileorNoneGets the activation root for a
Gio.Volumeif it is known ahead of mount time. ReturnsNoneotherwise. If notNoneand if self is mounted, then the result ofGio.Mount.get_root() on theGio.Mountobject obtained fromGio.Volume.get_mount() will always either be equal or a prefix of what this function returns. In other words, in codeGMount *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
True.Activation roots are typically used in
Gio.VolumeMonitorimplementations to find the underlying mount to shadow, seeGio.Mount.is_shadowed() for more details.New in version 2.18.
-
get_drive()[source]¶ Returns: a Gio.DriveorNoneif self is not associated with a drive. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.DriveorNoneGets the drive for the self.
-
get_icon()[source]¶ Returns: a Gio.Icon. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.IconGets the icon for self.
-
get_identifier(kind)[source]¶ Parameters: kind ( str) – the kind of identifier to returnReturns: a newly allocated string containing the requested identifier, or Noneif theGio.Volumedoesn’t have this kind of identifierReturn type: strorNoneGets the identifier of the given kind for self. See the introduction for more information about volume identifiers.
-
get_mount()[source]¶ Returns: a Gio.MountorNoneif self isn’t mounted. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.MountorNoneGets the mount for the self.
-
get_name()[source]¶ Returns: the name for the given self. The returned string should be freed with GLib.free() when no longer needed.Return type: strGets the name of self.
-
get_sort_key()[source]¶ Returns: Sorting key for self or Noneif no such key is availableReturn type: strorNoneGets the sort key for self, if any.
New in version 2.32.
-
get_symbolic_icon()[source]¶ Returns: a Gio.Icon. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.IconGets the symbolic icon for self.
New in version 2.34.
-
get_uuid()[source]¶ Returns: the UUID for self or Noneif no UUID can be computed. The returned string should be freed withGLib.free() when no longer needed.Return type: strorNoneGets 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
Noneif there is no UUID available.
-
mount(flags, mount_operation, cancellable, callback, *user_data)[source]¶ Parameters: - flags (
Gio.MountMountFlags) – flags affecting the operation - mount_operation (
Gio.MountOperationorNone) – aGio.MountOperationorNoneto avoid user interaction - cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback, orNone - user_data (
objectorNone) – user data that gets passed to callback
Mounts a volume. This is an asynchronous operation, and is finished by calling
Gio.Volume.mount_finish() with the self andGio.AsyncResultreturned in the callback.- flags (
-
mount_finish(result)[source]¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultRaises: GLib.ErrorReturns: True,Falseif operation failedReturn type: boolFinishes mounting a volume. If any errors occurred during the operation, error will be set to contain the errors and
Falsewill be returned.If the mount operation succeeded,
Gio.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 onGio.VolumeMonitor.
-
should_automount()[source]¶ Returns: Trueif the volume should be automatically mountedReturn type: boolReturns whether the volume should be automatically mounted.
-
do_can_eject() virtual¶ Returns: Trueif the volume can be ejected.FalseotherwiseReturn type: boolChecks if a volume can be ejected.
-
do_can_mount() virtual¶ Returns: Trueif the volume can be mounted.FalseotherwiseReturn type: boolChecks if a volume can be mounted.
-
do_changed() virtual¶
-
do_eject(flags, cancellable, callback, *user_data) virtual¶ Parameters: - flags (
Gio.MountUnmountFlags) – flags affecting the unmount if required for eject - cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback, orNone - user_data (
objectorNone) – user data that gets passed to callback
Ejects a volume. This is an asynchronous operation, and is finished by calling
Gio.Volume.eject_finish() with the volume andGio.AsyncResultreturned in the callback.Deprecated since version 2.22: Use
Gio.Volume.eject_with_operation() instead.- flags (
-
do_eject_finish(result) virtual¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultReturns: True,Falseif operation failedReturn type: boolFinishes ejecting a volume. If any errors occurred during the operation, error will be set to contain the errors and
Falsewill be returned.Deprecated since version 2.22: Use
Gio.Volume.eject_with_operation_finish() instead.
-
do_eject_with_operation(flags, mount_operation, cancellable, callback, *user_data) virtual¶ Parameters: - flags (
Gio.MountUnmountFlags) – flags affecting the unmount if required for eject - mount_operation (
Gio.MountOperationorNone) – aGio.MountOperationorNoneto avoid user interaction - cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback, orNone - user_data (
objectorNone) – user data passed to callback
Ejects a volume. This is an asynchronous operation, and is finished by calling
Gio.Volume.eject_with_operation_finish() with the volume andGio.AsyncResultdata returned in the callback.New in version 2.22.
- flags (
-
do_eject_with_operation_finish(result) virtual¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultReturns: Trueif the volume was successfully ejected.FalseotherwiseReturn type: boolFinishes ejecting a volume. If any errors occurred during the operation, error will be set to contain the errors and
Falsewill be returned.New in version 2.22.
-
do_enumerate_identifiers() virtual¶ Returns: a None-terminated array of strings containing kinds of identifiers. UseGLib.strfreev() to free.Return type: [ str]Gets the kinds of identifiers that volume has. Use
Gio.Volume.get_identifier() to obtain the identifiers themselves.
-
do_get_activation_root() virtual¶ Returns: the activation root of volume or None. UseGObject.Object.unref() to free.Return type: Gio.FileorNoneGets the activation root for a
Gio.Volumeif it is known ahead of mount time. ReturnsNoneotherwise. If notNoneand if volume is mounted, then the result ofGio.Mount.get_root() on theGio.Mountobject obtained fromGio.Volume.get_mount() will always either be equal or a prefix of what this function returns. In other words, in codeGMount *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
True.Activation roots are typically used in
Gio.VolumeMonitorimplementations to find the underlying mount to shadow, seeGio.Mount.is_shadowed() for more details.New in version 2.18.
-
do_get_drive() virtual¶ Returns: a Gio.DriveorNoneif volume is not associated with a drive. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.DriveorNoneGets the drive for the volume.
-
do_get_icon() virtual¶ Returns: a Gio.Icon. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.IconGets the icon for volume.
-
do_get_identifier(kind) virtual¶ Parameters: kind ( str) – the kind of identifier to returnReturns: a newly allocated string containing the requested identifier, or Noneif theGio.Volumedoesn’t have this kind of identifierReturn type: strorNoneGets the identifier of the given kind for volume. See the introduction for more information about volume identifiers.
-
do_get_mount() virtual¶ Returns: a Gio.MountorNoneif volume isn’t mounted. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.MountorNoneGets the mount for the volume.
-
do_get_name() virtual¶ Returns: the name for the given volume. The returned string should be freed with GLib.free() when no longer needed.Return type: strGets the name of volume.
-
do_get_sort_key() virtual¶ Returns: Sorting key for volume or Noneif no such key is availableReturn type: strorNoneGets the sort key for volume, if any.
New in version 2.32.
-
do_get_symbolic_icon() virtual¶ Returns: a Gio.Icon. The returned object should be unreffed withGObject.Object.unref() when no longer needed.Return type: Gio.IconGets the symbolic icon for volume.
New in version 2.34.
-
do_get_uuid() virtual¶ Returns: the UUID for volume or Noneif no UUID can be computed. The returned string should be freed withGLib.free() when no longer needed.Return type: strorNoneGets the UUID for the volume. The reference is typically based on the file system UUID for the volume in question and should be considered an opaque string. Returns
Noneif there is no UUID available.
-
do_mount_finish(result) virtual¶ Parameters: result ( Gio.AsyncResult) – aGio.AsyncResultReturns: True,Falseif operation failedReturn type: boolFinishes mounting a volume. If any errors occurred during the operation, error will be set to contain the errors and
Falsewill be returned.If the mount operation succeeded,
Gio.Volume.get_mount() on volume is guaranteed to return the mount right after calling this function; there’s no need to listen for the ‘mount-added’ signal onGio.VolumeMonitor.
-
do_mount_fn(flags, mount_operation, cancellable, callback, *user_data) virtual¶ Parameters: - flags (
Gio.MountMountFlags) – flags affecting the operation - mount_operation (
Gio.MountOperationorNone) – aGio.MountOperationorNoneto avoid user interaction - cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore - callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback, orNone - user_data (
objectorNone) – user data that gets passed to callback
Mounts a volume. This is an asynchronous operation, and is finished by calling
Gio.Volume.mount_finish() with the volume andGio.AsyncResultreturned in the callback.- flags (
-
do_removed() virtual¶
Signal Details¶
-
Gio.Volume.signals.changed(volume)¶ Signal Name: changedFlags: RUN_LASTParameters: volume ( Gio.Volume) – The object which received the signalEmitted when the volume has been changed.
-
Gio.Volume.signals.removed(volume)¶ Signal Name: removedFlags: RUN_LASTParameters: volume ( Gio.Volume) – The object which received the signalThis signal is emitted when the
Gio.Volumehave been removed. If the recipient is holding references to the object they should release them so the object can be finalized.