I already thought of blocking handlers during refresh, but it means adding two instructions (_block and _unblock) for each set_value().

A simple and clear sequence of instructions:

  _set_value()
  _set_value()
  ..

will be transformed in a complex, long and cryptic sequence of instructions:

  _block()
  _set_value()
  _unblock()
  _block()
  _set_value()
  _unblock()


I hoped there was another better solution. Actually I'm using a flag that is checked in the handler:

  refreshing = True
  _set_value()
  _set_value()
  ...
  refreshing = False

  # In the handler
  if not refreshing:
    # Process the handler

This is simple enough, but I have to remember to check the flag in the handler and this is error prone.


Il 01/11/2016 20:33, Chris Moller ha scritto:
Have you tried

g_signal_handler_block (gpointer instance, gulong handler_id);

and

g_signal_handler_unblock (gpointer instance, gulong handler_id);

Putting these before and after your set_value() should temporarily block the handler.

You get the handler_id from g_signal_connect(...):

handler_id = g_signal_connect(...);



On 11/01/16 11:29, pozzugno wrote:
I have a SpinButton with an associated Adjustment. I connected a handler for "value-changed" signal, because I have to make something when the user changes the value. I sometimes need to change the value in the code, using set_value() method of SpinButton or Adjustment. In this case, I don't want to execute the signal handler.

I will try to describe the situation. I have many widgets on the window, mainly SpinButton (but I have Entry too). I retrieve the values from remote, so I use set_value() methods for each widget when the values are received. The user can change some values and I need to detect this, because I have to send the new values to remote. So I have to connect a custom signal handler. Of course, I have to avoid calling the signal handler when the values are changed by code.

Is it possible?



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to