[gtkada] Addressing external data in a GUI

Rick Duley 30294025 at student.murdoch.edu.au
Mon Jun 27 04:27:07 CEST 2005


Hi folks

I have a Text Analysis engine which I wish to operate through a GUI to
facilitate User Input for the less computer-literate.  This engine is
Structured Design (not-quite-pure Jackson) and runs in batch mode in the
background.  It is not uncommon for this engine (with a Command-line Interface)
to run 24x7 for a couple of weeks - it'll run until it runs out of work.  For
the sake of user friendliness I want to be able to kill it in mid-run from the
GUI.  The only way I can see to do that is to run it from a task thereby
freeing the GUI to accept the command to Quit.  (This is the answer to Preben's
query as to why I want to use a task.  If I run the engine directly from the
GUI, the GUI siezes up until the program finishes of its own accord and you
can't click the Quit Button.  Alternatively, if the worst comes to the worst,
you can always abort a task!)  However, using a task causes other faults in the
user-friendliness.

My GUI has two features to inform the User of progress:
(1)  A Gtk.GEntry which displays the name of the file being processed;
(2)  A Gtk.Progress_Bar (in Pulse mode) to show that work continues.

My problem is adressing these widgets from the Engine, i.e. from outside the
GUI.  I have devised a task which does this.  It's a brutal way to do the job
but it's the only way I could devise.  Trouble is, to get the effects to
display properly on-screen I need the Interrupts created by moving the cursor
over the GUI - otherwise I get (at best) intermittent, jumpy movement of the
Progressbar.  (I don't want the User to have to sit all day moving the cursor
over the GUI. ;}  )  I've tried 'Grab_Focus', 'Show_All' and 'Show_Now' but I
just can't get the thing to update without the Cursor Interrupts.  This is the
task I devised:

--==========
   task body Engine_Type is
      GUI        : Analyse60_Window_Access;         -- Toplevel GUI.
      Signal_Box : Analyst.Signal.Box_Access_Type;  -- Protected Type.
      Arguments  : Arguments_Type;                  -- User-selected Settings.
   begin  -- Engine_Type
      accept Initialise                             -- Get the Links.
        (Window  : in     Analyse60_Window_Access;
         Signals : in     Analyst.Signal.Box_Access_Type)
      do
         GUI        := Window;
         Signal_Box := Signals;
      end;

      Run_Loop:  -- Dummy Analysis Engine.
      loop
         Signal_Box.Start(Law_Book => Arguments);      -- Get settings for job.

         Pretend_Loop:            -- Pretends to send messages from the engine.
         for Count in 1 .. 250 loop
            GUI.Analyse60_Progress_Progressbar.Pulse;  -- Move Progressbar.

            Gtk.GEntry.Set_Text                        -- Write a file name.
              (The_Entry => GUI.Analyse60_Processing_File_Entry,
               Text      => "This is file number" & Integer'Image(Count));

            delay 0.1;
         end loop Pretend_Loop;

         Signal_Box.Stop;                              -- Signal ready for job.
      end loop Run_Loop;
   end Engine_Type;
--==========

Q.1. Can someone please tell me how I can make the GUI display the changes made
from the task?

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