Module: Gio::Drive

Defined in:
(unknown)

Overview

#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 potententially 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.

Instance Method Summary collapse

Instance Method Details

#can_eject(drive) ⇒ TrueClass

Returns true if the drive can be ejected, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive can be ejected, false otherwise.

#can_poll_for_media(drive) ⇒ TrueClass

Returns true if the drive can be polled for media changes, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive can be polled for media changes, false otherwise.

#can_start(drive) ⇒ TrueClass

Returns true if the drive can be started, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive can be started, false otherwise.

#can_start_degraded(drive) ⇒ TrueClass

Returns true if the drive can be started degraded, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive can be started degraded, false otherwise.

#can_stop(drive) ⇒ TrueClass

Returns true if the drive can be stopped, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive can be stopped, false otherwise.

#changed(drive) ⇒ nil

Parameters:

Returns:

  • (nil)

#disconnected(drive) ⇒ nil

Parameters:

Returns:

  • (nil)

#eject(drive, flags, cancellable, callback, user_data) ⇒ nil

Parameters:

  • drive (Gio::Drive)

    a #GDrive.

  • flags (Gio::MountUnmountFlags)

    flags affecting the unmount if required for eject

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data to pass to callback

Returns:

  • (nil)

#eject_button(drive) ⇒ nil

Parameters:

Returns:

  • (nil)

#eject_finish(drive, result) ⇒ TrueClass

Returns true if the drive has been ejected successfully, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive has been ejected successfully, false otherwise.

#eject_with_operation(drive, flags, mount_operation, cancellable, callback, user_data) ⇒ nil

Parameters:

  • drive (Gio::Drive)

    a #GDrive.

  • flags (Gio::MountUnmountFlags)

    flags affecting the unmount if required for eject

  • mount_operation (Gio::MountOperation)

    a GMount::Operation or nil to avoid user interaction.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data passed to callback.

Returns:

  • (nil)

#eject_with_operation_finish(drive, result) ⇒ TrueClass

Returns true if the drive was successfully ejected. false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive was successfully ejected. false otherwise.

#enumerate_identifiers(drive) ⇒ Array<String>

Returns a nil-terminated array of strings containing kinds of identifiers. Use g_strfreev() to free.

Parameters:

Returns:

  • (Array<String>)

    a nil-terminated array of strings containing kinds of identifiers. Use g_strfreev() to free.

#get_icon(drive) ⇒ Gio::Icon

Returns #GIcon for the drive. Free the returned object with g_object_unref().

Parameters:

Returns:

  • (Gio::Icon)

    #GIcon for the drive. Free the returned object with g_object_unref().

#get_identifier(drive, kind) ⇒ String

Returns a newly allocated string containing the requested identifier, or nil if the #GDrive doesn’t have this kind of identifier.

Parameters:

  • drive (Gio::Drive)

    a #GDrive

  • kind (String)

    the kind of identifier to return

Returns:

  • (String)

    a newly allocated string containing the requested identifier, or nil if the #GDrive doesn’t have this kind of identifier.

#get_name(drive) ⇒ String

Returns a string containing drive’s name. The returned string should be freed when no longer needed.

Parameters:

Returns:

  • (String)

    a string containing drive’s name. The returned string should be freed when no longer needed.

#get_sort_key(drive) ⇒ String

Returns Sorting key for drive or nil if no such key is available.

Parameters:

Returns:

  • (String)

    Sorting key for drive or nil if no such key is available.

#get_start_stop_type(drive) ⇒ Gio::DriveStartStopType

Returns A value from the GDrive::StartStopType enumeration.

Parameters:

Returns:

#get_symbolic_icon(drive) ⇒ Gio::Icon

Returns symbolic #GIcon for the drive. Free the returned object with g_object_unref().

Parameters:

Returns:

  • (Gio::Icon)

    symbolic #GIcon for the drive. Free the returned object with g_object_unref().

#get_volumes(drive) ⇒ GLib::List

Returns #GList containing any #GVolume objects on the given drive.

Parameters:

Returns:

  • (GLib::List)

    #GList containing any #GVolume objects on the given drive.

#has_media(drive) ⇒ TrueClass

Returns true if drive has media, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if drive has media, false otherwise.

#has_volumes(drive) ⇒ TrueClass

Returns true if the drive contains volumes, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive contains volumes, false otherwise.

#iconGio::Icon

Gets the icon for drive.

Returns:

  • (Gio::Icon)

    #GIcon for the drive. Free the returned object with g_object_unref().

#is_media_check_automatic(drive) ⇒ TrueClass

Returns true if the drive is capabable of automatically detecting media changes, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive is capabable of automatically detecting media changes, false otherwise.

#is_media_removable(drive) ⇒ TrueClass

Returns true if drive supports removable media, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if drive supports removable media, false otherwise.

#is_removable(drive) ⇒ TrueClass

Returns true if drive and/or its media is considered removable, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if drive and/or its media is considered removable, false otherwise.

#nameString

Gets the name of drive.

Returns:

  • (String)

    a string containing drive’s name. The returned string should be freed when no longer needed.

#poll_for_media(drive, cancellable, callback, user_data) ⇒ nil

Parameters:

  • drive (Gio::Drive)

    a #GDrive.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data to pass to callback

Returns:

  • (nil)

#poll_for_media_finish(drive, result) ⇒ TrueClass

Returns true if the drive has been poll_for_mediaed successfully, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive has been poll_for_mediaed successfully, false otherwise.

#sort_keyString

Gets the sort key for drive, if any.

Returns:

  • (String)

    Sorting key for drive or nil if no such key is available.

#start(drive, flags, mount_operation, cancellable, callback, user_data) ⇒ nil

Parameters:

  • drive (Gio::Drive)

    a #GDrive.

  • flags (Gio::DriveStartFlags)

    flags affecting the start operation.

  • mount_operation (Gio::MountOperation)

    a GMount::Operation or nil to avoid user interaction.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data to pass to callback

Returns:

  • (nil)

#start_finish(drive, result) ⇒ TrueClass

Returns true if the drive has been started successfully, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive has been started successfully, false otherwise.

#start_stop_typeGio::DriveStartStopType

Gets a hint about how a drive can be started/stopped.

Returns:

#stop(drive, flags, mount_operation, cancellable, callback, user_data) ⇒ nil

Parameters:

  • drive (Gio::Drive)

    a #GDrive.

  • flags (Gio::MountUnmountFlags)

    flags affecting the unmount if required for stopping.

  • mount_operation (Gio::MountOperation)

    a GMount::Operation or nil to avoid user interaction.

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore.

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback, or nil.

  • user_data (GObject)

    user data to pass to callback

Returns:

  • (nil)

#stop_button(drive) ⇒ nil

Parameters:

Returns:

  • (nil)

#stop_finish(drive, result) ⇒ TrueClass

Returns true if the drive has been stopped successfully, false otherwise.

Parameters:

Returns:

  • (TrueClass)

    true if the drive has been stopped successfully, false otherwise.

#symbolic_iconGio::Icon

Gets the icon for drive.

Returns:

  • (Gio::Icon)

    symbolic #GIcon for the drive. Free the returned object with g_object_unref().

#volumesGLib::List

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:

  • (GLib::List)

    #GList containing any #GVolume objects on the given drive.