1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* GIO - GLib Input, Output and Streaming Library
5 * Copyright (C) 2006-2007 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307, USA.
22 * Author: Alexander Larsson <alexl@redhat.com>
23 * David Zeuthen <davidz@redhat.com>
27 #include "gvolumemonitor.h"
33 * SECTION:gvolumemonitor
34 * @short_description: Volume Monitor
36 * @see_also: #GFileMonitor
38 * #GVolumeMonitor is for listing the user interesting devices and volumes
39 * on the computer. In other words, what a file selector or file manager
40 * would show in a sidebar.
43 G_DEFINE_TYPE (GVolumeMonitor, g_volume_monitor, G_TYPE_OBJECT);
59 static guint signals[LAST_SIGNAL] = { 0 };
63 g_volume_monitor_finalize (GObject *object)
65 GVolumeMonitor *monitor;
67 monitor = G_VOLUME_MONITOR (object);
69 G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize (object);
73 g_volume_monitor_class_init (GVolumeMonitorClass *klass)
75 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
77 gobject_class->finalize = g_volume_monitor_finalize;
80 * GVolumeMonitor::volume-added:
81 * @volume_monitor: The volume monitor emitting the signal.
82 * @volume: a #GVolume that was added.
84 * Emitted when a mountable volume is added to the system.
86 signals[VOLUME_ADDED] = g_signal_new (I_("volume_added"),
87 G_TYPE_VOLUME_MONITOR,
89 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_added),
91 g_cclosure_marshal_VOID__OBJECT,
92 G_TYPE_NONE, 1, G_TYPE_VOLUME);
95 * GVolumeMonitor::volume-removed:
96 * @volume_monitor: The volume monitor emitting the signal.
97 * @volume: a #GVolume that was removed.
99 * Emitted when a mountable volume is removed from the system.
101 signals[VOLUME_REMOVED] = g_signal_new (I_("volume_removed"),
102 G_TYPE_VOLUME_MONITOR,
104 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_removed),
106 g_cclosure_marshal_VOID__OBJECT,
107 G_TYPE_NONE, 1, G_TYPE_VOLUME);
110 * GVolumeMonitor::volume-changed:
111 * @volume_monitor: The volume monitor emitting the signal.
112 * @volume: a #GVolume that changed.
114 * Emitted when mountable volume is changed.
116 signals[VOLUME_CHANGED] = g_signal_new (I_("volume_changed"),
117 G_TYPE_VOLUME_MONITOR,
119 G_STRUCT_OFFSET (GVolumeMonitorClass, volume_changed),
121 g_cclosure_marshal_VOID__OBJECT,
122 G_TYPE_NONE, 1, G_TYPE_VOLUME);
125 * GVolumeMonitor::mount-added:
126 * @volume_monitor: The volume monitor emitting the signal.
127 * @mount: a #GMount that was added.
129 * Emitted when a mount is added.
131 signals[MOUNT_ADDED] = g_signal_new (I_("mount_added"),
132 G_TYPE_VOLUME_MONITOR,
134 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_added),
136 g_cclosure_marshal_VOID__OBJECT,
137 G_TYPE_NONE, 1, G_TYPE_MOUNT);
140 * GVolumeMonitor::mount-removed:
141 * @volume_monitor: The volume monitor emitting the signal.
142 * @mount: a #GMount that was removed.
144 * Emitted when a mount is removed.
146 signals[MOUNT_REMOVED] = g_signal_new (I_("mount_removed"),
147 G_TYPE_VOLUME_MONITOR,
149 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_removed),
151 g_cclosure_marshal_VOID__OBJECT,
152 G_TYPE_NONE, 1, G_TYPE_MOUNT);
155 * GVolumeMonitor::mount-pre-unmount:
156 * @volume_monitor: The volume monitor emitting the signal.
157 * @mount: a #GMount that is being unmounted.
159 * Emitted when a mount is about to be removed.
161 signals[MOUNT_PRE_UNMOUNT] = g_signal_new (I_("mount_pre_unmount"),
162 G_TYPE_VOLUME_MONITOR,
164 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_pre_unmount),
166 g_cclosure_marshal_VOID__OBJECT,
167 G_TYPE_NONE, 1, G_TYPE_MOUNT);
170 * GVolumeMonitor::mount-changed:
171 * @volume_monitor: The volume monitor emitting the signal.
172 * @mount: a #GMount that changed.
174 * Emitted when a mount changes.
176 signals[MOUNT_CHANGED] = g_signal_new (I_("mount_changed"),
177 G_TYPE_VOLUME_MONITOR,
179 G_STRUCT_OFFSET (GVolumeMonitorClass, mount_changed),
181 g_cclosure_marshal_VOID__OBJECT,
182 G_TYPE_NONE, 1, G_TYPE_MOUNT);
185 * GVolumeMonitor::drive-connected:
186 * @volume_monitor: The volume monitor emitting the signal.
187 * @drive: a #GDrive that was connected.
189 * Emitted when a drive is connected to the system.
191 signals[DRIVE_CONNECTED] = g_signal_new (I_("drive_connected"),
192 G_TYPE_VOLUME_MONITOR,
194 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_connected),
196 g_cclosure_marshal_VOID__OBJECT,
197 G_TYPE_NONE, 1, G_TYPE_DRIVE);
200 * GVolumeMonitor::drive-disconnected:
201 * @volume_monitor: The volume monitor emitting the signal.
202 * @drive: a #GDrive that was disconnected.
204 * Emitted when a drive is disconnected from the system.
206 signals[DRIVE_DISCONNECTED] = g_signal_new (I_("drive_disconnected"),
207 G_TYPE_VOLUME_MONITOR,
209 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_disconnected),
211 g_cclosure_marshal_VOID__OBJECT,
212 G_TYPE_NONE, 1, G_TYPE_DRIVE);
215 * GVolumeMonitor::drive-changed:
216 * @volume_monitor: The volume monitor emitting the signal.
217 * @drive: the drive that changed
219 * Emitted when a drive changes.
221 signals[DRIVE_CHANGED] = g_signal_new (I_("drive_changed"),
222 G_TYPE_VOLUME_MONITOR,
224 G_STRUCT_OFFSET (GVolumeMonitorClass, drive_changed),
226 g_cclosure_marshal_VOID__OBJECT,
227 G_TYPE_NONE, 1, G_TYPE_DRIVE);
232 g_volume_monitor_init (GVolumeMonitor *monitor)
238 * g_volume_monitor_get_connected_drives:
239 * @volume_monitor: a #GVolumeMonitor.
241 * Gets a list of drives connected to the system.
243 * The returned list should be freed with g_list_free(), after
244 * its elements have been unreffed with g_object_unref().
246 * Returns: a #GList of connected #GDrive<!-- -->s
249 g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor)
251 GVolumeMonitorClass *class;
253 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
255 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
257 return class->get_connected_drives (volume_monitor);
261 * g_volume_monitor_get_volumes:
262 * @volume_monitor: a #GVolumeMonitor.
264 * Gets a list of the volumes on the system.
266 * The returned list should be freed with g_list_free(), after
267 * its elements have been unreffed with g_object_unref().
269 * Returns: a #GList of #GVolume<!-- -->s.
272 g_volume_monitor_get_volumes (GVolumeMonitor *volume_monitor)
274 GVolumeMonitorClass *class;
276 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
278 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
280 return class->get_volumes (volume_monitor);
284 * g_volume_monitor_get_mounts:
285 * @volume_monitor: a #GVolumeMonitor.
287 * Gets a list of the mounts on the system.
289 * The returned list should be freed with g_list_free(), after
290 * its elements have been unreffed with g_object_unref().
292 * Returns: a #GList of #GMount<!-- -->s
295 g_volume_monitor_get_mounts (GVolumeMonitor *volume_monitor)
297 GVolumeMonitorClass *class;
299 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
301 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
303 return class->get_mounts (volume_monitor);
307 * g_volume_monitor_get_volume_for_uuid:
308 * @volume_monitor: a #GVolumeMonitor.
309 * @uuid: the UUID to look for
311 * Finds a #GVolume object by it's UUID (see g_volume_get_uuid())
313 * Returns: a #GVolume or %NULL if no such volume is available.
316 g_volume_monitor_get_volume_for_uuid (GVolumeMonitor *volume_monitor,
319 GVolumeMonitorClass *class;
321 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
322 g_return_val_if_fail (uuid != NULL, NULL);
324 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
326 return class->get_volume_for_uuid (volume_monitor, uuid);
330 * g_volume_monitor_get_mount_for_uuid:
331 * @volume_monitor: a #GVolumeMonitor.
332 * @uuid: the UUID to look for
334 * Finds a #GMount object by it's UUID (see g_mount_get_uuid())
336 * Returns: a #GMount or %NULL if no such mount is available.
339 g_volume_monitor_get_mount_for_uuid (GVolumeMonitor *volume_monitor,
342 GVolumeMonitorClass *class;
344 g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
345 g_return_val_if_fail (uuid != NULL, NULL);
347 class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
349 return class->get_mount_for_uuid (volume_monitor, uuid);
353 #define __G_VOLUME_MONITOR_C__
354 #include "gioaliasdef.c"