:right-sidebar: True VolumeMonitor =================================================================== .. currentmodule:: gi.repository.Gio .. class:: VolumeMonitor(*args, **kwargs) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gio.NativeVolumeMonitor` ``GVolumeMonitor`` 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. ``GVolumeMonitor`` is not thread-default-context aware (see :obj:`~gi.repository.GLib.MainContext.push_thread_default`), and so should not be used other than from the main thread, with no thread-default-context active. In order to receive updates about volumes and mounts monitored through GVFS, a main loop must be running. Methods ------- .. rst-class:: interim-class .. class:: VolumeMonitor :no-index: .. classmethod:: adopt_orphan_mount() -> ~gi.repository.Gio.Volume This function should be called by any :obj:`~gi.repository.Gio.VolumeMonitor` implementation when a new :obj:`~gi.repository.Gio.Mount` object is created that is not associated with a :obj:`~gi.repository.Gio.Volume` object. It must be called just before emitting the ``mount_added`` signal. If the return value is not :const:`None`, the caller must associate the returned :obj:`~gi.repository.Gio.Volume` object with the :obj:`~gi.repository.Gio.Mount`. This involves returning it in its :func:`~gi.repository.Gio.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 Similarly, if implementing :func:`~gi.repository.Gio.VolumeMonitor.adopt_orphan_mount`, the implementor must take a reference to ``mount`` and return it in its :func:`~gi.repository.Gio.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 :obj:`~gi.repository.Gio.Mount` object that needs to be associated with the :obj:`~gi.repository.Gio.Volume` object that represents the volume. The other is for implementing a :obj:`~gi.repository.Gio.VolumeMonitor` whose sole purpose is to return :obj:`~gi.repository.Gio.Volume` objects representing entries in the users "favorite servers" list or similar. .. deprecated:: 2.20 Instead of using this function, :obj:`~gi.repository.Gio.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 :func:`~gi.repository.Gio.Mount.is_shadowed`, :func:`~gi.repository.Gio.Mount.shadow` and :func:`~gi.repository.Gio.Mount.unshadow` functions. .. method:: do_drive_changed(self, drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_connected(self, drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_disconnected(self, drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_eject_button(self, drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_stop_button(self, drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_get_connected_drives(self) -> list[~gi.repository.Gio.Drive] .. method:: do_get_mount_for_uuid(self, uuid: str) -> ~gi.repository.Gio.Mount | None :param uuid: .. method:: do_get_mounts(self) -> list[~gi.repository.Gio.Mount] .. method:: do_get_volume_for_uuid(self, uuid: str) -> ~gi.repository.Gio.Volume | None :param uuid: .. method:: do_get_volumes(self) -> list[~gi.repository.Gio.Volume] .. method:: do_mount_added(self, mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_mount_changed(self, mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_mount_pre_unmount(self, mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_mount_removed(self, mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_volume_added(self, volume: ~gi.repository.Gio.Volume) -> None :param volume: .. method:: do_volume_changed(self, volume: ~gi.repository.Gio.Volume) -> None :param volume: .. method:: do_volume_removed(self, volume: ~gi.repository.Gio.Volume) -> None :param volume: .. classmethod:: get() -> ~gi.repository.Gio.VolumeMonitor Gets the volume monitor used by gio. .. method:: get_connected_drives() -> list[~gi.repository.Gio.Drive] Gets a list of drives connected to the system. The returned list should be freed with :func:`~gi.repository.GLib.List.free`, after its elements have been unreffed with :func:`~gi.repository.GObject.GObject.Object.unref`. .. method:: get_mount_for_uuid(uuid: str) -> ~gi.repository.Gio.Mount | None Finds a :obj:`~gi.repository.Gio.Mount` object by its UUID (see :func:`~gi.repository.Gio.Mount.get_uuid`) :param uuid: the UUID to look for .. method:: get_mounts() -> list[~gi.repository.Gio.Mount] Gets a list of the mounts on the system. The returned list should be freed with :func:`~gi.repository.GLib.List.free`, after its elements have been unreffed with :func:`~gi.repository.GObject.GObject.Object.unref`. .. method:: get_volume_for_uuid(uuid: str) -> ~gi.repository.Gio.Volume | None Finds a :obj:`~gi.repository.Gio.Volume` object by its UUID (see :func:`~gi.repository.Gio.Volume.get_uuid`) :param uuid: the UUID to look for .. method:: get_volumes() -> list[~gi.repository.Gio.Volume] Gets a list of the volumes on the system. The returned list should be freed with :func:`~gi.repository.GLib.List.free`, after its elements have been unreffed with :func:`~gi.repository.GObject.GObject.Object.unref`. Signals ------- .. rst-class:: interim-class .. class:: VolumeMonitor.signals :no-index: .. method:: drive_changed(drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param drive: the drive that changed .. method:: drive_connected(drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param drive: a :obj:`~gi.repository.Gio.Drive` that was connected. .. method:: drive_disconnected(drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param drive: a :obj:`~gi.repository.Gio.Drive` that was disconnected. .. method:: drive_eject_button(drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. .. versionadded:: 2.18 :param drive: the drive where the eject button was pressed .. method:: drive_stop_button(drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. .. versionadded:: 2.22 :param drive: the drive where the stop button was pressed .. method:: mount_added(mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param mount: a :obj:`~gi.repository.Gio.Mount` that was added. .. method:: mount_changed(mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param mount: a :obj:`~gi.repository.Gio.Mount` that changed. .. method:: mount_pre_unmount(mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param mount: a :obj:`~gi.repository.Gio.Mount` that is being unmounted. .. method:: mount_removed(mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param mount: a :obj:`~gi.repository.Gio.Mount` that was removed. .. method:: volume_added(volume: ~gi.repository.Gio.Volume) -> None The type of the None singleton. :param volume: a :obj:`~gi.repository.Gio.Volume` that was added. .. method:: volume_changed(volume: ~gi.repository.Gio.Volume) -> None The type of the None singleton. :param volume: a :obj:`~gi.repository.Gio.Volume` that changed. .. method:: volume_removed(volume: ~gi.repository.Gio.Volume) -> None The type of the None singleton. :param volume: a :obj:`~gi.repository.Gio.Volume` that was removed. Virtual Methods --------------- .. rst-class:: interim-class .. class:: VolumeMonitor :no-index: .. method:: do_drive_changed(type, self, drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param type: :param self: :param drive: .. method:: do_drive_connected(type, self, drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param type: :param self: :param drive: .. method:: do_drive_disconnected(type, self, drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param type: :param self: :param drive: .. method:: do_drive_eject_button(type, self, drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param type: :param self: :param drive: .. method:: do_drive_stop_button(type, self, drive: ~gi.repository.Gio.Drive) -> None The type of the None singleton. :param type: :param self: :param drive: .. method:: do_get_connected_drives(type, self) -> list[~gi.repository.Gio.Drive] Gets a list of drives connected to the system. The returned list should be freed with :func:`~gi.repository.GLib.List.free`, after its elements have been unreffed with :func:`~gi.repository.GObject.GObject.Object.unref`. :param type: :param self: .. method:: do_get_mount_for_uuid(type, self, uuid: str) -> ~gi.repository.Gio.Mount | None Finds a :obj:`~gi.repository.Gio.Mount` object by its UUID (see :func:`~gi.repository.Gio.Mount.get_uuid`) :param type: :param self: :param uuid: the UUID to look for .. method:: do_get_mounts(type, self) -> list[~gi.repository.Gio.Mount] Gets a list of the mounts on the system. The returned list should be freed with :func:`~gi.repository.GLib.List.free`, after its elements have been unreffed with :func:`~gi.repository.GObject.GObject.Object.unref`. :param type: :param self: .. method:: do_get_volume_for_uuid(type, self, uuid: str) -> ~gi.repository.Gio.Volume | None Finds a :obj:`~gi.repository.Gio.Volume` object by its UUID (see :func:`~gi.repository.Gio.Volume.get_uuid`) :param type: :param self: :param uuid: the UUID to look for .. method:: do_get_volumes(type, self) -> list[~gi.repository.Gio.Volume] Gets a list of the volumes on the system. The returned list should be freed with :func:`~gi.repository.GLib.List.free`, after its elements have been unreffed with :func:`~gi.repository.GObject.GObject.Object.unref`. :param type: :param self: .. method:: do_mount_added(type, self, mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param type: :param self: :param mount: .. method:: do_mount_changed(type, self, mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param type: :param self: :param mount: .. method:: do_mount_pre_unmount(type, self, mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param type: :param self: :param mount: .. method:: do_mount_removed(type, self, mount: ~gi.repository.Gio.Mount) -> None The type of the None singleton. :param type: :param self: :param mount: .. method:: do_volume_added(type, self, volume: ~gi.repository.Gio.Volume) -> None The type of the None singleton. :param type: :param self: :param volume: .. method:: do_volume_changed(type, self, volume: ~gi.repository.Gio.Volume) -> None The type of the None singleton. :param type: :param self: :param volume: .. method:: do_volume_removed(type, self, volume: ~gi.repository.Gio.Volume) -> None The type of the None singleton. :param type: :param self: :param volume: Fields ------ .. rst-class:: interim-class .. class:: VolumeMonitor :no-index: .. attribute:: parent_instance .. attribute:: priv