Package ch.bailu.gtk.gio
Class Drive
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.type.Interface
ch.bailu.gtk.gio.Drive
- All Implemented Interfaces:
PointerInterface
#GDrive - this represent 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 #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.
It's 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, 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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canEject()
Checks if a drive can be ejected.boolean
Checks if a drive can be polled for media changes.boolean
canStart()
Checks if a drive can be started.boolean
Checks if a drive can be started degraded.boolean
canStop()
Checks if a drive can be stopped.void
ejectWithOperation
(int flags, MountOperation mount_operation, Cancellable cancellable, Drive.OnAsyncReadyCallback callback, Pointer user_data) Ejects a drive.boolean
ejectWithOperationFinish
(AsyncResult result) Finishes ejecting a drive.Gets the kinds of identifiers that @drive has.static ClassHandler
getIcon()
Gets the icon for @drive.getIdentifier
(Str kind) Gets the identifier of the given kind for @drive.getIdentifier
(String kind) Gets the identifier of the given kind for @drive.static int
getName()
Gets the name of @drive.static long
static TypeSystem.TypeSize
Gets the sort key for @drive, if any.int
Gets a hint about how a drive can be started/stopped.Gets the icon for @drive.static long
static TypeSystem.TypeSize
Get a list of mountable volumes for @drive.boolean
hasMedia()
Checks if the @drive has media.boolean
Check if @drive has any mountable volumes.boolean
Checks if @drive is capable of automatically detecting media changes.boolean
Checks if the @drive supports removable media.boolean
Checks if the #GDrive and/or its media is considered removable by the user.onChanged
(Drive.OnChanged signal) Connect to signal "changed".onDisconnected
(Drive.OnDisconnected signal) Connect to signal "disconnected".onEjectButton
(Drive.OnEjectButton signal) Connect to signal "eject-button".onStopButton
(Drive.OnStopButton signal) Connect to signal "stop-button".void
pollForMedia
(Cancellable cancellable, Drive.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously polls @drive to see if media has been inserted or removed.boolean
pollForMediaFinish
(AsyncResult result) Finishes an operation started with g_drive_poll_for_media() on a drive.void
start
(int flags, MountOperation mount_operation, Cancellable cancellable, Drive.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously starts a drive.boolean
startFinish
(AsyncResult result) Finishes starting a drive.void
stop
(int flags, MountOperation mount_operation, Cancellable cancellable, Drive.OnAsyncReadyCallback callback, Pointer user_data) Asynchronously stops a drive.boolean
stopFinish
(AsyncResult result) Finishes stopping a drive.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_CHANGED
- See Also:
-
SIGNAL_ON_DISCONNECTED
- See Also:
-
SIGNAL_ON_EJECT_BUTTON
- See Also:
-
SIGNAL_ON_STOP_BUTTON
- See Also:
-
-
Constructor Details
-
Drive
-
-
Method Details
-
getClassHandler
-
canEject
public boolean canEject()Checks if a drive can be ejected.- Returns:
- %TRUE if the @drive can be ejected, %FALSE otherwise.
-
canPollForMedia
public boolean canPollForMedia()Checks if a drive can be polled for media changes.- Returns:
- %TRUE if the @drive can be polled for media changes, %FALSE otherwise.
-
canStart
public boolean canStart()Checks if a drive can be started.- Returns:
- %TRUE if the @drive can be started, %FALSE otherwise.
-
canStartDegraded
public boolean canStartDegraded()Checks if a drive can be started degraded.- Returns:
- %TRUE if the @drive can be started degraded, %FALSE otherwise.
-
canStop
public boolean canStop()Checks if a drive can be stopped.- Returns:
- %TRUE if the @drive can be stopped, %FALSE otherwise.
-
ejectWithOperation
public void ejectWithOperation(int flags, @Nullable MountOperation mount_operation, @Nullable Cancellable cancellable, Drive.OnAsyncReadyCallback callback, @Nullable Pointer user_data) 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.- Parameters:
flags
- flags affecting the unmount if required for ejectmount_operation
- a #GMountOperation or %NULL to avoid user interaction.cancellable
- optional #GCancellable object, %NULL to ignore.callback
- a #GAsyncReadyCallback, or %NULL.user_data
- user data passed to @callback.
-
ejectWithOperationFinish
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
- a #GAsyncResult.- Returns:
- %TRUE if the drive was successfully ejected. %FALSE otherwise.
- Throws:
AllocationError
-
enumerateIdentifiers
Gets the kinds of identifiers that @drive has.
Use g_drive_get_identifier() to obtain the identifiers
themselves.- Returns:
- a %NULL-terminated array of strings containing kinds of identifiers. Use g_strfreev() to free.
-
getIcon
Gets the icon for @drive.- Returns:
- #GIcon for the @drive. Free the returned object with g_object_unref().
-
getIdentifier
Gets the identifier of the given kind for @drive. The only
identifier currently available is
%G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE.- Parameters:
kind
- the kind of identifier to return- Returns:
- a newly allocated string containing the requested identifier, or %NULL if the #GDrive doesn't have this kind of identifier.
-
getIdentifier
Gets the identifier of the given kind for @drive. The only
identifier currently available is
%G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE.- Parameters:
kind
- the kind of identifier to return- Returns:
- a newly allocated string containing the requested identifier, or %NULL if the #GDrive doesn't have this kind of identifier.
-
getName
Gets the name of @drive.- Returns:
- a string containing @drive's name. The returned string should be freed when no longer needed.
-
getSortKey
Gets the sort key for @drive, if any.- Returns:
- Sorting key for @drive or %NULL if no such key is available.
-
getStartStopType
public int getStartStopType()Gets a hint about how a drive can be started/stopped.- Returns:
- A value from the #GDriveStartStopType enumeration.
-
getSymbolicIcon
Gets the icon for @drive.- Returns:
- symbolic #GIcon for the @drive. Free the returned object with g_object_unref().
-
getVolumes
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 g_object_unref().- Returns:
- #GList containing any #GVolume objects on the given @drive.
-
hasMedia
public boolean hasMedia()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.- Returns:
- %TRUE if @drive has media, %FALSE otherwise.
-
hasVolumes
public boolean hasVolumes()Check if @drive has any mountable volumes.- Returns:
- %TRUE if the @drive contains volumes, %FALSE otherwise.
-
isMediaCheckAutomatic
public boolean isMediaCheckAutomatic()Checks if @drive is capable of automatically detecting media changes.- Returns:
- %TRUE if the @drive is capable of automatically detecting media changes, %FALSE otherwise.
-
isMediaRemovable
public boolean isMediaRemovable()Checks if the @drive supports removable media.- Returns:
- %TRUE if @drive supports removable media, %FALSE otherwise.
-
isRemovable
public boolean isRemovable()Checks if the #GDrive and/or its media is considered removable by the user.
See g_drive_is_media_removable().- Returns:
- %TRUE if @drive and/or its media is considered removable, %FALSE otherwise.
-
pollForMedia
public void pollForMedia(@Nullable Cancellable cancellable, Drive.OnAsyncReadyCallback callback, @Nullable Pointer user_data) 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 g_drive_poll_for_media_finish() to obtain the
result of the operation.- Parameters:
cancellable
- optional #GCancellable object, %NULL to ignore.callback
- a #GAsyncReadyCallback, or %NULL.user_data
- user data to pass to @callback
-
pollForMediaFinish
Finishes an operation started with g_drive_poll_for_media() on a drive.- Parameters:
result
- a #GAsyncResult.- Returns:
- %TRUE if the drive has been poll_for_mediaed successfully, %FALSE otherwise.
- Throws:
AllocationError
-
start
public void start(int flags, @Nullable MountOperation mount_operation, @Nullable Cancellable cancellable, Drive.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously starts a drive.
When the operation is finished, @callback will be called.
You can then call g_drive_start_finish() to obtain the
result of the operation.- Parameters:
flags
- flags affecting the start operation.mount_operation
- a #GMountOperation or %NULL to avoid user interaction.cancellable
- optional #GCancellable object, %NULL to ignore.callback
- a #GAsyncReadyCallback, or %NULL.user_data
- user data to pass to @callback
-
startFinish
Finishes starting a drive.- Parameters:
result
- a #GAsyncResult.- Returns:
- %TRUE if the drive has been started successfully, %FALSE otherwise.
- Throws:
AllocationError
-
stop
public void stop(int flags, @Nullable MountOperation mount_operation, @Nullable Cancellable cancellable, Drive.OnAsyncReadyCallback callback, @Nullable Pointer user_data) Asynchronously stops a drive.
When the operation is finished, @callback will be called.
You can then call g_drive_stop_finish() to obtain the
result of the operation.- Parameters:
flags
- flags affecting the unmount if required for stopping.mount_operation
- a #GMountOperation or %NULL to avoid user interaction.cancellable
- optional #GCancellable object, %NULL to ignore.callback
- a #GAsyncReadyCallback, or %NULL.user_data
- user data to pass to @callback
-
stopFinish
Finishes stopping a drive.- Parameters:
result
- a #GAsyncResult.- Returns:
- %TRUE if the drive has been stopped successfully, %FALSE otherwise.
- Throws:
AllocationError
-
onChanged
Connect to signal "changed".
SeeDrive.OnChanged.onChanged()
for signal description.
FieldSIGNAL_ON_CHANGED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onDisconnected
Connect to signal "disconnected".
SeeDrive.OnDisconnected.onDisconnected()
for signal description.
FieldSIGNAL_ON_DISCONNECTED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onEjectButton
Connect to signal "eject-button".
SeeDrive.OnEjectButton.onEjectButton()
for signal description.
FieldSIGNAL_ON_EJECT_BUTTON
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onStopButton
Connect to signal "stop-button".
SeeDrive.OnStopButton.onStopButton()
for signal description.
FieldSIGNAL_ON_STOP_BUTTON
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-