## MateVFSVolumeMonitor MateVFSVolumeMonitor — Monitors volume mounts and unmounts |

## Synopsis

    #define             MATE_IS_VFS_VOLUME_MONITOR         (o)
    #define             MATE_IS_VFS_VOLUME_MONITOR_CLASS   (k)
    #define             MATE_VFS_TYPE_VOLUME_MONITOR
    #define             MATE_VFS_VOLUME_MONITOR            (o)
    #define             MATE_VFS_VOLUME_MONITOR_CLASS      (k)
    struct              MateVFSVolumeMonitor;
    struct              MateVFSVolumeMonitorClass;
    MateVFSVolumeMonitor * mate_vfs_get_volume_monitor    (void);
    GList *             mate_vfs_volume_monitor_get_connected_drives
                                                            (MateVFSVolumeMonitor *volume_monitor);
    MateVFSDrive *     mate_vfs_volume_monitor_get_drive_by_id
                                                            (MateVFSVolumeMonitor *volume_monitor,
                                                             gulong id);
    GList *             mate_vfs_volume_monitor_get_mounted_volumes
                                                            (MateVFSVolumeMonitor *volume_monitor);
    GType               mate_vfs_volume_monitor_get_type   (void);
    MateVFSVolume *    mate_vfs_volume_monitor_get_volume_by_id
                                                            (MateVFSVolumeMonitor *volume_monitor,
                                                             gulong id);
    MateVFSVolume *    mate_vfs_volume_monitor_get_volume_for_path
                                                            (MateVFSVolumeMonitor *volume_monitor,
                                                             const char *path);
    MateVFSVolumeMonitor * mate_vfs_volume_monitor_ref    (MateVFSVolumeMonitor *volume_monitor);
    void                mate_vfs_volume_monitor_unref      (MateVFSVolumeMonitor *volume_monitor);

## Object Hierarchy

      GObject
       +----MateVFSVolumeMonitor

## Signals

      "drive-connected"                                : Run First
      "drive-disconnected"                             : Run First
      "volume-mounted"                                 : Run First
      "volume-pre-unmount"                             : Run First
      "volume-unmounted"                               : Run First

## Description

## Details

### MATE_IS_VFS_VOLUME_MONITOR()

    #define MATE_IS_VFS_VOLUME_MONITOR(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_VFS_TYPE_VOLUME_MONITOR))

`o` : |

### MATE_IS_VFS_VOLUME_MONITOR_CLASS()

    #define MATE_IS_VFS_VOLUME_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MATE_VFS_TYPE_VOLUME_MONITOR))

`k` : |

### MATE_VFS_TYPE_VOLUME_MONITOR

    #define MATE_VFS_TYPE_VOLUME_MONITOR        (mate_vfs_volume_monitor_get_type ())

### MATE_VFS_VOLUME_MONITOR()

    #define MATE_VFS_VOLUME_MONITOR(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_VFS_TYPE_VOLUME_MONITOR, MateVFSVolumeMonitor))

`o` : |

### MATE_VFS_VOLUME_MONITOR_CLASS()

    #define MATE_VFS_VOLUME_MONITOR_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), MATE_VFS_TYPE_VOLUME_MONITOR, MateVFSVolumeMonitorClass))

`k` : |

### struct MateVFSVolumeMonitor

    struct MateVFSVolumeMonitor;

### struct MateVFSVolumeMonitorClass

    struct MateVFSVolumeMonitorClass {
    	GObjectClass parent_class;

    	/* signals */
    	void (* volume_mounted)	  	(MateVFSVolumeMonitor *volume_monitor,
    				   	 MateVFSVolume	       *volume);
    	void (* volume_pre_unmount) (MateVFSVolumeMonitor *volume_monitor,
    				   	 MateVFSVolume	       *volume);
    	void (* volume_unmounted) (MateVFSVolumeMonitor *volume_monitor,
    				   	 MateVFSVolume	       *volume);
    	void (* drive_connected) 	(MateVFSVolumeMonitor *volume_monitor,
    				   	 MateVFSDrive	       *drive);
    	void (* drive_disconnected) (MateVFSVolumeMonitor *volume_monitor,
    				   	 MateVFSDrive         *drive);
    };

### mate_vfs_get_volume_monitor ()

    MateVFSVolumeMonitor * mate_vfs_get_volume_monitor    (void);

Returns a pointer to the MateVFSVolumeMonitor singleton. MateVFSVolumeMonitor is a singleton, this means it is guaranteed to exist and be valid until `mate_vfs_shutdown()` is called. Consequently, it doesn't need to be refcounted since mate-vfs will hold a reference to it until it is shut down.

Returns : | a pointer to the MateVFSVolumeMonitor singleton.

Since 2.6

### mate_vfs_volume_monitor_get_connected_drives ()

    GList *             mate_vfs_volume_monitor_get_connected_drives
                                                            (MateVFSVolumeMonitor *volume_monitor);

Returns a GList of all drives connected to the machine. The MateVFSDrive objects must be unreffed by the caller when no longer needed with `mate_vfs_drive_unref()` and the GList must be freed.

`volume_monitor` : | a MateVFSVolumeMonitor.
Returns : | a GList of all connected drives.

Since 2.6

### mate_vfs_volume_monitor_get_drive_by_id ()

    MateVFSDrive *     mate_vfs_volume_monitor_get_drive_by_id
                                                            (MateVFSVolumeMonitor *volume_monitor,
                                                             gulong id);

Looks for a MateVFSDrive whose id is `id`. A valid `volume_monitor` to pass to this function can be acquired using `mate_vfs_get_volume_monitor()`

`volume_monitor` : | a MateVFSVolumeMonitor.
`id` : | the MateVFSVolume id to look for.
Returns : | the MateVFSDrive corresponding to `id`, or `NULL` if no MateVFSDrive with a matching id could be found. The caller owns a reference on the returned drive, and must call `mate_vfs_drive_unref()` when it no longer needs it.

Since 2.6

### mate_vfs_volume_monitor_get_mounted_volumes ()

    GList *             mate_vfs_volume_monitor_get_mounted_volumes
                                                            (MateVFSVolumeMonitor *volume_monitor);

Gets the list of all the mounted MateVFSVolume volumes.

`volume_monitor` : | a MateVFSVolumeMonitor.
Returns : | GList of MateVFSVolume. The MateVFSVolume objects must be unreffed by the caller when no longer needed with `mate_vfs_volume_unref()` and the GList must be freed.

Since 2.6

### mate_vfs_volume_monitor_get_type ()

    GType               mate_vfs_volume_monitor_get_type   (void);

Returns : |

### mate_vfs_volume_monitor_get_volume_by_id ()

    MateVFSVolume *    mate_vfs_volume_monitor_get_volume_by_id
                                                            (MateVFSVolumeMonitor *volume_monitor,
                                                             gulong id);

Looks for a MateVFSVolume whose id is `id`. A valid `volume_monitor` to pass to this function can be acquired using `mate_vfs_get_volume_monitor()`.

`volume_monitor` : | a MateVFSVolumeMonitor.
`id` : | MateVFSVolume id to look for.
Returns : | the MateVFSVolume corresponding to `id`, or `NULL` if no MateVFSVolume with a matching id could be found. The caller owns a reference on the returned volume, and must call `mate_vfs_volume_unref()` when it no longer needs it.

Since 2.6

### mate_vfs_volume_monitor_get_volume_for_path ()

    MateVFSVolume *    mate_vfs_volume_monitor_get_volume_for_path
                                                            (MateVFSVolumeMonitor *volume_monitor,
                                                             const char *path);

Returns the MateVFSVolume corresponding to `path`, or `NULL`.

The volume referring to `path` is found by calling `stat` on `path`, and then iterating through the list of volumes that refer to currently mounted local file systems. The first volume in this list maching the `path`'s UNIX device is returned.

If the `stat` on `path` was not successful, or no volume matches `path`, or `NULL` is returned.

`volume_monitor` : | a MateVFSVolumeMonitor.
`path` : | string representing a path.
Returns : | the MateVFSVolume corresponding to the `path`, or `NULL`. Volume returned must be unreffed by the caller with `mate_vfs_volume_unref()`.

Since 2.6

### mate_vfs_volume_monitor_ref ()

    MateVFSVolumeMonitor * mate_vfs_volume_monitor_ref    (MateVFSVolumeMonitor *volume_monitor);

Increases the refcount of `volume_monitor` by one, if it is not `NULL`.

You shouldn't use this function unless you know what you are doing: MateVFSVolumeMonitor is to be used as a singleton object, see `mate_vfs_get_volume_monitor()` for more details.

`volume_monitor` : | the MateVFSVolumeMonitor, or `NULL`.
Returns : | `volume_monitor` with its refcount increased by one, or `NULL` if `volume_monitor` is `NULL`.

Since 2.6

### mate_vfs_volume_monitor_unref ()

    void                mate_vfs_volume_monitor_unref      (MateVFSVolumeMonitor *volume_monitor);

Decreases the refcount of `volume_monitor` by one, if it is not `NULL`.

You shouldn't use this function unless you know what you are doing: MateVFSVolumeMonitor is to be used as a singleton object, see `mate_vfs_get_volume_monitor()` for more details.

`volume_monitor` : | MateVFSVolumeMonitor, or `NULL`.

Since 2.6

## Signal Details

### The `"drive-connected"` signal

    void                user_function                      (MateVFSVolumeMonitor *volume_monitor,
                                                            MateVFSDrive         *drive,
                                                            gpointer               user_data)           : Run First

This signal is emitted when the MateVFSDrive `drive` has been connected.

When the `drive` is connected, it is present in the `volume_monitor`'s list of connected drives, which can be queried using `mate_vfs_volume_monitor_get_connected_drives()`.

`volume_monitor` : | the MateVFSVolumeMonitor which received the signal.
`drive` : | the MateVFSDrive that has been connected.
`user_data` : | user data set when the signal handler was connected.

### The `"drive-disconnected"` signal

    void                user_function                      (MateVFSVolumeMonitor *volume_monitor,
                                                            MateVFSDrive         *drive,
                                                            gpointer               user_data)           : Run First

This signal is emitted after the MateVFSDrive `drive` has been disconnected.

When the `drive` is disconnected, it is removed from the `volume_monitor`'s list of connected drives, which can be queried using `mate_vfs_volume_monitor_get_connected_drives()`.

`volume_monitor` : | the MateVFSVolumeMonitor which received the signal.
`drive` : | the MateVFSDrive that has been disconnected.
`user_data` : | user data set when the signal handler was connected.

### The `"volume-mounted"` signal

    void                user_function                      (MateVFSVolumeMonitor *volume_monitor,
                                                            MateVFSVolume        *volume,
                                                            gpointer               user_data)           : Run First

This signal is emitted after the MateVFSVolume `volume` has been mounted.

When the `volume` is mounted, it is present in the `volume_monitor`'s list of mounted volumes, which can be queried using `mate_vfs_volume_monitor_get_mounted_volumes()`.

If the `volume` has an associated MateVFSDrive, it also appears in the drive's list of mounted volumes, which can be queried using `mate_vfs_drive_get_mounted_volumes()`.

`volume_monitor` : | the MateVFSVolumeMonitor which received the signal.
`volume` : | the MateVFSVolume that has been mounted.
`user_data` : | user data set when the signal handler was connected.

### The `"volume-pre-unmount"` signal

    void                user_function                      (MateVFSVolumeMonitor *volume_monitor,
                                                            MateVFSVolume        *volume,
                                                            gpointer               user_data)           : Run First

This signal is emitted when the MateVFSVolume `volume` is about to be unmounted.

When the `volume` is unmounted, it is removed from the `volume_monitor`'s list of mounted volumes, which can be queried using `mate_vfs_volume_monitor_get_mounted_volumes()`.

If the `volume` has an associated MateVFSDrive, it is also removed from in the drive's list of mounted volumes, which can be queried using `mate_vfs_drive_get_mounted_volumes()`.

When a client application receives this signal, it must free all resources associated with the `volume`, for instance cancel all pending file operations on the `volume`, and cancel all pending file monitors using `mate_vfs_monitor_cancel()`.

`volume_monitor` : | the MateVFSVolumeMonitor which received the signal.
`volume` : | the MateVFSVolume that is about to be unmounted.
`user_data` : | user data set when the signal handler was connected.

### The `"volume-unmounted"` signal

    void                user_function                      (MateVFSVolumeMonitor *volume_monitor,
                                                            MateVFSVolume        *volume,
                                                            gpointer               user_data)           : Run First

This signal is emitted after the MateVFSVolume `volume` has been unmounted.

When the `volume` is unmounted, it is removed from the `volume_monitor`'s list of mounted volumes, which can be queried using `mate_vfs_volume_monitor_get_mounted_volumes()`.

If the `volume` has an associated MateVFSDrive, it is also removed from in the drive's list of mounted volumes, which can be queried using `mate_vfs_drive_get_mounted_volumes()`.

`volume_monitor` : | the MateVFSVolumeMonitor which received the signal.
`volume` : | the MateVFSVolume that has been unmounted.
`user_data` : | user data set when the signal handler was connected.