Re: [gtk-list] Re: Spin button problem



On Wed, 30 Sep 1998, Havoc Pennington wrote:

> 
> On Wed, 30 Sep 1998, Robert M. Muth wrote:
> > 
> > The problem is that the hiding/showing of these button apparently
> > takes so long that the spin button will have triggered a new
> > "value_changed" signal by the time I am done.
> > This means that an attempt to increment the spin button value by 1 will
> > actually increment it by say 4.
> > 
> 
> That doesn't make sense to me - you should only get value_changed once per
> value change. So if the user clicks once, it should increment once. Maybe
> you have the step_size in the adjustment wrong?
 
I am pretty sure that the step_size is not the problem. 
BTW: My problems go away if I add a call "sleep(1);" to the
"value_changed" callback.

> In general a good solution for getting input too fast is to queue your
> button matrix update rather than doing it immediately. That is, write an
> idle function that updates the button matrix. Then keep a flag
> idle_function_installed; when the spin button changes, run:
> 
> if (!idle_function_installed) {
>   /* install your idle function */
> }
> else /* do nothing, update already pending */
> 
> When your idle function finished it should update itself and flip the
> idle_function_installed flag.


I contemplated doing that but it feels some what of an overkill.


> Then you will only get one update per continuous series of events. If
> that's still too many updates, you can use a timeout instead of an idle,
> so you update only once anytime there are multiple events in the same
> small timeslice. 
> 
> HTH,
> Havoc
> 

If anybody feels the urge to look at my code. I have placed a copy of it
at ftp://ftp.cs.arizona.edu/people/muth/trommler.buggy.tar.gz
Besides the code it also contains an executable.
The problem is with the spin button which has the label "Units:"
next to it. Strange enough the  very similar spin button
"BPUs:" does not exhibit this problem.

The relevant callback is "gui.c::ActionChangePatternUnits"
which in turn call gui.c::SetPatternLength to show/hide the buttons.

Any help is greatly appreciated.

	Robert






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