| GIO Reference Manual | ||||
|---|---|---|---|---|
#include <gio/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);
char ** g_drive_enumerate_identifiers (GDrive *drive);
char * g_drive_get_identifier (GDrive *drive,
const char *kind);
GDrive - this represent a piece of hardware connected to the machine. Its generally only created for removable hardware or hardware with removable media.
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);
char * (*get_identifier) (GDrive *drive,
const char *kind);
char ** (*enumerate_identifiers) (GDrive *drive);
} GDriveIface;
Interface for creating GDrive implementations.
g_iface; |
The parent interface. |
changed () |
Signal emitted when the drive is changed. |
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. |
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 GDrive. |
get_icon () |
Returns a GIcon for the given GDrive. |
has_volumes () |
Returns TRUE |
get_volumes () |
Returns a list |
is_media_removable () |
Returns TRUE |
has_media () |
Returns TRUE |
is_media_check_automatic () |
Returns TRUE |
can_eject () |
Returns TRUE |
can_poll_for_media () |
Returns TRUE |
eject () |
Ejects a GDrive. |
eject_finish () |
Finishes an eject operation. |
poll_for_media () |
Poll for media insertion/removal on a GDrive. |
poll_for_media_finish () |
Finishes a media poll operation. |
get_identifier () |
Returns the identifier of the given kind, or NULL |
enumerate_identifiers () |
Returns an array strings listing the kinds of identifiers which the GDrive has. |
char * g_drive_get_name (GDrive *drive);
Gets the name of drive.
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.
drive : |
a GDrive. |
| Returns : | TRUEdrive contains volumes, FALSE |
GList * g_drive_get_volumes (GDrive *drive);
Get a list of mountable volumes for drive.
The returned list should be freed with g_list_free()g_object_unref()
gboolean g_drive_can_eject (GDrive *drive);
Checks if a drive can be ejected.
drive : |
pointer to a GDrive. |
| Returns : | TRUEdrive can be ejected. FALSE |
gboolean g_drive_can_poll_for_media (GDrive *drive);
Checks if a drive can be polled for media changes.
drive : |
a GDrive. |
| Returns : | TRUEdrive can be polled for media changes. FALSE |
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.
drive : |
a GDrive. |
cancellable : |
optional GCancellable object, NULL |
callback : |
a GAsyncReadyCallback, or NULL |
user_data : |
a |
gboolean g_drive_poll_for_media_finish (GDrive *drive, GAsyncResult *result,GError **error);
Finishes poll_for_mediaing a drive.
drive : |
a GDrive. |
result : |
a GAsyncResult. |
error : |
a |
| Returns : | TRUEFALSE |
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.
drive : |
a GDrive. |
| Returns : | TRUEdrive has media, FALSE |
gboolean g_drive_is_media_check_automatic (GDrive *drive);
Checks if drive is capabable of automatically detecting media changes.
drive : |
a GDrive. |
| Returns : | TRUEdrive is capabable of automatically detecting media changes, FALSE |
gboolean g_drive_is_media_removable (GDrive *drive);
Checks if the drive supports removable media.
drive : |
a GDrive. |
| Returns : | TRUEdrive supports removable media, FALSE |
void g_drive_eject (GDrive *drive, GMountUnmountFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback,gpointer user_data);
Ejects a drive.
drive : |
a GDrive. |
flags : |
flags affecting the unmount if required for eject |
cancellable : |
optional GCancellable object, NULL |
callback : |
a GAsyncReadyCallback, or NULL |
user_data : |
a |
gboolean g_drive_eject_finish (GDrive *drive, GAsyncResult *result,GError **error);
Finishes ejecting a drive.
drive : |
a GDrive. |
result : |
a GAsyncResult. |
error : |
a |
| Returns : | TRUEFALSE |
char ** g_drive_enumerate_identifiers (GDrive *drive);
Gets the kinds of identifiers that drive has.
Use g_drive_get_identifer()
drive : |
a GDrive |
| Returns : | a NULLg_strfreev() |
char * g_drive_get_identifier (GDrive *drive, constchar *kind);
Gets the identifier of the given kind for drive.
"changed" signalvoid user_function (GDrive *drive,gpointer user_data) : Run Last
Emitted when the drive's state has changed.
drive : |
a GDrive. |
user_data : |
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.
drive : |
a GDrive. |
user_data : |
user data set when the signal handler was connected. |