Well, I'm hardly the expert, but I typically declare things like that in 
main() and pass them to the routines and callbacks as userdata if it's 
needed. For example, let's say you have an array of guint's to hold each 
of your timer id's (or if you don't know how many you'll have, perhaps a 
GSlist of guint).

#define TIMER_ID_COUNT 4

/* array containing 5 timer id's */
guint timeout_id_array[TIMER_ID_COUNT];

/*
... calls to g_timeout_add() storing
the return values in the timeout_id_array array...
*/

g_signal_connect(G_OBJECT(button1), "clicked",
            G_CALLBACK(on_button1_clicked), timeout_id_array);

/* or if you're using libglade */

glade_xml_signal_connect (gxml, "on_button1_clicked",
                G_CALLBACK(on_button1_clicked), timeout_id_array);

I've even put some data into structures when I'm passing the same group 
of data
around a lot. That way I only have to pass one pointer. But then again, 
I haven't
been doing this very long. I'm sure there are better ways.


- Micah Carrick
  http://www.micahcarrick.com | GTK+ Forums http://www.gtkforums.com


chao yeaj wrote:
> Hello,all
>     You know ,we can register a timeout function  using g_timeout_add
>    and g_timeout_add return an  ID
>
>     And,we must mannually remove the timeout function  using g_source_remove
>
>
>     The problem is,in my application,there are several  timeout
> functions ,in many modules
>
>     In my application,when and how to remove the timeout function is
> depents on  many conditions
>
>      I have no idea about how to store  the   ID    returned by
> g_timeout_add,I think  using  global  variable is not a good idea
>
>      How to mange the id?  I need your advise!
> Any comments would be much appreciated , thanks in advance !
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to