Comment 36 for bug 1349838

Revision history for this message
Siergiej Riaguzow (riaguzov) wrote :

Considering conventions:

From the answers in the Russian site linux.org.ru I've found out that maybe GTK guys have created their conventions by statistics. The most common scenarion when creating a GTK widget is to put it to container and add callbacks and such and forget about. So you need to upcast in GtkWidget* to do all that. As there are no upcasts in C they just decided to return GtkWidget* for every derived from GtkWidget type i type_new().

On the other hand what is stored in Private is also a question of convenience. If most things you do with widgets in you *Private is calling functions which accept GtkWidget or something in the middle of this then is make sense to store them as GtkWidget*. If mostly you use them with functions like concre_type_do_smth(...) then it is better to store them as ConcreteType.

From my observation when *Private if full of GtkWidgets it is very hard to understand the layout of the complex widget. So I propose to follow one of this two solutions:

First solution:

1. As all GTK *xxx_new() functions which return anything deriving from GtkWidget* return GtkWidget* and not Xxx* we should do the same
2. To increase readability we should store pointers to concrete types in *Private like Xxx* so that layout if obvious.

Second solution

1. As xpad is not a library we can as well return Derived* from deriver_new() even if Derived inherits from GtkWidget
2. Same as above

I think any of this solution is OK as long as we are consistent and don't store part of things derived from GtkWidget* as GtkWidget* in *Private and part as DerivedFromGktWidget*.

Am I really alone with that code style issue? No one cares, except me?