diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-04-09 13:06:30 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-04-09 13:06:30 -0700 |
commit | 9e4f9fad19bd4696bf08da67b60ed9d2eb29b446 (patch) | |
tree | 762d87bb965705c6d51b89c6abf594e6c5b6bba5 /statistics.c | |
parent | ed3f67bc33fbd9aac819687317d3066c22799f83 (diff) | |
download | subsurface-9e4f9fad19bd4696bf08da67b60ed9d2eb29b446.tar.gz |
Store the tag names instead of an opaque number
And as we need the names for that, simplify the way we show the tags in the
Dive Info tab (and mark them for translation while we are at it).
In the process I renamed the constants to DTAG_ from DTYPE_ (and made
their nature as being just bits more obvious).
Also mark the box on the Info tab "Dive Tags", not "Dive Type".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/statistics.c b/statistics.c index 552694563..acb9ee3d8 100644 --- a/statistics.c +++ b/statistics.c @@ -15,6 +15,13 @@ #include "display-gtk.h" #include "divelist.h" +/* mark for translation but don't translate here as these terms are used + * in save-xml.c */ +char *dtag_names[DTAG_NR] = { + N_("invalid"), N_("boat"), N_("shore"), N_("drift"), N_("deep"), N_("cavern"), + N_("ice"), N_("wreck"), N_("cave"), N_("altitude"), N_("pool") +}; + typedef struct { GtkWidget *date, *dive_time, @@ -633,35 +640,17 @@ static void show_single_dive_stats(struct dive *dive) set_label(single_w.gas_used, ""); } /* Dive type */ + *buf = '\0'; 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; + int i, more = 0; + + for (i = 0; i < DTAG_NR; i++) + if(dive->dive_tags & (1 << i)) { + if (more) + strcat(buf, ", "); + strcat(buf, _(dtag_names[i])); + more = 1; + } } set_label(single_w.dive_type, buf); } @@ -902,7 +891,7 @@ GtkWidget *single_stats_widget(void) 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")); + single_w.dive_type = new_info_label_in_frame(hbox, _("Dive Tags")); return vbox; } |