Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
GLocalFileMonitor: Support for GFileMonitorFlags
Browse files Browse the repository at this point in the history
Evaluate and remember GFileMonitorFlags. This is a part of move 
event support for fs-monitoring (bug #547890).
  • Loading branch information
gicmo committed Feb 18, 2010
1 parent 41956b2 commit 239af97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
28 changes: 25 additions & 3 deletions gio/glocalfilemonitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "config.h"

#include "gioenumtypes.h"
#include "glocalfilemonitor.h"
#include "giomodule-priv.h"
#include "gioerror.h"
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"));
Expand Down
1 change: 1 addition & 0 deletions gio/glocalfilemonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct _GLocalFileMonitor
GFileMonitor parent_instance;

gchar *filename;
GFileMonitorFlags flags;
};

struct _GLocalFileMonitorClass
Expand Down

0 comments on commit 239af97

Please sign in to comment.