diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-19 16:41:56 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-19 16:41:56 -0700 |
commit | 87e8ff9c3e16e2786a9ba9d551e52cd8b9dd9728 (patch) | |
tree | d1f03a840246adae27d1e48e42e008d3dc2dbd8f /divelist.c | |
parent | dfacb5e124125e0e864509459d9ffef73495a3cd (diff) | |
download | subsurface-87e8ff9c3e16e2786a9ba9d551e52cd8b9dd9728.tar.gz |
Update the divelist when dive info changes
This flushes the dive changes to the dive list, the way the old dive
info frame would update as you update dive fields.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/divelist.c b/divelist.c index d215fd236..9c1510664 100644 --- a/divelist.c +++ b/divelist.c @@ -232,23 +232,14 @@ static void get_sac(struct dive *dive, int *val, char **str) *str = strdup(buffer); } -static gboolean set_one_dive(GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) +static void fill_one_dive(struct dive *dive, + GtkTreeModel *model, + GtkTreeIter *iter) { - GValue value = {0, }; - struct dive *dive; int date, depth, duration, temp, nitrox, sac; char *datestr, *depthstr, *durationstr, *tempstr, *nitroxstr, *sacstr; char *location; - /* Get the dive number */ - gtk_tree_model_get_value(model, iter, DIVE_INDEX, &value); - dive = get_dive(g_value_get_int(&value)); - if (!dive) - return TRUE; - get_date(dive, &date, &datestr); get_depth(dive, &depth, &depthstr); get_duration(dive, &duration, &durationstr); @@ -273,8 +264,33 @@ static gboolean set_one_dive(GtkTreeModel *model, DIVE_SACSTR, sacstr, DIVE_SAC, sac, -1); +} + +static gboolean set_one_dive(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + GValue value = {0, }; + struct dive *dive; + + /* Get the dive number */ + gtk_tree_model_get_value(model, iter, DIVE_INDEX, &value); + dive = get_dive(g_value_get_int(&value)); + if (!dive) + return TRUE; + if (data && dive != data) + return FALSE; + + fill_one_dive(dive, model, iter); + return dive == data; +} + +void flush_divelist(struct DiveList *dive_list, struct dive *dive) +{ + GtkTreeModel *model = GTK_TREE_MODEL(dive_list->model); - return FALSE; + gtk_tree_model_foreach(model, set_one_dive, dive); } void update_dive_list_units(struct DiveList *dive_list) |