From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: hreba Newsgroups: comp.lang.ada Subject: Re: GTK and tasking (GNAT) Date: Sun, 04 May 2014 15:10:18 -0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net mVC6gROppqDHMK8HLR44vQRyetEoZ4ZppgGFB+YWOrxYUYwL2g Cancel-Lock: sha1:dIgKm0xorhdQCJe8dpv4wdk2XEo= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:19660 Date: 2014-05-04T15:10:18-03:00 List-Id: On 05/03/2014 06:23 PM, Simon Wright wrote: > hreba 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? > I didn't expect that my first excursion into GUI programming (GTK) with Ada would confront me with tasking and lead me into the cliffs of thread-safety. I am no software engineer, unfortunately I cannot answer these questions. So I will have a look at Dimitry's library. Thanks for the answer. -- Frank Hrebabetzky +55 / 48 / 3235 1106 Florianopolis, Brazil