Re: Creating widgets with auto-repeat


"David J. Singer" <doc deadvirgins org uk> writes:

> Thanks to Pauk for the pointers on how to make my autorepeat
> code a bit more elegant, but having looked at the suggestions
> I'm a bit puzzled...
>     info->value++;
>     info->count = 0;
>     info->state = 0;
>     info->timer_id = gtk_timeout_add(REPEAT_STAGE0_DELAY, 
>                                       (GtkFunction)timer_func, info);
> The "gtk_timeout_add" line doesn't work, becasue you're *passing*
> the value of info->timer *before* it gets assigned.  Hence the timeout
> function doesn't know the ID of the timer....

I don't see the problem. You are passing a pointer to the info
structure and of course you can change it's contents later and the
timer_func will get the current value when it accesses info->timer_id.
Apart from that, I don't think you need the timer_id since you can
remove the timeout by returning FALSE from timer_func.

Salut, Sven

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