cvs: php-gtk-doc /examples/reference/gtk/gtk timeout_add.phpw /manual/en/reference/gtk gtk-functions.xml

From: Date: Mon, 20 Nov 2006 14:06:40 +0000
Subject: cvs: php-gtk-doc /examples/reference/gtk/gtk timeout_add.phpw /manual/en/reference/gtk gtk-functions.xml
Groups: php.gtk.doc 
Request: Send a blank email to php-gtk-doc+get-3089@lists.php.net to get a copy of this message
cweiske Mon Nov 20 14:06:40 2006 UTC Added files: /php-gtk-doc/examples/reference/gtk/gtk timeout_add.phpw Modified files: /php-gtk-doc/manual/en/reference/gtk gtk-functions.xml Log: Gtk::timeout_add() documentation and example http://cvs.php.net/viewvc.cgi/php-gtk-doc/manual/en/reference/gtk/gtk-functions.xml?r1=1.13&r2=1.14&diff_format=u Index: php-gtk-doc/manual/en/reference/gtk/gtk-functions.xml diff -u php-gtk-doc/manual/en/reference/gtk/gtk-functions.xml:1.13 php-gtk-doc/manual/en/reference/gtk/gtk-functions.xml:1.14 --- php-gtk-doc/manual/en/reference/gtk/gtk-functions.xml:1.13 Fri Aug 11 05:15:33 2006 +++ php-gtk-doc/manual/en/reference/gtk/gtk-functions.xml Mon Nov 20 14:06:40 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8" ?> -<!-- $Revision: 1.13 $ --> +<!-- $Revision: 1.14 $ --> <refentry id="gtk.functions"> <refmeta> <!-- do *not* change this to "Gtk Static Methods" or anything @@ -2443,7 +2443,31 @@ Adds a callback to be called at regular intervals. </shortdesc> <desc> + <para> + Registers a function to be called periodically. + The function will be called repeatedly after + <parameter>interval</parameter> milliseconds until it + returns <literal>false</literal> (or nothing) at which point the timeout + is destroyed and will not be called again. + </para> + <para> + So to keep the timeout alive, your callback function + needs to <literal>return true;</literal> + </para> + <example> + <title>Using Gtk::timeout_add() to create a simple clock</title> + <programlisting role="php"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="&directory.examples;/reference/gtk/gtk/timeout_add.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + <para> + The integer returned by this method can be used by + <function class="Gtk">timeout_remove</function> to destroy + the timeout independent of the return value of the callback. + </para> </desc> </method> @@ -2475,7 +2499,14 @@ Removes a callback from being called at regular intervals. </shortdesc> <desc> - + <para> + Destroys a timeout, stopping the callback from being + called periodically. + </para> + <para> + <parameter>timeout_handler_id</parameter> is the value + returned by <function class="Gtk">timeout_add</function>. + </para> </desc> </method> http://cvs.php.net/viewvc.cgi/php-gtk-doc/examples/reference/gtk/gtk/timeout_add.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/reference/gtk/gtk/timeout_add.phpw +++ php-gtk-doc/examples/reference/gtk/gtk/timeout_add.phpw <?php //Simple clock using Gtk::timeout_add() //At first, we need a label displaying the time $lbl = new GtkLabel('Clock'); //Now, call function "onTimeout" every 1 second // (1 second == 1000 milliseconds) //Also pass $lbl as parameter so we can // change it in the function without using // global variables (bad!) Gtk::timeout_add(1000, 'onTimeout', $lbl); //our callback function has one parameter, // the one we defined in Gtk::timeout_add() function onTimeout($lbl) { //do the things we want to do $lbl->set_text(date('H:i:s')); //at the end, return "true" if the timeout shall // be executed again. If you don't return anything // or return false, the timeout is stopped. return true; } //standard stuff $wnd = new GtkWindow(); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $wnd->add($lbl); $wnd->show_all(); Gtk::main(); ?>

« previous php.gtk.doc (#3089) next »