Re: [gtk-list] Re: Automatic generation of gtk+ interface



Tero Pulkkinen writes:
> What data members should be used by users? (think of GtkFileSelection and
> buttons inside it -- users need access to it, but there's no way to determine
> if they're public or private or if you should be able to read value or
> set it on the fly etc..) Same situation is with many other widgets too...
>

I'd like to make a sugestion here which will probably raise a storm of
protest.:-)  Tero's comments above about GtkFileSelection above illustrate
a point nicely.

Basically, I consider GTK+'s interface to be horribly non object-orientated
despite all its claims to be. Tero speaks above of wanting to determine
'public' and 'private' members of the widget. This is surely a side effect
of widget implementers not being bothered to write their interfaces
properly. You should *never* expect to access a member of a widget's data
structure directly!

Why should I (as a user of GtkFileSelection) have to know that it contains
a struct member called "ok_button" or another called "cancel_button"?
Dammit - that might be true in version X of the code, but what if the writer
of GtkFileSelection decides to change it in version X+1? Everyone's code
breaks!


It might be harder work initially, but the writer of GtkFileSelection
*ought* to have provided access-functions or #defines to "wrap up" all
the functionality that a File_Selection box ought to provide.

I reckon that rather than saying:

	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), "clicked"....

..the user ought to say:

	gtk_signal_connect(GTK_OBJECT(fs), "OK-button-clicked",......



After all, if you want to get the selected filename out of a gtk_file_selection,
you make a call to "gtk_file_selection_get_filename", you don't go poking
around inside the widget. Why are the OK and Cancel buttons not similarly
wrapped?


GtkCombo is another fine example. You have to go poking around at it's 'list'
and 'entry' widgets.


And what about that query that was made on this list earlier in the week
about setting the alignment of labels in tables? The solution was to
cast the label to a GTK_MISC, then call 'gtk_misc_set_alignment'! Why oh
why didn't the writer of gtklabel.h provide a 'gtk_label_set_alignment'
wrapper?

Admittedly, all these wrappers would make the .h files bigger, but they don't
make the eventual *code* any bigger, and they do make the .h file become a
better document on what exactly a widget can do (thus solving Tero's problem).

--

Steve                                       | Steve's law of House Rewiring:
S.Hosgood@swansea.ac.uk                     | "No matter how many power sockets
Phone: +44 1792 297292 + ask for Steve      |  you fit in a room, you will run
Fax:   +44 1792 295811                      |  out within the first week of use
--------------------------------------------+  even if you took Steve's law of
http://iiit.swan.ac.uk/~iisteve/steve.html  |  House Rewiring into account"




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