mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-26 01:20:05 +01:00
Merge branch 'file-monitor-props-cleanups' into 'main'
gfilemonitor: Various cleanups and minor fixes to property handling See merge request GNOME/glib!4492
This commit is contained in:
commit
a3d3e3b96e
@ -64,13 +64,13 @@ struct _GFileMonitorPrivate
|
|||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GFileMonitor, g_file_monitor, G_TYPE_OBJECT)
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GFileMonitor, g_file_monitor, G_TYPE_OBJECT)
|
||||||
|
|
||||||
enum
|
typedef enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_RATE_LIMIT = 1,
|
||||||
PROP_RATE_LIMIT,
|
|
||||||
PROP_CANCELLED
|
PROP_CANCELLED
|
||||||
};
|
} GFileMonitorProperty;
|
||||||
|
|
||||||
|
static GParamSpec *props[PROP_CANCELLED + 1];
|
||||||
static guint g_file_monitor_changed_signal;
|
static guint g_file_monitor_changed_signal;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -79,16 +79,17 @@ g_file_monitor_set_property (GObject *object,
|
|||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
//GFileMonitor *monitor;
|
switch ((GFileMonitorProperty) prop_id)
|
||||||
|
|
||||||
//monitor = G_FILE_MONITOR (object);
|
|
||||||
|
|
||||||
switch (prop_id)
|
|
||||||
{
|
{
|
||||||
case PROP_RATE_LIMIT:
|
case PROP_RATE_LIMIT:
|
||||||
/* not supported by default */
|
/* not supported by default */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_CANCELLED:
|
||||||
|
/* Read only */
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -101,7 +102,9 @@ g_file_monitor_get_property (GObject *object,
|
|||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
switch (prop_id)
|
GFileMonitor *self = G_FILE_MONITOR (object);
|
||||||
|
|
||||||
|
switch ((GFileMonitorProperty) prop_id)
|
||||||
{
|
{
|
||||||
case PROP_RATE_LIMIT:
|
case PROP_RATE_LIMIT:
|
||||||
/* we expect this to be overridden... */
|
/* we expect this to be overridden... */
|
||||||
@ -109,9 +112,7 @@ g_file_monitor_get_property (GObject *object,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_CANCELLED:
|
case PROP_CANCELLED:
|
||||||
//g_mutex_lock (&fms->lock);
|
g_value_set_boolean (value, g_file_monitor_is_cancelled (self));
|
||||||
g_value_set_boolean (value, FALSE);//fms->cancelled);
|
|
||||||
//g_mutex_unlock (&fms->lock);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -200,19 +201,21 @@ g_file_monitor_class_init (GFileMonitorClass *klass)
|
|||||||
*
|
*
|
||||||
* The limit of the monitor to watch for changes, in milliseconds.
|
* The limit of the monitor to watch for changes, in milliseconds.
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class, PROP_RATE_LIMIT,
|
props[PROP_RATE_LIMIT] =
|
||||||
g_param_spec_int ("rate-limit", NULL, NULL,
|
g_param_spec_int ("rate-limit", NULL, NULL,
|
||||||
0, G_MAXINT, DEFAULT_RATE_LIMIT_MSECS, G_PARAM_READWRITE |
|
0, G_MAXINT, DEFAULT_RATE_LIMIT_MSECS, G_PARAM_READWRITE |
|
||||||
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GFileMonitor:cancelled:
|
* GFileMonitor:cancelled:
|
||||||
*
|
*
|
||||||
* Whether the monitor has been cancelled.
|
* Whether the monitor has been cancelled.
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (object_class, PROP_CANCELLED,
|
props[PROP_CANCELLED] =
|
||||||
g_param_spec_boolean ("cancelled", NULL, NULL,
|
g_param_spec_boolean ("cancelled", NULL, NULL,
|
||||||
FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, G_N_ELEMENTS (props), props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,7 +254,7 @@ g_file_monitor_cancel (GFileMonitor *monitor)
|
|||||||
G_FILE_MONITOR_GET_CLASS (monitor)->cancel (monitor);
|
G_FILE_MONITOR_GET_CLASS (monitor)->cancel (monitor);
|
||||||
|
|
||||||
g_atomic_int_set (&monitor->priv->cancelled, CANCEL_STATE_CANCELLED);
|
g_atomic_int_set (&monitor->priv->cancelled, CANCEL_STATE_CANCELLED);
|
||||||
g_object_notify (G_OBJECT (monitor), "cancelled");
|
g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_CANCELLED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user