I write a program in which when user click on the main window button a dialog is displayed . on the dialog is a button I want both dialogue and main window destroy when user press dialogue button I write following code but is dosent work what is the problem?
Code:
#include <gtk/gtk.h>
GtkWidget *window;
gint delete_event(GtkWidget *widget,GdkEvent *event,gpointer data)
{
gtk_main_quit();
return FALSE;
}
void hi(GtkWidget *widget , gpointer data)
{
GtkWidget *win;
GtkWidget *label;
label=gtk_label_new("MAN GTK RO DOST DARAM");
gtk_window_set_transient_for(GTK_WINDOW(win),GTK_WINDOW(window));
win=gtk_dialog_new_with_buttons("WELCOME",GTK_WINDOW(window),GTK_DIALOG_DESTROY_WITH_PARENT,"yes",-5,NULL);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win)->vbox),label);
gtk_window_set_destroy_with_parent(GTK_WINDOW(window),TRUE);
gtk_widget_show(label);
int as=gtk_dialog_run(GTK_DIALOG(win));
if (as==-5){
gtk_widget_destroy(win);
}
}
int main(int argc , char *argv[])
{
gtk_init(&argc,&argv);
GtkWidget *button;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
button=gtk_button_new_with_label("_SHOW DIALOG");
gtk_container_add(GTK_CONTAINER(window),button);
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(hi),NULL);
g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(delete_event),NULL);
gtk_widget_show(window);
gtk_widget_show(button);
gtk_main();
return 0;
}
And the second question GTK_DIALOG_MODAL is what kind of dialogue ? is it possible for you to show a form of this dialogue for me? :( ...