comp.lang.ada
 help / color / mirror / Atom feed
* Timers and GTK
@ 2000-01-10  0:00 GUILLOU Jacques
  2000-01-11  0:00 ` Bobby D. Bryant
  0 siblings, 1 reply; 2+ messages in thread
From: GUILLOU Jacques @ 2000-01-10  0:00 UTC (permalink / raw)


Can anyone help me using GTK timer functions ? (callback function that
is called every 100 ms for example) ?
thanx





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Timers and GTK
  2000-01-10  0:00 Timers and GTK GUILLOU Jacques
@ 2000-01-11  0:00 ` Bobby D. Bryant
  0 siblings, 0 replies; 2+ messages in thread
From: Bobby D. Bryant @ 2000-01-11  0:00 UTC (permalink / raw)


GUILLOU Jacques wrote:

> Can anyone help me using GTK timer functions ? (callback function that
> is called every 100 ms for example) ?
> thanx

By chance I just worked that out a couple of days ago.  The following
example uses the GtkAda bindings; I'm picking out lines that are widely
separated among my files, so here's hoping I haven't forgotten anything.

-----
Instantiate the "Timeout" package:

   -- Package for handling timeout callbacks:
   package Timeout_Callback is
      new Gtk.Main.Timeout( Data_Type => Integer );

[Use whatever data type you happen to need in your callback function.]

-----
Declare a variable to recieve the timeout's identifier:

      Timeout_Handle : Glib.Guint;

and a variable to define the interval (or just use a constant):

   Migration_Interval    : Glib.Guint := 1000; -- ms.

-----
Declare a function to be invoked by the timer:

   function Migrate( Number_To_Move : in Integer )
      return Boolean;

   function Migrate( Number_To_Move : in Integer ) return Boolean is
...
   begin
...
      return True; -- "false" will disable further timeouts on this.
   end Migrate;

[Notice that the integer argument matches the data type in the package I
instantiated above.]

-----
Set up the callback:

      Timeout_Handle
        := Timeout_Callback.Add( Interval => Migration_Interval,
                                           Func     => Migrate'Access,
                                           D        => 1000 ); -- # to
move.

[ The "D" value is passed to Migrate whenever it is invoked.]

-----
Works like a charm.  Good luck!

Bobby Bryant
Austin, Texas





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-01-11  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-10  0:00 Timers and GTK GUILLOU Jacques
2000-01-11  0:00 ` Bobby D. Bryant

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