Re: synchronize widgets without redundant signals
- From: Paul Davis <paul linuxaudiosystems com>
- To: JLM <jsado_sc1 comcast net>
- Cc: gtkmm-list gnome org
- Subject: Re: synchronize widgets without redundant signals
- Date: Mon, 10 Mar 2008 07:24:07 -0400
On Sun, 2008-03-09 at 19:48 -0400, JLM wrote:
> I am working on an application that will have multiple widgets that
> display the same value in different ways. For example I could have a
> scroll bar that represents a numeric value, and an entry that also
> represents the same value. That way the user can either slide the scroll
> bar or enter a value into the entry.
>
> What I am trying to avoid is having one value update cause multiple
> signals to be emitted. The concern is that this could lead to an
> infinite loop, particularly if the datatypes aren't exact with each
> other, and one widget update rounds one way and another rounds another
> for example.
>
> I'm looking for a way to call a widget's set_value() without having the
> on_value_changed() called, or the signal_value_changed() emitted.
That's what you *think* you're looking for.
But what you're actually looking for is Gtk::Adjustment. In fact,
precisely *one* Gtk::Adjustment that will be used by your scroll bar,
spin buttons, and what ever else. Each "Control" widget will update the
"Model" (Adjustment). The "Model" will emit "value_changed()" precisely
once, and they will all update. Each one will check to see if the
current value differs from the value they are showing in the "View". If
it is they will change that to match the new value. Of course, spin
buttons, scrollbars etc. do this automatically.
Before you start, google "model view controller programming".
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]