- snprintf(buffer, sizeof(buffer),
- "%s %02d/%02d/%04d",
- weekday(tm->tm_wday),
- tm->tm_mon+1, tm->tm_mday, tm->tm_year+1900);
- gtk_label_set_text(GTK_LABEL(divedate), buffer);
-
- snprintf(buffer, sizeof(buffer),
- "%02d:%02d:%02d",
- tm->tm_hour, tm->tm_min, tm->tm_sec);
- gtk_label_set_text(GTK_LABEL(divetime), buffer);
-
- snprintf(buffer, sizeof(buffer),
- "%d ft",
- to_feet(dive->maxdepth));
- gtk_label_set_text(GTK_LABEL(depth), buffer);
-
- snprintf(buffer, sizeof(buffer),
- "%d min",
- dive->duration.seconds / 60);
- gtk_label_set_text(GTK_LABEL(duration), buffer);
-
- *buffer = 0;
- if (dive->watertemp.mkelvin)
- snprintf(buffer, sizeof(buffer),
- "%d C",
- to_C(dive->watertemp));
- gtk_label_set_text(GTK_LABEL(temperature), buffer);
-
- text = dive->location ? : "";
- gtk_entry_set_text(location, text);
- gtk_label_set_text(GTK_LABEL(locationnote), text);
-
- text = dive->notes ? : "";
- gtk_text_buffer_set_text(notes, text, -1);
-}
-
-static GtkWidget *info_label(GtkWidget *box, const char *str, GtkJustification jtype)
-{
- GtkWidget *label = gtk_label_new(str);
- gtk_label_set_justify(GTK_LABEL(label), jtype);
- gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
- return label;
-}
-
-GtkWidget *dive_info_frame(void)
-{
- GtkWidget *frame;
- GtkWidget *hbox, *hbox2;
- GtkWidget *vbox;
-
- frame = gtk_frame_new("Dive info");
- gtk_widget_show(frame);
-
- vbox = gtk_vbox_new(TRUE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 3);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
-
- hbox = gtk_hbox_new(TRUE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
- gtk_container_add(GTK_CONTAINER(vbox), hbox);
-
- hbox2 = gtk_hbox_new(FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(hbox2), 3);
- gtk_container_add(GTK_CONTAINER(vbox), hbox2);
-
- divedate = info_label(hbox, "date", GTK_JUSTIFY_RIGHT);
- divetime = info_label(hbox, "time", GTK_JUSTIFY_RIGHT);
- depth = info_label(hbox, "depth", GTK_JUSTIFY_RIGHT);
- duration = info_label(hbox, "duration", GTK_JUSTIFY_RIGHT);
- temperature = info_label(hbox, "temperature", GTK_JUSTIFY_RIGHT);
-
- locationnote = info_label(hbox2, "location", GTK_JUSTIFY_LEFT);
- gtk_label_set_width_chars(GTK_LABEL(locationnote), 80);
-
- return frame;
+ text = dive->location;
+ if (!text)
+ text = "";
+ if (*text) {
+ snprintf(buffer, sizeof(buffer), "Dive #%d - %s", dive->number, text);
+ } else {
+ snprintf(buffer, sizeof(buffer), "Dive #%d - %s %02d/%02d/%04d at %d:%02d",
+ dive->number,
+ weekday(tm->tm_wday),
+ tm->tm_mon+1, tm->tm_mday,
+ tm->tm_year+1900,
+ tm->tm_hour, tm->tm_min);
+ }
+ text = buffer;
+ if (!dive->number)
+ text += 10; /* Skip the "Dive #0 - " part */
+ gtk_window_set_title(GTK_WINDOW(main_window), text);
+
+ SET_TEXT_ENTRY(divemaster);
+ SET_TEXT_ENTRY(buddy);
+ SET_TEXT_ENTRY(location);
+ gtk_text_buffer_set_text(notes, dive && dive->notes ? dive->notes : "", -1);