Re-setting the callback function from within ... the callback function?
- From: Chris Quinn <cq htec demon co uk>
- To: gtk-list gnome org
- Subject: Re-setting the callback function from within ... the callback function?
- Date: Fri, 13 Apr 2001 11:21:10 +0100
Hello folks,
I ran into an endless loop when trying to replace a handler attached to a button from within the original handler itself.
It seems that while a handler has yet to return, attaching another handler for the same signal causes the new handler to immediately receive the signal that came from originally pushing the button. Thus the code below endlessly prints out "pressed..." once the button is clicked.
So my question is: is there a way upon entering a handler to stop the widget emitting a signal(or perhaps all signals) while a new handler is being installed, reactivating the widget afterwards?
I'm trying to structure my program in "continuation passing style" which emphasises callbacks as self-contained future directions for the program. The least ugly work-around I can think of is to generate a new button and replace the original on the display, so being free to attach a handler without risk of looping.
Thanks for any assistance.
Chris
void continuation( GtkWidget *widget,
gpointer callback_data )
{
g_print("pressed...\n");
gtk_signal_disconnect(GTK_OBJECT(button),signo);
display_tree();
}
void display_tree()
{
signo = gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(continuation), "clicked");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]