From c6b13fad5aebdf7ee7f1b67da58512e49840a7c1 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 13 Sep 2011 14:58:06 -0700 Subject: [PATCH] Add divemaster/buddy field and text entry I have it in some of my notes, and Dirk seems to fill that in too, so let's just show it, save it, and allow editing of it.. Signed-off-by: Linus Torvalds --- dive.h | 1 + info.c | 30 +++++++++++++++++++++++++++--- parse-xml.c | 5 +++++ save-xml.c | 2 ++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/dive.h b/dive.h index cc6e85da2..8503c3b93 100644 --- a/dive.h +++ b/dive.h @@ -132,6 +132,7 @@ struct dive { time_t when; char *location; char *notes; + char *divemaster, *buddy; depth_t maxdepth, meandepth; duration_t duration, surfacetime; depth_t visibility; diff --git a/info.c b/info.c index 2cc98f4fd..14ede0b83 100644 --- a/info.c +++ b/info.c @@ -9,9 +9,10 @@ static GtkWidget *info_frame; static GtkWidget *divedate, *divetime, *depth, *duration, *temperature; -static GtkEntry *location; +static GtkEntry *location, *buddy, *divemaster; static GtkTextBuffer *notes; static int location_changed = 1, notes_changed = 1; +static int divemaster_changed = 1, buddy_changed = 1; static const char *weekday(int wday) { @@ -41,6 +42,16 @@ void flush_dive_info_changes(struct dive *dive) dive->location = gtk_editable_get_chars(GTK_EDITABLE(location), 0, -1); } + if (divemaster_changed) { + g_free(dive->divemaster); + dive->divemaster = gtk_editable_get_chars(GTK_EDITABLE(divemaster), 0, -1); + } + + if (buddy_changed) { + g_free(dive->buddy); + dive->buddy = gtk_editable_get_chars(GTK_EDITABLE(buddy), 0, -1); + } + if (notes_changed) { g_free(dive->notes); dive->notes = get_text(notes); @@ -118,6 +129,12 @@ void show_dive_info(struct dive *dive) text = dive->location ? : ""; gtk_entry_set_text(location, text); + text = dive->divemaster ? : ""; + gtk_entry_set_text(divemaster, text); + + text = dive->buddy ? : ""; + gtk_entry_set_text(buddy, text); + text = "Dive Info"; if (dive->location && *dive->location) text = dive->location; @@ -208,11 +225,18 @@ static GtkTextBuffer *text_view(GtkWidget *box, const char *label) GtkWidget *extended_dive_info_widget(void) { - GtkWidget *vbox; + GtkWidget *vbox, *hbox; vbox = gtk_vbox_new(FALSE, 6); - location = text_entry(vbox, "Location"); gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); + location = text_entry(vbox, "Location"); + + hbox = gtk_hbox_new(FALSE, 3); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); + + divemaster = text_entry(hbox, "Divemaster"); + buddy = text_entry(hbox, "Buddy"); + notes = text_view(vbox, "Notes"); /* Add extended info here: name, description, yadda yadda */ diff --git a/parse-xml.c b/parse-xml.c index 24acb1c1c..cecfbb304 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -652,6 +652,7 @@ static int divinglog_dive_match(struct dive *dive, const char *name, int len, ch MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) || MATCH(".presw", pressure, &dive->cylinder[0].type.workingpressure) || MATCH(".comments", utf8_string, &dive->notes) || + MATCH(".buddy.names", utf8_string, &dive->buddy) || MATCH(".country.name", utf8_string, &country) || MATCH(".city.name", utf8_string, &city) || MATCH(".place.name", divinglog_place, &dive->location) || @@ -953,6 +954,10 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) return; if (MATCH(".notes", utf8_string, &dive->notes)) return; + if (MATCH(".divemaster", utf8_string, &dive->divemaster)) + return; + if (MATCH(".buddy", utf8_string, &dive->buddy)) + return; if (MATCH(".cylinder.size", cylindersize, &dive->cylinder[cylinder_index].type.size)) return; diff --git a/save-xml.c b/save-xml.c index 91ead9f1d..47a8a7ebb 100644 --- a/save-xml.c +++ b/save-xml.c @@ -153,6 +153,8 @@ static void save_overview(FILE *f, struct dive *dive) save_temperatures(f, dive); show_duration(f, dive->surfacetime, " ", "\n"); show_utf8(f, dive->location, " ","\n"); + show_utf8(f, dive->divemaster, " ","\n"); + show_utf8(f, dive->buddy, " ","\n"); show_utf8(f, dive->notes, " ","\n"); }