Re: g_object_get_property could return the GValue passed in, instead of void



On Fri, 4 May 2007, Gabriel Schulhof wrote:

Hi!

I don't know how much of an ABI break this would be, since all current
code ignores the non-existent return value of g_object_get_property.

OTOH, were we to have

GValue *g_object_get_property (GObject *object, const gchar
*property_name, GValue *value);

We could do nice things like

GValue val = {0, } ;


where's your g_value_init? you cannot pass an uninitialized GValue into
g_object_get_property().

g_object_set (G_OBJECT (gtk_entry),
 "sensitive", g_value_get_boolean (
   g_object_get_property (G_OBJECT (checkbox), "active", &val)),
 NULL) ;

This expresses the relationship between the GtkEntry and the
GtkCheckButton quite clearly. In addition, if you were to switch to a
GtkToggleToolButton, for example, you wouldn't have to change the code
at all, because both have the "active" property.

well, if you correctly outline the missing g_value_init/g_value_unset
calls, the example is not so simple anymore...
in any case, feel free to file a bugzilla bug containing an implementation
patch for your requested feature.

Of course, it would be even nicer to just have a family of functions
g_object_get_<type> (object, "property") similar to g_value_get_<type>,
because it would save us the GValue declaration.



Gabriel

---
ciaoTJ



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