Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GTK probs

Status
Not open for further replies.

VBMan

Programmer
Jul 1, 2000
49
0
0
US
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), &quot;Hello World!&quot;);
gtk_signal_connect(GTK_OBJECT(window), &quot;delete_event&quot;,
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(&quot;Hello Linux. This is Ben coding with GTK!&quot;);
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

 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top