]> git.tdb.fi Git - ext/subsurface.git/blob - info.c
Redo dive editing
[ext/subsurface.git] / info.c
1 /* info.c */
2 /* creates the UI for the info frame - 
3  * controlled through the following interfaces:
4  * 
5  * void show_dive_info(struct dive *dive)
6  *
7  * called from gtk-ui:
8  * GtkWidget *extended_dive_info_widget(void)
9  */
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <time.h>
14 #include <ctype.h>
15 #include <sys/time.h>
16
17 #include "dive.h"
18 #include "display.h"
19 #include "display-gtk.h"
20 #include "divelist.h"
21
22 static GtkEntry *location, *buddy, *divemaster, *rating;
23 static GtkTextView *notes;
24 static GtkListStore *location_list, *people_list, *star_list;
25
26 static char *get_text(GtkTextView *view)
27 {
28         GtkTextBuffer *buffer;
29         GtkTextIter start;
30         GtkTextIter end;
31
32         buffer = gtk_text_view_get_buffer(view);
33         gtk_text_buffer_get_start_iter(buffer, &start);
34         gtk_text_buffer_get_end_iter(buffer, &end);
35         return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
36 }
37
38 /* old is NULL or a valid string, new is a valid string
39  * NOTW: NULL and "" need to be treated as "unchanged" */
40 static int text_changed(const char *old, const char *new)
41 {
42         return (old && strcmp(old,new)) ||
43                 (!old && strcmp("",new));
44 }
45
46 static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp)
47 {
48         char *old = *textp;
49         const gchar *new;
50         GtkEntry *entry;
51
52         entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box)));
53         new = gtk_entry_get_text(entry);
54         while (isspace(*new))
55                 new++;
56         if (!text_changed(old,new))
57                 return NULL;
58         free(old);
59         *textp = strdup(new);
60         return *textp;
61 }
62
63 #define SET_TEXT_VALUE(x) \
64         gtk_entry_set_text(x, dive && dive->x ? dive->x : "")
65
66 static int divename(char *buf, size_t size, struct dive *dive)
67 {
68         struct tm *tm = gmtime(&dive->when);
69         return snprintf(buf, size, "Dive #%d - %s %02d/%02d/%04d at %d:%02d",
70                 dive->number,
71                 weekday(tm->tm_wday),
72                 tm->tm_mon+1, tm->tm_mday,
73                 tm->tm_year+1900,
74                 tm->tm_hour, tm->tm_min);
75 }
76
77 void show_dive_info(struct dive *dive)
78 {
79         const char *text;
80         char buffer[80];
81
82         /* dive number and location (or lacking that, the date) go in the window title */
83         text = dive->location;
84         if (!text)
85                 text = "";
86         if (*text) {
87                 snprintf(buffer, sizeof(buffer), "Dive #%d - %s", dive->number, text);
88         } else {
89                 divename(buffer, sizeof(buffer), dive);
90         }
91         text = buffer;
92         if (!dive->number)
93                 text += 10;     /* Skip the "Dive #0 - " part */
94         gtk_window_set_title(GTK_WINDOW(main_window), text);
95
96         SET_TEXT_VALUE(divemaster);
97         SET_TEXT_VALUE(buddy);
98         SET_TEXT_VALUE(location);
99         gtk_entry_set_text(rating, star_strings[dive->rating]);
100         gtk_text_buffer_set_text(gtk_text_view_get_buffer(notes),
101                 dive && dive->notes ? dive->notes : "", -1);
102 }
103
104 static int delete_dive_info(struct dive *dive)
105 {
106         int success;
107         GtkWidget *dialog;
108
109         if (!dive)
110                 return 0;
111
112         dialog = gtk_dialog_new_with_buttons("Delete Dive",
113                 GTK_WINDOW(main_window),
114                 GTK_DIALOG_DESTROY_WITH_PARENT,
115                 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
116                 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
117                 NULL);
118
119         gtk_widget_show_all(dialog);
120         success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
121         if (success) {
122                 delete_dive(dive);
123                 mark_divelist_changed(TRUE);
124                 dive_list_update_dives();
125         }
126
127         gtk_widget_destroy(dialog);
128
129         return success;
130 }
131
132 static void info_menu_edit_cb(GtkMenuItem *menuitem, gpointer user_data)
133 {
134         edit_dive_info(current_dive);
135 }
136
137 static void info_menu_delete_cb(GtkMenuItem *menuitem, gpointer user_data)
138 {
139         delete_dive_info(current_dive);
140 }
141
142 static void add_menu_item(GtkMenu *menu, const char *label, void (*cb)(GtkMenuItem *, gpointer))
143 {
144         GtkWidget *item = gtk_menu_item_new_with_label(label);
145         g_signal_connect(item, "activate", G_CALLBACK(cb), NULL);
146         gtk_widget_show(item); /* Yes, really */
147         gtk_menu_prepend(menu, item);
148 }
149
150 static void populate_popup_cb(GtkTextView *entry, GtkMenu *menu, gpointer user_data)
151 {
152         add_menu_item(menu, "Delete", info_menu_delete_cb);
153         add_menu_item(menu, "Edit", info_menu_edit_cb);
154 }
155
156 static GtkEntry *text_value(GtkWidget *box, const char *label)
157 {
158         GtkWidget *widget;
159         GtkWidget *frame = gtk_frame_new(label);
160
161         gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
162         widget = gtk_entry_new();
163         gtk_widget_set_can_focus(widget, FALSE);
164         gtk_editable_set_editable(GTK_EDITABLE(widget), FALSE);
165         gtk_container_add(GTK_CONTAINER(frame), widget);
166         g_signal_connect(widget, "populate-popup", G_CALLBACK(populate_popup_cb), NULL);
167         return GTK_ENTRY(widget);
168 }
169
170 static GtkComboBoxEntry *text_entry(GtkWidget *box, const char *label, GtkListStore *completions, const char *text)
171 {
172         GtkEntry *entry;
173         GtkWidget *combo_box;
174         GtkWidget *frame = gtk_frame_new(label);
175         GtkEntryCompletion *completion;
176
177         gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0);
178
179         combo_box = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(completions), 0);
180         gtk_container_add(GTK_CONTAINER(frame), combo_box);
181
182         entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box)));
183         if (text && *text)
184                 gtk_entry_set_text(entry, text);
185
186         completion = gtk_entry_completion_new();
187         gtk_entry_completion_set_text_column(completion, 0);
188         gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(completions));
189         gtk_entry_completion_set_inline_completion(completion, TRUE);
190         gtk_entry_completion_set_inline_selection(completion, TRUE);
191         gtk_entry_completion_set_popup_single_match(completion, FALSE);
192         gtk_entry_set_completion(entry, completion);
193
194         return GTK_COMBO_BOX_ENTRY(combo_box);
195 }
196
197 enum writable {
198         READ_ONLY,
199         READ_WRITE
200 };
201
202 static GtkTextView *text_view(GtkWidget *box, const char *label, enum writable writable)
203 {
204         GtkWidget *view, *vbox;
205         GtkWidget *frame = gtk_frame_new(label);
206
207         gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
208         box = gtk_hbox_new(FALSE, 3);
209         gtk_container_add(GTK_CONTAINER(frame), box);
210         vbox = gtk_vbox_new(FALSE, 3);
211         gtk_container_add(GTK_CONTAINER(box), vbox);
212
213         GtkWidget* scrolled_window = gtk_scrolled_window_new(0, 0);
214         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
215         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN);
216
217         view = gtk_text_view_new();
218         if (writable == READ_ONLY) {
219                 gtk_widget_set_can_focus(view, FALSE);
220                 gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);
221                 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view), FALSE);
222                 g_signal_connect(view, "populate-popup", G_CALLBACK(populate_popup_cb), NULL);
223         }
224         gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
225         gtk_container_add(GTK_CONTAINER(scrolled_window), view);
226         gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
227         return GTK_TEXT_VIEW(view);
228 }
229
230 static enum {
231         MATCH_EXACT,
232         MATCH_PREPEND,
233         MATCH_AFTER
234 } found_string_entry;
235 static GtkTreeIter string_entry_location;
236
237 static gboolean match_string_entry(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
238 {
239         const char *string = data;
240         char *entry;
241         int cmp;
242
243         gtk_tree_model_get(model, iter, 0, &entry, -1);
244         cmp = strcmp(entry, string);
245
246         /* Stop. The entry is bigger than the new one */
247         if (cmp > 0)
248                 return TRUE;
249
250         /* Exact match */
251         if (!cmp) {
252                 found_string_entry = MATCH_EXACT;
253                 return TRUE;
254         }
255
256         string_entry_location = *iter;
257         found_string_entry = MATCH_AFTER;
258         return FALSE;
259 }
260
261 static int match_list(GtkListStore *list, const char *string)
262 {
263         found_string_entry = MATCH_PREPEND;
264         gtk_tree_model_foreach(GTK_TREE_MODEL(list), match_string_entry, (void *)string);
265         return found_string_entry;
266 }
267
268 static void add_string_list_entry(const char *string, GtkListStore *list)
269 {
270         GtkTreeIter *iter, loc;
271
272         if (!string || !*string)
273                 return;
274
275         switch (match_list(list, string)) {
276         case MATCH_EXACT:
277                 return;
278         case MATCH_PREPEND:
279                 iter = NULL;
280                 break;
281         case MATCH_AFTER:
282                 iter = &string_entry_location;
283                 break;
284         }
285         gtk_list_store_insert_after(list, &loc, iter);
286         gtk_list_store_set(list, &loc, 0, string, -1);
287 }
288
289 void add_people(const char *string)
290 {
291         add_string_list_entry(string, people_list);
292 }
293
294 void add_location(const char *string)
295 {
296         add_string_list_entry(string, location_list);
297 }
298
299 static int get_rating(const char *string)
300 {
301         int rating_val = 0;
302         int i;
303
304         for (i = 0; i <= 5; i++)
305                 if (!strcmp(star_strings[i],string))
306                         rating_val = i;
307         return rating_val;
308 }
309
310 struct dive_info {
311         GtkComboBoxEntry *location, *divemaster, *buddy, *rating;
312         GtkTextView *notes;
313 };
314
315 static void save_dive_info_changes(struct dive *dive, struct dive_info *info)
316 {
317         char *old_text, *new_text;
318         char *rating_string;
319         int changed = 0;
320
321         new_text = get_combo_box_entry_text(info->location, &dive->location);
322         if (new_text) {
323                 add_location(new_text);
324                 changed = 1;
325         }
326
327         new_text = get_combo_box_entry_text(info->divemaster, &dive->divemaster);
328         if (new_text) {
329                 add_people(new_text);
330                 changed = 1;
331         }
332
333         new_text = get_combo_box_entry_text(info->buddy, &dive->buddy);
334         if (new_text) {
335                 add_people(new_text);
336                 changed = 1;
337         }
338
339         rating_string = strdup(star_strings[dive->rating]);
340         new_text = get_combo_box_entry_text(info->rating, &rating_string);
341         if (new_text) {
342                 dive->rating = get_rating(rating_string);
343                 free(rating_string);
344                 changed =1;
345         }
346
347         if (info->notes) {
348                 old_text = dive->notes;
349                 dive->notes = get_text(info->notes);
350                 if (text_changed(old_text,dive->notes))
351                         changed = 1;
352                 if (old_text)
353                         g_free(old_text);
354         }
355         if (changed) {
356                 mark_divelist_changed(TRUE);
357                 update_dive(dive);
358         }
359 }
360
361 static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info *info, gboolean multi)
362 {
363         GtkWidget *hbox, *label, *frame, *equipment;
364         char buffer[80] = "Edit multiple dives";
365
366         if (!multi)
367                 divename(buffer, sizeof(buffer), dive);
368         label = gtk_label_new(buffer);
369         gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0);
370
371         info->location = text_entry(box, "Location", location_list, dive->location);
372
373         hbox = gtk_hbox_new(FALSE, 3);
374         gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
375
376         info->divemaster = text_entry(hbox, "Dive master", people_list, dive->divemaster);
377         info->buddy = text_entry(hbox, "Buddy", people_list, dive->buddy);
378
379         hbox = gtk_hbox_new(FALSE, 3);
380         gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
381
382         info->rating = text_entry(hbox, "Rating", star_list, star_strings[dive->rating]);
383
384         /* only show notes if editing a single dive */
385         if (multi) {
386                 info->notes = NULL;
387         } else {
388                 info->notes = text_view(box, "Notes", READ_WRITE);
389                 if (dive->notes && *dive->notes)
390                         gtk_text_buffer_set_text(gtk_text_view_get_buffer(info->notes), dive->notes, -1);
391         }
392         hbox = gtk_hbox_new(FALSE, 3);
393         gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
394
395         /* create a secondary Equipment widget */
396         frame = gtk_frame_new("Equipment");
397         equipment = equipment_widget(W_IDX_SECONDARY);
398         gtk_container_add(GTK_CONTAINER(frame), equipment);
399         gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
400 }
401
402 /* we use these to find out if we edited the cylinder or weightsystem entries */
403 static cylinder_t remember_cyl[MAX_CYLINDERS];
404 static weightsystem_t remember_ws[MAX_WEIGHTSYSTEMS];
405
406 void save_equipment_data(struct dive *dive)
407 {
408         if (dive) {
409                 memcpy(remember_cyl, dive->cylinder, sizeof(cylinder_t) * MAX_CYLINDERS);
410                 memcpy(remember_ws, dive->weightsystem, sizeof(weightsystem_t) * MAX_WEIGHTSYSTEMS);
411         }
412 }
413
414 void update_equipment_data(struct dive *dive, struct dive *master)
415 {
416         if (dive == master)
417                 return;
418         if (memcmp(remember_cyl, master->cylinder, sizeof(cylinder_t) * MAX_CYLINDERS)) {
419                 memcpy(dive->cylinder, master->cylinder, sizeof(cylinder_t) * MAX_CYLINDERS);
420         }
421         if (memcmp(remember_ws, master->weightsystem, sizeof(weightsystem_t) * MAX_WEIGHTSYSTEMS)) {
422                 memcpy(dive->weightsystem, master->weightsystem, sizeof(weightsystem_t) * MAX_WEIGHTSYSTEMS);
423         }
424 }
425
426 int edit_multi_dive_info(int nr, int *indices)
427 {
428         int success, i;
429         GtkWidget *dialog, *vbox;
430         struct dive_info info;
431         struct dive *dive;
432
433         if (!nr)
434                 return 0;
435         dialog = gtk_dialog_new_with_buttons("Dive Info",
436                 GTK_WINDOW(main_window),
437                 GTK_DIALOG_DESTROY_WITH_PARENT,
438                 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
439                 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
440                 NULL);
441
442         vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
443         /* SCARY STUFF - IS THIS THE BEST WAY TO DO THIS???
444          *
445          * current_dive is one of our selected dives - and that is
446          * the one that is used to pre-fill the edit widget. Its
447          * data is used as the starting point for all selected dives
448          * I think it would be better to somehow collect and combine
449          * info from all the selected dives */
450         dive = current_dive;
451         dive_info_widget(vbox, dive, &info, (nr > 1));
452         show_dive_equipment(dive, W_IDX_SECONDARY);
453         save_equipment_data(dive);
454         gtk_widget_show_all(dialog);
455         success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
456         if (success)
457                 for (i = 0; i < nr; i++) {
458                         /* copy all "info" fields */
459                         save_dive_info_changes(get_dive(indices[i]), &info);
460                         /* copy the cylinders / weightsystems */
461                         update_equipment_data(get_dive(indices[i]), dive);
462                         /* this is extremely inefficient... it loops through all
463                            dives to find the right one - but we KNOW the index already */
464                         flush_divelist(get_dive(indices[i]));
465                 }
466         gtk_widget_destroy(dialog);
467
468         return success;
469 }
470
471 int edit_dive_info(struct dive *dive)
472 {
473         int idx;
474
475         if (!dive)
476                 return 0;
477         idx = dive->number;
478         return edit_multi_dive_info(1, &idx);
479 }
480
481 static GtkWidget *frame_box(GtkWidget *vbox, const char *fmt, ...)
482 {
483         va_list ap;
484         char buffer[64];
485         GtkWidget *frame, *hbox;
486
487         va_start(ap, fmt);
488         vsnprintf(buffer, sizeof(buffer), fmt, ap);
489         va_end(ap);
490
491         frame = gtk_frame_new(buffer);
492         gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 0);
493         hbox = gtk_hbox_new(0, 3);
494         gtk_container_add(GTK_CONTAINER(frame), hbox);
495         return hbox;
496 }
497
498 /* Fixme - should do at least depths too - a dive without a depth is kind of pointless */
499 static time_t dive_time_widget(struct dive *dive)
500 {
501         GtkWidget *dialog;
502         GtkWidget *cal, *hbox, *vbox, *box;
503         GtkWidget *h, *m;
504         GtkWidget *duration, *depth;
505         GtkWidget *label;
506         guint yval, mval, dval;
507         struct tm tm, *tmp;
508         struct timeval tv;
509         time_t time;
510         int success;
511         double depthinterval, val;
512
513         dialog = gtk_dialog_new_with_buttons("Date and Time",
514                 GTK_WINDOW(main_window),
515                 GTK_DIALOG_DESTROY_WITH_PARENT,
516                 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
517                 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
518                 NULL);
519
520         vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
521
522         /* Calendar hbox */
523         hbox = frame_box(vbox, "Date:");
524         cal = gtk_calendar_new();
525         gtk_box_pack_start(GTK_BOX(hbox), cal, FALSE, TRUE, 0);
526
527         /* Time hbox */
528         hbox = frame_box(vbox, "Time");
529
530         h = gtk_spin_button_new_with_range (0.0, 23.0, 1.0);
531         m = gtk_spin_button_new_with_range (0.0, 59.0, 1.0);
532
533         gettimeofday(&tv, NULL);
534         time = tv.tv_sec;
535         tmp = localtime(&time);
536         gtk_spin_button_set_value(GTK_SPIN_BUTTON(h), tmp->tm_hour);
537         gtk_spin_button_set_value(GTK_SPIN_BUTTON(m), (tmp->tm_min / 5)*5);
538
539         gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(h), TRUE);
540         gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(m), TRUE);
541
542         gtk_box_pack_end(GTK_BOX(hbox), m, FALSE, FALSE, 0);
543         label = gtk_label_new(":");
544         gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
545         gtk_box_pack_end(GTK_BOX(hbox), h, FALSE, FALSE, 0);
546
547         hbox = gtk_hbox_new(TRUE, 3);
548         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
549
550         /* Duration hbox */
551         box = frame_box(hbox, "Duration (min)");
552         duration = gtk_spin_button_new_with_range (0.0, 1000.0, 1.0);
553         gtk_box_pack_end(GTK_BOX(box), duration, FALSE, FALSE, 0);
554
555         /* Depth box */
556         box = frame_box(hbox, "Depth (%s):", output_units.length == FEET ? "ft" : "m");
557         if (output_units.length == FEET) {
558                 depthinterval = 1.0;
559         } else {
560                 depthinterval = 0.1;
561         }
562         depth = gtk_spin_button_new_with_range (0.0, 1000.0, depthinterval);
563         gtk_box_pack_end(GTK_BOX(box), depth, FALSE, FALSE, 0);
564
565         /* All done, show it and wait for editing */
566         gtk_widget_show_all(dialog);
567         success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
568         if (!success) {
569                 gtk_widget_destroy(dialog);
570                 return 0;
571         }
572
573         memset(&tm, 0, sizeof(tm));
574         gtk_calendar_get_date(GTK_CALENDAR(cal), &yval, &mval, &dval);
575         tm.tm_year = yval;
576         tm.tm_mon = mval;
577         tm.tm_mday = dval;
578
579         tm.tm_hour = gtk_spin_button_get_value(GTK_SPIN_BUTTON(h));
580         tm.tm_min = gtk_spin_button_get_value(GTK_SPIN_BUTTON(m));
581
582         val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(depth));
583         if (output_units.length == FEET) {
584                 dive->maxdepth.mm = feet_to_mm(val);
585         } else {
586                 dive->maxdepth.mm = val * 1000 + 0.5;
587         }
588
589         dive->duration.seconds = gtk_spin_button_get_value(GTK_SPIN_BUTTON(duration))*60;
590
591         gtk_widget_destroy(dialog);
592         dive->when = utc_mktime(&tm);
593
594         return 1;
595 }
596
597 int add_new_dive(struct dive *dive)
598 {
599         if (!dive)
600                 return 0;
601
602         if (!dive_time_widget(dive))
603                 return 0;
604
605         return edit_dive_info(dive);
606 }
607
608 GtkWidget *extended_dive_info_widget(void)
609 {
610         GtkWidget *vbox, *hbox;
611         vbox = gtk_vbox_new(FALSE, 6);
612
613         people_list = gtk_list_store_new(1, G_TYPE_STRING);
614         location_list = gtk_list_store_new(1, G_TYPE_STRING);
615         star_list = gtk_list_store_new(1, G_TYPE_STRING);
616         add_string_list_entry(ZERO_STARS, star_list);
617         add_string_list_entry(ONE_STARS, star_list);
618         add_string_list_entry(TWO_STARS, star_list);
619         add_string_list_entry(THREE_STARS, star_list);
620         add_string_list_entry(FOUR_STARS, star_list);
621         add_string_list_entry(FIVE_STARS, star_list);
622
623         gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
624         location = text_value(vbox, "Location");
625
626         hbox = gtk_hbox_new(FALSE, 3);
627         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
628
629         divemaster = text_value(hbox, "Divemaster");
630         buddy = text_value(hbox, "Buddy");
631
632         hbox = gtk_hbox_new(FALSE, 3);
633         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
634
635         rating = text_value(hbox, "Rating");
636
637         notes = text_view(vbox, "Notes", READ_ONLY);
638         return vbox;
639 }