comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GtkAda and timeout
Date: Thu, 16 Sep 2021 15:05:33 +0200	[thread overview]
Message-ID: <shvfet$hl1$1@gioia.aioe.org> (raw)
In-Reply-To: b58495a7-5134-4b51-962f-d197d4cdaa2dn@googlegroups.com

On 2021-09-16 13:18, AdaMagica wrote:
> Example: a ticket automaton
> 
> When a ticket is selected (button press), the user has to insert coins (button press). If no coins are inserted within a certain time, the ticket selection is aborted.
> 
> Thus, I need a timeout that starts each time a button is pressed.
> 
> I'm struggling with the GtkAda RM and UG - no help. Also testgtk is no real help.

GTK is synchronous, there is no timeouts. You have two options:

1. An Ada task using a delay statement and then triggering GTK action.
2. A timer queued to the GTK loop.

Note that GTK is not multitasking, if you choose #1 you will need to 
marshal actions to the GTK loop (the task running it). See the GtkAda 
contributions how to use tasks with GTK.

For the option #2 see GLib.Main, the function Timeout_Add and generic 
package Generic_Sources queue a timer. When timer triggers you do your 
stuff and then remove the timer.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2021-09-16 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 11:18 GtkAda and timeout AdaMagica
2021-09-16 13:05 ` Dmitry A. Kazakov [this message]
2021-09-16 18:07   ` AdaMagica
2021-09-16 18:17     ` Dmitry A. Kazakov
replies disabled

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