[gtkada] Addressing external data in a GUI

Rick Duley 30294025 at student.murdoch.edu.au
Thu Jun 16 03:16:04 CEST 2005


Hi folks

Believe it or not, I think we're nearly there!  The last postings in 
this thread
from Stephen Leake and Preben Randhol both had the key I was looking 
for to the
way to address the main window of a widget.  Now I have a GUI which is doing
what I want it to do.  It's been a long road.  Thanks very much guys.

However, there is another step.

Here is the dream:

I have a task which creates the GUI.  The GUI accepts user input and writes it
to a record and, on command, passes a copy of the record to a protected type.
Another task, which runs the analysis engine reads the record from the
protected type and then goes about the business of analysis.  There is two-way
communication between the tasks through the protected type.  My current 
problem
is to have the Main Loop of the GUI include checks on flags and data in the
protected type.

My GUI includes a Gtk.Progress_Bar.  I tried to operate the progress_bar from
the GUI driver thus:

--==========
with Gtk.Main;
with Analyse60_Window_Pkg; use Analyse60_Window_Pkg;

-- debug
with Ada.Text_Io; use Ada.Text_Io;
-- debug

procedure Analyse60_Window is
    Analyse60_Window : Analyse60_Window_Access;
begin
    Gtk.Main.Set_Locale;
    Gtk.Main.Init;
    Gtk_New(Analyse60_Window);
    Show_All(Analyse60_Window);
    Gtk.Main.Main;

    -- debug
    loop
       Put_Line("Pulse");
       Analyse60_Window.Analyse60_Progress_Progressbar.Pulse;
       delay 0.5;
    end loop;
    -- debug
end Analyse60_Window;
--==========

The problem is probably obvious to you.  The 'Pulse' method is not addressed
until 'Main' is exited - by which time it is too late and an access failure
occurs.

In my dream, the Engine Task sets a flag in the protected type which is 
read by
the GUI Main Loop and the 'Pulse' method is called from there.  (In this
example, I am trying to make the call from the driver but it does not break in
to the Loop.  I tried adding a new method to Analyse60_Window_Pkg but that
didn't work either.)  What I cannot discern from reading the GtkAdaRM on
Gtk.Main is how to get the check on the flag made within the loop.  I must,
somehow, be able to make a modification to the list of things checked by the
Main Loop to carry out that check.

How do I do that?

I would much appreciate someone answering that question as clearly and
explicitly as Preben and Stephe answered the last one.

Thanks
-------------------------------------------
"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