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
- classmethod adopt_orphan_mount(mount: Mount) Volume#
This function should be called by any
VolumeMonitorimplementation when a newMountobject is created that is not associated with aVolumeobject. It must be called just before emitting themount_addedsignal.If the return value is not
None, the caller must associate the returnedVolumeobject with theMount. This involves returning it in itsget_volume()implementation. The caller must also listen for the “removed” signal on the returned object and give up its reference when handling that signalSimilarly, if implementing
adopt_orphan_mount(), the implementor must take a reference tomountand return it in itsget_mount()implemented. Also, the implementor must listen for the “unmounted” signal onmountand 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
Mountobject that needs to be associated with theVolumeobject that represents the volume.The other is for implementing a
VolumeMonitorwhose sole purpose is to returnVolumeobjects representing entries in the users “favorite servers” list or similar.Deprecated since version 2.20: Instead of using this function,
VolumeMonitorimplementations 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 seeis_shadowed(),shadow()andunshadow()functions.- Parameters:
mount – a
Mountobject to find a parent for
- classmethod 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 withunref().
- get_mount_for_uuid(uuid: str) Mount | None#
Finds a
Mountobject by its UUID (seeget_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 withunref().
Signals#
- class VolumeMonitor.signals
- drive_changed(drive: Drive) None#
Emitted when a drive changes.
- Parameters:
drive – the drive that changed
- drive_connected(drive: Drive) None#
Emitted when a drive is connected to the system.
- Parameters:
drive – a
Drivethat was connected.
- drive_disconnected(drive: Drive) None#
Emitted when a drive is disconnected from the system.
- Parameters:
drive – a
Drivethat was disconnected.
- drive_eject_button(drive: Drive) None#
Emitted when the eject button is pressed on
drive.Added in version 2.18.
- Parameters:
drive – the drive where the eject button was pressed
- drive_stop_button(drive: Drive) None#
Emitted when the stop button is pressed on
drive.Added in version 2.22.
- Parameters:
drive – the drive where the stop button was pressed
- mount_added(mount: Mount) None#
Emitted when a mount is added.
- Parameters:
mount – a
Mountthat was added.
- mount_changed(mount: Mount) None#
Emitted when a mount changes.
- Parameters:
mount – a
Mountthat changed.
- mount_pre_unmount(mount: 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.
- Parameters:
mount – a
Mountthat is being unmounted.
- mount_removed(mount: Mount) None#
Emitted when a mount is removed.
- Parameters:
mount – a
Mountthat was removed.
- volume_added(volume: Volume) None#
Emitted when a mountable volume is added to the system.
- Parameters:
volume – a
Volumethat was added.
Virtual Methods#
- class VolumeMonitor
-
- 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 withunref().
- do_get_mount_for_uuid(uuid: str) Mount | None#
Finds a
Mountobject by its UUID (seeget_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 withunref().
- do_get_volume_for_uuid(uuid: str) Volume | None#
Finds a
Volumeobject by its UUID (seeget_uuid())- Parameters:
uuid – the UUID to look for