• GtkAda and timeout

    From AdaMagica@21:1/5 to All on Thu Sep 16 04:18:37 2021
    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.

    Christoph

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to AdaMagica on Thu Sep 16 15:05:33 2021
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From AdaMagica@21:1/5 to Dmitry A. Kazakov on Thu Sep 16 11:07:31 2021
    Dmitry A. Kazakov schrieb am Donnerstag, 16. September 2021 um 15:05:36 UTC+2:
    2. A timer queued to the GTK loop.
    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.

    It's this second option I'm trying. Doing slight progress...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to AdaMagica on Thu Sep 16 20:17:59 2021
    On 2021-09-16 20:07, AdaMagica wrote:
    Dmitry A. Kazakov schrieb am Donnerstag, 16. September 2021 um 15:05:36 UTC+2:
    2. A timer queued to the GTK loop.
    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.

    It's this second option I'm trying. Doing slight progress...

    #1 is actually based on #2. It installs is a timer that periodically
    checks if an Ada task requested some GTK action.

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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)