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