summaryrefslogtreecommitdiffstats
path: root/divelist-gtk.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-02 10:38:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-02 10:39:35 -0700
commit63c50805610c8d0dd0ec85dc62b3007df4e5dc0b (patch)
tree7ac298d79f30d4ca92fd70fd326fd9b7513812db /divelist-gtk.c
parente6ec626c9758d30c3f714ddbf6f79195e710e037 (diff)
downloadsubsurface-63c50805610c8d0dd0ec85dc62b3007df4e5dc0b.tar.gz
Move gas string computation into core logic code
This is now a helper called from the Gtk UI code (and will soon be used by the Qt UI code). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist-gtk.c')
-rw-r--r--divelist-gtk.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/divelist-gtk.c b/divelist-gtk.c
index a5d70f348..18ef0d122 100644
--- a/divelist-gtk.c
+++ b/divelist-gtk.c
@@ -431,40 +431,24 @@ static gint nitrox_sort_func(GtkTreeModel *model,
return a_he - b_he;
}
-#define UTF8_ELLIPSIS "\xE2\x80\xA6"
-
static void nitrox_data_func(GtkTreeViewColumn *col,
GtkCellRenderer *renderer,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- int idx, o2, he, o2low;
- char buffer[80];
+ int idx;
+ char *buffer;
struct dive *dive;
gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, -1);
- if (idx < 0) {
- *buffer = '\0';
- goto exit;
+ if (idx >= 0 && (dive = get_dive(idx))) {
+ buffer = get_nitrox_string(dive);
+ g_object_set(renderer, "text", buffer, NULL);
+ free(buffer);
+ } else {
+ g_object_set(renderer, "text", "", NULL);
}
- dive = get_dive(idx);
- get_dive_gas(dive, &o2, &he, &o2low);
- o2 = (o2 + 5) / 10;
- he = (he + 5) / 10;
- o2low = (o2low + 5) / 10;
-
- if (he)
- snprintf(buffer, sizeof(buffer), "%d/%d", o2, he);
- else if (o2)
- if (o2 == o2low)
- snprintf(buffer, sizeof(buffer), "%d", o2);
- else
- snprintf(buffer, sizeof(buffer), "%d" UTF8_ELLIPSIS "%d", o2low, o2);
- else
- strcpy(buffer, _("air"));
-exit:
- g_object_set(renderer, "text", buffer, NULL);
}
/* Render the SAC data (integer value of "ml / min") */