![]() |
![]() |
![]() |
GIO Reference Manual | ![]() |
---|---|---|---|---|
#include <gio.h> GDrive; GDriveIface; char* g_drive_get_name (GDrive *drive); GIcon* g_drive_get_icon (GDrive *drive); gboolean g_drive_has_volumes (GDrive *drive); GList* g_drive_get_volumes (GDrive *drive); gboolean g_drive_can_eject (GDrive *drive); gboolean g_drive_can_poll_for_media (GDrive *drive); void g_drive_poll_for_media (GDrive *drive, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean g_drive_poll_for_media_finish (GDrive *drive, GAsyncResult *result, GError **error); gboolean g_drive_has_media (GDrive *drive); gboolean g_drive_is_media_check_automatic (GDrive *drive); gboolean g_drive_is_media_removable (GDrive *drive); void g_drive_eject (GDrive *drive, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean g_drive_eject_finish (GDrive *drive, GAsyncResult *result, GError **error);
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, determing 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 potententially expensive and may spin up the drive creating noise.
For porting from GnomeVFS note that there is no equivalent of GDrive in that API.
typedef struct { GTypeInterface g_iface; /* signals */ void (*changed) (GDrive *drive); void (*disconnected) (GDrive *drive); void (*eject_button) (GDrive *drive); /* Virtual Table */ 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); } GDriveIface;
Interface for creating GDrive implementations.
GTypeInterface |
The parent interface. |
|
Signal emitted when the drive is changed. |
|
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. |
|
Signal emitted when the physical eject button (if any) of a drive have been pressed. |
|
Returns the name for the given GDrive. |
|
Returns a GIcon for the given GDrive. |
|
Returns TRUE if the GDrive has mountable volumes.
|
|
Returns a list GList of GVolume for the GDrive. |
|
Returns TRUE if the GDrive supports removal and insertion of media.
|
|
Returns TRUE if the GDrive has media inserted.
|
|
Returns TRUE if the GDrive is capabable of automatically detecting media changes.
|
|
Returns TRUE if the GDrive can eject media.
|
|
Returns TRUE if the GDrive is capable of manually polling for media change.
|
|
Ejects a GDrive. |
|
Finishes an eject operation. |
|
Poll for media insertion/removal on a GDrive. |
|
Finishes a media poll operation. |
char* g_drive_get_name (GDrive *drive);
Gets the name of drive
.
|
a GDrive. |
Returns : |
a string containing drive 's name. The returned
string should be freed when no longer needed.
|
gboolean g_drive_has_volumes (GDrive *drive);
Check if drive
has any mountable volumes.
|
a GDrive. |
Returns : |
TRUE if the drive contains volumes, FALSE otherwise.
|
GList* g_drive_get_volumes (GDrive *drive);
Get a list of mountable volumes for drive
.
gboolean g_drive_can_eject (GDrive *drive);
Checks if a drive can be ejected.
|
pointer to a GDrive. |
Returns : |
TRUE if the drive can be ejected. FALSE otherwise.
|
gboolean g_drive_can_poll_for_media (GDrive *drive);
Checks if a drive can be polled for media changes.
|
a GDrive. |
Returns : |
TRUE if the drive can be polled for media changes. FALSE otherwise.
|
void g_drive_poll_for_media (GDrive *drive, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
Polls drive
to see if media has been inserted or removed.
|
a GDrive. |
|
optional GCancellable object, NULL to ignore.
|
|
a GAsyncReadyCallback. |
|
a gpointer. |
gboolean g_drive_poll_for_media_finish (GDrive *drive, GAsyncResult *result, GError **error);
Finishes poll_for_mediaing a drive.
|
a GDrive. |
|
a GAsyncResult. |
|
a GError. |
Returns : |
TRUE if the drive has been poll_for_mediaed successfully,
FALSE otherwise.
|
gboolean g_drive_has_media (GDrive *drive);
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.
|
a GDrive. |
Returns : |
TRUE if drive has media, FALSE otherwise.
|
gboolean g_drive_is_media_check_automatic (GDrive *drive);
Checks if drive
is capabable of automatically detecting media changes.
|
a GDrive. |
Returns : |
TRUE if the drive is capabable of automatically detecting media changes, FALSE otherwise.
|
gboolean g_drive_is_media_removable (GDrive *drive);
Checks if the drive
supports removable media.
|
a GDrive. |
Returns : |
TRUE if drive supports removable media, FALSE otherwise.
|
void g_drive_eject (GDrive *drive, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
Ejects a drive.
|
a GDrive. |
|
flags affecting the unmount if required for eject |
|
optional GCancellable object, NULL to ignore.
|
|
a GAsyncReadyCallback. |
|
a gpointer. |
gboolean g_drive_eject_finish (GDrive *drive, GAsyncResult *result, GError **error);
Finishes ejecting a drive.
|
a GDrive. |
|
a GAsyncResult. |
|
a GError. |
Returns : |
TRUE if the drive has been ejected successfully,
FALSE otherwise.
|
"changed"
signalvoid user_function (GDrive *drive, gpointer user_data) : Run Last
Emitted when the drive's state has changed.
|
a GDrive. |
|
user data set when the signal handler was connected. |
"disconnected"
signalvoid user_function (GDrive *drive, gpointer user_data) : Run Last
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.
|
a GDrive. |
|
user data set when the signal handler was connected. |