g_object_get_property could return the GValue passed in, instead of void



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, } ;

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.

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




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