]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Show dive number in dive list
authorDirk Hohndel <dirk@hohndel.org>
Sun, 23 Oct 2011 15:50:14 +0000 (08:50 -0700)
committerDirk Hohndel <dirk@hohndel.org>
Sun, 23 Oct 2011 16:09:00 +0000 (09:09 -0700)
Make sure that renumbering the divelist correctly shows up on the display.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
divelist.c
main.c

index 5f2063e9f8192fa6f10fb4a744f046dd5b448904..4146deca7e06749783ddc06da4cdb5877b5a1835 100644 (file)
@@ -25,7 +25,7 @@ struct DiveList {
        GtkWidget    *tree_view;
        GtkWidget    *container_widget;
        GtkListStore *model;
-       GtkTreeViewColumn *date, *depth, *duration, *location;
+       GtkTreeViewColumn *nr, *date, *depth, *duration, *location;
        GtkTreeViewColumn *temperature, *cylinder, *nitrox, *sac, *otu;
        int changed;
 };
@@ -38,6 +38,7 @@ static struct DiveList dive_list;
  */
 enum {
        DIVE_INDEX = 0,
+       DIVE_NR,                /* int: dive->nr */
        DIVE_DATE,              /* time_t: dive->when */
        DIVE_DEPTH,             /* int: dive->maxdepth in mm */
        DIVE_DURATION,          /* int: in seconds */
@@ -375,6 +376,7 @@ static void fill_one_dive(struct dive *dive,
         * The core data itself is unaffected by units
         */
        gtk_list_store_set(GTK_LIST_STORE(model), iter,
+               DIVE_NR, dive->number,
                DIVE_LOCATION, location,
                DIVE_CYLINDER, cylinder,
                DIVE_SAC, sac,
@@ -469,6 +471,7 @@ static void fill_dive_list(void)
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter,
                        DIVE_INDEX, i,
+                       DIVE_NR, dive->number,
                        DIVE_DATE, dive->when,
                        DIVE_DEPTH, dive->maxdepth,
                        DIVE_DURATION, dive->duration.seconds,
@@ -515,6 +518,7 @@ GtkWidget *dive_list_create(void)
 
        dive_list.model = gtk_list_store_new(DIVELIST_COLUMNS,
                                G_TYPE_INT,                     /* index */
+                               G_TYPE_INT,                     /* nr */
                                G_TYPE_INT,                     /* Date */
                                G_TYPE_INT,                     /* Depth */
                                G_TYPE_INT,                     /* Duration */
@@ -533,6 +537,7 @@ GtkWidget *dive_list_create(void)
        gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
        gtk_widget_set_size_request(dive_list.tree_view, 200, 200);
 
+       dive_list.nr = divelist_column(&dive_list, DIVE_NR, "#", NULL, PANGO_ALIGN_RIGHT, TRUE);
        dive_list.date = divelist_column(&dive_list, DIVE_DATE, "Date", date_data_func, PANGO_ALIGN_LEFT, TRUE);
        dive_list.depth = divelist_column(&dive_list, DIVE_DEPTH, "ft", depth_data_func, PANGO_ALIGN_RIGHT, TRUE);
        dive_list.duration = divelist_column(&dive_list, DIVE_DURATION, "min", duration_data_func, PANGO_ALIGN_RIGHT, TRUE);
diff --git a/main.c b/main.c
index ee09b9a82e50b4ee0bceda0ef9eebdd7cadaae64..a82cffc2bc8c9de71fe7a38a5c08c27df94d911e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -203,6 +203,7 @@ void renumber_dives(int nr)
        for (i = 0; i < dive_table.nr; i++) {
                struct dive *dive = dive_table.dives[i];
                dive->number = nr + i;
+               flush_divelist(dive);
        }
        mark_divelist_changed(TRUE);
 }