GTK退出对话框使用gtk_widget_destroy?

时间:2018-05-01 07:58:33

标签: c gtk gtk2

我编写了一个简单的应用程序来显示是/否对话框。这是我的计划:

static gint confirmation_dialog()
{
GtkWidget *label;
GtkWidget *box;
GtkWidget *dialog;
gint response;
gtk_init(NULL,NULL);
/* If we use convenience API function gtk_dialog_new_with_buttons,
    * last six function calls can be written as: */
dialog = gtk_dialog_new_with_buttons( "Confirmation",
                                        NULL,
                                        GTK_DIALOG_MODAL,
                                        GTK_STOCK_YES, GTK_RESPONSE_YES,
                                        GTK_STOCK_NO,  GTK_RESPONSE_NO,
                                        NULL );

/* Create label */
label = gtk_label_new( "There is new update, do you want to proceed?" );

/* Pack label, taking API change in account. */
 #if GTK_MINOR_VERSION < 14
box = GTK_DIALOG(dialog)->vbox;
#else
box = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) );
#endif
gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);

/* Show dialog */
gtk_widget_show_all( dialog );
/* Run dialog */
response = gtk_dialog_run(GTK_DIALOG(dialog));
//gtk_widget_hide( dialog );
gtk_widget_destroy(dialog);
return response;
}

当我单击是或否按钮时,将返回响应值。但程序无法退出对话框。大家可以帮我找出问题吗? 非常感谢。

0 个答案:

没有答案