Interface
GioDrive
Description [src]
interface Gio.Drive : GObject.Object
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 GVolume
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 g_drive_get_start_stop_type()
.
For porting from GnomeVFS note that there is no
equivalent of GDrive
in that API.
Prerequisite
In order to implement Drive, your type must inherit fromGObject
.
Instance methods
g_drive_eject_with_operation
Ejects a drive. This is an asynchronous operation, and is
finished by calling g_drive_eject_with_operation_finish()
with the drive
and GAsyncResult
data returned in the callback
.
since: 2.22
g_drive_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.
since: 2.22
g_drive_enumerate_identifiers
Gets the kinds of identifiers that drive
has.
Use g_drive_get_identifier()
to obtain the identifiers themselves.
g_drive_get_identifier
Gets the identifier of the given kind for drive
. The only
identifier currently available is
G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE
.
g_drive_has_media
Checks if the drive
has media. Note that the OS may not be polling
the drive for media changes; see g_drive_is_media_check_automatic()
for more details.
g_drive_is_media_check_automatic
Checks if drive
is capable of automatically detecting media changes.
g_drive_is_removable
Checks if the GDrive
and/or its media is considered removable by the user.
See g_drive_is_media_removable().
since: 2.50
g_drive_poll_for_media_finish
Finishes an operation started with g_drive_poll_for_media()
on a drive.
Signals
Gio.Drive::disconnected
This signal is emitted when the GDrive
have been
disconnected. If the recipient is holding references to the
object they should release them so the object can be finalized.
Gio.Drive::eject-button
Emitted when the physical eject button (if any) of a drive has been pressed.
Gio.Drive::stop-button
Emitted when the physical stop button (if any) of a drive has been pressed.
since: 2.22
Interface structure
struct GioDriveIface {
GTypeInterface g_iface;
void (* changed) (
GDrive* drive
);
void (* disconnected) (
GDrive* drive
);
void (* eject_button) (
GDrive* drive
);
char* (* get_name) (
GDrive* drive
);
GIcon* (* get_icon) (
GDrive* drive
);
gboolean (* has_volumes) (
GDrive* drive
);
GList* (* get_volumes) (
GDrive* drive
);
gboolean (* is_media_removable) (
GDrive* drive
);
gboolean (* has_media) (
GDrive* drive
);
gboolean (* is_media_check_automatic) (
GDrive* drive
);
gboolean (* can_eject) (
GDrive* drive
);
gboolean (* can_poll_for_media) (
GDrive* drive
);
void (* eject) (
GDrive* drive,
GMountUnmountFlags flags,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
gboolean (* eject_finish) (
GDrive* drive,
GAsyncResult* result,
GError** error
);
void (* poll_for_media) (
GDrive* drive,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
gboolean (* poll_for_media_finish) (
GDrive* drive,
GAsyncResult* result,
GError** error
);
char* (* get_identifier) (
GDrive* drive,
const char* kind
);
char** (* enumerate_identifiers) (
GDrive* drive
);
GDriveStartStopType (* get_start_stop_type) (
GDrive* drive
);
gboolean (* can_start) (
GDrive* drive
);
gboolean (* can_start_degraded) (
GDrive* drive
);
void (* start) (
GDrive* drive,
GDriveStartFlags flags,
GMountOperation* mount_operation,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
gboolean (* start_finish) (
GDrive* drive,
GAsyncResult* result,
GError** error
);
gboolean (* can_stop) (
GDrive* drive
);
void (* stop) (
GDrive* drive,
GMountUnmountFlags flags,
GMountOperation* mount_operation,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
gboolean (* stop_finish) (
GDrive* drive,
GAsyncResult* result,
GError** error
);
void (* stop_button) (
GDrive* drive
);
void (* eject_with_operation) (
GDrive* drive,
GMountUnmountFlags flags,
GMountOperation* mount_operation,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data
);
gboolean (* eject_with_operation_finish) (
GDrive* drive,
GAsyncResult* result,
GError** error
);
const gchar* (* get_sort_key) (
GDrive* drive
);
GIcon* (* get_symbolic_icon) (
GDrive* drive
);
gboolean (* is_removable) (
GDrive* drive
);
}
Interface for creating GDrive
implementations.
Interface members
g_iface |
|
The parent interface. |
|
changed |
|
Signal emitted when the drive is changed. |
|
disconnected |
|
The removed signal that is emitted when the |
|
eject_button |
|
Signal emitted when the physical eject button (if any) of a drive have been pressed. |
|
get_name |
|
Returns the name for the given |
|
get_icon |
|
Returns a |
|
has_volumes |
|
Returns |
|
get_volumes |
|
Returns a list |
|
is_media_removable |
|
Returns |
|
has_media |
|
Returns |
|
is_media_check_automatic |
|
Returns |
|
can_eject |
|
Returns |
|
can_poll_for_media |
|
Returns |
|
eject |
|
Ejects a |
|
eject_finish |
|
Finishes an eject operation. |
|
poll_for_media |
|
Poll for media insertion/removal on a |
|
poll_for_media_finish |
|
Finishes a media poll operation. |
|
get_identifier |
|
Returns the identifier of the given kind, or |
|
enumerate_identifiers |
|
Returns an array strings listing the kinds
of identifiers which the |
|
get_start_stop_type |
|
Gets a |
|
can_start |
|
Returns |
|
can_start_degraded |
|
Returns |
|
start |
|
Starts a |
|
start_finish |
|
Finishes a start operation. Since 2.22. |
|
can_stop |
|
Returns |
|
stop |
|
Stops a |
|
stop_finish |
|
Finishes a stop operation. Since 2.22. |
|
stop_button |
|
Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22. |
|
eject_with_operation |
|
Starts ejecting a |
|
eject_with_operation_finish |
|
Finishes an eject operation using a |
|
get_sort_key |
|
Gets a key used for sorting |
|
get_symbolic_icon |
|
Returns a symbolic |
|
is_removable |
|
Returns |
Virtual methods
Gio.Drive.disconnected
The removed signal that is emitted when the GDrive
have been disconnected. If the recipient is holding references to the object they should release them so the object can be finalized.
Gio.Drive.eject_button
Signal emitted when the physical eject button (if any) of a drive have been pressed.
Gio.Drive.eject_with_operation
Ejects a drive. This is an asynchronous operation, and is
finished by calling g_drive_eject_with_operation_finish()
with the drive
and GAsyncResult
data returned in the callback
.
since: 2.22
Gio.Drive.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.
since: 2.22
Gio.Drive.enumerate_identifiers
Gets the kinds of identifiers that drive
has.
Use g_drive_get_identifier()
to obtain the identifiers themselves.
Gio.Drive.get_identifier
Gets the identifier of the given kind for drive
. The only
identifier currently available is
G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE
.
Gio.Drive.has_media
Checks if the drive
has media. Note that the OS may not be polling
the drive for media changes; see g_drive_is_media_check_automatic()
for more details.
Gio.Drive.is_media_check_automatic
Checks if drive
is capable of automatically detecting media changes.
Gio.Drive.is_removable
Checks if the GDrive
and/or its media is considered removable by the user.
See g_drive_is_media_removable().
since: 2.50
Gio.Drive.poll_for_media_finish
Finishes an operation started with g_drive_poll_for_media()
on a drive.
Gio.Drive.stop_button
Signal emitted when the physical stop button (if any) of a drive have been pressed. Since 2.22.