I will definitely research "model view controller". From the quick scan I did at Wikipedia it sounds like a very good idea indeed.
I made my first pop up window. What I learned from it is; always use a interface designer because looking up and typing the code to set up the windows and event handling is a real pain in the butt. Took me a couple hours to find all the necessary bits to get it working. Then I redid the same window in Glade and it only took 5 min to accomplish the same task.
Code:
#include <stdlib.h>
#include <gtk/gtk.h>
static void hello(GtkWidget *widget, gpointer data){
g_print("Hello World it's Jim\n");
}
static gboolean delete_event(GtkWidget *widget,
GdkEvent *event,
gpointer data){
g_print("delete event occured\n");
return TRUE;
}
static void destroy(GtkWidget *widget, gpointer data){
gtk_main_quit();
}
int main(int argc, char *argv[]){
GtkWidget *window;
GtkWidget *button;
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "delete event",
G_CALLBACK(delete_event),NULL);
g_signal_connect(window, "destroy",
G_CALLBACK(destroy),NULL);
gtk_container_set_border_width(GTK_CONTAINER(window),10);
button = gtk_button_new_with_label("Hello World");
g_signal_connect(button, "clicked",
G_CALLBACK(hello),NULL);
g_signal_connect_swapped(button, "clicked",
G_CALLBACK(gtk_widget_destroy),window);
gtk_container_add(GTK_CONTAINER(window),button);
gtk_widget_show(button);
gtk_main();
return 0;
}