From 239af977126a4a4b6c68cb43e0876847c7ce2211 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 18 Feb 2010 15:43:45 +0100 Subject: [PATCH] GLocalFileMonitor: Support for GFileMonitorFlags Evaluate and remember GFileMonitorFlags. This is a part of move event support for fs-monitoring (bug #547890). --- gio/glocalfilemonitor.c | 28 +++++++++++++++++++++++++--- gio/glocalfilemonitor.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c index 7618fff22..8405d3a0e 100644 --- a/gio/glocalfilemonitor.c +++ b/gio/glocalfilemonitor.c @@ -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")); diff --git a/gio/glocalfilemonitor.h b/gio/glocalfilemonitor.h index 7cc6b134f..66438661d 100644 --- a/gio/glocalfilemonitor.h +++ b/gio/glocalfilemonitor.h @@ -43,6 +43,7 @@ struct _GLocalFileMonitor GFileMonitor parent_instance; gchar *filename; + GFileMonitorFlags flags; }; struct _GLocalFileMonitorClass