Gio.Drive¶
interface
GDrive represents a piece of hardware connected to the machine.
It’s generally only created for removable hardware or hardware with
removable media. For example, an optical disc drive, or a USB flash drive.
GDrive is a container class for Volume objects that stem from
the same piece of media. As such, GDrive abstracts a drive with
(or without) removable media and provides operations for querying
whether media is available, determining whether media change is
automatically detected and ejecting the media.
If the GDrive reports that media isn’t automatically detected, one
can poll for media; typically one should not do this periodically
as a poll for media operation is potentially expensive and may
spin up the drive creating noise.
GDrive supports starting and stopping drives with authentication
support for the former. This can be used to support a diverse set
of use cases including connecting/disconnecting iSCSI devices,
powering down external disk enclosures and starting/stopping
multi-disk devices such as RAID devices. Note that the actual
semantics and side-effects of starting/stopping a GDrive may vary
according to implementation. To choose the correct verbs in e.g. a
file manager, use Drive.get_start_stop_type.
For porting from GnomeVFS note that there is no
equivalent of GDrive in that API.
Methods¶
can_eject¶
Checks if a drive can be ejected.
can_poll_for_media¶
Checks if a drive can be polled for media changes.
can_start¶
Checks if a drive can be started.
can_start_degraded¶
Checks if a drive can be started degraded.
can_stop¶
Checks if a drive can be stopped.
eject¶
def eject(self, flags: MountUnmountFlags | int, cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
:::warning Deprecated since 2.22 This API is deprecated. :::
Asynchronously ejects a drive.
When the operation is finished, callback will be called.
You can then call Drive.eject_finish to obtain the
result of the operation.
Parameters:
flags— flags affecting the unmount if required for ejectcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
eject_finish¶
:::warning Deprecated since 2.22 This API is deprecated. :::
Finishes ejecting a drive.
Parameters:
result— aAsyncResult.
eject_with_operation¶
def eject_with_operation(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Ejects a drive. This is an asynchronous operation, and is
finished by calling Drive.eject_with_operation_finish with the drive
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the unmount if required for ejectmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
eject_with_operation_finish¶
Finishes ejecting a drive. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
enumerate_identifiers¶
Gets the kinds of identifiers that drive has.
Use Drive.get_identifier to obtain the identifiers
themselves.
get_icon¶
Gets the icon for drive.
get_identifier¶
Gets the identifier of the given kind for drive. The only
identifier currently available is
DRIVE_IDENTIFIER_KIND_UNIX_DEVICE.
Parameters:
kind— the kind of identifier to return
get_name¶
Gets the name of drive.
get_sort_key¶
Gets the sort key for drive, if any.
get_start_stop_type¶
Gets a hint about how a drive can be started/stopped.
get_symbolic_icon¶
Gets the icon for drive.
get_volumes¶
Get a list of mountable volumes for drive.
The returned list should be freed with g_list_free(), after
its elements have been unreffed with GObject.Object.unref.
has_media¶
Checks if the drive has media. Note that the OS may not be polling
the drive for media changes; see Drive.is_media_check_automatic
for more details.
has_volumes¶
Check if drive has any mountable volumes.
is_media_check_automatic¶
Checks if drive is capable of automatically detecting media changes.
is_media_removable¶
Checks if the drive supports removable media.
is_removable¶
Checks if the Drive and/or its media is considered removable by the user.
See Drive.is_media_removable.
poll_for_media¶
def poll_for_media(self, cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Asynchronously polls drive to see if media has been inserted or removed.
When the operation is finished, callback will be called.
You can then call Drive.poll_for_media_finish to obtain the
result of the operation.
Parameters:
cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
poll_for_media_finish¶
Finishes an operation started with Drive.poll_for_media on a drive.
Parameters:
result— aAsyncResult.
start¶
def start(self, flags: DriveStartFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Asynchronously starts a drive.
When the operation is finished, callback will be called.
You can then call Drive.start_finish to obtain the
result of the operation.
Parameters:
flags— flags affecting the start operation.mount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
start_finish¶
Finishes starting a drive.
Parameters:
result— aAsyncResult.
stop¶
def stop(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Asynchronously stops a drive.
When the operation is finished, callback will be called.
You can then call Drive.stop_finish to obtain the
result of the operation.
Parameters:
flags— flags affecting the unmount if required for stopping.mount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
stop_finish¶
Finishes stopping a drive.
Parameters:
result— aAsyncResult.
Virtual methods¶
do_can_eject¶
Checks if a drive can be ejected.
do_can_poll_for_media¶
Checks if a drive can be polled for media changes.
do_can_start¶
Checks if a drive can be started.
do_can_start_degraded¶
Checks if a drive can be started degraded.
do_can_stop¶
Checks if a drive can be stopped.
do_changed¶
Signal emitted when the drive is changed.
do_disconnected¶
The removed signal that is emitted when the Drive have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.
do_eject¶
def do_eject(self, flags: MountUnmountFlags | int, cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
:::warning Deprecated since 2.22 This API is deprecated. :::
Asynchronously ejects a drive.
When the operation is finished, callback will be called.
You can then call Drive.eject_finish to obtain the
result of the operation.
Parameters:
flags— flags affecting the unmount if required for ejectcancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_eject_button¶
Signal emitted when the physical eject button (if any) of a drive have been pressed.
do_eject_finish¶
:::warning Deprecated since 2.22 This API is deprecated. :::
Finishes ejecting a drive.
Parameters:
result— aAsyncResult.
do_eject_with_operation¶
def do_eject_with_operation(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Ejects a drive. This is an asynchronous operation, and is
finished by calling Drive.eject_with_operation_finish with the drive
and AsyncResult data returned in the callback.
Parameters:
flags— flags affecting the unmount if required for ejectmount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_eject_with_operation_finish¶
Finishes ejecting a drive. If any errors occurred during the operation,
error will be set to contain the errors and False will be returned.
Parameters:
result— aAsyncResult.
do_enumerate_identifiers¶
Gets the kinds of identifiers that drive has.
Use Drive.get_identifier to obtain the identifiers
themselves.
do_get_icon¶
Gets the icon for drive.
do_get_identifier¶
Gets the identifier of the given kind for drive. The only
identifier currently available is
DRIVE_IDENTIFIER_KIND_UNIX_DEVICE.
Parameters:
kind— the kind of identifier to return
do_get_name¶
Gets the name of drive.
do_get_sort_key¶
Gets the sort key for drive, if any.
do_get_start_stop_type¶
Gets a hint about how a drive can be started/stopped.
do_get_symbolic_icon¶
Gets the icon for drive.
do_get_volumes¶
Get a list of mountable volumes for drive.
The returned list should be freed with g_list_free(), after
its elements have been unreffed with GObject.Object.unref.
do_has_media¶
Checks if the drive has media. Note that the OS may not be polling
the drive for media changes; see Drive.is_media_check_automatic
for more details.
do_has_volumes¶
Check if drive has any mountable volumes.
do_is_media_check_automatic¶
Checks if drive is capable of automatically detecting media changes.
do_is_media_removable¶
Checks if the drive supports removable media.
do_is_removable¶
Checks if the Drive and/or its media is considered removable by the user.
See Drive.is_media_removable.
do_poll_for_media¶
def do_poll_for_media(self, cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Asynchronously polls drive to see if media has been inserted or removed.
When the operation is finished, callback will be called.
You can then call Drive.poll_for_media_finish to obtain the
result of the operation.
Parameters:
cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_poll_for_media_finish¶
Finishes an operation started with Drive.poll_for_media on a drive.
Parameters:
result— aAsyncResult.
do_start¶
def do_start(self, flags: DriveStartFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Asynchronously starts a drive.
When the operation is finished, callback will be called.
You can then call Drive.start_finish to obtain the
result of the operation.
Parameters:
flags— flags affecting the start operation.mount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_start_finish¶
Finishes starting a drive.
Parameters:
result— aAsyncResult.
do_stop¶
def do_stop(self, flags: MountUnmountFlags | int, mount_operation: MountOperation | None = ..., cancellable: Cancellable | None = ..., callback: Callable[[Drive | None, AsyncResult], None] | None = ...) -> None
Asynchronously stops a drive.
When the operation is finished, callback will be called.
You can then call Drive.stop_finish to obtain the
result of the operation.
Parameters:
flags— flags affecting the unmount if required for stopping.mount_operation— aMountOperationorNoneto avoid user interaction.cancellable— optionalCancellableobject,Noneto ignore.callback— aGAsyncReadyCallback, orNone.
do_stop_button¶
Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.
do_stop_finish¶
Finishes stopping a drive.
Parameters:
result— aAsyncResult.
Signals¶
changed¶
Emitted when the drive's state has changed.
disconnected¶
This signal is emitted when the Drive have been
disconnected. If the recipient is holding references to the
object they should release them so the object can be
finalized.
eject-button¶
Emitted when the physical eject button (if any) of a drive has been pressed.
stop-button¶
Emitted when the physical stop button (if any) of a drive has been pressed.