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>
21 * David Zeuthen <davidz@redhat.com>
25 #include "gvolumemonitor.h"
31 * SECTION:gvolumemonitor
32 * @short_description: Volume Monitor
33 * @see_also: #GDirectoryMonitor, #GFileMonitor
35 * Monitors a mounted volume for changes.
38 G_DEFINE_TYPE (GVolumeMonitor, g_volume_monitor, G_TYPE_OBJECT);
54 static guint signals[LAST_SIGNAL] = { 0 };
58 g_volume_monitor_finalize (GObject *object)
60 GVolumeMonitor *monitor;
62 monitor = G_VOLUME_MONITOR (object);
64 if (G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize)
65 (*G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize) (object);
69 g_volume_monitor_class_init (GVolumeMonitorClass *klass)
71 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
73 gobject_class->finalize = g_volume_monitor_finalize;
76 * GVolumeMonitor::volume-added:
77 * @volume_monitor: The volume monitor emitting the signal.
78 * @volume: a #GVolume that was added.
80 * Emitted when a mountable volume is added to the system.
82 signals[VOLUME_ADDED] = g_signal_new (I_("volume_added"),
83 G_TYPE_VOLUME_MONITOR,
85 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_added),
87 g_cclosure_marshal_VOID__OBJECT,
88 G_TYPE_NONE, 1, G_TYPE_VOLUME);
91 * GVolumeMonitor::volume-removed:
92 * @volume_monitor: The volume monitor emitting the signal.
93 * @volume: a #GVolume that was removed.
95 * Emitted when a mountable volume is removed from the system.
97 signals[VOLUME_REMOVED] = g_signal_new (I_("volume_removed"),
98 G_TYPE_VOLUME_MONITOR,
100 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_removed),
102 g_cclosure_marshal_VOID__OBJECT,
103 G_TYPE_NONE, 1, G_TYPE_VOLUME);
106 * GVolumeMonitor::volume-changed:
107 * @volume_monitor: The volume monitor emitting the signal.
108 * @volume: a #GVolume that changed.
110 * Emitted when mountable volume is changed.
112 signals[VOLUME_CHANGED] = g_signal_new (I_("volume_changed"),
113 G_TYPE_VOLUME_MONITOR,
115 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_changed),
117 g_cclosure_marshal_VOID__OBJECT,
118 G_TYPE_NONE, 1, G_TYPE_VOLUME);
121 * GVolumeMonitor::mount-added:
122 * @volume_monitor: The volume monitor emitting the signal.
123 * @mount: a #GMount that was added.
125 * Emitted when a mount is added.
127 signals[MOUNT_ADDED] = g_signal_new (I_("mount_added"),
128 G_TYPE_VOLUME_MONITOR,
130 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_added),
132 g_cclosure_marshal_VOID__OBJECT,
133 G_TYPE_NONE, 1, G_TYPE_MOUNT);
136 * GVolumeMonitor::mount-removed:
137 * @volume_monitor: The volume monitor emitting the signal.
138 * @mount: a #GMount that was removed.
140 * Emitted when a mount is removed.
142 signals[MOUNT_REMOVED] = g_signal_new (I_("mount_removed"),
143 G_TYPE_VOLUME_MONITOR,
145 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_removed),
147 g_cclosure_marshal_VOID__OBJECT,
148 G_TYPE_NONE, 1, G_TYPE_MOUNT);
151 * GVolumeMonitor::mount-pre-unmount:
152 * @volume_monitor: The volume monitor emitting the signal.
153 * @mount: a #GMount that is being unmounted.
155 * Emitted when a mount is about to be removed.
157 signals[MOUNT_PRE_UNMOUNT] = g_signal_new (I_("mount_pre_unmount"),
158 G_TYPE_VOLUME_MONITOR,
160 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_pre_unmount),
162 g_cclosure_marshal_VOID__OBJECT,
163 G_TYPE_NONE, 1, G_TYPE_MOUNT);
166 * GVolumeMonitor::mount-changed:
167 * @volume_monitor: The volume monitor emitting the signal.
168 * @mount: a #GMount that changed.
170 * Emitted when a mount changes.
172 signals[MOUNT_CHANGED] = g_signal_new (I_("mount_changed"),
173 G_TYPE_VOLUME_MONITOR,
175 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_changed),
177 g_cclosure_marshal_VOID__OBJECT,
178 G_TYPE_NONE, 1, G_TYPE_MOUNT);
181 * GVolumeMonitor::drive-connected:
182 * @volume_monitor: The volume monitor emitting the signal.
183 * @drive: a #GDrive that was connected.
185 * Emitted when a drive is connected to the system.
187 signals[DRIVE_CONNECTED] = g_signal_new (I_("drive_connected"),
188 G_TYPE_VOLUME_MONITOR,
190 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_connected),
192 g_cclosure_marshal_VOID__OBJECT,
193 G_TYPE_NONE, 1, G_TYPE_DRIVE);
196 * GVolumeMonitor::drive-disconnected:
197 * @volume_monitor: The volume monitor emitting the signal.
198 * @drive: a #GDrive that was disconnected.
200 * Emitted when a drive is disconnected from the system.
202 signals[DRIVE_DISCONNECTED] = g_signal_new (I_("drive_disconnected"),
203 G_TYPE_VOLUME_MONITOR,
205 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_disconnected),
207 g_cclosure_marshal_VOID__OBJECT,
208 G_TYPE_NONE, 1, G_TYPE_DRIVE);
211 * GVolumeMonitor::drive-changed:
212 * @volume_monitor: The volume monitor emitting the signal.
213 * @drive: the drive that changed
215 * Emitted when a drive changes.
217 signals[DRIVE_CHANGED] = g_signal_new (I_("drive_changed"),
218 G_TYPE_VOLUME_MONITOR,
220 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_changed),
222 g_cclosure_marshal_VOID__OBJECT,
223 G_TYPE_NONE, 1, G_TYPE_DRIVE);
228 g_volume_monitor_init (GVolumeMonitor *monitor)
234 * g_volume_monitor_get_drives:
235 * @volume_monitor: a #GVolumeMonitor.
237 * Gets a list of drives connected to the system.
239 * Returns: a #GList of connected #GDrives.
242 g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor)
244 GVolumeMonitorClass *class;
246 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
248 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
250 return class->get_connected_drives (volume_monitor);
254 * g_volume_monitor_get_volumes:
255 * @volume_monitor: a #GVolumeMonitor.
257 * Gets a list of the volumes on the system.
259 * Returns: a #GList of #GVolume.
262 g_volume_monitor_get_volumes (GVolumeMonitor *volume_monitor)
264 GVolumeMonitorClass *class;
266 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
268 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
270 return class->get_volumes (volume_monitor);
274 * g_volume_monitor_get_mounts:
275 * @volume_monitor: a #GVolumeMonitor.
277 * Gets a list of the mounts on the system.
279 * Returns: a #GList of #GMount.
282 g_volume_monitor_get_mounts (GVolumeMonitor *volume_monitor)
284 GVolumeMonitorClass *class;
286 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
288 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
290 return class->get_mounts (volume_monitor);
293 #define __G_VOLUME_MONITOR_C__
294 #include "gioaliasdef.c"