[gtkada] Addressing external data in a GUI

Rick Duley 30294025 at student.murdoch.edu.au
Wed Jun 1 03:10:53 CEST 2005


Hi Emmanuel

You wrote:

>
> There is not a single global variable in GPS used for that purpose, so I
> am sure you are not using the right technics.
>

I don't know how GPS is involved here.  What I have done is include the
"necessary" access type in the record that defines the Window.  Oh, I 
am _sure_
it is not the _right_ technique - it's terrible Ada!  That's why I am 
trying to
find out what the _right_ technique _is_!

You wrote:

>
> Start with "4.3 Handling user data".
>

Well, I have read that, and re-read it, but I am none the wiser.

Perhaps some of the confusion arises from the fact that the GUI stubs 
with which
I am working are created by Glade_2, but that won't be all of it.  I 
had a quick
look this morning but I haven't found the instantiation of the generic package
User_Callback.  It must be there, I just didn't have enough time to find it,
perhaps someone can tell me offhand.

Anyway: I cannot see how a widget can raise a callback involving data 
originally
defined outside the GUI.  Given that, how can I have a callback 
declaration such
as:

procedure My_Callback(Widget    : access Gtk_Widget_Record'Class,
                       User_Data : in out My_External_Data_Access_Type);

Somehow, the body of the callback must have access to User_Data but I 
cannot see
how the Widget (which raises the callback) can 'know about it' unless it is
global to the Toplevel Widget.  Then, if User_Data is global to the Toplevel
Widget, why use a parameter?  I know it is good Ada to use parameters, 
but then
it is not good Ada to use global variables in the first place and if I have
sinned by included them should I not sin the more by using them?  You have!
Refer to Gtk User's Guide p.15, section 4.3.1:

When you define the procedure My_Destroy2 you include the statement:

   Destroy(Data);

There is no parameter 'Data' to the procedure 'My_Destroy2'.  Therefore 
you must
be making a call to something which is globally visible!

No matter how many times I have read Chapter 4 of the User's Guide I have not
devised some image in my mind of the linkages between the different entities.
This is the major problem.  Perhaps you could draw me (and the rest of the
confused) a picture.  I'd really like to get to the bottom of this sooner
rather than later.

All help is much appreciated.

Cheers


-------------------------------------------
"Professional qualitative judgement
    consists in knowing the rules
      for using (or occasionally breaking)
        the rules."
                             D. Royce Sadler
-------------------------------------------
Rick Duley
Murdoch University
School of Engineering Science
Perth, Western Australia
http://eng.murdoch.edu.au/~rick
aussie : 040 910 6049                .-_|\
o'seas : + 61 40 910 6049           /     \
                               perth *_.-._/
                                          v



More information about the gtkada mailing list