mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
GLocalFileMonitor: Support for GFileMonitorFlags
Evaluate and remember GFileMonitorFlags. This is a part of move event support for fs-monitoring (bug #547890).
This commit is contained in:
parent
41956b2376
commit
239af97712
@ -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"));
|
||||
|
@ -43,6 +43,7 @@ struct _GLocalFileMonitor
|
||||
GFileMonitor parent_instance;
|
||||
|
||||
gchar *filename;
|
||||
GFileMonitorFlags flags;
|
||||
};
|
||||
|
||||
struct _GLocalFileMonitorClass
|
||||
|
Loading…
Reference in New Issue
Block a user