# Gio::VolumeMonitor Class Reference

Monitors a file or directory for changes. More...

`#include <giomm/volumemonitor.h>`

Inheritance diagram for Gio::VolumeMonitor:
[legend]

List of all members.

## Public Member Functions
virtual | ~VolumeMonitor ()
GVolumeMonitor* | gobj ()
| Provides access to the underlying C GObject.
const GVolumeMonitor* | gobj () const
| Provides access to the underlying C GObject.
GVolumeMonitor* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::ListHandle< Glib::RefPtr < Drive > > | get_connected_drives ()
| Gets a list of drives connected to the system.
Glib::ListHandle< Glib::RefPtr < Volume > > | get_volumes ()
| Gets a list of the volumes on the system.
Glib::ListHandle< Glib::RefPtr < Mount > > | get_mounts ()
| Gets a list of the mounts on the system.
Glib::RefPtr< Volume > | get_volume_for_uuid (const std::string& uuid)
| Finds a Volume object by its UUID (see g_volume_get_uuid()).
Glib::RefPtr< Mount > | get_mount_for_uuid (const std::string& uuid)
| Finds a Mount object by its UUID (see g_mount_get_uuid()).
Glib::SignalProxy1< void, const Glib::RefPtr< Volume >& > | signal_volume_added ()
Glib::SignalProxy1< void, const Glib::RefPtr< Volume >& > | signal_volume_removed ()
Glib::SignalProxy1< void, const Glib::RefPtr< Volume >& > | signal_volume_changed ()
Glib::SignalProxy1< void, const Glib::RefPtr< Mount >& > | signal_mount_added ()
Glib::SignalProxy1< void, const Glib::RefPtr< Mount >& > | signal_mount_removed ()
Glib::SignalProxy1< void, const Glib::RefPtr< Mount >& > | signal_mount_pre_unmount ()
Glib::SignalProxy1< void, const Glib::RefPtr< Mount >& > | signal_mount_changed ()
Glib::SignalProxy1< void, const Glib::RefPtr< Drive >& > | signal_drive_connected ()
Glib::SignalProxy1< void, const Glib::RefPtr< Drive >& > | signal_drive_disconnected ()
Glib::SignalProxy1< void, const Glib::RefPtr< Drive >& > | signal_drive_changed ()
Glib::SignalProxy1< void, const Glib::RefPtr< Drive >& > | signal_drive_eject_button ()
Glib::SignalProxy1< void, const Glib::RefPtr< Drive >& > | signal_drive_stop_button ()
## Static Public Member Functions
static Glib::RefPtr < VolumeMonitor > | get ()
| Gets the volume monitor used by gio.
static Glib::RefPtr< Volume > | adopt_orphan_mount (const Glib::RefPtr< Mount >& mount)
| This function should be called by any VolumeMonitor implementation when a new Mount object is created that is not associated with a Volume object.
## Public Attributes
gboolean(* | is_supported )(void)
## Protected Member Functions
virtual void | on_volume_added (const Glib::RefPtr< Volume >& volume)
virtual void | on_volume_removed (const Glib::RefPtr< Volume >& volume)
virtual void | on_volume_changed (const Glib::RefPtr< Volume >& volume)
virtual void | on_mount_added (const Glib::RefPtr< Mount >& mount)
virtual void | on_mount_removed (const Glib::RefPtr< Mount >& mount)
virtual void | on_mount_pre_unmount (const Glib::RefPtr< Mount >& mount)
virtual void | on_mount_changed (const Glib::RefPtr< Mount >& mount)
virtual void | on_drive_connected (const Glib::RefPtr< Drive >& drive)
virtual void | on_drive_disconnected (const Glib::RefPtr< Drive >& drive)
virtual void | on_drive_changed (const Glib::RefPtr< Drive >& drive)
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::VolumeMonitor > | wrap (GVolumeMonitor* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Monitors a file or directory for changes.

VolumeMonitor is for listing the user-interesting devices and volumes on the computer. In other words, what a file selector or file manager would show in a sidebar.

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::VolumeMonitor::~VolumeMonitor | ( |  | ) | `[virtual]`

## Member Function Documentation

static Glib::RefPtr<Volume> Gio::VolumeMonitor::adopt_orphan_mount | ( | const Glib::RefPtr< Mount >& | mount | ) | `[static]`

This function should be called by any VolumeMonitor implementation when a new Mount object is created that is not associated with a Volume object.

It must be called just before emitting the mount_added signal.

If the return value is not `0`, the caller must associate the returned Volume object with the Mount. This involves returning it in its g_mount_get_volume() implementation. The caller must also listen for the "removed" signal on the returned object and give up its reference when handling that signal

Similary, if implementing g_volume_monitor_adopt_orphan_mount(), the implementor must take a reference to mount and return it in its g_volume_get_mount() implemented. Also, the implementor must listen for the "unmounted" signal on mount and give up its reference upon handling that signal.

There are two main use cases for this function.

One is when implementing a user space file system driver that reads blocks of a block device that is already represented by the native volume monitor (for example a CD Audio file system driver). Such a driver will generate its own Mount object that needs to be assoicated with the Volume object that represents the volume.

The other is for implementing a VolumeMonitor whose sole purpose is to return Volume objects representing entries in the users "favorite servers" list or similar.

Parameters:

  | mount | A Mount object to find a parent for.

Returns:
  The Volume object that is the parent for mount or `0` if no wants to adopt the Mount.

Deprecated: 2.20: Instead of using this function, VolumeMonitor implementations should instead create shadow mounts with the URI of the mount they intend to adopt. See the proxy volume monitor in gvfs for an example of this. Also see g_mount_is_shadowed(), g_mount_shadow() and g_mount_unshadow() functions.

static Glib::RefPtr<VolumeMonitor> Gio::VolumeMonitor::get | ( |  | ) | `[static]`

Gets the volume monitor used by gio.

Returns:
  A reference to the VolumeMonitor used by gio. Call Glib::object_unref() when done with it.

Glib::ListHandle< Glib::RefPtr<Drive> > Gio::VolumeMonitor::get_connected_drives | ( |  | ) |

Gets a list of drives connected to the system.

The returned list should be freed with Glib::list_free(), after its elements have been unreffed with Glib::object_unref().

Returns:
  A List of connected Drive objects.

Glib::RefPtr<Mount> Gio::VolumeMonitor::get_mount_for_uuid | ( | const std::string & | uuid | ) |

Finds a Mount object by its UUID (see g_mount_get_uuid()).

Parameters:

  | uuid | The UUID to look for.

Returns:
  A Mount or `0` if no such mount is available. Free the returned object with Glib::object_unref().

Glib::ListHandle< Glib::RefPtr<Mount> > Gio::VolumeMonitor::get_mounts | ( |  | ) |

Gets a list of the mounts on the system.

The returned list should be freed with Glib::list_free(), after its elements have been unreffed with Glib::object_unref().

Returns:
  A List of Mount objects.

Glib::RefPtr<Volume> Gio::VolumeMonitor::get_volume_for_uuid | ( | const std::string & | uuid | ) |

Finds a Volume object by its UUID (see g_volume_get_uuid()).

Parameters:

  | uuid | The UUID to look for.

Returns:
  A Volume or `0` if no such volume is available. Free the returned object with Glib::object_unref().

Glib::ListHandle< Glib::RefPtr<Volume> > Gio::VolumeMonitor::get_volumes | ( |  | ) |

Gets a list of the volumes on the system.

The returned list should be freed with Glib::list_free(), after its elements have been unreffed with Glib::object_unref().

Returns:
  A List of Volume objects.

const GVolumeMonitor* Gio::VolumeMonitor::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GVolumeMonitor* Gio::VolumeMonitor::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GVolumeMonitor* Gio::VolumeMonitor::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

virtual void Gio::VolumeMonitor::on_drive_changed | ( | const Glib::RefPtr< Drive >& | drive | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_drive_connected | ( | const Glib::RefPtr< Drive >& | drive | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_drive_disconnected | ( | const Glib::RefPtr< Drive >& | drive | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_mount_added | ( | const Glib::RefPtr< Mount >& | mount | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_mount_changed | ( | const Glib::RefPtr< Mount >& | mount | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_mount_pre_unmount | ( | const Glib::RefPtr< Mount >& | mount | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_mount_removed | ( | const Glib::RefPtr< Mount >& | mount | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_volume_added | ( | const Glib::RefPtr< Volume >& | volume | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_volume_changed | ( | const Glib::RefPtr< Volume >& | volume | ) | `[protected, virtual]`

virtual void Gio::VolumeMonitor::on_volume_removed | ( | const Glib::RefPtr< Volume >& | volume | ) | `[protected, virtual]`

Glib::SignalProxy1< void,const Glib::RefPtr<Drive>& > Gio::VolumeMonitor::signal_drive_changed | ( |  | ) |

Prototype:
  `void on_my_drive_changed(const Glib::RefPtr<Drive>& drive)`

Glib::SignalProxy1< void,const Glib::RefPtr<Drive>& > Gio::VolumeMonitor::signal_drive_connected | ( |  | ) |

Prototype:
  `void on_my_drive_connected(const Glib::RefPtr<Drive>& drive)`

Glib::SignalProxy1< void,const Glib::RefPtr<Drive>& > Gio::VolumeMonitor::signal_drive_disconnected | ( |  | ) |

Prototype:
  `void on_my_drive_disconnected(const Glib::RefPtr<Drive>& drive)`

Glib::SignalProxy1< void,const Glib::RefPtr<Drive>& > Gio::VolumeMonitor::signal_drive_eject_button | ( |  | ) |

Prototype:
  `void on_my_drive_eject_button(const Glib::RefPtr<Drive>& drive)`

Glib::SignalProxy1< void,const Glib::RefPtr<Drive>& > Gio::VolumeMonitor::signal_drive_stop_button | ( |  | ) |

Prototype:
  `void on_my_drive_stop_button(const Glib::RefPtr<Drive>& drive)`

Glib::SignalProxy1< void,const Glib::RefPtr<Mount>& > Gio::VolumeMonitor::signal_mount_added | ( |  | ) |

Prototype:
  `void on_my_mount_added(const Glib::RefPtr<Mount>& mount)`

Glib::SignalProxy1< void,const Glib::RefPtr<Mount>& > Gio::VolumeMonitor::signal_mount_changed | ( |  | ) |

Prototype:
  `void on_my_mount_changed(const Glib::RefPtr<Mount>& mount)`

Glib::SignalProxy1< void,const Glib::RefPtr<Mount>& > Gio::VolumeMonitor::signal_mount_pre_unmount | ( |  | ) |

Prototype:
  `void on_my_mount_pre_unmount(const Glib::RefPtr<Mount>& mount)`

Glib::SignalProxy1< void,const Glib::RefPtr<Mount>& > Gio::VolumeMonitor::signal_mount_removed | ( |  | ) |

Prototype:
  `void on_my_mount_removed(const Glib::RefPtr<Mount>& mount)`

Glib::SignalProxy1< void,const Glib::RefPtr<Volume>& > Gio::VolumeMonitor::signal_volume_added | ( |  | ) |

Prototype:
  `void on_my_volume_added(const Glib::RefPtr<Volume>& volume)`

Glib::SignalProxy1< void,const Glib::RefPtr<Volume>& > Gio::VolumeMonitor::signal_volume_changed | ( |  | ) |

Prototype:
  `void on_my_volume_changed(const Glib::RefPtr<Volume>& volume)`

Glib::SignalProxy1< void,const Glib::RefPtr<Volume>& > Gio::VolumeMonitor::signal_volume_removed | ( |  | ) |

Prototype:
  `void on_my_volume_removed(const Glib::RefPtr<Volume>& volume)`

## Friends And Related Function Documentation

Glib::RefPtr< Gio::VolumeMonitor > wrap | ( | GVolumeMonitor * | 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.

## Member Data Documentation

gboolean(* Gio::VolumeMonitor::is_supported)(void)