Module: Gio::Volume
- Defined in:
- (unknown)
Overview
The #GVolume interface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS, #GVolume is the moral equivalent of Gnome::VFSDrive.
Mounting a #GVolume instance is an asynchronous operation. For more information about asynchronous operations, see GAsync::Result and #GTask. To mount a #GVolume, first call g_volume_mount() with (at least) the #GVolume instance, optionally a GMount::Operation object and a GAsync::ReadyCallback.
Typically, one will only want to pass nil for the GMount::Operation if automounting all volumes when a desktop session starts since it’s not desirable to put up a lot of dialogs asking for credentials.
The callback will be fired when the operation has resolved (either with success or failure), and a GAsync::Result instance will be passed to the callback. That callback should then call g_volume_mount_finish() with the #GVolume instance and the GAsync::Result data to see if the operation was completed successfully. If an error is present when g_volume_mount_finish() is called, then it will be filled with any error information.
## Volume Identifiers # #volume-identifier
It is sometimes necessary to directly access the underlying operating system object behind a volume (e.g. for passing a volume to an application via the commandline). For this purpose, GIO allows to obtain an ‘identifier’ for the volume. There can be different kinds of identifiers, such as Hal UDIs, filesystem labels, traditional Unix devices (e.g. ‘/dev/sda2`), UUIDs. GIO uses predefined strings as names for the different kinds of identifiers: #G_VOLUME_IDENTIFIER_KIND_UUID, #G_VOLUME_IDENTIFIER_KIND_LABEL, etc. Use g_volume_get_identifier() to obtain an identifier for a volume.
Note that #G_VOLUME_IDENTIFIER_KIND_HAL_UDI will only be available when the gvfs hal volume monitor is in use. Other volume monitors will generally be able to provide the #G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE identifier, which can be used to obtain a hal device by means of libhal_manager_find_device_string_match().
Instance Method Summary collapse
-
#activation_root ⇒ Gio::File
Gets the activation root for a #GVolume if it is known ahead of mount time.
-
#can_eject(volume) ⇒ TrueClass
True if the volume can be ejected.
-
#can_mount(volume) ⇒ TrueClass
True if the volume can be mounted.
- #changed(volume) ⇒ nil
-
#drive ⇒ Gio::Drive
Gets the drive for the volume.
- #eject(volume, flags, cancellable, callback, user_data) ⇒ nil
-
#eject_finish(volume, result) ⇒ TrueClass
True, false if operation failed.
- #eject_with_operation(volume, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#eject_with_operation_finish(volume, result) ⇒ TrueClass
True if the volume was successfully ejected.
-
#enumerate_identifiers(volume) ⇒ Array<String>
An array of strings containing kinds of identifiers.
-
#get_activation_root(volume) ⇒ Gio::File
The activation root of volume or nil.
-
#get_drive(volume) ⇒ Gio::Drive
A #GDrive or nil if volume is not associated with a drive.
-
#get_icon(volume) ⇒ Gio::Icon
A #GIcon.
-
#get_identifier(volume, kind) ⇒ String
A newly allocated string containing the requested identifier, or nil if the #GVolume doesn’t have this kind of identifier.
-
#get_mount(volume) ⇒ Gio::Mount
A #GMount or nil if volume isn’t mounted.
-
#get_name(volume) ⇒ String
The name for the given volume.
-
#get_sort_key(volume) ⇒ String
Sorting key for volume or nil if no such key is available.
-
#get_symbolic_icon(volume) ⇒ Gio::Icon
A #GIcon.
-
#get_uuid(volume) ⇒ String
The UUID for volume or nil if no UUID can be computed.
-
#icon ⇒ Gio::Icon
Gets the icon for volume.
-
#mount(flags, mount_operation, cancellable, callback, user_data) ⇒ nil
Mounts a volume.
-
#mount_finish(volume, result) ⇒ TrueClass
True, false if operation failed.
- #mount_fn(volume, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
-
#name ⇒ String
Gets the name of volume.
- #removed(volume) ⇒ nil
-
#should_automount(volume) ⇒ TrueClass
True if the volume should be automatically mounted.
-
#sort_key ⇒ String
Gets the sort key for volume, if any.
-
#symbolic_icon ⇒ Gio::Icon
Gets the symbolic icon for volume.
-
#uuid ⇒ String
Gets the UUID for the volume.
Instance Method Details
#activation_root ⇒ Gio::File
Gets the activation root for a #GVolume if it is known ahead of mount time. Returns nil otherwise. If not nil and if volume is mounted, then the result of g_mount_get_root() on the #GMount object obtained from g_volume_get_mount() will always either be equal or a prefix of what this function returns. In other words, in code
(g_file_has_prefix (volume_activation_root, mount_root) ||
g_file_equal (volume_activation_root, mount_root))
will always be true.
Activation roots are typically used in GVolume::Monitor implementations to find the underlying mount to shadow, see g_mount_is_shadowed() for more details.
#can_eject(volume) ⇒ TrueClass
Returns true if the volume can be ejected. false otherwise.
#can_mount(volume) ⇒ TrueClass
Returns true if the volume can be mounted. false otherwise.
#changed(volume) ⇒ nil
#drive ⇒ Gio::Drive
Gets the drive for the volume.
#eject(volume, flags, cancellable, callback, user_data) ⇒ nil
#eject_finish(volume, result) ⇒ TrueClass
Returns true, false if operation failed.
#eject_with_operation(volume, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#eject_with_operation_finish(volume, result) ⇒ TrueClass
Returns true if the volume was successfully ejected. false otherwise.
#enumerate_identifiers(volume) ⇒ Array<String>
Returns an array of strings containing kinds of identifiers. Use g_strfreev() to free.
#get_activation_root(volume) ⇒ Gio::File
Returns the activation root of volume or nil. Use g_object_unref() to free.
#get_drive(volume) ⇒ Gio::Drive
Returns a #GDrive or nil if volume is not associated with a drive. The returned object should be unreffed with g_object_unref() when no longer needed.
#get_icon(volume) ⇒ Gio::Icon
Returns a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.
#get_identifier(volume, kind) ⇒ String
Returns a newly allocated string containing the requested identifier, or nil if the #GVolume doesn’t have this kind of identifier.
#get_mount(volume) ⇒ Gio::Mount
Returns a #GMount or nil if volume isn’t mounted. The returned object should be unreffed with g_object_unref() when no longer needed.
#get_name(volume) ⇒ String
Returns the name for the given volume. The returned string should be freed with g_free() when no longer needed.
#get_sort_key(volume) ⇒ String
Returns Sorting key for volume or nil if no such key is available.
#get_symbolic_icon(volume) ⇒ Gio::Icon
Returns a #GIcon. The returned object should be unreffed with g_object_unref() when no longer needed.
#get_uuid(volume) ⇒ String
Returns the UUID for volume or nil if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.
#icon ⇒ Gio::Icon
Gets the icon for volume.
#mount(flags, mount_operation, cancellable, callback, user_data) ⇒ nil
Mounts a volume. This is an asynchronous operation, and is finished by calling g_volume_mount_finish() with the volume and GAsync::Result returned in the callback.
#mount_finish(volume, result) ⇒ TrueClass
Returns true, false if operation failed.
#mount_fn(volume, flags, mount_operation, cancellable, callback, user_data) ⇒ nil
#name ⇒ String
Gets the name of volume.
#removed(volume) ⇒ nil
#should_automount(volume) ⇒ TrueClass
Returns true if the volume should be automatically mounted.
#sort_key ⇒ String
Gets the sort key for volume, if any.
#symbolic_icon ⇒ Gio::Icon
Gets the symbolic icon for volume.
#uuid ⇒ String
Gets the UUID for the volume. The reference is typically based on the file system UUID for the volume in question and should be considered an opaque string. Returns nil if there is no UUID available.