Gio.Drive¶
- Implementations:
None
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
Name |
Short Description |
---|---|
Emitted when the drive’s state has changed. |
|
This signal is emitted when the |
|
Emitted when the physical eject button (if any) of a drive has been pressed. |
|
Emitted when the physical stop button (if any) of a drive has been pressed. |
Fields¶
None
Class Details¶
- class Gio.Drive¶
- Bases:
- Structure:
GDrive
represents a piece of hardware connected to the machine. It’s generally only created for removable hardware or hardware with removable media.GDrive
is a container class for [iface`Gio`.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 aGDrive
may vary according to implementation. To choose the correct verbs in e.g. a file manager, use [method`Gio`.Drive.get_start_stop_type].For porting from GnomeVFS note that there is no equivalent of
GDrive
in that API.- eject(flags, cancellable, callback, *user_data)[source]¶
- Parameters:
flags (
Gio.MountUnmountFlags
) – flags affecting the unmount if required for ejectcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously ejects a drive.
When the operation is finished, callback will be called. You can then call
Gio.Drive.eject_finish
() to obtain the result of the operation.Deprecated since version 2.22: Use
Gio.Drive.eject_with_operation
() instead.
- eject_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
True
if the drive has been ejected successfully,False
otherwise.- Return type:
Finishes ejecting a drive.
Deprecated since version 2.22: Use
Gio.Drive.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 ejectmount_operation (
Gio.MountOperation
orNone
) – aGio.MountOperation
orNone
to avoid user interaction.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Ejects a drive. This is an asynchronous operation, and is finished by calling
Gio.Drive.eject_with_operation_finish
() with the self andGio.AsyncResult
data returned in the callback.New in version 2.22.
- eject_with_operation_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
True
if the drive was successfully ejected.False
otherwise.- Return type:
Finishes ejecting a drive. If any errors occurred during the operation, error will be set to contain the errors and
False
will 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.Drive.get_identifier
() to obtain the identifiers themselves.
- get_icon()[source]¶
- Returns:
Gio.Icon
for the self. Free the returned object withGObject.Object.unref
().- Return type:
Gets the icon for self.
- get_identifier(kind)[source]¶
- Parameters:
kind (
str
) – the kind of identifier to return- Returns:
a newly allocated string containing the requested identifier, or
None
if theGio.Drive
doesn’t have this kind of identifier.- Return type:
Gets the identifier of the given kind for self. The only identifier currently available is
Gio.DRIVE_IDENTIFIER_KIND_UNIX_DEVICE
.
- get_name()[source]¶
- Returns:
a string containing self's name. The returned string should be freed when no longer needed.
- Return type:
Gets the name of self.
- get_start_stop_type()[source]¶
- Returns:
A value from the
Gio.DriveStartStopType
enumeration.- Return type:
Gets a hint about how a drive can be started/stopped.
New in version 2.22.
- get_symbolic_icon()[source]¶
- Returns:
symbolic
Gio.Icon
for the self. Free the returned object withGObject.Object.unref
().- Return type:
Gets the icon for self.
New in version 2.34.
- get_volumes()[source]¶
- Returns:
GLib.List
containing anyGio.Volume
objects on the given self.- Return type:
Get a list of mountable volumes for self.
The returned list should be freed with g_list_free(), after its elements have been unreffed with
GObject.Object.unref
().
- has_media()[source]¶
-
Checks if the self has media. Note that the OS may not be polling the drive for media changes; see
Gio.Drive.is_media_check_automatic
() for more details.
- is_media_check_automatic()[source]¶
- Returns:
True
if the self is capable of automatically detecting media changes,False
otherwise.- Return type:
Checks if self is capable of automatically detecting media changes.
- is_removable()[source]¶
-
Checks if the
Gio.Drive
and/or its media is considered removable by the user. SeeGio.Drive.is_media_removable
().New in version 2.50.
- poll_for_media(cancellable, callback, *user_data)[source]¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously polls self to see if media has been inserted or removed.
When the operation is finished, callback will be called. You can then call
Gio.Drive.poll_for_media_finish
() to obtain the result of the operation.
- poll_for_media_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
True
if the drive has been poll_for_mediaed successfully,False
otherwise.- Return type:
Finishes an operation started with
Gio.Drive.poll_for_media
() on a drive.
- start(flags, mount_operation, cancellable, callback, *user_data)[source]¶
- Parameters:
flags (
Gio.DriveStartFlags
) – flags affecting the start operation.mount_operation (
Gio.MountOperation
orNone
) – aGio.MountOperation
orNone
to avoid user interaction.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously starts a drive.
When the operation is finished, callback will be called. You can then call
Gio.Drive.start_finish
() to obtain the result of the operation.New in version 2.22.
- start_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
True
if the drive has been started successfully,False
otherwise.- Return type:
Finishes starting a drive.
New in version 2.22.
- stop(flags, mount_operation, cancellable, callback, *user_data)[source]¶
- Parameters:
flags (
Gio.MountUnmountFlags
) – flags affecting the unmount if required for stopping.mount_operation (
Gio.MountOperation
orNone
) – aGio.MountOperation
orNone
to avoid user interaction.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously stops a drive.
When the operation is finished, callback will be called. You can then call
Gio.Drive.stop_finish
() to obtain the result of the operation.New in version 2.22.
- stop_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Raises:
- Returns:
True
if the drive has been stopped successfully,False
otherwise.- Return type:
Finishes stopping a drive.
New in version 2.22.
- do_can_eject() virtual¶
-
Checks if a drive can be ejected.
- do_can_poll_for_media() virtual¶
-
Checks if a drive can be polled for media changes.
- do_can_start() virtual¶
-
Checks if a drive can be started.
New in version 2.22.
- do_can_start_degraded() virtual¶
-
Checks if a drive can be started degraded.
New in version 2.22.
- do_can_stop() virtual¶
-
Checks if a drive can be stopped.
New in version 2.22.
- do_changed() virtual¶
Signal emitted when the drive is changed.
- do_disconnected() virtual¶
The removed signal that is emitted when the
Gio.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(flags, cancellable, callback, *user_data) virtual¶
- Parameters:
flags (
Gio.MountUnmountFlags
) – flags affecting the unmount if required for ejectcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously ejects a drive.
When the operation is finished, callback will be called. You can then call
Gio.Drive.eject_finish
() to obtain the result of the operation.Deprecated since version 2.22: Use
Gio.Drive.eject_with_operation
() instead.
- do_eject_button() virtual¶
Signal emitted when the physical eject button (if any) of a drive have been pressed.
- do_eject_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Returns:
True
if the drive has been ejected successfully,False
otherwise.- Return type:
Finishes ejecting a drive.
Deprecated since version 2.22: Use
Gio.Drive.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 ejectmount_operation (
Gio.MountOperation
orNone
) – aGio.MountOperation
orNone
to avoid user interaction.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Ejects a drive. This is an asynchronous operation, and is finished by calling
Gio.Drive.eject_with_operation_finish
() with the drive andGio.AsyncResult
data returned in the callback.New in version 2.22.
- do_eject_with_operation_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Returns:
True
if the drive was successfully ejected.False
otherwise.- Return type:
Finishes ejecting a drive. If any errors occurred during the operation, error will be set to contain the errors and
False
will 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 drive has. Use
Gio.Drive.get_identifier
() to obtain the identifiers themselves.
- do_get_icon() virtual¶
- Returns:
Gio.Icon
for the drive. Free the returned object withGObject.Object.unref
().- Return type:
Gets the icon for drive.
- do_get_identifier(kind) virtual¶
- Parameters:
kind (
str
) – the kind of identifier to return- Returns:
a newly allocated string containing the requested identifier, or
None
if theGio.Drive
doesn’t have this kind of identifier.- Return type:
Gets the identifier of the given kind for drive. The only identifier currently available is
Gio.DRIVE_IDENTIFIER_KIND_UNIX_DEVICE
.
- do_get_name() virtual¶
- Returns:
a string containing drive's name. The returned string should be freed when no longer needed.
- Return type:
Gets the name of drive.
- do_get_sort_key() virtual¶
-
Gets the sort key for drive, if any.
New in version 2.32.
- do_get_start_stop_type() virtual¶
- Returns:
A value from the
Gio.DriveStartStopType
enumeration.- Return type:
Gets a hint about how a drive can be started/stopped.
New in version 2.22.
- do_get_symbolic_icon() virtual¶
- Returns:
symbolic
Gio.Icon
for the drive. Free the returned object withGObject.Object.unref
().- Return type:
Gets the icon for drive.
New in version 2.34.
- do_get_volumes() virtual¶
- Returns:
GLib.List
containing anyGio.Volume
objects on the given drive.- Return type:
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() virtual¶
-
Checks if the drive has media. Note that the OS may not be polling the drive for media changes; see
Gio.Drive.is_media_check_automatic
() for more details.
- do_has_volumes() virtual¶
-
Check if drive has any mountable volumes.
- do_is_media_check_automatic() virtual¶
- Returns:
True
if the drive is capable of automatically detecting media changes,False
otherwise.- Return type:
Checks if drive is capable of automatically detecting media changes.
- do_is_media_removable() virtual¶
-
Checks if the drive supports removable media.
- do_is_removable() virtual¶
-
Checks if the
Gio.Drive
and/or its media is considered removable by the user. SeeGio.Drive.is_media_removable
().New in version 2.50.
- do_poll_for_media(cancellable, callback, *user_data) virtual¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
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
Gio.Drive.poll_for_media_finish
() to obtain the result of the operation.
- do_poll_for_media_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Returns:
True
if the drive has been poll_for_mediaed successfully,False
otherwise.- Return type:
Finishes an operation started with
Gio.Drive.poll_for_media
() on a drive.
- do_start(flags, mount_operation, cancellable, callback, *user_data) virtual¶
- Parameters:
flags (
Gio.DriveStartFlags
) – flags affecting the start operation.mount_operation (
Gio.MountOperation
orNone
) – aGio.MountOperation
orNone
to avoid user interaction.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously starts a drive.
When the operation is finished, callback will be called. You can then call
Gio.Drive.start_finish
() to obtain the result of the operation.New in version 2.22.
- do_start_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Returns:
True
if the drive has been started successfully,False
otherwise.- Return type:
Finishes starting a drive.
New in version 2.22.
- do_stop(flags, mount_operation, cancellable, callback, *user_data) virtual¶
- Parameters:
flags (
Gio.MountUnmountFlags
) – flags affecting the unmount if required for stopping.mount_operation (
Gio.MountOperation
orNone
) – aGio.MountOperation
orNone
to avoid user interaction.cancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object,None
to ignore.callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
.
Asynchronously stops a drive.
When the operation is finished, callback will be called. You can then call
Gio.Drive.stop_finish
() to obtain the result of the operation.New in version 2.22.
- do_stop_button() virtual¶
Signal emitted when the physical stop button (if any) of a drive have been pressed.
New in version 2.22.
- do_stop_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
.- Returns:
True
if the drive has been stopped successfully,False
otherwise.- Return type:
Finishes stopping a drive.
New in version 2.22.
Signal Details¶
- Gio.Drive.signals.changed(drive)¶
- Signal Name:
changed
- Flags:
- Parameters:
drive (
Gio.Drive
) – The object which received the signal
Emitted when the drive’s state has changed.
- Gio.Drive.signals.disconnected(drive)¶
- Signal Name:
disconnected
- Flags:
- Parameters:
drive (
Gio.Drive
) – The object which received the signal
This signal is emitted when the
Gio.Drive
have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.