Re: Best practise inheritance

2017-03-21 Thread S. Jacobi
On Tue, 21 Mar 2017 20:53:04 + Emmanuele Bassi wrote: > > Also, do not store a private pointer in your instance structure, and > use the get_private_instance() function that the G_DEFINE_TYPE macro > creates for you. > So you say whenever I need access to the objects private data I should c

Re: Best practise inheritance

2017-03-21 Thread S. Jacobi
On Mon, 20 Mar 2017 16:01:39 + Tristan Van Berkom wrote: > > Use instance private data, this will not need any priv pointer and > can be done with th G_DEFINE_TYPE_WITH_PRIVATE() macro, and another > to lookup your private data inside your C file (under the hood, this > uses negative instanc

Re: Best practise inheritance

2017-03-20 Thread S. Jacobi
On Mon, 20 Mar 2017 18:10:16 +0100 Joël Krähemann wrote: > Hi > > As Tristan told you. The struct contains the other struct as not using > a pointer. > > struct MyCompositeWidget > { > GtkAlignment alignment; > > GtkBox *box; > }; > The parent-is-a-pointer mistake was just me not thinking

Re: Best practise inheritance

2017-03-20 Thread S. Jacobi
On Mon, 20 Mar 2017 16:01:39 + Tristan Van Berkom wrote: > > Use instance private data, this will not need any priv pointer and > can be done with th G_DEFINE_TYPE_WITH_PRIVATE() macro, and another > to lookup your private data inside your C file (under the hood, this > uses negative instanc

Best practise inheritance

2017-03-20 Thread S. Jacobi
First of all, inheritance may be the wrong word here in plain c, but I don't know how else to name it. In different projects I see different approaches how to derive custom widgets from existing ones. I can roughly group them into 2 to 3. 1) The header only has a typedef to make the struct opaque