GLocalFileMonitor: Support for GFileMonitorFlags
authorChristian Kellner <gicmo@gnome.org>
Thu, 18 Feb 2010 14:43:45 +0000 (15:43 +0100)
committerChristian Kellner <gicmo@gnome.org>
Thu, 18 Feb 2010 14:50:26 +0000 (15:50 +0100)
Evaluate and remember GFileMonitorFlags. This is a part of move
event support for fs-monitoring (bug #547890).

gio/glocalfilemonitor.c
gio/glocalfilemonitor.h

index 7618fff22e56a0d280f636253342379d0be64966..8405d3a0edc194e05ed751ce673d58d3db967d2a 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "config.h"
 
+#include "gioenumtypes.h"
 #include "glocalfilemonitor.h"
 #include "giomodule-priv.h"
 #include "gioerror.h"
@@ -34,7 +35,8 @@
 enum
 {
   PROP_0,
-  PROP_FILENAME
+  PROP_FILENAME,
+  PROP_FLAGS
 };
 
 G_DEFINE_ABSTRACT_TYPE (GLocalFileMonitor, g_local_file_monitor, G_TYPE_FILE_MONITOR)
@@ -55,6 +57,9 @@ g_local_file_monitor_set_property (GObject      *object,
     case PROP_FILENAME:
       /* Do nothing */
       break;
+    case PROP_FLAGS:
+      /* Do nothing as well */
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -71,6 +76,7 @@ g_local_file_monitor_constructor (GType                  type,
   GObjectClass *parent_class;
   GLocalFileMonitor *local_monitor;
   const gchar *filename = NULL;
+  GFileMonitorFlags flags = 0;
   gint i;
   
   klass = G_LOCAL_FILE_MONITOR_CLASS (g_type_class_peek (G_TYPE_LOCAL_FILE_MONITOR));
@@ -87,13 +93,18 @@ g_local_file_monitor_constructor (GType                  type,
         {
           g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value));
           filename = g_value_get_string (construct_properties[i].value);
-          break;
+        }
+      else if (strcmp ("flags", g_param_spec_get_name (construct_properties[i].pspec)) == 0)
+        {
+          g_warn_if_fail (G_VALUE_HOLDS_FLAGS (construct_properties[i].value));
+          flags = g_value_get_flags (construct_properties[i].value);
         }
     }
 
   g_warn_if_fail (filename != NULL);
 
   local_monitor->filename = g_strdup (filename);
+  local_monitor->flags = flags;
   return obj;
 }
 
@@ -127,6 +138,17 @@ static void g_local_file_monitor_class_init (GLocalFileMonitorClass *klass)
                                                         G_PARAM_CONSTRUCT_ONLY|
                                                         G_PARAM_WRITABLE|
                                                         G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_FLAGS,
+                                   g_param_spec_flags ("flags",
+                                                      P_("Monitor flags"),
+                                                      P_("Monitor flags"),
+                                                      G_TYPE_FILE_MONITOR_FLAGS,
+                                                      0,
+                                                      G_PARAM_CONSTRUCT_ONLY|
+                                                      G_PARAM_WRITABLE|
+                                                      G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
 }
 
 static gpointer
@@ -185,7 +207,7 @@ _g_local_file_monitor_new (const char         *pathname,
 
   monitor = NULL;
   if (type != G_TYPE_INVALID)
-    monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, NULL));
+    monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, "flags", flags, NULL));
   else
     g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                          _("Unable to find default local file monitor type"));
index 7cc6b134fa4b16fa9a24b0ae878904c6c42604aa..66438661d29a7bb959eb79c61553573cdcc0aeda 100644 (file)
@@ -43,6 +43,7 @@ struct _GLocalFileMonitor
   GFileMonitor parent_instance;
 
   gchar *filename;
+  GFileMonitorFlags flags;
 };
 
 struct _GLocalFileMonitorClass