VolumeMonitor#

class VolumeMonitor(*args, **kwargs)#

Superclasses: Object

Subclasses: 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 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#

class VolumeMonitor
adopt_orphan_mount(mount: Mount) Volume#

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 None, the caller must associate the returned Volume object with the Mount. This involves returning it in its 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 adopt_orphan_mount(), the implementor must take a reference to mount and return it in its 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 associated 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.

Deprecated since version 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 is_shadowed(), shadow() and unshadow() functions.

Parameters:

mount – a Mount object to find a parent for

get() VolumeMonitor#

Gets the volume monitor used by gio.

get_connected_drives() list[Drive]#

Gets a list of drives connected to the system.

The returned list should be freed with free(), after its elements have been unreffed with unref().

get_mount_for_uuid(uuid: str) Mount | None#

Finds a Mount object by its UUID (see get_uuid())

Parameters:

uuid – the UUID to look for

get_mounts() list[Mount]#

Gets a list of the mounts on the system.

The returned list should be freed with free(), after its elements have been unreffed with unref().

get_volume_for_uuid(uuid: str) Volume | None#

Finds a Volume object by its UUID (see get_uuid())

Parameters:

uuid – the UUID to look for

get_volumes() list[Volume]#

Gets a list of the volumes on the system.

The returned list should be freed with free(), after its elements have been unreffed with unref().

Signals#

class VolumeMonitor.signals
drive_changed(drive: Drive) None#

The type of the None singleton.

Parameters:

drive – the drive that changed

drive_connected(drive: Drive) None#

The type of the None singleton.

Parameters:

drive – a Drive that was connected.

drive_disconnected(drive: Drive) None#

The type of the None singleton.

Parameters:

drive – a Drive that was disconnected.

drive_eject_button(drive: Drive) None#

The type of the None singleton.

Added in version 2.18.

Parameters:

drive – the drive where the eject button was pressed

drive_stop_button(drive: Drive) None#

The type of the None singleton.

Added in version 2.22.

Parameters:

drive – the drive where the stop button was pressed

mount_added(mount: Mount) None#

The type of the None singleton.

Parameters:

mount – a Mount that was added.

mount_changed(mount: Mount) None#

The type of the None singleton.

Parameters:

mount – a Mount that changed.

mount_pre_unmount(mount: Mount) None#

The type of the None singleton.

Parameters:

mount – a Mount that is being unmounted.

mount_removed(mount: Mount) None#

The type of the None singleton.

Parameters:

mount – a Mount that was removed.

volume_added(volume: Volume) None#

The type of the None singleton.

Parameters:

volume – a Volume that was added.

volume_changed(volume: Volume) None#

The type of the None singleton.

Parameters:

volume – a Volume that changed.

volume_removed(volume: Volume) None#

The type of the None singleton.

Parameters:

volume – a Volume that was removed.

Virtual Methods#

class VolumeMonitor
do_drive_changed(drive: Drive) None#

The type of the None singleton.

Parameters:

drive

do_drive_connected(drive: Drive) None#

The type of the None singleton.

Parameters:

drive

do_drive_disconnected(drive: Drive) None#

The type of the None singleton.

Parameters:

drive

do_drive_eject_button(drive: Drive) None#

The type of the None singleton.

Parameters:

drive

do_drive_stop_button(drive: Drive) None#

The type of the None singleton.

Parameters:

drive

do_get_connected_drives() list[Drive]#

Gets a list of drives connected to the system.

The returned list should be freed with free(), after its elements have been unreffed with unref().

do_get_mount_for_uuid(uuid: str) Mount | None#

Finds a Mount object by its UUID (see get_uuid())

Parameters:

uuid – the UUID to look for

do_get_mounts() list[Mount]#

Gets a list of the mounts on the system.

The returned list should be freed with free(), after its elements have been unreffed with unref().

do_get_volume_for_uuid(uuid: str) Volume | None#

Finds a Volume object by its UUID (see get_uuid())

Parameters:

uuid – the UUID to look for

do_get_volumes() list[Volume]#

Gets a list of the volumes on the system.

The returned list should be freed with free(), after its elements have been unreffed with unref().

do_mount_added(mount: Mount) None#

The type of the None singleton.

Parameters:

mount

do_mount_changed(mount: Mount) None#

The type of the None singleton.

Parameters:

mount

do_mount_pre_unmount(mount: Mount) None#

The type of the None singleton.

Parameters:

mount

do_mount_removed(mount: Mount) None#

The type of the None singleton.

Parameters:

mount

do_volume_added(volume: Volume) None#

The type of the None singleton.

Parameters:

volume

do_volume_changed(volume: Volume) None#

The type of the None singleton.

Parameters:

volume

do_volume_removed(volume: Volume) None#

The type of the None singleton.

Parameters:

volume

Fields#

class VolumeMonitor
parent_instance#
priv#