+static GtkWidget *divedate, *divetime, *depth, *duration, *temperature, *locationnote;
+static GtkEntry *location;
+static GtkTextBuffer *notes;
+static int location_changed = 1, notes_changed = 1;
+static struct dive *buffered_dive;
+
+static const char *weekday(int wday)
+{
+ static const char wday_array[7][4] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ return wday_array[wday];
+}
+
+static char *get_text(GtkTextBuffer *buffer)
+{
+ GtkTextIter start;
+ GtkTextIter end;
+
+ gtk_text_buffer_get_start_iter(buffer, &start);
+ gtk_text_buffer_get_end_iter(buffer, &end);
+ return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+}
+
+void flush_dive_info_changes(void)
+{
+ struct dive *dive = buffered_dive;
+
+ if (!dive)
+ return;
+
+ if (location_changed) {
+ g_free(dive->location);
+ dive->location = gtk_editable_get_chars(GTK_EDITABLE(location), 0, -1);
+ }
+
+ if (notes_changed) {
+ g_free(dive->notes);
+ dive->notes = get_text(notes);
+ }
+}