[glib/wip/gdesktopappinfo: 5/20] GFileMonitor: support specifying a context
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gdesktopappinfo: 5/20] GFileMonitor: support specifying a context
- Date: Wed, 25 Sep 2013 20:37:14 +0000 (UTC)
commit 477f873ab0accc4a8e05980eb0743482a2b4ef7e
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jul 25 14:17:09 2013 -0400
GFileMonitor: support specifying a context
Add a new "context" construct-only property to allow explicitly
specifying the context in which events should be dispatched.
gio/gfilemonitor.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gio/gfilemonitor.c b/gio/gfilemonitor.c
index 974bd73..d8e974f 100644
--- a/gio/gfilemonitor.c
+++ b/gio/gfilemonitor.c
@@ -89,7 +89,8 @@ struct _GFileMonitorPrivate {
enum {
PROP_0,
PROP_RATE_LIMIT,
- PROP_CANCELLED
+ PROP_CANCELLED,
+ PROP_CONTEXT
};
/* work around a limitation of the aliasing foo */
@@ -113,6 +114,12 @@ g_file_monitor_set_property (GObject *object,
g_file_monitor_set_rate_limit (monitor, g_value_get_int (value));
break;
+ case PROP_CONTEXT:
+ monitor->priv->context = g_value_dup_boxed (value);
+ if (monitor->priv->context == NULL)
+ monitor->priv->context = g_main_context_ref_thread_default ();
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -260,6 +267,14 @@ g_file_monitor_class_init (GFileMonitorClass *klass)
FALSE,
G_PARAM_READABLE|
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_CONTEXT,
+ g_param_spec_boxed ("context",
+ P_("Context"),
+ P_("The main context to dispatch from"),
+ G_TYPE_MAIN_CONTEXT, G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
}
static void
@@ -269,7 +284,6 @@ g_file_monitor_init (GFileMonitor *monitor)
monitor->priv->rate_limit_msec = DEFAULT_RATE_LIMIT_MSECS;
monitor->priv->rate_limiter = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal,
NULL, (GDestroyNotify) rate_limiter_free);
- monitor->priv->context = g_main_context_ref_thread_default ();
g_mutex_init (&monitor->priv->mutex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]