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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,90658f16b7ae9f47 X-Google-Attributes: gid103376,public From: "Bobby D. Bryant" Subject: Re: Timers and GTK Date: 2000/01/11 Message-ID: <387B76A9.B73A35F1@mail.utexas.edu>#1/1 X-Deja-AN: 571285216 Content-Transfer-Encoding: 7bit References: <387A4644.5992EF02@ensica.fr> X-Accept-Language: en,fr,de Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@cc.utexas.edu X-Trace: geraldo.cc.utexas.edu 947615373 7432 128.83.46.95 (11 Jan 2000 18:29:33 GMT) Organization: The University of Texas at Austin Mime-Version: 1.0 NNTP-Posting-Date: 11 Jan 2000 18:29:33 GMT Newsgroups: comp.lang.ada Date: 2000-01-11T18:29:33+00:00 List-Id: 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