How do I dispatch a signal containing a variant with DBus-GLib?

David Tucker David.Tucker at hillcrestlabs.com
Fri Oct 9 15:44:02 PDT 2009


Hi all,

 

I'm using the DBus-GLib bindings and would like to dispatch a signal
containing a GValue variant type.  I am not able to receive signals that
contain a variant type, but I am able to dispatch and receive signals
using non-variant types. 

I'm also able to send and receive GValue types using method calls just
fine. 

 

I'm using the following code: 

(again, this works fine when sending a char*, or other non-variant,
instead of GValue)

 

Introspection:

<signal name="VariantSignal">

<arg type="v" name="value" />

</signal>

 

C code fragments:

--to create the signal ----

signals[VARIANT_SIGNAL] =

    g_signal_new ("VariantSignal",

                  G_OBJECT_CLASS_TYPE (klass),

                  (GSignalFlags) (G_SIGNAL_RUN_LAST |
G_SIGNAL_DETAILED),

                  0,

                  NULL, NULL,

                  g_cclosure_marshal_VOID__BOXED,

                  G_TYPE_NONE, 1, G_TYPE_VALUE);

 

----- to dispatch the signal  ---

    GValue gv = {0};

    g_value_init(&gv, G_TYPE_STRING);    

    g_value_set_string(&gv, "Hello");    

    g_signal_emit (obj, signals[VARIANT_SIGNAL], 0, value);

    return TRUE;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20091009/d5757589/attachment.html 


More information about the dbus mailing list