I'm just learning GTK so if my questions sound dumb... thats why. I'm editing a sample piece of code. I wish to make a window appear when the OK button is clicked. I got that... the problem is I don't want the X in the top of the window to kill the whole app... just the 2nd window. If I'm making any sense. Here's the code:
#include <gtk/gtk.h>
gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data){
gtk_main_quit();
return (FALSE);
}
void hello(int argc, char *argv[]){
GtkWidget *window;
GtkWidget *box1;
GtkWidget *box2;
GtkWidget *label;
GtkWidget *separator;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Hello World!"
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(gtk_widget_distroy),
GTK_OBJECT (window));
gtk_container_set_border_width(GTK_CONTAINER(window), 30);
box1 = gtk_vbox_new(FALSE, 10);
gtk_container_add(GTK_CONTAINER(window), box1);
label = gtk_label_new("Hello Linux. This is Ben coding with GTK!"
gtk_box_pack_start(GTK_BOX(box1), label, TRUE, TRUE, 0);
gtk_widget_show(label);
separator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(box1), separator, FALSE, FALSE, 5);
gtk_widget_show(separator);
box2 = gtk_hbox_new(FALSE, 10);
gtk_container_add(GTK_CONTAINER(box1), box2);
gtk_widget_show(box2);
gtk_widget_show(box1);
gtk_widget_show(window);
}
This code is for the second window. If you can read it any tips would be taken happily.
Thanks,
Ben
#include <gtk/gtk.h>
gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data){
gtk_main_quit();
return (FALSE);
}
void hello(int argc, char *argv[]){
GtkWidget *window;
GtkWidget *box1;
GtkWidget *box2;
GtkWidget *label;
GtkWidget *separator;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Hello World!"
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(gtk_widget_distroy),
GTK_OBJECT (window));
gtk_container_set_border_width(GTK_CONTAINER(window), 30);
box1 = gtk_vbox_new(FALSE, 10);
gtk_container_add(GTK_CONTAINER(window), box1);
label = gtk_label_new("Hello Linux. This is Ben coding with GTK!"
gtk_box_pack_start(GTK_BOX(box1), label, TRUE, TRUE, 0);
gtk_widget_show(label);
separator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(box1), separator, FALSE, FALSE, 5);
gtk_widget_show(separator);
box2 = gtk_hbox_new(FALSE, 10);
gtk_container_add(GTK_CONTAINER(box1), box2);
gtk_widget_show(box2);
gtk_widget_show(box1);
gtk_widget_show(window);
}
This code is for the second window. If you can read it any tips would be taken happily.
Thanks,
Ben