Re: Interdependent adjustments conundrum



[...]

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.

The "instance" argument is the object (the GtkAdjustment in your case)
on which the signal has been set. You don't need to keep the IDs, it's
probably much easier to use g_signal_handlers_[un]block_by_func, which
allow you to (un)block handler by instance, function and user_data.

You then put some kind of the following into the handlers of A, B, and
C:

g_signal_handlers_block_by_func(
        D,
        [Function which was connected on D],
        [Data which was connected on D, probably NULL]);

gtk_adjustment_change_value(D, d);

g_signal_handlers_unblock_by_func([same arguments as above]);


This will prevent your callback from being invoked between block and
unblock calls.

Kind regards,
Patrik Fimml




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