The Completed Code for Our Project #include GtkWidget *label; GtkWidget *entry; GtkWidget *list; static char *titles[] = { "Date", "Todo item for that day." }; void quit_function( ) { exit(); } void print_date( GtkWidget *src, gpointer user_data ) { char buf[256]; int month, day, year; char row_data[2][512]; char *rows[2]; char *todo_text; int row; /* Get the date from the calendar */ gtk_calendar_get_date(GTK_CALENDAR(src), &year, &month, &day); sprintf(buf, "%02d/%02d/%d", month+1, day, year); /* Get the todo entry */ todo_text = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); /* Place the date into the Todo date along with the Todo entry */ sprintf((char *)row_data[0], buf); sprintf((char *)row_data[1], todo_text); rows[0] = row_data[0]; rows[1] = row_data[1]; row = gtk_clist_prepend(GTK_CLIST(list), rows); /* Update the date label above the calendar */ gtk_label_set_text(GTK_LABEL(label), buf); /* Cleanup */ g_free(todo_text); } int main( int argc, char **argv ) { GtkWidget *window; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *cal; GtkWidget *quit; /* GTK initialization - required of every GTK program */ gtk_init(&argc, &argv); /* This establishes the top-level window, the parent of all other windows */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* Add a HBox, to handle horizontal layout, inside the top-level window. */ hbox = gtk_hbox_new(FALSE,0); gtk_container_add (GTK_CONTAINER (window), hbox); /* Add a VBox, to handle vertical layout, inside the hbox. */ vbox = gtk_vbox_new(FALSE,0); gtk_container_add (GTK_CONTAINER (hbox), vbox); /* A List for each days Todo */ list = gtk_clist_new_with_titles(2, titles); gtk_container_add (GTK_CONTAINER (hbox), list); gtk_clist_set_column_width(GTK_CLIST(list), 0, 140); gtk_clist_set_column_width(GTK_CLIST(list), 1, 240); /* A label gets added to the Vbox first. */ label = gtk_label_new("Date Chosen: None."); gtk_container_add (GTK_CONTAINER (vbox), label); /* The Calendar widget does most of the hard work for us */ cal = gtk_calendar_new(); /* Add the callback when a new date is chose */ gtk_signal_connect (GTK_OBJECT (cal), "day_selected", GTK_SIGNAL_FUNC (print_date), (gpointer)0); /* Place it after the label and inside our vertical layout box */ gtk_container_add (GTK_CONTAINER (vbox), cal); /* A text entry field for adding a note to each date */ entry = gtk_entry_new(); gtk_container_add (GTK_CONTAINER (vbox), entry); /* A Quit button, to exit gracefully */ quit = gtk_button_new_with_label("Quit"); gtk_container_add (GTK_CONTAINER (vbox), quit); /* Add the callback for the Quit button */ gtk_signal_connect (GTK_OBJECT (quit), "clicked", GTK_SIGNAL_FUNC (quit_function), (gpointer)0); /* And display all the windows */ gtk_widget_show(quit); gtk_widget_show(entry); gtk_widget_show(cal); gtk_widget_show(label); gtk_widget_show(list); gtk_widget_show(vbox); gtk_widget_show(hbox); gtk_widget_show(window); /* This is a main loop that all simple GTK applications go into. */ gtk_main(); return(0); }