Without so many detours hopefully I can help with something that has me stranded a whole week, I have a serious confusion with GTK + and its object system, reading the documentation of the GNOME project I understood that uses GType to have a list of all objects and its properties and GObject
is an abstract class with all the functions basically required.
Now my confusion is in the two functions _init
and class_init
, one initializes the instance of the class or the object and the other the class as such, within class_init
you have to initialize all the properties, virtual functions etc, but I found the mechanism for the properties of objects, explained here and left very lost. Why the properties do not go in the structure of the object ?, looking for a bit I found this response in this community which half explained me but left me the other half still in doubt, I show you my two structures:
Object structure
struct _WindowPrincipal
{
GtkWindow *padre;
GtkMenuBar *menuBar;
GtkDrawingArea *areaDibujo;
GtkGrid *grid;
};
Class structure
struct _WindowPrincipalClass
{
GtkWindowClass *clasePadre;
GtkMenuBar (*menu) ();
void (*design) (WindowPrincipal *self);
};
As you can see they do not have anything of the other world, in _WindowPrincipal
I define the parent that is a GtkWindow
and the properties of that instance, it has a menu, a drawing area and a grid for the design of the window , in the structure of the class two functions for the design of the menu and the design of the window.
In the function class_init
the properties are registered with GParamType
, but I do not find logic to this, so then, why do I define the properties in the structure of the object if in class_init
I will register them to the class and the object respectively? What logic does that have? Or am I confusing myself with two things that have nothing to do with it? I really can not understand it.