From ed3f67bc33fbd9aac819687317d3066c22799f83 Mon Sep 17 00:00:00 2001 From: Ďoďo Date: Tue, 9 Apr 2013 17:54:36 +0200 Subject: Add dive tags and support invalid dives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This started out as a way to keep dives in the dive list but being able to mark them as 'invalid' so they wouldn't be visible (with an option to disable that feature). Now it supports an (at this point, fixed) set of tags that can be assigned to a dive with 'invalid' being just one of them (but one that is special as it gets some additional support for hiding such dive and marking dives as (in)valid from the divelist). [Dirk Hohndel: merged with the latest code and minor changes for coding style and consistency. Ensure divelist is marked as modified when changing 'invalid' tag] Signed-Off-By: Jozef Ivanecký (dodo.sk@gmail.com) Signed-off-by: Dirk Hohndel --- statistics.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'statistics.c') diff --git a/statistics.c b/statistics.c index 502c06cb4..552694563 100644 --- a/statistics.c +++ b/statistics.c @@ -28,7 +28,8 @@ typedef struct { *sac, *otu, *o2he, - *gas_used; + *gas_used, + *dive_type; } single_stat_widget_t; static single_stat_widget_t single_w; @@ -631,6 +632,38 @@ static void show_single_dive_stats(struct dive *dive) } else { set_label(single_w.gas_used, ""); } + /* Dive type */ + if (dive->dive_tags) { + buf[0]=0; + if(dive->dive_tags & DTYPE_INVALID) + strcat(buf, " Invalid,"); + if(dive->dive_tags & DTYPE_BOAT) + strcat(buf, " Boat,"); + if(dive->dive_tags & DTYPE_SHORE) + strcat(buf, " Shore,"); + if(dive->dive_tags & DTYPE_DRIFT) + strcat(buf, " Drift,"); + if(dive->dive_tags & DTYPE_DEEP) + strcat(buf, " Deep,"); + if(dive->dive_tags & DTYPE_CAVERN) + strcat(buf, " Cavern,"); + if(dive->dive_tags & DTYPE_ICE) + strcat(buf, " Ice,"); + if(dive->dive_tags & DTYPE_WRECK) + strcat(buf, " Wreck,"); + if(dive->dive_tags & DTYPE_CAVE) + strcat(buf, " Cave,"); + if(dive->dive_tags & DTYPE_ALTITUDE) + strcat(buf, " Altitude,"); + if(dive->dive_tags & DTYPE_POOL) + strcat(buf, " Pool,"); + if(strlen(buf) > 1) + buf[strlen(buf)-1] = 0; + } + else { + buf[0] = 0; + } + set_label(single_w.dive_type, buf); } /* this gets called when at least two but not all dives are selected */ @@ -865,6 +898,12 @@ GtkWidget *single_stats_widget(void) single_w.o2he = new_info_label_in_frame(hbox, "O" UTF8_SUBSCRIPT_2 " / He"); single_w.gas_used = new_info_label_in_frame(hbox, C_("Amount","Gas Used")); + /* fifth row */ + hbox = gtk_hbox_new(FALSE, 3); + gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3); + + single_w.dive_type = new_info_label_in_frame(hbox, _("Dive Type")); + return vbox; } @@ -884,6 +923,7 @@ void clear_stats_widgets(void) set_label(single_w.otu, ""); set_label(single_w.o2he, ""); set_label(single_w.gas_used, ""); + set_label(single_w.dive_type, ""); set_label(stats_w.total_time,""); set_label(stats_w.avg_time,""); set_label(stats_w.shortest_time,""); -- cgit v1.2.3-70-g09d2