Destroying spin button on value change



I'm writing gtk code in which I want to destroy a spin button whenever
the user lowers it's value to zero.  So I connect the 'value-changed'
signal of the spin button's adjustment to a callback.  The callback
checks the value of the adjustment - if it is zero, it
gtk_widget_destroy()s the spinbutton (along with it's container and a
sister widget, but I don't think thats relevant).

When I run the prog and lower the spin value to 0 (using the down
arrow), the following error loops on the console until I terminate the
app (WM close works fine):

Gtk-CRITICAL **: file gtkspinbutton.c: line 1275
(gtk_spin_button_real_spin): assertion `GTK_IS_SPIN_BUTTON
(spin_button)' failed.

>From looking through the source, it appears that the handler for the
button press event emits the adjustment value changed signal before
updating the spin button; thus the spin button is gone before it get's
to that code, hence the error in real_spin.

So how can I fix it?  I couldn't find an entry point between the
value-changed emmision and real_spin to head off the error.  I could use
the value changed handler to set a flag or set up another signal handler
to delete the spin button 'later', but what can I hook into that will be
called immediately after the spin button has finished updating but not
before.

This is all gtk+ v1.2.8.  Actually, it is through PyGTK, but I don't
think the python layer has a great deal to do with it.

TIA,
Jay





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