[gtkada] Callbacks
Preben Randhol
randhol at pvv.org
Mon Mar 6 10:20:57 CET 2000
I'm developing a small app for learning foreign language. It is not a
big app as I'm trying to learn both Ada 95, OOP and GtkAda at the same
time :-) Btw. thank you very much for the GtkAda documentation it is
great!
My problem is this. All the words are in a linked list. They are listed in
a clist widget too. Connected to the clist I have an Edit button.
My idea was that if I select an element and press edit then I should be able
to edit the element (actually the two words the foreign word and the
explanation in the native language) in two entry widgets.
I can make the latter into a new widget, that I could call say
My_Word_Edit, with the two entry widgets and a submit button.
When I press the edit button I now need to be able to tell
My_Word_Edit that it should get element #X in the linked list and that
it should edit this.
As I see it I have three options:
-- To put Clist, Edit and the MY_Word_Edit into the same object so that
they "know" eachother and the functions and therefore I can rather read
the selected value in the clist from the callback. Something like the
fileselector example in the documentation.
-- To have two callbacks connected to the Edit. One that first sets
which element to edit and then a second which does the rest (grabs focus
etc). I don't like this one as I'm not sure I can know that the
callbacks will happen in this order. Can I?
-- To have a callback with more than one argument, but then I have to
extend the marshallers package if I understand the GtkAda documentation
right.
From the GtkAda ref. manual:
This is the case for example when the callback accepts several
extra parameters. In such cases, two options are available: The
first option is to use the "standard" callback mechanism with
one parameter, this parameter being an array of arguments that
you will parse yourself. The second option is to create a new
Marshaller package. This is more interesting if more than one
callback will follow the same pattern. The body of this package
can be used as a good model to build such new marshallers. See
also the example in the GtkAda distribution for how to create
your own marshaller
Any hints much appreciated.
--
Preben Randhol -- [randhol at pvv.org] -- [http://www.pvv.org/~randhol/]
"Det eneste trygge stedet i verden er inne i en fortelling."
-- Athol Fugard
More information about the gtkada
mailing list