VolumeMonitor
- class VolumeMonitor(*args, **kwargs)
Superclasses: Object
Subclasses: NativeVolumeMonitor
- Constructors:
VolumeMonitor(**properties)
Methods
- class VolumeMonitor
- adopt_orphan_mount(mount: Mount) Volume
This function should be called by any
VolumeMonitor
implementation when a newMount
object is created that is not associated with aVolume
object. It must be called just before emitting themount_added
signal.If the return value is not
None
, the caller must associate the returnedVolume
object 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 tomount
and return it in itsget_mount()
implemented. Also, the implementor must listen for the “unmounted” signal onmount
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 theVolume
object that represents the volume.The other is for implementing a
VolumeMonitor
whose sole purpose is to returnVolume
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 seeis_shadowed()
,shadow()
andunshadow()
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 withunref()
.
- get_mount_for_uuid(uuid: str) Mount | None
Finds a
Mount
object 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
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.
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
Mount
object 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
Volume
object by its UUID (seeget_uuid()
)- Parameters:
uuid – the UUID to look for