+ /* Calendar hbox */
+ hbox = frame_box(vbox, "Date:");
+ cal = gtk_calendar_new();
+ gtk_box_pack_start(GTK_BOX(hbox), cal, FALSE, TRUE, 0);
+
+ /* Time hbox */
+ hbox = frame_box(vbox, "Time");
+
+ h = gtk_spin_button_new_with_range (0.0, 23.0, 1.0);
+ m = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
+
+ /*
+ * If we have a dive selected, 'add dive' will default
+ * to one hour after the end of that dive. Otherwise,
+ * we'll just take the current time.
+ */
+ if (amount_selected == 1) {
+ time_t when = current_dive->when;
+ when += current_dive->duration.seconds;
+ when += 60*60;
+ time = gmtime(&when);
+ } else {
+ time_t now;
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ now = tv.tv_sec;
+ time = localtime(&now);
+ }
+ gtk_calendar_select_month(GTK_CALENDAR(cal), time->tm_mon, time->tm_year + 1900);
+ gtk_calendar_select_day(GTK_CALENDAR(cal), time->tm_mday);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(h), time->tm_hour);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(m), (time->tm_min / 5)*5);
+
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(h), TRUE);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(m), TRUE);
+
+ gtk_box_pack_end(GTK_BOX(hbox), m, FALSE, FALSE, 0);
+ label = gtk_label_new(":");
+ gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), h, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new(TRUE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
+ /* Duration hbox */
+ box = frame_box(hbox, "Duration (min)");
+ duration = gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
+ gtk_box_pack_end(GTK_BOX(box), duration, FALSE, FALSE, 0);
+
+ /* Depth box */
+ box = frame_box(hbox, "Depth (%s):", output_units.length == FEET ? "ft" : "m");
+ if (output_units.length == FEET) {
+ depthinterval = 1.0;
+ } else {
+ depthinterval = 0.1;
+ }
+ depth = gtk_spin_button_new_with_range (0.0, 1000.0, depthinterval);
+ gtk_box_pack_end(GTK_BOX(box), depth, FALSE, FALSE, 0);
+
+ /* All done, show it and wait for editing */