[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtkmm
Subject:    Re: how to lock two sliders or spin buttons
From:       "Amadeus W. M." <amadeus84 () cablespeed ! com>
Date:       2005-12-23 18:19:49
Message-ID: pan.2005.12.23.18.19.47.667241 () cablespeed ! com
[Download RAW message or body]

On Fri, 23 Dec 2005 10:22:03 +0100, Matthias Kestenholz wrote:

> Hi Amadeus,
> 
> On Fri, 2005-12-23 at 00:14 -0500, Amadeus W. M. wrote:
>> I want to mimic the behavior of the knobs in volume control applications.
>> Usually there is a knob for the left speaker and another for the right
>> one, and a lock check button. If the lock is on, sliding one of the knobs
>> moves the other one simultaneously.
>> 
>> I have two spin buttons rather than knobs, DxSpin and DySpin, and
>> callbacks on_DxSpin_changed() and on_DySpin_changed(), connected each to
>> the corresponding changed signal. 
>> 
>> >From within either callback, I read the value and set the other spin
>> button to the exact same value:
>> 
>> on_DxSpin_changed()
>> {
>>   if(Lock->get_active())
>>     DySpin->set_value(DxSpin->get_value());
>> }
>> 
>> and similarly for DySpin. This naive approach produces an infinite loop,
>> obviously: each time the Dx button changes the value of Dy, Dy will also
>> change the value of Dy, and so on.
>> 
>> How do I do this? 
> 
> You could test for equality before setting the new value, e.g.
> 
> if(Lock->get_active() && get_value()!=the_other->get_value()) {
> 	the_other->set_value(get_value());
> }
> 
> or something similar.
> 
> Matthias

Thanks, works like a charm!



_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic