#include <gtk/gtk.h>
void button_event(GtkWidget *widget, gpointer *data);
void destroy(GtkWidget *widget, gpointer *data);
int main(int argc,char *argv[ ])
{
GtkWidget *window;
GtkWidget *button;
gtk_init(&argc,&argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),”destroy”,G_CALLBACK(gtk_main_quit),NULL);
button=gtk_button_new_with_label(“Exit”);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_signal_connect(GTK_OBJECT(button),”clicked”,G_CALLBACK(button_event),NULL);
gtk_widget_show(button);
gtk_widget_show(window);
gtk_main();
}
void button_event(GtkWidget *widget, gpointer *data)
{
GtkWidget *button;
GtkWidget *dialog;
dialog=gtk_dialog_new( );
button=gtk_button_new_with_label(“Yes”);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),button,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(button),”clicked”,G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show(button);
button=gtk_button_new_with_label(“No”);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),button,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(button),”clicked”,G_CALLBACK(destroy),dialog);
gtk_widget_show(button);
gtk_widget_show(dialog);
}
void destroy(GtkWidget *widget, gpointer *data)
{
gtk_widget_destroy(GTK_WIDGET(data));
} |