: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` :Constructors: :: VolumeMonitor(**properties) Methods ------- .. rst-class:: interim-class .. class:: VolumeMonitor :no-index: .. method:: adopt_orphan_mount(mount: ~gi.repository.Gio.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. :param mount: a :obj:`~gi.repository.Gio.Mount` object to find a parent for .. method:: 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 Emitted when a drive changes. :param drive: the drive that changed .. method:: drive_connected(drive: ~gi.repository.Gio.Drive) -> None Emitted when a drive is connected to the system. :param drive: a :obj:`~gi.repository.Gio.Drive` that was connected. .. method:: drive_disconnected(drive: ~gi.repository.Gio.Drive) -> None Emitted when a drive is disconnected from the system. :param drive: a :obj:`~gi.repository.Gio.Drive` that was disconnected. .. method:: drive_eject_button(drive: ~gi.repository.Gio.Drive) -> None Emitted when the eject button is pressed on ``drive``. .. versionadded:: 2.18 :param drive: the drive where the eject button was pressed .. method:: drive_stop_button(drive: ~gi.repository.Gio.Drive) -> None Emitted when the stop button is pressed on ``drive``. .. versionadded:: 2.22 :param drive: the drive where the stop button was pressed .. method:: mount_added(mount: ~gi.repository.Gio.Mount) -> None Emitted when a mount is added. :param mount: a :obj:`~gi.repository.Gio.Mount` that was added. .. method:: mount_changed(mount: ~gi.repository.Gio.Mount) -> None Emitted when a mount changes. :param mount: a :obj:`~gi.repository.Gio.Mount` that changed. .. method:: mount_pre_unmount(mount: ~gi.repository.Gio.Mount) -> None May be emitted when a mount is about to be removed. This signal depends on the backend and is only emitted if GIO was used to unmount. :param mount: a :obj:`~gi.repository.Gio.Mount` that is being unmounted. .. method:: mount_removed(mount: ~gi.repository.Gio.Mount) -> None Emitted when a mount is removed. :param mount: a :obj:`~gi.repository.Gio.Mount` that was removed. .. method:: volume_added(volume: ~gi.repository.Gio.Volume) -> None Emitted when a mountable volume is added to the system. :param volume: a :obj:`~gi.repository.Gio.Volume` that was added. .. method:: volume_changed(volume: ~gi.repository.Gio.Volume) -> None Emitted when mountable volume is changed. :param volume: a :obj:`~gi.repository.Gio.Volume` that changed. .. method:: volume_removed(volume: ~gi.repository.Gio.Volume) -> None Emitted when a mountable volume is removed from the system. :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(drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_connected(drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_disconnected(drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_eject_button(drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_drive_stop_button(drive: ~gi.repository.Gio.Drive) -> None :param drive: .. method:: do_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:: do_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:: do_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:: do_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:: do_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`. .. method:: do_mount_added(mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_mount_changed(mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_mount_pre_unmount(mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_mount_removed(mount: ~gi.repository.Gio.Mount) -> None :param mount: .. method:: do_volume_added(volume: ~gi.repository.Gio.Volume) -> None :param volume: .. method:: do_volume_changed(volume: ~gi.repository.Gio.Volume) -> None :param volume: .. method:: do_volume_removed(volume: ~gi.repository.Gio.Volume) -> None :param volume: Fields ------ .. rst-class:: interim-class .. class:: VolumeMonitor :no-index: .. attribute:: parent_instance .. attribute:: priv