Re: Question aboutusing message dialog to ask confirmation
- From: "Eduardo M KALINOWSKI" <eduardo kalinowski com br>
- To: gtk-app-devel-list gnome org
- Subject: Re: Question aboutusing message dialog to ask confirmation
- Date: Fri, 16 May 2008 15:25:29 -0300
On Fri, May 16, 2008 at 3:19 PM, John M Collins <jmc xisl com> 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.
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"?
It is a feature, and of the kind that bears to similarity to a bug.
You do not need to use gtk_signal_connect to connect to the "response"
signal if you are using the standard interface: it is already
connected. By connecting, you are probably destroying the dialog
before the value can be read, and it is surprinsing that you do not
get some random garbage.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]