how can i use gtk signal for exiting a window and then a diolog message showed that questions that Are you sure? and by clicking in Yes button it closes all of windows? this is my code :
void show_queExit(GtkWidget *widget, gpointer window)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new(GTK_WINDOW(window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
"Are you sure to exit?");
gtk_window_set_title(GTK_WINDOW(dialog), "Exit");
gint result = gtk_dialog_run (GTK_DIALOG (dialog));
if (result==GTK_RESPONSE_YES)
{
g_signal_connect(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_destroy (dialog);
printf("\n***\n");
}
else
gtk_widget_destroy (dialog);
}
and this is my main function: int main(int argc, char **argv) {
gtk_init(&argc, &argv);
GtkWidget *window;
GtkToolItem *exitIcon;
GtkWidget *toolbar;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
toolbar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
exitIcon = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), exitIcon, -1);
gtk_window_set_default_size(GTK_WINDOW(window), win_width, win_height);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
g_signal_connect(G_OBJECT(exitIcon), "clicked",G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}