Question aboutusing message dialog to ask confirmation



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.

However if I get rid of the "response" signal and put

retval = gtk_dialog_run(GTK_DIALOG(dlg));
gtk_widget_destroy(dlg);

if (retval ==  GTK_RESPONSE_YES)  {

        /* Do stuff */
}
else  {
        /* Get out of here */
}

It works OK.

"Is this a bug or a feature"?


John Collins Xi Software Ltd www.xisl.com




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