[gtkada] Using libglade2 with GtkAda 2.0.0
Ludovic Brenta
ludovic.brenta at skynet.be
Tue Feb 18 00:28:46 CET 2003
Le dim 16/02/2003 à 11:58, Preben Randhol a écrit :
> you will loose the tests done by the compiler when not
> compiling the GUI. For example how do you ensure that the callbacks work
> properly? How do you make your own composite widgets etc... I can agree
> with the problems you may encounter when you change the layout of the
> GUI, but I don't want to loose the static strengths of Ada.
>
> This is also why I always hand-edit the GUI code a bit after generating
> it. Mostly it is to copy the body into my package, AND removing the
>
> pragma Suppress (All_Checks);
>
> which I don't think should be put in there by gate in the first place.
> At least it should be configurable.
I think you have a point. For long-lived systems and carefully written
GUIs, this is the way to go IMHO. However, I can imagine situations
where the GUI is not very important, compared to the rest of the
system. For example, one may want to build an artificial intelligence
engine, a database server, or a number-crunching program, and spend most
of their time optimising that and not the GUI that runs on top of it.
Or, there may be a situation where a system must support several UI's
(e.g. a text-based UI, a network-based UI, a GUI, and a web-based UI),
and each UI receives only little development time. IMHO, libglade is
good for this kind of situations; plus, later on, one may always choose
to run their .glade file through gate, hand-edit the code, and enhance
the GUI.
Now, to answer your specific questions:
> how do you ensure that the callbacks work properly?
Though there may not be a perfect answer, perhaps declaring a type along
the lines of
type Callback is access procedure
(Widget : access GTK_Widget_Record'Class;
User_Data : System.Address);
and using it to make sure all your callbacks have the proper prototype,
would help. You would use one User_Data object to represent your entire
application's model, thus separating the view (your glade file) and
controller (GtkAda) from it.
> How do you make your own composite widgets
You wouldn't make any; you would create a GUI by composing the existing
widgets.
To summarise, I think gate is the way to go for state-of-the-art,
hand-crafted GUIs, while libglade may be the better option for
prototypes, or when the GUI is not the top priority. And, if you start
a project using libglade, you can always switch to the state-of-the-art
approach later, taking advantage of the separation between the
application's data model and its GUI.
--
Ludovic Brenta.
More information about the gtkada
mailing list