gio.VolumeMonitor
Prev | PyGio Class Reference | Next

## gio.VolumeMonitor

gio.VolumeMonitor — Volume Monitor.

## Synopsis

    class gio.VolumeMonitor(gobject.GObject):
        def get_connected_drives()
        def get_mount_for_uuid(uuid)
        def get_mounts()
        def get_volume_for_uuid(uuid)
        def get_volumes()

    Functions
        def gio.volume_monitor_adopt_orphan_mount()
        def gio.volume_monitor_get()

## Ancestry

    +-- gobject.GObject
      +-- gio.VolumeMonitor

## gio.VolumeMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"drive-changed" | `def callback(`volume_monitor`, `drive`, `user_param1`, `...`)`
"drive-connected" | `def callback(`volume_monitor`, `drive`, `user_param1`, `...`)`
"drive-disconnected" | `def callback(`volume_monitor`, `drive`, `user_param1`, `...`)`
"drive-eject-button" | `def callback(`volume_monitor`, `drive`, `user_param1`, `...`)`
"mount-added" | `def callback(`volume_monitor`, `mount`, `user_param1`, `...`)`
"mount-changed" | `def callback(`volume_monitor`, `mount`, `user_param1`, `...`)`
"mount-pre-unmount" | `def callback(`volume_monitor`, `mount`, `user_param1`, `...`)`
"mount-removed" | `def callback(`volume_monitor`, `mount`, `user_param1`, `...`)`
"volume-added" | `def callback(`volume_monitor`, `volume`, `user_param1`, `...`)`
"volume-changed" | `def callback(`volume_monitor`, `volume`, `user_param1`, `...`)`
"volume-removed" | `def callback(`volume_monitor`, `volume`, `user_param1`, `...`)`

## Description

The `gio.VolumeMonitor` 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.

## Methods

### gio.VolumeMonitor.get_connected_drives

        def get_connected_drives()

Returns : | a list of connected `gio.Drive` objects.

The `get_connected_drives`() method gets a list of drives connected to the system.

### gio.VolumeMonitor.get_mount_for_uuid

        def get_mount_for_uuid(uuid)

`uuid` : | The UUID to look for.
Returns : | A `gio.Mount` or `None` if no such mount is available.

The `get_mount_for_uuid`() method finds a `gio.Mount` object by it's UUID (see `gio.Mount.get_uuid`())

### gio.VolumeMonitor.get_mounts

        def get_mounts()

Returns : | A list of `gio.Mount` objects.

The `get_mounts`() method gets a list of the mounts on the system.

### gio.VolumeMonitor.get_volume_for_uuid

        def get_volume_for_uuid(uuid)

`uuid` : | The UUID to look for.
Returns : | A `gio.Volume` or `None` if no such volume is available.

The `get_mount_for_uuid`() method finds a `gio.Mount` object by it's UUID (see `gio.Mount.get_uuid`())

### gio.VolumeMonitor.get_volumes

        def get_volumes()

Returns : | A list of `gio.Volume` objects.

The `get_volumes`() method gets a list of the volumes on the system.

## Functions

### gio.volume_monitor_adopt_orphan_mount

        def volume_monitor_adopt_orphan_mount()

Returns : | The `gio.Volume` object that is the parent for mount or `None` if no wants to adopt the `gio.Mount`.

### Warning

This method will be deprecated starting from GIO 2.20

The `volume_monitor_adopt_orphan_mount`() 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 it's `gio.Mount.get_volumes`() implementation. The caller must also listen for the "removed" signal on the returned object and give up it's reference when handling that signal

Similary, if implementing `gio.volume_monitor_adopt_orphan_mount`(), the implementor must take a reference to mount and return it in it's `gio.Volume.get_mount`() implemented. Also, the implementor must listen for the "unmounted" signal on mount and give up it's 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 it's own `gio.Mount` object that needs to be assoicated 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.

### gio.volume_monitor_get

        def volume_monitor_get()

Returns : | A reference to the `gio.VolumeMonitor` used by gio.

The `volume_monitor_get`() function gets the volume monitor used by gio.

## Signals

### The "drive-changed" gio.Volume Signal

        def callback(volume_monitor, drive, user_param1, ...)

`volume_monitor` : | the volume monitor
`drive` : | the drive that changed
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a drive changes.

### The "drive-connected" gio.Volume Signal

        def callback(volume_monitor, drive, user_param1, ...)

`volume_monitor` : | the volume monitor
`drive` : | the drive that was connected
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a drive is connected to the system.

### The "drive-disconnected" gio.Volume Signal

        def callback(volume_monitor, drive, user_param1, ...)

`volume_monitor` : | the volume monitor
`drive` : | the drive that was disconnected
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a drive is disconnected from the system.

### The "drive-eject-button" gio.Volume Signal

        def callback(volume_monitor, drive, user_param1, ...)

`volume_monitor` : | the volume monitor
`drive` : | the drive where the eject button was pressed
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when the eject button is pressed on drive.

### The "mount-added" gio.Volume Signal

        def callback(volume, mount, user_param1, ...)

`volume_monitor` : | the volume monitor
`mount` : | a Mount that was added.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a mount is added.

### The "mount-changed" gio.Volume Signal

        def callback(volume_monitor, mount, user_param1, ...)

`volume_monitor` : | the volume monitor
`mount` : | the Mount that changed.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a mount changes.

### The "mount-pre-unmount" gio.Volume Signal

        def callback(volume_monitor, mount, user_param1, ...)

`volume_monitor` : | the volume monitor
`mount` : | the Mount that is being unmounted.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a mount is about to be removed.

### The "mount-removed" gio.Volume Signal

        def callback(volume_monitor, mount, user_param1, ...)

`volume_monitor` : | the volume monitor
`mount` : | the Mount that was removed.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a mount is removed.

### The "volume-added" gio.Volume Signal

        def callback(volume_monitor, volume, user_param1, ...)

`volume_monitor` : | the volume monitor
`volume` : | a Volume that was added.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a mountable volume is added to the system.

### The "volume-changed" gio.Volume Signal

        def callback(volume_monitor, volume, user_param1, ...)

`volume_monitor` : | the volume monitor
`volume` : | a Volume that changed.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when mountable volume is changed.

### The "volume-removed" gio.Volume Signal

        def callback(volume_monitor, volume, user_param1, ...)

`volume_monitor` : | the volume monitor
`volume` : | a Volume that was removed.
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

Emitted when a mountable volume is removed from the system.

Prev | Up | Next
gio.Volume | Home | gio Functions