Re: The g_object_{set,get} class of functions seem strange
- From: Havoc Pennington <hp redhat com>
- To: skip pobox com (Skip Montanaro)
- Cc: gtk-list gnome org
- Subject: Re: The g_object_{set,get} class of functions seem strange
- Date: 22 Jun 2001 14:08:38 -0400
Skip Montanaro <skip pobox com> writes:
> In trying to figure out how I can get a list of property names for an
> object, I came across the g_object_set and g_object_get functions and their
> _valist versions. Their signatures seem rather bizarre to me. The get
> functions are declared to return void while the set functions are declared
> to return a gpointer. How does g_object_get return values to its caller
> (g_object_get_valist does something weird with its var_args argument)? Why
> doesn't it just allocate an array of gpointers and return them? Why does
> g_object_set need to return its first argument to its caller?
>
The return value is a conspiracy by Tim to confuse people. ;-)
Well, it is to support some kind of bizarre coding style:
g_object_set (object, "child_object",
g_object_set (object2, "foo", 10, NULL),
NULL);
Basically my recommendation is to pretend it returns void.
g_object_get() works like this, say "foo" is an integer property:
int val;
g_object_get (object, "foo", &val, NULL);
To get a list of properties that exist for an object you'd use
something like g_object_class_list_properties().
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]