[gtkada] Addressing external data in a GUI
Michael Bode
michael.bode at laserline.de
Mon Jun 27 08:44:19 CEST 2005
Rick Duley schrieb:
>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:
>
>
I do things like that using a protected type and a timer or idle procedure.
In the worker package:
type status_record is
-- status information
end record;
protected Status is
procedure set (S: status_record);
function get return status_record;
end Status;
and in the GUI package:
function Display_Status return Boolean
is
S : Status_Record;
begin
Gdk.Threads.Enter; -- timeout callback must call this
S := Some_Instance_of_Status.Get;
...
Gdk.Threads.Leave; -- timeout callback must call this
return True;
end Display_Status;
ID := Gtk.Main.Timeout_Add (500, Display_Status'access); -- call it
every 500ms
Code not compiled, likely contains bugs.
--
Michael Bode
Laserline GmbH
Fraunhoferstr.
56218 Mülheim-Kärlich
Phone: +49 2630 964-2200
Fax: +49 2630 964-2209
More information about the gtkada
mailing list