- 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_text_buffer_set_text(location, text, -1);
- text = dive->notes ? : "";
- gtk_text_buffer_set_text(notes, text, -1);
-}
-
-static GtkWidget *info_label(GtkWidget *box, const char *str)
-{
- GtkWidget *label = gtk_label_new(str);
- gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
- gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
- return label;
+ 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);