Re: timer or idle function ? HOWTO ?



>I would like to use the gtk_idle_add() function,
>but I'm not sure how to have widgets updated w/in
>the function. Does anybody have an example I
>could look at? 

you need to pass pointers to widgets, then use them:

gint my_idle_function (gpointer arg)

{
	GtkWidget *w = (GtkWidget *) arg;

	gtk_widget_do_something (w, ...);
	return (should_be_called_again ? TRUE : FALSE);
}

>Also, why does the "clicked" signal get sent when
>I call gtk_toggle_button_set_active()?

because GTK+ is broken like that :)

>Is there some widget or something that will send
>out signals periodically so I can update the
>screen ever 1second or so with new data?

gint my_timeout (gpointer arg)
{
	... do something, perhaps with `arg' ...

	return (should_be_called_again ? TRUE : FALSE);
}

gtk_timeout_add (1000, my_timeout, some_argument_pointer);

See the GTK+ tutorial for more details, then read the docs at gtk.org.

--p








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]