Hi all,
I’m having fun making some objects at home using GObject-2.0. I created a Person object with these private members:
gchar *name;
gint age;
gboolean gender; (simplified, don't judge me)
Person *father;
Person *mother;
Now I have installed all of these as properties and was able to use the set_property
and get_property
methods to set and get each property as I would like. However, I’m struggling with traversing to the property I want, for example, if I want to get:
PersonA.father.name
I can use
g_object_get_property(G_OBJECT(PersonA), "father", &gval);
father = g_value_get_object(&gval);
g_object_get_property(G_OBJECT(father), "name", &gval2);
name = g_value_dup_string(&gval2);
and so on. Now as you can see, it is quite a hassle if I want to access the name of the person’s great grandfather:
PersonA.father.father.father.name
So the question is, is there a more convenient way to traverse the hierarchy and get to the property I want?
Your help is appreciated. And if I’m doing anything wrong, please don’t hesitate to point it out.
Best regards,
SL