/** vertboxes.c **/ #include GtkWidget *makeBoxes(); gint eventDelete(GtkWidget *widget, GdkEvent *event,gpointer data); gint eventDestroy(GtkWidget *widget, GdkEvent *event,gpointer data); void buttonFill(GtkWidget *box,gboolean expand, gboolean fill,guint spacing); static gchar *buttonLabel[] = { "Purple", "Red", "Lavender\nBlue", "Yellow" }; int main(int argc,char *argv[]) { GtkWidget *window; GtkWidget *box; gnome_init("vertboxes","1.0",argc,argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(eventDelete), NULL); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(eventDestroy), NULL); box = makeBoxes(); gtk_container_set_border_width( GTK_CONTAINER(window),25); gtk_container_add(GTK_CONTAINER(window),box); gtk_widget_show(box); gtk_widget_show(window); gtk_main(); exit(0); } GtkWidget *makeBoxes() { GtkWidget *hbox; GtkWidget *buttonBox; GtkWidget *label; gboolean homogeneous; gboolean expand; gboolean fill; gint hCount; gint eCount; gint fCount; gint count = 0; gchar labelString[80]; hbox = gtk_hbox_new(FALSE,0); for(hCount = 0; hCount <= 1; hCount++) { homogeneous = hCount ? TRUE : FALSE; for(eCount = 0; eCount <= 1; eCount++) { expand = eCount ? TRUE : FALSE; for(fCount = 0; fCount <= 1; fCount++) { fill = fCount ? TRUE : FALSE; if(count > 0) { label = gtk_label_new(" "); gtk_box_pack_start(GTK_BOX(hbox), label,FALSE,FALSE,0); gtk_widget_show(label); } sprintf(labelString," %d. ",++count); label = gtk_label_new(labelString); gtk_misc_set_alignment( GTK_MISC(label),0,0); gtk_box_pack_start(GTK_BOX(hbox), label,FALSE,FALSE,0); gtk_widget_show(label); buttonBox = gtk_vbox_new(homogeneous,0); buttonFill(buttonBox,expand,fill,0); gtk_box_pack_start(GTK_BOX(hbox), buttonBox,FALSE,FALSE,0); gtk_widget_show(buttonBox); } } } return(hbox); } void buttonFill(GtkWidget *box,gboolean expand, gboolean fill,guint spacing) { GtkWidget *button; gint i; for(i=0; i<4; i++) { button = gtk_button_new_with_label(buttonLabel[i]); gtk_box_pack_start(GTK_BOX(box),button, expand,fill,spacing); gtk_widget_show(button); } } gint eventDelete(GtkWidget *widget, GdkEvent *event,gpointer data) { return(FALSE); } gint eventDestroy(GtkWidget *widget, GdkEvent *event,gpointer data) { gtk_main_quit(); return(0); }