Re: gtk_spin_button_set_adjustment without triggering value-changed signal



I've used constructs along the lines of:

   GtkWidget *spin_button = gtk_spin_button_new_with_range (...);
   gulong spin_handler = g_signal_connect (...);

   // whatever

   g_signal_handler_block (spin_button, spin_handler);
   gtk_spin_button_set_value (spin_button, ...);
   g_signal_handler_unblock (spin_button, spin_handler);




On 02/06/17 15:14, Anthony Ruth wrote:
Hello,

I have a bunch of spin buttons with the "value-changed" signal connected:

        g_signal_connect_swapped(spinbutton, "value-changed", G_CALLBACK
(run),NULL);

When I load a file, I want to set sane values for the spin buttons and I do
this by calling gtk_spin_button_set_adjustment.


gboolean load()
{
         //Do stuff with file chooser
         gtk_spin_button_set_adjustment(spinbutton1,gtk_adjustment_new (0,
0, T_max, 1, 10, 0.0));
gtk_spin_button_set_adjustment(spinbutton2,gtk_adjustment_new (T_max, 0,
T_max, 1, 10, 0.0));
          run();
          return TRUE;
}
The problem is that when gtk_spin_button_set_adjustment is called it
immediately triggers the signal. So for instance after I call set
adjustment on spinbutton1 it goes and triggers the "run" function, even
before setting the adjustment on spinbutton2. This triggers the function
"run" with insane values. I tried using change-value instead of
value-changed, but then the signal does not trigger even when I manually
adjust the spinbutton. How can I prevent gtk_spin_button_set_adjustment
from triggering the value-changed event? I only want the event to trigger
if the user changes the value of the spin button?


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





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