comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: GTK and tasking (GNAT)
Date: Sat, 03 May 2014 22:23:01 +0100
Date: 2014-05-03T22:23:01+01:00	[thread overview]
Message-ID: <lyeh0ablqi.fsf@pushface.org> (raw)
In-Reply-To: bsl1uhFd8asU1@mid.individual.net

hreba <hreba@terra.com.br> writes:

>             accept StartCounter (txtBox: Gtk.GEntry.Gtk_Entry) do
>                for i in 1..10 loop
>                   Gtk.GEntry.Set_Text (txtBox, Integer'Image(i));
>                   Gtk.Widget.Queue_Draw (Gtk.Widget.Gtk_Widget(txtBox));
>                   delay 0.5;
>                end loop;
>             end StartCounter;

The calling task (probably the Gtk main loop) blocks while the body of
the accept statement is executed.

I don't know how this ought to be done in Gtk, though I strongly suspect
it's not like that! However, the way to deal with the task problem would
normally be to save the values passed with the accept and deal with them
afterward:

   accept StartCounter (txtBox: Gtk.GEntry.Gtk_Entry) do
      txtBoxCopy := txtBox;
   end StartCounter;
   --  Now the caller can carry on while we work with the passed value.
   for i in 1..10 loop
      Gtk.GEntry.Set_Text (txtBoxCopy, Integer'Image(i));
      Gtk.Widget.Queue_Draw (Gtk.Widget.Gtk_Widget(txtBoxCopy));
      delay 0.5;
   end loop;

Questions: is Gtk thread-safe? is Queue_Draw something that should only
be called from the Gtk event queue?


  reply	other threads:[~2014-05-03 21:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-03 20:30 GTK and tasking (GNAT) hreba
2014-05-03 21:23 ` Simon Wright [this message]
2014-05-04 18:10   ` hreba
2014-05-04 18:29     ` Simon Wright
2014-05-04 22:10   ` hreba
2014-05-04  7:31 ` Dmitry A. Kazakov
2014-05-04 18:36   ` hreba
2014-05-04 19:26     ` Dmitry A. Kazakov
2014-05-04 20:40       ` hreba
2014-05-04 21:07         ` Shark8
2014-05-04 21:32           ` hreba
2014-05-04 21:44             ` Shark8
2014-05-04 21:57               ` hreba
2014-05-05  7:33             ` Dmitry A. Kazakov
2014-05-06 12:43               ` hreba
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox