]> git.tdb.fi Git - ext/subsurface.git/blobdiff - divelist.c
Improve tank pressure sac coloring
[ext/subsurface.git] / divelist.c
index eb8f231432a99f33f40a8ca0341aee8a66b14148..60ad16a7fe541ced018f03010e732957b6974024 100644 (file)
@@ -335,6 +335,14 @@ static int calculate_sac(struct dive *dive)
        return sac * 1000;
 }
 
+void update_cylinder_related_info(struct dive *dive)
+{
+       if (dive != NULL) {
+               dive->sac = calculate_sac(dive);
+               dive->otu = calculate_otu(dive);
+       }
+}
+
 static void get_string(char **str, const char *s)
 {
        int len;
@@ -343,8 +351,8 @@ static void get_string(char **str, const char *s)
        if (!s)
                s = "";
        len = strlen(s);
-       if (len > 40)
-               len = 40;
+       if (len > 60)
+               len = 60;
        n = malloc(len+1);
        memcpy(n, s, len);
        n[len] = 0;
@@ -449,11 +457,11 @@ static void fill_dive_list(void)
 
        store = GTK_LIST_STORE(dive_list.model);
 
-       for (i = 0; i < dive_table.nr; i++) {
+       i = dive_table.nr;
+       while (--i >= 0) {
                struct dive *dive = dive_table.dives[i];
 
-               dive->otu = calculate_otu(dive);
-               dive->sac = calculate_sac(dive);
+               update_cylinder_related_info(dive);
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter,
                        DIVE_INDEX, i,