glibmm 2.55.2

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::Volume Class Reference

The Volume interface represents user-visible objects that can be mounted. More...

`#include <giomm/volume.h>`

Inheritance diagram for Gio::Volume:
[legend]

## Public Member Functions
| Volume (Volume&& src) noexcept
Volume& | operator= (Volume&& src) noexcept
| ~Volume () noexcept override
GVolume* | gobj ()
| Provides access to the underlying C GObject. More...
const GVolume* | gobj () const
| Provides access to the underlying C GObject. More...
std::string | get_name () const
| Gets the name of volume. More...
std::string | get_uuid () const
| Gets the UUID for the volume. More...
Glib::RefPtr< Icon > | get_icon ()
| Gets the icon for volume. More...
Glib::RefPtr< const Icon > | get_icon () const
| Gets the icon for volume. More...
Glib::RefPtr< Icon > | get_symbolic_icon ()
| Gets the symbolic icon for volume. More...
Glib::RefPtr< const Icon > | get_symbolic_icon () const
| Gets the symbolic icon for volume. More...
Glib::RefPtr< Drive > | get_drive ()
| Gets the drive for the volume. More...
Glib::RefPtr< const Drive > | get_drive () const
| Gets the drive for the volume. More...
Glib::RefPtr< Mount > | get_mount ()
| Gets the mount for the volume. More...
Glib::RefPtr< const Mount > | get_mount () const
| Gets the mount for the volume. More...
bool | can_mount () const
| Checks if a volume can be mounted. More...
bool | can_eject () const
| Checks if a volume can be ejected. More...
bool | should_automount () const
| Returns whether the volume should be automatically mounted. More...
void | mount (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, Mount::MountFlags flags=Mount::MountFlags::NONE)
| Mounts a volume. More...
void | mount (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, Mount::MountFlags flags=Mount::MountFlags::NONE)
| Mounts a volume. More...
void | mount (const Glib::RefPtr< MountOperation >& mount_operation, Mount::MountFlags flags=Mount::MountFlags::NONE)
| Mounts a volume. More...
void | mount (Mount::MountFlags flags=Mount::MountFlags::NONE)
| Mounts a volume. More...
bool | mount_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes mounting a volume. More...
void | eject (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, Mount::UnmountFlags flags=Mount::UnmountFlags::NONE)
void | eject (const SlotAsyncReady& slot, Mount::UnmountFlags flags=Mount::UnmountFlags::NONE)
void | eject (Mount::UnmountFlags flags=Mount::UnmountFlags::NONE)
void | eject (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, Mount::UnmountFlags flags=Mount::UnmountFlags::NONE)
void | eject (const Glib::RefPtr< MountOperation >& mount_operation, const SlotAsyncReady& slot, Mount::UnmountFlags flags=Mount::UnmountFlags::NONE)
void | eject (const Glib::RefPtr< MountOperation >& mount_operation, Mount::UnmountFlags flags=Mount::UnmountFlags::NONE)
bool | eject_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes ejecting a volume. More...
std::string | get_identifier (const std::string& kind) const
| Gets the identifier of the given kind for volume. More...
std::vector< Glib::ustring > | enumerate_identifiers () const
| Gets the kinds of [identifiers][volume-identifier] that volume has. More...
Glib::RefPtr< File > | get_activation_root ()
| Gets the activation root for a Volume if it is known ahead of mount time. More...
Glib::RefPtr< const File > | get_activation_root () const
| Gets the activation root for a Volume if it is known ahead of mount time. More...
Glib::ustring | sort_key ()
| Gets the sort key for volume, if any. More...
Glib::SignalProxy< void()> | signal_changed ()
Glib::SignalProxy< void()> | signal_removed ()
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (Interface&& src) noexcept
Interface& | operator= (Interface&& src) noexcept
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
| ~Interface () noexcept override
| Interface (const Interface&)=delete
Interface& | operator= (const Interface&)=delete
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
PropertyType | get_property (const Glib::ustring& property_name) const
| You probably want to use a specific property_*() accessor method instead. More...
sigc::connection | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void()>& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void()>&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Member Functions
| Volume ()
| You should derive from this class to use it. More...
virtual void | on_changed ()
| This is a default handler for the signal signal_changed(). More...
virtual void | on_removed ()
| This is a default handler for the signal signal_removed(). More...
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::Volume > | wrap (GVolume* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Detailed Description

The Volume interface represents user-visible objects that can be mounted.

Mounting a Volume instance is an asynchronous operation. For more information about asynchronous operations, see AsyncReady and SimpleAsyncReady. To mount a GVolume, first call mount(), optionally providing a MountOperation object and a SlotAsyncReady callback.

Typically, you will not want to provide a 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 AsyncReady structure will be passed to the callback. That callback should then call g_volume_mount_finish() with the GVolume instance and the GAsyncReady data to see if the operation was completed successfully. If an error is present when finish() is called, then it will be filled with any error information.

Since glibmm 2.16:

## Constructor & Destructor Documentation

## ◆ Volume() [1/2]

Gio::Volume::Volume | ( |  | ) |
| protected

You should derive from this class to use it.

## ◆ Volume() [2/2]

Gio::Volume::Volume | ( | Volume&& | src | ) |
| noexcept

## ◆ ~Volume()

Gio::Volume::~Volume | ( |  | ) |
| override noexcept

## Member Function Documentation

## ◆ add_interface()

static void Gio::Volume::add_interface | ( | GType | gtype_implementer | ) |
| static

## ◆ can_eject()

bool Gio::Volume::can_eject | ( |  | ) | const

Checks if a volume can be ejected.

Returns
  `true` if the volume can be ejected. `false` otherwise.

## ◆ can_mount()

bool Gio::Volume::can_mount | ( |  | ) | const

Checks if a volume can be mounted.

Returns
  `true` if the volume can be mounted. `false` otherwise.

## ◆ eject() [1/6]

void Gio::Volume::eject | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | Mount::UnmountFlags | flags = `Mount::UnmountFlags::NONE`
| ) |  |

## ◆ eject() [2/6]

void Gio::Volume::eject | ( | const SlotAsyncReady& | slot,
|  | Mount::UnmountFlags | flags = `Mount::UnmountFlags::NONE`
| ) |  |

## ◆ eject() [3/6]

void Gio::Volume::eject | ( | Mount::UnmountFlags | flags = `Mount::UnmountFlags::NONE` | ) |

## ◆ eject() [4/6]

void Gio::Volume::eject | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | Mount::UnmountFlags | flags = `Mount::UnmountFlags::NONE`
| ) |  |

## ◆ eject() [5/6]

void Gio::Volume::eject | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | Mount::UnmountFlags | flags = `Mount::UnmountFlags::NONE`
| ) |  |

## ◆ eject() [6/6]

void Gio::Volume::eject | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | Mount::UnmountFlags | flags = `Mount::UnmountFlags::NONE`
| ) |  |

## ◆ eject_finish()

bool Gio::Volume::eject_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

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 glibmm 2.22:

Parameters

  result | A AsyncResult.

Returns
  `true` if the volume was successfully ejected. `false` otherwise.

Exceptions

  Glib::Error |

## ◆ enumerate_identifiers()

std::vector<Glib::ustring> Gio::Volume::enumerate_identifiers | ( |  | ) | const

Gets the kinds of [identifiers][volume-identifier] that volume has.

Use g_volume_get_identifier() to obtain the identifiers themselves.

Returns
  A `nullptr`-terminated array of strings containing kinds of identifiers.

## ◆ get_activation_root() [1/2]

Glib::RefPtr<File> Gio::Volume::get_activation_root | ( |  | ) |

Gets the activation root for a Volume if it is known ahead of mount time.

Returns `nullptr` otherwise. If not `nullptr` and if volume is mounted, then the result of g_mount_get_root() on the Mount 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

[C example ellipted] then the expression

[C example ellipted] will always be `true`.

Activation roots are typically used in VolumeMonitor implementations to find the underlying mount to shadow, see g_mount_is_shadowed() for more details.

Since glibmm 2.18:

Returns
  The activation root of volume or `nullptr`. Use Glib::object_unref() to free.

## ◆ get_activation_root() [2/2]

Glib::RefPtr<const File> Gio::Volume::get_activation_root | ( |  | ) | const

Gets the activation root for a Volume if it is known ahead of mount time.

Returns `nullptr` otherwise. If not `nullptr` and if volume is mounted, then the result of g_mount_get_root() on the Mount 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

[C example ellipted] then the expression

[C example ellipted] will always be `true`.

Activation roots are typically used in VolumeMonitor implementations to find the underlying mount to shadow, see g_mount_is_shadowed() for more details.

Since glibmm 2.18:

Returns
  The activation root of volume or `nullptr`. Use Glib::object_unref() to free.

## ◆ get_drive() [1/2]

Glib::RefPtr<Drive> Gio::Volume::get_drive | ( |  | ) |

Gets the drive for the volume.

Returns
  A Drive or `nullptr` if volume is not associated with a drive. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_drive() [2/2]

Glib::RefPtr<const Drive> Gio::Volume::get_drive | ( |  | ) | const

Gets the drive for the volume.

Returns
  A Drive or `nullptr` if volume is not associated with a drive. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_icon() [1/2]

Glib::RefPtr<Icon> Gio::Volume::get_icon | ( |  | ) |

Gets the icon for volume.

Returns
  A Icon. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_icon() [2/2]

Glib::RefPtr<const Icon> Gio::Volume::get_icon | ( |  | ) | const

Gets the icon for volume.

Returns
  A Icon. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_identifier()

std::string Gio::Volume::get_identifier | ( | const std::string & | kind | ) | const

Gets the identifier of the given kind for volume.

See the [introduction][volume-identifier] for more information about volume identifiers.

Parameters

  kind | The kind of identifier to return.

Returns
  A newly allocated string containing the requested identfier, or `nullptr` if the Volume doesn't have this kind of identifier.

## ◆ get_mount() [1/2]

Glib::RefPtr<Mount> Gio::Volume::get_mount | ( |  | ) |

Gets the mount for the volume.

Returns
  A Mount or `nullptr` if volume isn't mounted. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_mount() [2/2]

Glib::RefPtr<const Mount> Gio::Volume::get_mount | ( |  | ) | const

Gets the mount for the volume.

Returns
  A Mount or `nullptr` if volume isn't mounted. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_name()

std::string Gio::Volume::get_name | ( |  | ) | const

Gets the name of volume.

Returns
  The name for the given volume.

## ◆ get_symbolic_icon() [1/2]

Glib::RefPtr<Icon> Gio::Volume::get_symbolic_icon | ( |  | ) |

Gets the symbolic icon for volume.

Since glibmm 2.34:

Returns
  A Icon. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_symbolic_icon() [2/2]

Glib::RefPtr<const Icon> Gio::Volume::get_symbolic_icon | ( |  | ) | const

Gets the symbolic icon for volume.

Since glibmm 2.34:

Returns
  A Icon. The returned object should be unreffed with Glib::object_unref() when no longer needed.

## ◆ get_type()

static GType Gio::Volume::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ get_uuid()

std::string Gio::Volume::get_uuid | ( |  | ) | const

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 `nullptr` if there is no UUID available.

Returns
  The UUID for volume or `nullptr` if no UUID can be computed.

## ◆ gobj() [1/2]

GVolume* Gio::Volume::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GVolume* Gio::Volume::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ mount() [1/4]

void Gio::Volume::mount | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | Mount::MountFlags | flags = `Mount::MountFlags::NONE`
| ) |  |

Mounts a volume.

This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.

Parameters

  mount_operation | A mount operation.
  slot | A callback which will be called when the operation is completed or canceled.
  cancellable | A cancellable object which can be used to cancel the operation.
  flags | Flags affecting the operation.

## ◆ mount() [2/4]

void Gio::Volume::mount | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | const SlotAsyncReady& | slot,
|  | Mount::MountFlags | flags = `Mount::MountFlags::NONE`
| ) |  |

Mounts a volume.

This is an asynchronous operation, and is finished by calling mount_finish() with the AsyncResult data returned in the callback slot.

Parameters

  mount_operation | A mount operation.
  slot | A callback which will be called when the operation is completed or canceled.
  flags | Flags affecting the operation.

## ◆ mount() [3/4]

void Gio::Volume::mount | ( | const Glib::RefPtr< MountOperation >& | mount_operation,
|  | Mount::MountFlags | flags = `Mount::MountFlags::NONE`
| ) |  |

Mounts a volume.

Parameters

  mount_operation | A mount operation.
  flags | Flags affecting the operation.

## ◆ mount() [4/4]

void Gio::Volume::mount | ( | Mount::MountFlags | flags = `Mount::MountFlags::NONE` | ) |

Mounts a volume.

Parameters

  flags | Flags affecting the operation.

## ◆ mount_finish()

bool Gio::Volume::mount_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

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, g_volume_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 VolumeMonitor.

Parameters

  result | A AsyncResult.

Returns
  `true`, `false` if operation failed.

Exceptions

  Glib::Error |

## ◆ on_changed()

virtual void Gio::Volume::on_changed | ( |  | ) |
| protected virtual

This is a default handler for the signal signal_changed().

## ◆ on_removed()

virtual void Gio::Volume::on_removed | ( |  | ) |
| protected virtual

This is a default handler for the signal signal_removed().

## ◆ operator=()

Volume& Gio::Volume::operator= | ( | Volume&& | src | ) |
| noexcept

## ◆ should_automount()

bool Gio::Volume::should_automount | ( |  | ) | const

Returns whether the volume should be automatically mounted.

Returns
  `true` if the volume should be automatically mounted.

## ◆ signal_changed()

Glib::SignalProxy<void()> Gio::Volume::signal_changed | ( |  | ) |

Slot Prototype:
  `void on_my_changed()`

Flags: Run Last

Emitted when the volume has been changed.

## ◆ signal_removed()

Glib::SignalProxy<void()> Gio::Volume::signal_removed | ( |  | ) |

Slot Prototype:
  `void on_my_removed()`

Flags: Run Last

This signal is emitted when the Volume have been removed. If the recipient is holding references to the object they should release them so the object can be finalized.

## ◆ sort_key()

Glib::ustring Gio::Volume::sort_key | ( |  | ) |

Gets the sort key for volume, if any.

Since glibmm 2.32:

Returns
  Sorting key for volume or `nullptr` if no such key is available.

## Friends And Related Function Documentation

## ◆ wrap()

Glib::RefPtr< Gio::Volume > wrap | ( | GVolume * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.