Interdependent adjustments conundrum
- From: "Daniel Haude" <dunno stoptrick com>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Interdependent adjustments conundrum
- Date: Tue, 20 Jun 2006 10:11:55 +0200
Hello,
For argument's sake, let's consider the following situation: There are
four GtkAdjustments: A, B, C, D, with corresponding values a, b, c, d,
each linked to a GtkSpinButton (which probably doesn't matter). The
following condition is supposed to be always true: d = a + b + c.
I wrote two callbacks: One is called on a "value-changed" signal of either
A, B, C; it builds the sum d = d = a + b + c and calls
gtk_adjustment_change_value(D, d). This part, of course, works.
Now to adjustment D: When the user changes D, I want A thru C to assume
some default distribution with a = d/4, b = d/4, c = d/2. Of course, if I
plug these values into A thru C, they in turn change their value and send
the result back to D.
Not only that; all four values are supposed to be integers which
introduces rounding issues: If the user changes D to 10, the resulting
values are a = 2, b = 2, c = 5 which results in d = 9. This is the
behavior I want; however, this in turn emits another "value-changed" on D
which results in c = 4, d = 8 at which point the signal rigmarole finally
settles.
The behavior I need is this: If the user changes any one of A thru C, D is
updated accordingly. If he changes D, A thru C are filled with the default
split and D is updated to the resulting value without disturbing A thru C
another time round.
How is this accomplished?
I looked at g_signal_handler_block(); I do have the signal IDs (using some
ugly external global variables) but I can't figure out what the "instance"
argument is supposed to mean. But even if I could I wouldn't know how to
use it because where would I put it? Somehow D must distinguish the
value-changes of A, B, C that were caused by direct user interaction from
those that are a result of D issuing changes on A, B, C.
Thanks,
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]