Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login


module GLib::Volume

The GLib::Volume interface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS, GLib::Volume is the moral equivalent of GnomeVFS::Drive.

Mounting a GLib::Volume instance is an asynchronous operation. For more information about asynchronous operations, see GLib::AsyncReady? and GLib::SimpleAsyncReady?. To mount a GLib::Volume, first call Glib::Volume#mount, optionally with a GLib::MountOperation object and a block.

Typically, one will only want to pass nil for the GLib::MountOperation 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::AsyncReady? object will be passed to the callback. That callback should then call GLib::Volume#mount_finish with the GLib::Volume instance and the GLib::AsyncReady? data to see if the operation was completed successfully. If an error is present when GLib::Volume#mount_finish is called, then it will be raised.

It is sometimes necessary to directly access the underlying operating system object behind a volume (for example, 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 (for example, /dev/sda2), uuids. GIO uses predefind strings as names for the different kinds of identifiers: GLib::Volume::IDENTIFIER_KIND_HAL_UDI, GLib::Volume::IDENTIFIER_KIND_LABEL, etc. Use GLib::Volume#identifier to obtain an identifier for a volume.

Note that GLib::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 GLib::Volume#IDENTIFIER_KIND_UNIX_DEVICE identifier, which can be used to obtain a hal device by means of libhal_manger_find_device_string_match.

Instance Methods


Gets the activation root for this GLib::Volume if it is known ahead of mount time. Returns nil otherwise. If not nil and if the volume is mounted, then the result of GLib::Mount#root on the GLib::Mount object obtained from GLib::Volume#mount will always either be equal to or a prefix of what this function returns. In other words the code

volume.activation_root.has_prefix? mount.root or
  volume.activation_root == mount.root

will always be true.

Activation roots are typically used in GLib::VolumeMonitor implementations to find the underlying mount to shadow, see GLib::Mount#shadowed? for more details.

Since 2.18

Checks if a volume can be ejected.
Checks if a volume can be mounted.
  • Returns: true if the volume can be mounted
Gets the drive for a volume.
  • Returns: A GLib::Drive, or nil if the volume is not associated with a drive
eject_with_operation(flags = GLib::Mount::UNMOUNT_NONE, mount_operation = nil, cancellable = nil){ |result| }

Ejects a volume. This is an asynchronous operation, and is finished by calling GLib::Volume#eject_with_operation_finish.

Since 2.22


Finishes ejecting a volume.

A GLib::IO::Error is raised if this volume couldn’t be ejected.

Since 2.22

Same As GLib::Volume#identifiers.
Gets the identifier of the given kind for this volume. See the introduction for more information about volume identifiers.
  • kind: The kind of identifier to return
  • Returns: A String containing the requested identfier, or nil if the GLib::Volume doesn’t have this kind of identifier
Gets the icon for this volume.
Gets the kinds of identifiers that this volume has. Use GLib::Volume#get_identifier to obtain the identifiers themselves.
  • Returns: An Array of Strings containing the kinds of identifiers
mount(flags = GLib::Mount::MOUNT_NONE, mount_operation = nil, cancellable = nil){ |result| }
Mounts a volume. This is an asynchronous operation, and is finished by calling GLib::Volume#mount_finish in the block.

Finishes mounting a volume. If any errors occured during the operation, error will be set to contain the errors and false will be returned.

If the mount operation succeeded, GLib::Volume#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 GLib::VolumeMonitor.

Gets the name of this volume.
  • Returns: The name of this volume
Checks if the volume should be automatically mounted.
  • Returns: true if the volume should be automatically mounted
Gets the UUID for this 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.
  • Returns: The UUID for this volume, or nil if no UUID can be computed


The string used to obtain a Hal UDI with GLib::Volume#get_identifier.
The string used to obtain a filesystem label with GLib::Volume#get_identifier.
The string used to obtain a NFS mount with GLib::Volume#get_identifier.
The string used to obtain a Unix device path with GLib::Volume#get_identifier.
The string used to obtain a Unix device path with GLib::Volume#get_identifier.


changed: self
This signal is emitted when the volume has changed.
removed: self
This signal is emitted when the volume has been removed.
Last modified:2010/12/27 21:59:23
References:[index-ruby-glib2] [GLib::Mount] [Ruby/GIO] [GLib::Volume] [GLib::VolumeMonitor] [index-ruby-gio2] [GLib::Drive]