[jsonrpc-glib] client: allow detailed notification signals
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jsonrpc-glib] client: allow detailed notification signals
- Date: Sun, 24 Dec 2017 22:06:47 +0000 (UTC)
commit b673f1a3a1273a01feba0fc31c4e72216fc5cd9d
Author: Christian Hergert <chergert redhat com>
Date: Sun Dec 24 14:05:13 2017 -0800
client: allow detailed notification signals
This is convenient so you can have separate signal connections
for different notifications. For example, if you have a
notification with method "mount-added", you could connect with
something like:
g_signal_connect_object (client,
"notification::mount-added",
G_CALLBACK (mount_added_cb),
self,
G_CONNECT_SWAPPED);
This is useful to allow consumers to avoid having to do their
own notification dispatch function.
src/jsonrpc-client.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/jsonrpc-client.c b/src/jsonrpc-client.c
index a786a57..d84657b 100644
--- a/src/jsonrpc-client.c
+++ b/src/jsonrpc-client.c
@@ -458,7 +458,7 @@ jsonrpc_client_class_init (JsonrpcClientClass *klass)
signals [NOTIFICATION] =
g_signal_new ("notification",
G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (JsonrpcClientClass, notification),
NULL, NULL, NULL,
G_TYPE_NONE,
@@ -633,8 +633,10 @@ jsonrpc_client_call_read_cb (GObject *object,
if (g_variant_dict_lookup (&dict, "method", "&s", &method_name))
{
+ GQuark detail = g_quark_try_string (method_name);
+
params = g_variant_dict_lookup_value (&dict, "params", NULL);
- g_signal_emit (self, signals [NOTIFICATION], 0, method_name, params);
+ g_signal_emit (self, signals [NOTIFICATION], detail, method_name, params);
}
goto begin_next_read;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]