glib r6306 - trunk/gio



Author: alexl
Date: Mon Jan 14 15:00:31 2008
New Revision: 6306
URL: http://svn.gnome.org/viewvc/glib?rev=6306&view=rev

Log:
2008-01-14  Alexander Larsson  <alexl redhat com>

        * gfile.[ch]:
        (g_file_monitor_directory):
        (g_file_monitor_file):
	Add GError to file monitor calls
	
        * glocaldirectorymonitor.c:
        * glocaldirectorymonitor.h:
        * glocalfile.c:
        * glocalfilemonitor.c:
        * glocalfilemonitor.h:
        * gunixmounts.c:
	Update for above change



Modified:
   trunk/gio/ChangeLog
   trunk/gio/gfile.c
   trunk/gio/gfile.h
   trunk/gio/glocaldirectorymonitor.c
   trunk/gio/glocaldirectorymonitor.h
   trunk/gio/glocalfile.c
   trunk/gio/glocalfilemonitor.c
   trunk/gio/glocalfilemonitor.h
   trunk/gio/gunixmounts.c

Modified: trunk/gio/gfile.c
==============================================================================
--- trunk/gio/gfile.c	(original)
+++ trunk/gio/gfile.c	Mon Jan 14 15:00:31 2008
@@ -3249,6 +3249,7 @@
  * @file: input #GFile.
  * @flags: a set of #GFileMonitorFlags.
  * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @error: a #GError, or %NULL.
  * 
  * Obtains a directory monitor for the given file.
  * This may fail if directory monitoring is not supported.
@@ -3263,18 +3264,27 @@
 GFileMonitor*
 g_file_monitor_directory (GFile             *file,
 			  GFileMonitorFlags  flags,
-			  GCancellable      *cancellable)
+			  GCancellable      *cancellable,
+			  GError           **error)
 {
   GFileIface *iface;
 
   g_return_val_if_fail (G_IS_FILE (file), NULL);
 
+  if (g_cancellable_set_error_if_cancelled (cancellable, error))
+    return NULL;
+
   iface = G_FILE_GET_IFACE (file);
 
   if (iface->monitor_dir == NULL)
-    return NULL;
+    {
+      g_set_error (error, G_IO_ERROR,
+		   G_IO_ERROR_NOT_SUPPORTED,
+		   _("Operation not supported"));
+      return NULL;
+    }
 
-  return (* iface->monitor_dir) (file, flags, cancellable);
+  return (* iface->monitor_dir) (file, flags, cancellable, error);
 }
 
 /**
@@ -3282,6 +3292,7 @@
  * @file: input #GFile.
  * @flags: a set of #GFileMonitorFlags.
  * @cancellable: optional #GCancellable object, %NULL to ignore.
+ * @error: a #GError, or %NULL.
  * 
  * Obtains a file monitor for the given file. If no file notification
  * mechanism exists, then regular polling of the file is used.
@@ -3295,19 +3306,23 @@
 GFileMonitor*
 g_file_monitor_file (GFile             *file,
 		     GFileMonitorFlags  flags,
-		     GCancellable      *cancellable)
+		     GCancellable      *cancellable,
+		     GError           **error)
 {
   GFileIface *iface;
   GFileMonitor *monitor;
   
   g_return_val_if_fail (G_IS_FILE (file), NULL);
 
+  if (g_cancellable_set_error_if_cancelled (cancellable, error))
+    return NULL;
+
   iface = G_FILE_GET_IFACE (file);
 
   monitor = NULL;
   
   if (iface->monitor_file)
-    monitor = (* iface->monitor_file) (file, flags, cancellable);
+    monitor = (* iface->monitor_file) (file, flags, cancellable, error);
 
 /* Fallback to polling */
   if (monitor == NULL)

Modified: trunk/gio/gfile.h
==============================================================================
--- trunk/gio/gfile.h	(original)
+++ trunk/gio/gfile.h	Mon Jan 14 15:00:31 2008
@@ -518,11 +518,13 @@
   
   GFileMonitor*      (*monitor_dir)         (GFile                  *file,
 					     GFileMonitorFlags       flags,
-					     GCancellable           *cancellable);
+					     GCancellable           *cancellable,
+					     GError                **error);
 
   GFileMonitor*      (*monitor_file)        (GFile                  *file,
 					     GFileMonitorFlags       flags,
-					     GCancellable           *cancellable);
+					     GCancellable           *cancellable,
+					     GError                **error);
 
 };
 
@@ -794,10 +796,12 @@
 
 GFileMonitor*           g_file_monitor_directory          (GFile                  *file,
 							   GFileMonitorFlags       flags,
-							   GCancellable           *cancellable);
+							   GCancellable           *cancellable,
+							   GError                **error);
 GFileMonitor*           g_file_monitor_file               (GFile                  *file,
 							   GFileMonitorFlags       flags,
-							   GCancellable           *cancellable);
+							   GCancellable           *cancellable,
+							   GError                **error);
 
 
 /* Utilities */

Modified: trunk/gio/glocaldirectorymonitor.c
==============================================================================
--- trunk/gio/glocaldirectorymonitor.c	(original)
+++ trunk/gio/glocaldirectorymonitor.c	Mon Jan 14 15:00:31 2008
@@ -276,8 +276,9 @@
  * Returns: new #GFileMonitor for the given @dirname.
  **/
 GFileMonitor*
-_g_local_directory_monitor_new (const char*       dirname,
-				GFileMonitorFlags flags)
+_g_local_directory_monitor_new (const char         *dirname,
+				GFileMonitorFlags   flags,
+				GError            **error)
 {
   static GOnce once_init = G_ONCE_INIT;
   GTypeClass *type_class;
@@ -291,6 +292,8 @@
   monitor = NULL;
   if (type != G_TYPE_INVALID)
     monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, NULL));
+  else
+    g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Unable to find default local directory monitor type"));
 
   /* This is non-null on first pass here. Unref the class now.
    * This is to avoid unloading the module and then loading it

Modified: trunk/gio/glocaldirectorymonitor.h
==============================================================================
--- trunk/gio/glocaldirectorymonitor.h	(original)
+++ trunk/gio/glocaldirectorymonitor.h	Mon Jan 14 15:00:31 2008
@@ -59,7 +59,8 @@
 GType g_local_directory_monitor_get_type (void) G_GNUC_CONST;
 
 GFileMonitor* _g_local_directory_monitor_new (const char* dirname,
-					      GFileMonitorFlags flags);
+					      GFileMonitorFlags flags,
+					      GError **error);
 
 G_END_DECLS
 

Modified: trunk/gio/glocalfile.c
==============================================================================
--- trunk/gio/glocalfile.c	(original)
+++ trunk/gio/glocalfile.c	Mon Jan 14 15:00:31 2008
@@ -1861,19 +1861,21 @@
 static GFileMonitor*
 g_local_file_monitor_dir (GFile             *file,
 			  GFileMonitorFlags  flags,
-			  GCancellable      *cancellable)
+			  GCancellable      *cancellable,
+			  GError           **error)
 {
   GLocalFile* local_file = G_LOCAL_FILE(file);
-  return _g_local_directory_monitor_new (local_file->filename, flags);
+  return _g_local_directory_monitor_new (local_file->filename, flags, error);
 }
 
 static GFileMonitor*
 g_local_file_monitor_file (GFile             *file,
 			   GFileMonitorFlags  flags,
-			   GCancellable      *cancellable)
+			   GCancellable      *cancellable,
+			   GError           **error)
 {
   GLocalFile* local_file = G_LOCAL_FILE(file);
-  return _g_local_file_monitor_new (local_file->filename, flags);
+  return _g_local_file_monitor_new (local_file->filename, flags, error);
 }
 
 static void

Modified: trunk/gio/glocalfilemonitor.c
==============================================================================
--- trunk/gio/glocalfilemonitor.c	(original)
+++ trunk/gio/glocalfilemonitor.c	Mon Jan 14 15:00:31 2008
@@ -205,8 +205,9 @@
  * Returns: a new #GFileMonitor for the given @pathname. 
  **/
 GFileMonitor*
-_g_local_file_monitor_new (const char        *pathname,
-			   GFileMonitorFlags  flags)
+_g_local_file_monitor_new (const char         *pathname,
+			   GFileMonitorFlags   flags,
+			   GError            **error)
 {
   static GOnce once_init = G_ONCE_INIT;
   GTypeClass *type_class;
@@ -220,6 +221,8 @@
   monitor = NULL;
   if (type != G_TYPE_INVALID)
     monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, NULL));
+  else
+    g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Unable to find default local file monitor type"));
 
   /* This is non-null on first pass here. Unref the class now.
    * This is to avoid unloading the module and then loading it

Modified: trunk/gio/glocalfilemonitor.h
==============================================================================
--- trunk/gio/glocalfilemonitor.h	(original)
+++ trunk/gio/glocalfilemonitor.h	Mon Jan 14 15:00:31 2008
@@ -53,7 +53,8 @@
 GType g_local_file_monitor_get_type (void) G_GNUC_CONST;
 
 GFileMonitor* _g_local_file_monitor_new (const char* pathname,
-					 GFileMonitorFlags flags);
+					 GFileMonitorFlags flags,
+					 GError **error);
 
 G_END_DECLS
 

Modified: trunk/gio/gunixmounts.c
==============================================================================
--- trunk/gio/gunixmounts.c	(original)
+++ trunk/gio/gunixmounts.c	Mon Jan 14 15:00:31 2008
@@ -1191,7 +1191,7 @@
   if (get_fstab_file () != NULL)
     {
       file = g_file_new_for_path (get_fstab_file ());
-      monitor->fstab_monitor = g_file_monitor_file (file, 0, NULL);
+      monitor->fstab_monitor = g_file_monitor_file (file, 0, NULL, NULL);
       g_object_unref (file);
       
       g_signal_connect (monitor->fstab_monitor, "changed", (GCallback)fstab_file_changed, monitor);
@@ -1200,7 +1200,7 @@
   if (get_mtab_monitor_file () != NULL)
     {
       file = g_file_new_for_path (get_mtab_monitor_file ());
-      monitor->mtab_monitor = g_file_monitor_file (file, 0, NULL);
+      monitor->mtab_monitor = g_file_monitor_file (file, 0, NULL, NULL);
       g_object_unref (file);
       
       g_signal_connect (monitor->mtab_monitor, "changed", (GCallback)mtab_file_changed, monitor);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]