Bumps documentation to 93% symbol coverage, touching most
[platform/upstream/glib.git] / gio / gvolumemonitor.c
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #include <config.h>
24 #include "gvolumemonitor.h"
25 #include "glibintl.h"
26
27 /**
28  * SECTION:gvolumemonitor
29  * @short_description: Volume Monitor
30  * @see_also: #GDirectoryMonitor, #GFileMonitor
31  * 
32  * Monitors a mounted volume for changes.
33  *
34  **/
35
36 G_DEFINE_TYPE (GVolumeMonitor, g_volume_monitor, G_TYPE_OBJECT);
37
38 enum {
39   VOLUME_MOUNTED,
40   VOLUME_PRE_UNMOUNT,
41   VOLUME_UNMOUNTED,
42   DRIVE_CONNECTED,
43   DRIVE_DISCONNECTED,
44   LAST_SIGNAL
45 };
46
47 static guint signals[LAST_SIGNAL] = { 0 };
48
49
50 static void
51 g_volume_monitor_finalize (GObject *object)
52 {
53   GVolumeMonitor *monitor;
54
55   monitor = G_VOLUME_MONITOR (object);
56
57   if (G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize)
58     (*G_OBJECT_CLASS (g_volume_monitor_parent_class)->finalize) (object);
59 }
60
61 static void
62 g_volume_monitor_class_init (GVolumeMonitorClass *klass)
63 {
64   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
65   
66   gobject_class->finalize = g_volume_monitor_finalize;
67
68   /**
69    * GVolumeMonitor::volume-mounted:   
70    * @volume_monitor: The volume monitor emitting the signal.
71    * @volume: the volume that was mounted.
72    *
73    * Emitted when a volume is mounted.
74    **/
75   signals[VOLUME_MOUNTED] = g_signal_new (I_("volume_mounted"),
76                                           G_TYPE_VOLUME_MONITOR,
77                                           G_SIGNAL_RUN_LAST,
78                                           G_STRUCT_OFFSET (GVolumeMonitorClass, volume_mounted),
79                                           NULL, NULL,
80                                           g_cclosure_marshal_VOID__OBJECT,
81                                           G_TYPE_NONE, 1, G_TYPE_VOLUME);
82   /**
83    * GVolumeMonitor::volume-pre-unmount:
84    * @volume_monitor: The volume monitor emitting the signal.
85    * @volume: the volume that is being unmounted.
86    *
87    * Emitted when a volume is about to be unmounted.
88    **/ 
89   signals[VOLUME_PRE_UNMOUNT] = g_signal_new (I_("volume_pre_unmount"),
90                                               G_TYPE_VOLUME_MONITOR,
91                                               G_SIGNAL_RUN_LAST,
92                                               G_STRUCT_OFFSET (GVolumeMonitorClass, volume_pre_unmount),
93                                               NULL, NULL,
94                                               g_cclosure_marshal_VOID__OBJECT,
95                                               G_TYPE_NONE, 1, G_TYPE_VOLUME);
96   /**
97    * GVolumeMonitor::volume-unmounted:
98    * @volume_monitor: The volume monitor emitting the signal.
99    * @volume: the volume that was unmounted.
100    * 
101    * Emitted when a volume is unmounted.
102    **/  
103   signals[VOLUME_UNMOUNTED] = g_signal_new (I_("volume_unmounted"),
104                                             G_TYPE_VOLUME_MONITOR,
105                                             G_SIGNAL_RUN_LAST,
106                                             G_STRUCT_OFFSET (GVolumeMonitorClass, volume_unmounted),
107                                             NULL, NULL,
108                                             g_cclosure_marshal_VOID__OBJECT,
109                                             G_TYPE_NONE, 1, G_TYPE_VOLUME);
110   /**
111    * GVolumeMonitor::drive-connected:
112    * @volume_monitor: The volume monitor emitting the signal.
113    * @drive: a #GDrive that was connected.
114    * 
115    * Emitted when a drive is connected to the system.
116    **/
117   signals[DRIVE_CONNECTED] = g_signal_new (I_("drive_connected"),
118                                            G_TYPE_VOLUME_MONITOR,
119                                            G_SIGNAL_RUN_LAST,
120                                            G_STRUCT_OFFSET (GVolumeMonitorClass, drive_connected),
121                                            NULL, NULL,
122                                            g_cclosure_marshal_VOID__OBJECT,
123                                            G_TYPE_NONE, 1, G_TYPE_DRIVE);
124   
125   /**
126    * GVolumeMonitor::drive-disconnected:
127    * @volume_monitor: The volume monitor emitting the signal.
128    * @drive: a #GDrive that was disconnected.
129    * 
130    * Emitted when a drive is disconnected from the system.
131    **/  
132   signals[DRIVE_DISCONNECTED] = g_signal_new (I_("drive_disconnected"),
133                                               G_TYPE_VOLUME_MONITOR,
134                                               G_SIGNAL_RUN_LAST,
135                                               G_STRUCT_OFFSET (GVolumeMonitorClass, drive_disconnected),
136                                               NULL, NULL,
137                                               g_cclosure_marshal_VOID__OBJECT,
138                                               G_TYPE_NONE, 1, G_TYPE_DRIVE);
139 }
140
141 static void
142 g_volume_monitor_init (GVolumeMonitor *monitor)
143 {
144 }
145
146 /**
147  * g_volume_monitor_get_mounted_volumes:
148  * @volume_monitor: a #GVolumeMonitor.
149  * 
150  * Gets a list of volumes mounted on the computer.
151  * 
152  * Returns a #GList of mounted #GVolumes.
153  **/
154 GList *
155 g_volume_monitor_get_mounted_volumes  (GVolumeMonitor *volume_monitor)
156 {
157   GVolumeMonitorClass *class;
158
159   g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
160
161   class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
162
163   return class->get_mounted_volumes (volume_monitor);
164 }
165
166 /**
167  * g_volume_monitor_get_connected_drives:
168  * @volume_monitor: a #GVolumeMonitor.
169  * 
170  * Gets a list of drives connected to the computer.
171  * 
172  * Returns: a #GList of connected #GDrives. 
173  **/
174 GList *
175 g_volume_monitor_get_connected_drives (GVolumeMonitor *volume_monitor)
176 {
177   GVolumeMonitorClass *class;
178
179   g_return_val_if_fail (G_IS_VOLUME_MONITOR (volume_monitor), NULL);
180
181   class = G_VOLUME_MONITOR_GET_CLASS (volume_monitor);
182
183   return class->get_connected_drives (volume_monitor);
184 }
185