Gio.VolumeMonitor

g GObject.Object GObject.Object Gio.VolumeMonitor Gio.VolumeMonitor GObject.Object->Gio.VolumeMonitor

Subclasses:

Gio.NativeVolumeMonitor

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

adopt_orphan_mount (mount)

class

get ()

get_connected_drives ()

get_mount_for_uuid (uuid)

get_mounts ()

get_volume_for_uuid (uuid)

get_volumes ()

Virtual Methods

Inherited:

GObject.Object (7)

do_drive_changed (drive)

do_drive_connected (drive)

do_drive_disconnected (drive)

do_drive_eject_button (drive)

do_drive_stop_button (drive)

do_get_connected_drives ()

do_get_mount_for_uuid (uuid)

do_get_mounts ()

do_get_volume_for_uuid (uuid)

do_get_volumes ()

do_mount_added (mount)

do_mount_changed (mount)

do_mount_pre_unmount (mount)

do_mount_removed (mount)

do_volume_added (volume)

do_volume_changed (volume)

do_volume_removed (volume)

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

drive-changed

Emitted when a drive changes.

drive-connected

Emitted when a drive is connected to the system.

drive-disconnected

Emitted when a drive is disconnected from the system.

drive-eject-button

Emitted when the eject button is pressed on drive.

drive-stop-button

Emitted when the stop button is pressed on drive.

mount-added

Emitted when a mount is added.

mount-changed

Emitted when a mount changes.

mount-pre-unmount

May be emitted when a mount is about to be removed.

mount-removed

Emitted when a mount is removed.

volume-added

Emitted when a mountable volume is added to the system.

volume-changed

Emitted when mountable volume is changed.

volume-removed

Emitted when a mountable volume is removed from the system.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

priv

object

r

Class Details

class Gio.VolumeMonitor(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gio.VolumeMonitorClass

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 [method`GLib`.MainContext.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.

classmethod adopt_orphan_mount(mount)[source]
Parameters:

mount (Gio.Mount) – a Gio.Mount object to find a parent for

Returns:

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

Return type:

Gio.Volume

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

Deprecated since version 2.20: Instead of using this function, 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 Gio.Mount.is_shadowed(), Gio.Mount.shadow() and Gio.Mount.unshadow() functions.

classmethod get()[source]
Returns:

a reference to the Gio.VolumeMonitor used by gio. Call GObject.Object.unref() when done with it.

Return type:

Gio.VolumeMonitor

Gets the volume monitor used by gio.

get_connected_drives()[source]
Returns:

a GLib.List of connected Gio.Drive objects.

Return type:

[Gio.Drive]

Gets a list of drives connected to the system.

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

get_mount_for_uuid(uuid)[source]
Parameters:

uuid (str) – the UUID to look for

Returns:

a Gio.Mount or None if no such mount is available. Free the returned object with GObject.Object.unref().

Return type:

Gio.Mount or None

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

get_mounts()[source]
Returns:

a GLib.List of Gio.Mount objects.

Return type:

[Gio.Mount]

Gets a list of the mounts on the system.

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

get_volume_for_uuid(uuid)[source]
Parameters:

uuid (str) – the UUID to look for

Returns:

a Gio.Volume or None if no such volume is available. Free the returned object with GObject.Object.unref().

Return type:

Gio.Volume or None

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

get_volumes()[source]
Returns:

a GLib.List of Gio.Volume objects.

Return type:

[Gio.Volume]

Gets a list of the volumes on the system.

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

do_drive_changed(drive) virtual
Parameters:

drive (Gio.Drive) –

do_drive_connected(drive) virtual
Parameters:

drive (Gio.Drive) –

do_drive_disconnected(drive) virtual
Parameters:

drive (Gio.Drive) –

do_drive_eject_button(drive) virtual
Parameters:

drive (Gio.Drive) –

do_drive_stop_button(drive) virtual
Parameters:

drive (Gio.Drive) –

do_get_connected_drives() virtual
Returns:

a GLib.List of connected Gio.Drive objects.

Return type:

[Gio.Drive]

Gets a list of drives connected to the system.

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

do_get_mount_for_uuid(uuid) virtual
Parameters:

uuid (str) – the UUID to look for

Returns:

a Gio.Mount or None if no such mount is available. Free the returned object with GObject.Object.unref().

Return type:

Gio.Mount or None

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

do_get_mounts() virtual
Returns:

a GLib.List of Gio.Mount objects.

Return type:

[Gio.Mount]

Gets a list of the mounts on the system.

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

do_get_volume_for_uuid(uuid) virtual
Parameters:

uuid (str) – the UUID to look for

Returns:

a Gio.Volume or None if no such volume is available. Free the returned object with GObject.Object.unref().

Return type:

Gio.Volume or None

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

do_get_volumes() virtual
Returns:

a GLib.List of Gio.Volume objects.

Return type:

[Gio.Volume]

Gets a list of the volumes on the system.

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

do_mount_added(mount) virtual
Parameters:

mount (Gio.Mount) –

do_mount_changed(mount) virtual
Parameters:

mount (Gio.Mount) –

do_mount_pre_unmount(mount) virtual
Parameters:

mount (Gio.Mount) –

do_mount_removed(mount) virtual
Parameters:

mount (Gio.Mount) –

do_volume_added(volume) virtual
Parameters:

volume (Gio.Volume) –

do_volume_changed(volume) virtual
Parameters:

volume (Gio.Volume) –

do_volume_removed(volume) virtual
Parameters:

volume (Gio.Volume) –

Signal Details

Gio.VolumeMonitor.signals.drive_changed(volume_monitor, drive)
Signal Name:

drive-changed

Flags:

RUN_LAST

Parameters:

Emitted when a drive changes.

Gio.VolumeMonitor.signals.drive_connected(volume_monitor, drive)
Signal Name:

drive-connected

Flags:

RUN_LAST

Parameters:

Emitted when a drive is connected to the system.

Gio.VolumeMonitor.signals.drive_disconnected(volume_monitor, drive)
Signal Name:

drive-disconnected

Flags:

RUN_LAST

Parameters:

Emitted when a drive is disconnected from the system.

Gio.VolumeMonitor.signals.drive_eject_button(volume_monitor, drive)
Signal Name:

drive-eject-button

Flags:

RUN_LAST

Parameters:
  • volume_monitor (Gio.VolumeMonitor) – The object which received the signal

  • drive (Gio.Drive) – the drive where the eject button was pressed

Emitted when the eject button is pressed on drive.

New in version 2.18.

Gio.VolumeMonitor.signals.drive_stop_button(volume_monitor, drive)
Signal Name:

drive-stop-button

Flags:

RUN_LAST

Parameters:
  • volume_monitor (Gio.VolumeMonitor) – The object which received the signal

  • drive (Gio.Drive) – the drive where the stop button was pressed

Emitted when the stop button is pressed on drive.

New in version 2.22.

Gio.VolumeMonitor.signals.mount_added(volume_monitor, mount)
Signal Name:

mount-added

Flags:

RUN_LAST

Parameters:

Emitted when a mount is added.

Gio.VolumeMonitor.signals.mount_changed(volume_monitor, mount)
Signal Name:

mount-changed

Flags:

RUN_LAST

Parameters:

Emitted when a mount changes.

Gio.VolumeMonitor.signals.mount_pre_unmount(volume_monitor, mount)
Signal Name:

mount-pre-unmount

Flags:

RUN_LAST

Parameters:

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.

Gio.VolumeMonitor.signals.mount_removed(volume_monitor, mount)
Signal Name:

mount-removed

Flags:

RUN_LAST

Parameters:

Emitted when a mount is removed.

Gio.VolumeMonitor.signals.volume_added(volume_monitor, volume)
Signal Name:

volume-added

Flags:

RUN_LAST

Parameters:

Emitted when a mountable volume is added to the system.

Gio.VolumeMonitor.signals.volume_changed(volume_monitor, volume)
Signal Name:

volume-changed

Flags:

RUN_LAST

Parameters:

Emitted when mountable volume is changed.

Gio.VolumeMonitor.signals.volume_removed(volume_monitor, volume)
Signal Name:

volume-removed

Flags:

RUN_LAST

Parameters:

Emitted when a mountable volume is removed from the system.