The Glib.GVolumes.Gvolume interface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS, Glib.GVolumes.Gvolume is the moral equivalent of Gnome_VFSDrive.
Mounting a Glib.GVolumes.Gvolume instance is an asynchronous operation. For more information about asynchronous operations, see Glib.G_Async_Result and Gtask.Gtask. To mount a Glib.GVolumes.Gvolume, first call Glib.GVolumes.Mount with (at least) the Glib.GVolumes.Gvolume instance, optionally a Glib.GMountOperations.Gmount_Operation object and a Gasync_Ready_Callback.
Typically, one will only want to pass null for the Glib.GMountOperations.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 Glib.G_Async_Result instance will be passed to the callback. That callback should then call Glib.GVolumes.Mount_Finish with the Glib.GVolumes.Gvolume instance and the Glib.G_Async_Result data to see if the operation was completed successfully. If an Error is present when Glib.GVolumes.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 Glib.GVolumes.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.
function "+" (W : Gvolume) return Gvolume
function Can_Eject (Self : Gvolume) return Boolean
Checks if a volume can be ejected.
True if the Volume can be ejected. False otherwise
function Can_Mount (Self : Gvolume) return Boolean
Checks if a volume can be mounted.
True if the Volume can be mounted. False otherwise
type Cb_GObject_Void is not null access procedure
(Self : access Glib.Object.GObject_Record'Class);
type Cb_Gvolume_Void is not null access procedure (Self : Gvolume);
function Convert (R : Glib.GVolumes.Gvolume) return System.Address
function Convert (R : System.Address) return Glib.GVolumes.Gvolume
procedure Eject_With_Operation
(Self : Gvolume;
Flags : Glib.GEnums.GMount_Unmount_Flags;
Mount_Operation : access Glib.GMountOperations.Gmount_Operation_Record'Class;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
Ejects a volume. This is an asynchronous operation, and is finished by calling Glib.GVolumes.Eject_With_Operation_Finish with the Volume and Glib.G_Async_Result data returned in the Callback. Since: gtk+ 2.22
flags affecting the unmount if required for eject
a Glib.GMountOperations.Gmount_Operation or null to avoid user interaction
optional Glib.Cancellable.Gcancellable object, null to ignore
a Gasync_Ready_Callback, or null
function Eject_With_Operation_Finish
(Self : Gvolume;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Boolean
Finishes ejecting a volume. If any errors occurred during the operation, Error will be set to contain the errors and False will be returned. Since: gtk+ 2.22
a Glib.G_Async_Result
the return location for a recoverable error
True if the volume was successfully ejected. False otherwise
function Enumerate_Identifiers
(Self : Gvolume) return GNAT.Strings.String_List
Gets the kinds of [identifiers][volume-identifier] that Volume has. Use Glib.GVolumes.Get_Identifier to obtain the identifiers themselves.
a null-terminated array of strings containing kinds of identifiers. Use g_strfreev to free.
type Gasync_Ready_Callback is access procedure
(Source_Object : access Glib.Object.GObject_Record'Class;
Res : Glib.G_Async_Result);
Type definition for a function that will be called back when an asynchronous operation within GIO has been completed. Gasync_Ready_Callback callbacks from Gtask.Gtask are guaranteed to be invoked in a later iteration of the thread-default main context (see [methodGlib.MainContext.push_thread_default]) where the Gtask.Gtask was created. All other users of Gasync_Ready_Callback must likewise call it asynchronously in a later iteration of the main context. The asynchronous operation is guaranteed to have held a reference to Source_Object from the time when the *_async function was called, until after this callback returns.
the object the asynchronous operation was started with.
a Glib.G_Async_Result.
function Get_Activation_Root (Self : Gvolume) return Glib.GFile.Gfile
Gets the activation root for a Glib.GVolumes.Gvolume if it is known ahead of mount time. Returns null otherwise. If not null and if Volume is mounted, then the result of Glib.GMounts.Get_Root on the Glib.GMounts.Gmount object obtained from Glib.GVolumes.Get_Mount will always either be equal or a prefix of what this function returns. In other words, in code
GMount *mount;
GFile *mount_root
GFile *volume_activation_root;
mount = g_volume_get_mount (volume); // mounted, so never NULL
mount_root = g_mount_get_root (mount);
volume_activation_root = g_volume_get_activation_root (volume); // assume not NULL
then the expression
(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.Gvolume_Monitor implementations to find the underlying mount to shadow, see Glib.GMounts.Is_Shadowed for more details. Since: gtk+ 2.18
the activation root of Volume or null. Use g_object_unref to free.
function Get_Drive (Self : Gvolume) return Glib.GDrives.Gdrive
Gets the drive for the Volume.
a Glib.GDrives.Gdrive or null if Volume is not associated with a drive. The returned object should be unreffed with g_object_unref when no longer needed.
function Get_Icon (Self : Gvolume) return Glib.G_Icon.G_Icon
Gets the icon for Volume.
a Glib.G_Icon.G_Icon. The returned object should be unreffed with g_object_unref when no longer needed.
function Get_Identifier
(Self : Gvolume;
Kind : UTF8_String) return UTF8_String
Gets the identifier of the given kind for Volume. See the [introduction][volume-identifier] for more information about volume identifiers.
the kind of identifier to return
a newly allocated string containing the requested identifier, or null if the Glib.GVolumes.Gvolume doesn't have this kind of identifier
function Get_Mount (Self : Gvolume) return Glib.GMounts.Gmount
Gets the mount for the Volume.
a Glib.GMounts.Gmount or null if Volume isn't mounted. The returned object should be unreffed with g_object_unref when no longer needed.
function Get_Name (Self : Gvolume) return UTF8_String
Gets the name of Volume.
the name for the given Volume. The returned string should be freed with g_free when no longer needed.
function Get_Sort_Key (Self : Gvolume) return UTF8_String
Gets the sort key for Volume, if any. Since: gtk+ 2.32
Sorting key for Volume or null if no such key is available
function Get_Symbolic_Icon (Self : Gvolume) return Glib.G_Icon.G_Icon
Gets the symbolic icon for Volume. Since: gtk+ 2.34
a Glib.G_Icon.G_Icon. The returned object should be unreffed with g_object_unref when no longer needed.
function Get_Type return Glib.GType
function Get_Uuid (Self : Gvolume) return UTF8_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 null if there is no UUID available.
the UUID for Volume or null if no UUID can be computed. The returned string should be freed with g_free when no longer needed.
type Gvolume is new Glib.Types.GType_Interface;
subtype GVolume_GList is GVolume_List.GList;
package GVolume_List is new Generic_List (Glib.GVolumes.Gvolume);
subtype GVolumes_Interface_Descr is Glib.Object.Interface_Description;
procedure Mount
(Self : Gvolume;
Flags : Glib.GEnums.GMount_Mount_Flags;
Mount_Operation : access Glib.GMountOperations.Gmount_Operation_Record'Class;
Cancellable : access Glib.Cancellable.Gcancellable_Record'Class;
Callback : Gasync_Ready_Callback)
Mounts a volume. This is an asynchronous operation, and is finished by calling Glib.GVolumes.Mount_Finish with the Volume and Glib.G_Async_Result returned in the Callback.
flags affecting the operation
a Glib.GMountOperations.Gmount_Operation or null to avoid user interaction
optional Glib.Cancellable.Gcancellable object, null to ignore
a Gasync_Ready_Callback, or null
function Mount_Finish
(Self : Gvolume;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Boolean
Finishes mounting a volume. If any errors occurred during the operation, Error will be set to contain the errors and False will be returned. If the mount operation succeeded, Glib.GVolumes.Get_Mount on Volume is guaranteed to return the mount right after calling this function; there's no need to listen for the 'mount-added' signal on Gvolume.Monitor.Gvolume_Monitor.
a Glib.G_Async_Result
the return location for a recoverable error
True, False if operation failed
Null_Gvolume : constant Gvolume;
procedure On_Changed
(Self : Gvolume;
Call : Cb_GObject_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
Emitted when the volume has been changed.
procedure On_Changed
(Self : Gvolume;
Call : Cb_Gvolume_Void;
After : Boolean := False)
Emitted when the volume has been changed.
procedure On_Removed
(Self : Gvolume;
Call : Cb_GObject_Void;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False)
This signal is emitted when the Glib.GVolumes.Gvolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
procedure On_Removed
(Self : Gvolume;
Call : Cb_Gvolume_Void;
After : Boolean := False)
This signal is emitted when the Glib.GVolumes.Gvolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
procedure Set_Can_Eject
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Can_Eject)
procedure Set_Can_Mount
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Can_Mount)
procedure Set_Changed
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Changed)
procedure Set_Eject_With_Operation
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Eject_With_Operation)
procedure Set_Eject_With_Operation_Finish
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Eject_With_Operation_Finish)
procedure Set_Enumerate_Identifiers
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Enumerate_Identifiers)
procedure Set_Get_Activation_Root
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Activation_Root)
procedure Set_Get_Drive
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Drive)
procedure Set_Get_Icon
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Icon)
procedure Set_Get_Identifier
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Identifier)
procedure Set_Get_Mount
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Mount)
procedure Set_Get_Name
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Name)
procedure Set_Get_Sort_Key
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Sort_Key)
procedure Set_Get_Symbolic_Icon
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Symbolic_Icon)
procedure Set_Get_Uuid
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Get_Uuid)
procedure Set_Mount_Finish
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Mount_Finish)
procedure Set_Mount_Fn
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Mount_Fn)
procedure Set_Removed
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Removed)
procedure Set_Should_Automount
(Self : GVolumes_Interface_Descr;
Handler : Virtual_Should_Automount)
See Glib.Object.Add_Interface
function Should_Automount (Self : Gvolume) return Boolean
Returns whether the volume should be automatically mounted.
True if the volume should be automatically mounted
Signal_Changed : constant Glib.Signal_Name := "changed";
Emitted when the volume has been changed.
Signal_Removed : constant Glib.Signal_Name := "removed";
This signal is emitted when the Glib.GVolumes.Gvolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
type Virtual_Can_Eject is access function (Self : Gvolume) return Glib.Gboolean;
Checks if a volume can be ejected.
True if the Volume can be ejected. False otherwise
type Virtual_Can_Mount is access function (Self : Gvolume) return Glib.Gboolean;
Checks if a volume can be mounted.
True if the Volume can be mounted. False otherwise
type Virtual_Changed is access procedure (Self : Gvolume);
Changed signal that is emitted when the volume's state has changed.
type Virtual_Eject_With_Operation is access procedure
(Self : Gvolume;
Flags : Glib.GEnums.GMount_Unmount_Flags;
Mount_Operation : System.Address;
Cancellable : System.Address;
Callback : System.Address;
User_Data : System.Address);
Ejects a volume. This is an asynchronous operation, and is finished by calling Glib.GVolumes.Eject_With_Operation_Finish with the Volume and Glib.G_Async_Result data returned in the Callback. Since: gtk+ 2.22
flags affecting the unmount if required for eject
a Glib.GMountOperations.Gmount_Operation or null to avoid user interaction
optional Glib.Cancellable.Gcancellable object, null to ignore
a Gasync_Ready_Callback, or null
user data passed to Callback
type Virtual_Eject_With_Operation_Finish is access function
(Self : Gvolume;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Glib.Gboolean;
Finishes ejecting a volume. If any errors occurred during the operation, Error will be set to contain the errors and False will be returned. Since: gtk+ 2.22
a Glib.G_Async_Result
the return location for a recoverable error
True if the volume was successfully ejected. False otherwise
type Virtual_Enumerate_Identifiers is access function (Self : Gvolume) return chars_ptr_array_access;
Gets the kinds of [identifiers][volume-identifier] that Volume has. Use Glib.GVolumes.Get_Identifier to obtain the identifiers themselves.
a null-terminated array of strings containing kinds of identifiers. Use g_strfreev to free.
type Virtual_Get_Activation_Root is access function (Self : Gvolume) return Glib.GFile.Gfile;
Gets the activation root for a Glib.GVolumes.Gvolume if it is known ahead of mount time. Returns null otherwise. If not null and if Volume is mounted, then the result of Glib.GMounts.Get_Root on the Glib.GMounts.Gmount object obtained from Glib.GVolumes.Get_Mount will always either be equal or a prefix of what this function returns. In other words, in code
GMount *mount;
GFile *mount_root
GFile *volume_activation_root;
mount = g_volume_get_mount (volume); // mounted, so never NULL
mount_root = g_mount_get_root (mount);
volume_activation_root = g_volume_get_activation_root (volume); // assume not NULL
then the expression
(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.Gvolume_Monitor implementations to find the underlying mount to shadow, see Glib.GMounts.Is_Shadowed for more details. Since: gtk+ 2.18
the activation root of Volume or null. Use g_object_unref to free.
type Virtual_Get_Drive is access function (Self : Gvolume) return Glib.GDrives.Gdrive;
Gets the drive for the Volume.
a Glib.GDrives.Gdrive or null if Volume is not associated with a drive. The returned object should be unreffed with g_object_unref when no longer needed.
type Virtual_Get_Icon is access function (Self : Gvolume) return Glib.G_Icon.G_Icon;
Gets the icon for Volume.
a Glib.G_Icon.G_Icon. The returned object should be unreffed with g_object_unref when no longer needed.
type Virtual_Get_Identifier is access function
(Self : Gvolume;
Kind : Gtkada.Types.Chars_Ptr) return Gtkada.Types.Chars_Ptr;
Gets the identifier of the given kind for Volume. See the [introduction][volume-identifier] for more information about volume identifiers.
the kind of identifier to return
a newly allocated string containing the requested identifier, or null if the Glib.GVolumes.Gvolume doesn't have this kind of identifier
type Virtual_Get_Mount is access function (Self : Gvolume) return Glib.GMounts.Gmount;
Gets the mount for the Volume.
a Glib.GMounts.Gmount or null if Volume isn't mounted. The returned object should be unreffed with g_object_unref when no longer needed.
type Virtual_Get_Name is access function (Self : Gvolume) return Gtkada.Types.Chars_Ptr;
Gets the name of Volume.
the name for the given Volume. The returned string should be freed with g_free when no longer needed.
type Virtual_Get_Sort_Key is access function (Self : Gvolume) return Gtkada.Types.Chars_Ptr;
Gets the sort key for Volume, if any. Since: gtk+ 2.32
Sorting key for Volume or null if no such key is available
type Virtual_Get_Symbolic_Icon is access function (Self : Gvolume) return Glib.G_Icon.G_Icon;
Gets the symbolic icon for Volume. Since: gtk+ 2.34
a Glib.G_Icon.G_Icon. The returned object should be unreffed with g_object_unref when no longer needed.
type Virtual_Get_Uuid is access function (Self : Gvolume) return Gtkada.Types.Chars_Ptr;
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 null if there is no UUID available.
the UUID for Volume or null if no UUID can be computed. The returned string should be freed with g_free when no longer needed.
type Virtual_Mount_Finish is access function
(Self : Gvolume;
Result : Glib.G_Async_Result;
Error : out Glib.Error.GError) return Glib.Gboolean;
Finishes mounting a volume. If any errors occurred during the operation, Error will be set to contain the errors and False will be returned. If the mount operation succeeded, Glib.GVolumes.Get_Mount on Volume is guaranteed to return the mount right after calling this function; there's no need to listen for the 'mount-added' signal on Gvolume.Monitor.Gvolume_Monitor.
a Glib.G_Async_Result
the return location for a recoverable error
True, False if operation failed
type Virtual_Mount_Fn is access procedure
(Self : Gvolume;
Flags : Glib.GEnums.GMount_Mount_Flags;
Mount_Operation : System.Address;
Cancellable : System.Address;
Callback : System.Address;
User_Data : System.Address);
Mounts a volume. This is an asynchronous operation, and is finished by calling Glib.GVolumes.Mount_Finish with the Volume and Glib.G_Async_Result returned in the Callback.
flags affecting the operation
a Glib.GMountOperations.Gmount_Operation or null to avoid user interaction
optional Glib.Cancellable.Gcancellable object, null to ignore
a Gasync_Ready_Callback, or null
user data that gets passed to Callback
type Virtual_Removed is access procedure (Self : Gvolume);
The removed signal that is emitted when the Glib.GVolumes.Gvolume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.
type Virtual_Should_Automount is access function (Self : Gvolume) return Glib.Gboolean;
Returns whether the volume should be automatically mounted.
True if the volume should be automatically mounted