Show dive number in dive list

Make sure that renumbering the divelist correctly shows up on the display.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2011-10-23 08:50:14 -07:00
parent 86fdd83e7b
commit b091916249
2 changed files with 7 additions and 1 deletions

View file

@ -25,7 +25,7 @@ struct DiveList {
GtkWidget *tree_view; GtkWidget *tree_view;
GtkWidget *container_widget; GtkWidget *container_widget;
GtkListStore *model; GtkListStore *model;
GtkTreeViewColumn *date, *depth, *duration, *location; GtkTreeViewColumn *nr, *date, *depth, *duration, *location;
GtkTreeViewColumn *temperature, *cylinder, *nitrox, *sac, *otu; GtkTreeViewColumn *temperature, *cylinder, *nitrox, *sac, *otu;
int changed; int changed;
}; };
@ -38,6 +38,7 @@ static struct DiveList dive_list;
*/ */
enum { enum {
DIVE_INDEX = 0, DIVE_INDEX = 0,
DIVE_NR, /* int: dive->nr */
DIVE_DATE, /* time_t: dive->when */ DIVE_DATE, /* time_t: dive->when */
DIVE_DEPTH, /* int: dive->maxdepth in mm */ DIVE_DEPTH, /* int: dive->maxdepth in mm */
DIVE_DURATION, /* int: in seconds */ 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 * The core data itself is unaffected by units
*/ */
gtk_list_store_set(GTK_LIST_STORE(model), iter, gtk_list_store_set(GTK_LIST_STORE(model), iter,
DIVE_NR, dive->number,
DIVE_LOCATION, location, DIVE_LOCATION, location,
DIVE_CYLINDER, cylinder, DIVE_CYLINDER, cylinder,
DIVE_SAC, sac, DIVE_SAC, sac,
@ -469,6 +471,7 @@ static void fill_dive_list(void)
gtk_list_store_append(store, &iter); gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, gtk_list_store_set(store, &iter,
DIVE_INDEX, i, DIVE_INDEX, i,
DIVE_NR, dive->number,
DIVE_DATE, dive->when, DIVE_DATE, dive->when,
DIVE_DEPTH, dive->maxdepth, DIVE_DEPTH, dive->maxdepth,
DIVE_DURATION, dive->duration.seconds, DIVE_DURATION, dive->duration.seconds,
@ -515,6 +518,7 @@ GtkWidget *dive_list_create(void)
dive_list.model = gtk_list_store_new(DIVELIST_COLUMNS, dive_list.model = gtk_list_store_new(DIVELIST_COLUMNS,
G_TYPE_INT, /* index */ G_TYPE_INT, /* index */
G_TYPE_INT, /* nr */
G_TYPE_INT, /* Date */ G_TYPE_INT, /* Date */
G_TYPE_INT, /* Depth */ G_TYPE_INT, /* Depth */
G_TYPE_INT, /* Duration */ 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_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_MULTIPLE);
gtk_widget_set_size_request(dive_list.tree_view, 200, 200); 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.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.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); dive_list.duration = divelist_column(&dive_list, DIVE_DURATION, "min", duration_data_func, PANGO_ALIGN_RIGHT, TRUE);

1
main.c
View file

@ -203,6 +203,7 @@ void renumber_dives(int nr)
for (i = 0; i < dive_table.nr; i++) { for (i = 0; i < dive_table.nr; i++) {
struct dive *dive = dive_table.dives[i]; struct dive *dive = dive_table.dives[i];
dive->number = nr + i; dive->number = nr + i;
flush_divelist(dive);
} }
mark_divelist_changed(TRUE); mark_divelist_changed(TRUE);
} }