On Fri, 16 May 2008 19:19:55 +0100 John M Collins wrote:

> I want to have a "do you really want to do this" type question and I'm
> trying to use a message dialog thus:
> 
> GtkWidget  *dlg = gtk_message_dialog_new(GTK_WINDOW(previous),
> GTK_DIALOG_DESTROY_WITH_PARENT,
>  GTK_MESSAGE_QUESTION,
>  GTK_BUTTONS_YES_NO, "Are you sure?");
> g_signal_connect_swapped(dlg,
>   "response", G_CALLBACK(gtk_widget_destroy), dlg);
>
> Then I put
> 
> if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_YES)  {
> 
>       /* Do the thing we asked about */
> }
> else  {
>       /* Get out of here */
> }
> 
> 
> the return value from gtk_dialog_run is never GTK_RESPONSE_YES, it's
> always zero whether the Yes or No button is clicked.

gtk_dialog_run() also connects to the 'response' signal.  You cannot
rely on signal callbacks being called in any particular order.  In your
case, likely your handler (gtk_widget_destroy()) is getting called
before gtk_dialog_run()'s response handler, so you destroy the widget
before the gtk_dialog_run() response handler can run.

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

Reply via email to