8 static GtkWidget *divedate, *divetime, *depth, *duration;
9 static GtkWidget *location, *notes;
11 static const char *weekday(int wday)
13 static const char wday_array[7][4] = {
14 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
16 return wday_array[wday];
19 void update_dive_info(struct dive *dive)
25 gtk_label_set_text(GTK_LABEL(divedate), "no dive");
26 gtk_label_set_text(GTK_LABEL(divetime), "");
27 gtk_label_set_text(GTK_LABEL(depth), "");
28 gtk_label_set_text(GTK_LABEL(duration), "");
32 tm = gmtime(&dive->when);
33 snprintf(buffer, sizeof(buffer),
36 tm->tm_mon+1, tm->tm_mday, tm->tm_year+1900);
37 gtk_label_set_text(GTK_LABEL(divedate), buffer);
39 snprintf(buffer, sizeof(buffer),
41 tm->tm_hour, tm->tm_min, tm->tm_sec);
42 gtk_label_set_text(GTK_LABEL(divetime), buffer);
44 snprintf(buffer, sizeof(buffer),
46 to_feet(dive->maxdepth));
47 gtk_label_set_text(GTK_LABEL(depth), buffer);
49 snprintf(buffer, sizeof(buffer),
51 dive->duration.seconds / 60);
52 gtk_label_set_text(GTK_LABEL(duration), buffer);
55 static GtkWidget *info_label(GtkWidget *box, const char *str)
57 GtkWidget *label = gtk_label_new(str);
58 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
59 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
63 GtkWidget *dive_info_frame(void)
68 frame = gtk_frame_new("Dive info");
69 gtk_widget_show(frame);
71 hbox = gtk_hbox_new(TRUE, 5);
72 gtk_container_set_border_width(GTK_CONTAINER(hbox), 3);
73 gtk_container_add(GTK_CONTAINER(frame), hbox);
75 divedate = info_label(hbox, "date");
76 divetime = info_label(hbox, "time");
77 depth = info_label(hbox, "depth");
78 duration = info_label(hbox, "duration");
83 static GtkWidget *text_entry(GtkWidget *box, const char *label)
86 GtkWidget *frame = gtk_frame_new(label);
87 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 0);
88 entry = gtk_entry_new();
89 gtk_container_add(GTK_CONTAINER(frame), entry);
93 GtkWidget *extended_dive_info_frame(void)
98 frame = gtk_frame_new("Extended dive info");
99 gtk_widget_show(frame);
101 vbox = gtk_vbox_new(FALSE, 5);
102 gtk_container_add(GTK_CONTAINER(frame), vbox);
104 location = text_entry(vbox, "Location");
105 notes = text_entry(vbox, "Notes");
106 location = gtk_entry_new();
108 /* Add extended info here: name, description, yadda yadda */
109 update_dive_info(current_dive);