Gio.VolumeMonitor.adopt_orphan_mount

function adopt_orphan_mount(mount: Gio.Mount): Gio.Volume {
    // Gjs wrapper for g_volume_monitor_adopt_orphan_mount()
}
  

This function should be called by any Gio.VolumeMonitor implementation when a new Gio.Mount object is created that is not associated with a Gio.Volume object. It must be called just before emitting the @mount_added signal.

If the return value is not null, the caller must associate the returned Gio.Volume object with the Gio.Mount. This involves returning it in its Gio.Mount.prototype.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

Similary, if implementing Gio.VolumeMonitor.adopt_orphan_mount, the implementor must take a reference to mount and return it in its Gio.Volume.prototype.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 Gio.Mount object that needs to be associated with the Gio.Volume object that represents the volume.

The other is for implementing a Gio.VolumeMonitor whose sole purpose is to return Gio.Volume objects representing entries in the users "favorite servers" list or similar.

mount

a Gio.Mount object to find a parent for

Returns

the Gio.Volume object that is the parent for mount or null if no wants to adopt the Gio.Mount.