g_object_get_property() with unknown type



Given a GObject* and a property name, what are the steps
required to extract the property inty a GValue, not
knowing its type beforehand?

It seems I can only make g_object_get_property work if
I set the type of the GValue before the call.

This code works when the property is string-valued:

	GValue v = {0, };
	g_value_init(&v, G_TYPE_STRING);
	g_object_get_property(object, name, &v);

- but is it not possible to initialize the GValue in a
manner so that  g_object_get_property()  can switch to
the appropriate type?

I tried with G_TYPE_INVALID and G_TYPE_NONE but this doesn't
work.

If I really do need to walk the type information, what are the
steps required to find out the type and initialize the GValue?





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]