1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
24 #include "gvolumemonitor.h"
28 * SECTION:gvolumemonitor
29 * @short_description: Volume Monitor
30 * @see_also: #GDirectoryMonitor, #GFileMonitor
32 * Monitors a mounted volume for changes.
36 G_DEFINE_TYPE (GVolumeMonitor, g_volume_monitor, G_TYPE_OBJECT);
47 static guint signals[LAST_SIGNAL] = { 0 };
51 g_volume_monitor_finalize (GObject *object)
53 GVolumeMonitor *monitor;
55 monitor = G_VOLUME_MONITOR (object);
57 if (G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize)
58 (*G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize) (object);
62 g_volume_monitor_class_init (GVolumeMonitorClass *klass)
64 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
66 gobject_class->finalize = g_volume_monitor_finalize;
69 * GVolumeMonitor::volume-mounted:
70 * @volume_monitor: The volume monitor emitting the signal.
71 * @volume: the volume that was mounted.
73 * Emitted when a volume is mounted.
75 signals[VOLUME_MOUNTED] = g_signal_new (I_("volume_mounted"),
76 G_TYPE_VOLUME_MONITOR,
78 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_mounted),
80 g_cclosure_marshal_VOID__OBJECT,
81 G_TYPE_NONE, 1, G_TYPE_VOLUME);
83 * GVolumeMonitor::volume-pre-unmount:
84 * @volume_monitor: The volume monitor emitting the signal.
85 * @volume: the volume that is being unmounted.
87 * Emitted when a volume is about to be unmounted.
89 signals[VOLUME_PRE_UNMOUNT] = g_signal_new (I_("volume_pre_unmount"),
90 G_TYPE_VOLUME_MONITOR,
92 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_pre_unmount),
94 g_cclosure_marshal_VOID__OBJECT,
95 G_TYPE_NONE, 1, G_TYPE_VOLUME);
97 * GVolumeMonitor::volume-unmounted:
98 * @volume_monitor: The volume monitor emitting the signal.
99 * @volume: the volume that was unmounted.
101 * Emitted when a volume is unmounted.
103 signals[VOLUME_UNMOUNTED] = g_signal_new (I_("volume_unmounted"),
104 G_TYPE_VOLUME_MONITOR,
106 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_unmounted),
108 g_cclosure_marshal_VOID__OBJECT,
109 G_TYPE_NONE, 1, G_TYPE_VOLUME);
111 * GVolumeMonitor::drive-connected:
112 * @volume_monitor: The volume monitor emitting the signal.
113 * @drive: a #GDrive that was connected.
115 * Emitted when a drive is connected to the system.
117 signals[DRIVE_CONNECTED] = g_signal_new (I_("drive_connected"),
118 G_TYPE_VOLUME_MONITOR,
120 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_connected),
122 g_cclosure_marshal_VOID__OBJECT,
123 G_TYPE_NONE, 1, G_TYPE_DRIVE);
126 * GVolumeMonitor::drive-disconnected:
127 * @volume_monitor: The volume monitor emitting the signal.
128 * @drive: a #GDrive that was disconnected.
130 * Emitted when a drive is disconnected from the system.
132 signals[DRIVE_DISCONNECTED] = g_signal_new (I_("drive_disconnected"),
133 G_TYPE_VOLUME_MONITOR,
135 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_disconnected),
137 g_cclosure_marshal_VOID__OBJECT,
138 G_TYPE_NONE, 1, G_TYPE_DRIVE);
142 g_volume_monitor_init (GVolumeMonitor *monitor)
147 * g_volume_monitor_get_mounted_volumes:
148 * @volume_monitor: a #GVolumeMonitor.
150 * Gets a list of volumes mounted on the computer.
152 * Returns: a #GList of mounted #GVolumes.
155 g_volume_monitor_get_mounted_volumes (GVolumeMonitor *volume_monitor)
157 GVolumeMonitorClass *class;
159 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
161 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
163 return class->get_mounted_volumes (volume_monitor);
167 * g_volume_monitor_get_connected_drives:
168 * @volume_monitor: a #GVolumeMonitor.
170 * Gets a list of drives connected to the computer.
172 * Returns: a #GList of connected #GDrives.
175 g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor)
177 GVolumeMonitorClass *class;
179 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
181 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
183 return class->get_connected_drives (volume_monitor);