]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Merge branch 'tree2' of git://git.hohndel.org/subsurface
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 17 Aug 2012 03:39:49 +0000 (20:39 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 17 Aug 2012 03:39:49 +0000 (20:39 -0700)
Pull selection tracking fixes from Dirk Hohndel:
 "I just gave up on gtk tracking our selection.  Way too much pain.  The
  implementation below has seen some testing with the debugging code
  enabled and seems to work - but it needs more banging onto it, I'm
  sure.

  Ideally I'd like to leave the debug code in, ask people on the mailing
  list to play with it and report any inconsistencies.  After that I'll
  be happy to remove it again."

* 'tree2' of git://git.hohndel.org/subsurface:
  Stop relying on gtk to track which dives are selected

display-gtk.h
dive.c
dive.h
divelist.c
equipment.c
gtk-gui.c
info.c
parse-xml.c
profile.c
save-xml.c

index 1cf150bb622d18c5e649f30d20d28f3eab3290cb..059c6aa23be39d104a2bb50d36781fb753822736 100644 (file)
@@ -14,6 +14,8 @@ typedef struct {
 typedef struct {
        gboolean cylinder;
        gboolean temperature;
+       gboolean totalweight;
+       gboolean suit;
        gboolean nitrox;
        gboolean sac;
        gboolean otu;
diff --git a/dive.c b/dive.c
index 9f57aed58146554969901198ac761fc888904e18..f5d0828015e2b64990a390d877839e43335ffd48 100644 (file)
--- a/dive.c
+++ b/dive.c
@@ -120,6 +120,28 @@ double get_depth_units(unsigned int mm, int *frac, const char **units)
        return d;
 }
 
+double get_weight_units(unsigned int grams, int *frac, const char **units)
+{
+       int decimals;
+       double value;
+       const char* unit;
+
+       if (output_units.weight == LBS) {
+               value = grams_to_lbs(grams);
+               unit = "lbs";
+               decimals = 0;
+       } else {
+               value = grams / 1000.0;
+               unit = "kg";
+               decimals = 1;
+       }
+       if (frac)
+               *frac = decimals;
+       if (units)
+               *units = unit;
+       return value;
+}
+
 struct dive *alloc_dive(void)
 {
        const int initial_samples = 5;
@@ -464,6 +486,7 @@ struct dive *fixup_dive(struct dive *dive)
        add_people(dive->buddy);
        add_people(dive->divemaster);
        add_location(dive->location);
+       add_suit(dive->suit);
        for (i = 0; i < MAX_CYLINDERS; i++) {
                cylinder_t *cyl = dive->cylinder + i;
                add_cylinder_description(&cyl->type);
@@ -472,6 +495,10 @@ struct dive *fixup_dive(struct dive *dive)
                if (same_rounded_pressure(cyl->sample_end, cyl->end))
                        cyl->end.mbar = 0;
        }
+       for (i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
+               weightsystem_t *ws = dive->weightsystem + i;
+               add_weightsystem_description(ws);
+       }
 
        return dive;
 }
@@ -677,6 +704,7 @@ struct dive *try_to_merge(struct dive *a, struct dive *b)
        MERGE_TXT(res, a, b, buddy);
        MERGE_TXT(res, a, b, divemaster);
        MERGE_MAX(res, a, b, rating);
+       MERGE_TXT(res, a, b, suit);
        MERGE_MAX(res, a, b, number);
        MERGE_MAX(res, a, b, maxdepth.mm);
        res->meandepth.mm = 0;
diff --git a/dive.h b/dive.h
index de95d5e6614c0d0b05ef77700454b6474de29dce..b42668c168041f15e8578cf30cef27862301a42b 100644 (file)
--- a/dive.h
+++ b/dive.h
@@ -97,8 +97,9 @@ extern int weightsystem_none(void *_data);
 
 extern int get_pressure_units(unsigned int mb, const char **units);
 extern double get_depth_units(unsigned int mm, int *frac, const char **units);
-extern double get_volume_units(unsigned int mm, int *frac, const char **units);
-extern double get_temp_units(unsigned int mm, const char **units);
+extern double get_volume_units(unsigned int ml, int *frac, const char **units);
+extern double get_temp_units(unsigned int mk, const char **units);
+extern double get_weight_units(unsigned int grams, int *frac, const char **units);
 
 static inline double grams_to_lbs(int grams)
 {
@@ -244,6 +245,7 @@ struct dive {
        temperature_t airtemp, watertemp;
        cylinder_t cylinder[MAX_CYLINDERS];
        weightsystem_t weightsystem[MAX_WEIGHTSYSTEMS];
+       char *suit;
        int sac, otu;
        struct event *events;
        int samples, alloc_samples;
@@ -279,6 +281,7 @@ struct dive_table {
 
 extern struct dive_table dive_table;
 
+extern int *selectiontracker;
 extern int selected_dive;
 #define current_dive (get_dive(selected_dive))
 
@@ -340,8 +343,10 @@ extern void exit_ui(void);
 extern void report_error(GError* error);
 
 extern void add_cylinder_description(cylinder_type_t *);
+extern void add_weightsystem_description(weightsystem_t *);
 extern void add_people(const char *string);
 extern void add_location(const char *string);
+extern void add_suit(const char *string);
 extern void remember_event(const char *eventname);
 extern void evn_foreach(void (*callback)(const char *, int *, void *), void *data);
 
index 19ab600e8d6dec95121eb69b9221b4a74dc6dfab..0e1b40dd6f71abb64f9acd32082b6df06585875f 100644 (file)
@@ -26,7 +26,7 @@ struct DiveList {
        GtkWidget    *container_widget;
        GtkTreeStore *model, *listmodel, *treemodel;
        GtkTreeViewColumn *nr, *date, *stars, *depth, *duration, *location;
-       GtkTreeViewColumn *temperature, *cylinder, *nitrox, *sac, *otu;
+       GtkTreeViewColumn *temperature, *cylinder, *totalweight, *suit, *nitrox, *sac, *otu;
        int changed;
 };
 
@@ -44,6 +44,8 @@ enum {
        DIVE_DEPTH,             /* int: dive->maxdepth in mm */
        DIVE_DURATION,          /* int: in seconds */
        DIVE_TEMPERATURE,       /* int: in mkelvin */
+       DIVE_TOTALWEIGHT,       /* int: in grams */
+       DIVE_SUIT,              /* "wet, 3mm" */
        DIVE_CYLINDER,
        DIVE_NITROX,            /* int: dummy */
        DIVE_SAC,               /* int: in ml/min */
@@ -77,7 +79,6 @@ static void dump_model(GtkListStore *store)
 #endif
 
 static GList *selected_dives;
-static int *selectiontracker;
 static int st_size = 0;
 
 gboolean is_in_st(int idx, int *atpos)
@@ -459,6 +460,38 @@ newmax:
        *o2low_p = mino2;
 }
 
+static int total_weight(struct dive *dive)
+{
+       int i, total_grams = 0;
+
+       if (dive)
+               for (i=0; i< MAX_WEIGHTSYSTEMS; i++)
+                       total_grams += dive->weightsystem[i].weight.grams;
+       return total_grams;
+}
+
+static void weight_data_func(GtkTreeViewColumn *col,
+                            GtkCellRenderer *renderer,
+                            GtkTreeModel *model,
+                            GtkTreeIter *iter,
+                            gpointer data)
+{
+       int indx, decimals;
+       double value;
+       char buffer[80];
+       struct dive *dive;
+
+       gtk_tree_model_get(model, iter, DIVE_INDEX, &indx, -1);
+       dive = get_dive(indx);
+       value = get_weight_units(total_weight(dive), &decimals, NULL);
+       if (value == 0.0)
+               *buffer = '\0';
+       else
+               snprintf(buffer, sizeof(buffer), "%.*f", decimals, value);
+
+       g_object_set(renderer, "text", buffer, NULL);
+}
+
 static gint nitrox_sort_func(GtkTreeModel *model,
        GtkTreeIter *iter_a,
        GtkTreeIter *iter_b,
@@ -693,6 +726,11 @@ static void get_cylinder(struct dive *dive, char **str)
        get_string(str, dive->cylinder[0].type.description);
 }
 
+static void get_suit(struct dive *dive, char **str)
+{
+       get_string(str, dive->suit);
+}
+
 /*
  * Set up anything that could have changed due to editing
  * of dive information; we need to do this for both models,
@@ -708,11 +746,12 @@ static void fill_one_dive(struct dive *dive,
                          GtkTreeModel *model,
                          GtkTreeIter *iter)
 {
-       char *location, *cylinder;
+       char *location, *cylinder, *suit;
        GtkTreeStore *othermodel;
 
        get_cylinder(dive, &cylinder);
        get_location(dive, &location);
+       get_suit(dive, &suit);
 
        gtk_tree_store_set(GTK_TREE_STORE(model), iter,
                DIVE_NR, dive->number,
@@ -721,7 +760,14 @@ static void fill_one_dive(struct dive *dive,
                DIVE_RATING, dive->rating,
                DIVE_SAC, dive->sac,
                DIVE_OTU, dive->otu,
+               DIVE_TOTALWEIGHT, total_weight(dive),
+               DIVE_SUIT, suit,
                -1);
+
+       free(location);
+       free(cylinder);
+       free(suit);
+
        if (model == GTK_TREE_MODEL(dive_list.treemodel))
                othermodel = dive_list.listmodel;
        else
@@ -778,6 +824,9 @@ void update_dive_list_units(void)
        (void) get_temp_units(0, &unit);
        gtk_tree_view_column_set_title(dive_list.temperature, unit);
 
+       (void) get_weight_units(0, NULL, &unit);
+       gtk_tree_view_column_set_title(dive_list.totalweight, unit);
+
        gtk_tree_model_foreach(model, set_one_dive, NULL);
 }
 
@@ -785,6 +834,8 @@ void update_dive_list_col_visibility(void)
 {
        gtk_tree_view_column_set_visible(dive_list.cylinder, visible_cols.cylinder);
        gtk_tree_view_column_set_visible(dive_list.temperature, visible_cols.temperature);
+       gtk_tree_view_column_set_visible(dive_list.totalweight, visible_cols.totalweight);
+       gtk_tree_view_column_set_visible(dive_list.suit, visible_cols.suit);
        gtk_tree_view_column_set_visible(dive_list.nitrox, visible_cols.nitrox);
        gtk_tree_view_column_set_visible(dive_list.sac, visible_cols.sac);
        gtk_tree_view_column_set_visible(dive_list.otu, visible_cols.otu);
@@ -876,6 +927,8 @@ static void fill_dive_list(void)
                        DIVE_LOCATION, dive->location,
                        DIVE_RATING, dive->rating,
                        DIVE_TEMPERATURE, dive->watertemp.mkelvin,
+                       DIVE_TOTALWEIGHT, 0,
+                       DIVE_SUIT, dive->suit,
                        DIVE_SAC, 0,
                        -1);
        }
@@ -913,6 +966,8 @@ static struct divelist_column {
        [DIVE_DEPTH] = { "ft", depth_data_func, NULL, ALIGN_RIGHT },
        [DIVE_DURATION] = { "min", duration_data_func, NULL, ALIGN_RIGHT },
        [DIVE_TEMPERATURE] = { UTF8_DEGREE "F", temperature_data_func, NULL, ALIGN_RIGHT, &visible_cols.temperature },
+       [DIVE_TOTALWEIGHT] = { "lbs", weight_data_func, NULL, ALIGN_RIGHT, &visible_cols.totalweight },
+       [DIVE_SUIT] = { "Suit", NULL, NULL, ALIGN_LEFT, &visible_cols.suit },
        [DIVE_CYLINDER] = { "Cyl", NULL, NULL, 0, &visible_cols.cylinder },
        [DIVE_NITROX] = { "O" UTF8_SUBSCRIPT_2 "%", nitrox_data_func, nitrox_sort_func, 0, &visible_cols.nitrox },
        [DIVE_SAC] = { "SAC", sac_data_func, NULL, 0, &visible_cols.sac },
@@ -1140,6 +1195,8 @@ GtkWidget *dive_list_create(void)
                                G_TYPE_INT,                     /* Depth */
                                G_TYPE_INT,                     /* Duration */
                                G_TYPE_INT,                     /* Temperature */
+                               G_TYPE_INT,                     /* Total weight */
+                               G_TYPE_STRING,                  /* Suit */
                                G_TYPE_STRING,                  /* Cylinder */
                                G_TYPE_INT,                     /* Nitrox */
                                G_TYPE_INT,                     /* SAC */
@@ -1154,6 +1211,8 @@ GtkWidget *dive_list_create(void)
                                G_TYPE_INT,                     /* Depth */
                                G_TYPE_INT,                     /* Duration */
                                G_TYPE_INT,                     /* Temperature */
+                               G_TYPE_INT,                     /* Total weight */
+                               G_TYPE_STRING,                  /* Suit */
                                G_TYPE_STRING,                  /* Cylinder */
                                G_TYPE_INT,                     /* Nitrox */
                                G_TYPE_INT,                     /* SAC */
@@ -1175,6 +1234,8 @@ GtkWidget *dive_list_create(void)
        dive_list.depth = divelist_column(&dive_list, dl_column + DIVE_DEPTH);
        dive_list.duration = divelist_column(&dive_list, dl_column + DIVE_DURATION);
        dive_list.temperature = divelist_column(&dive_list, dl_column + DIVE_TEMPERATURE);
+       dive_list.totalweight = divelist_column(&dive_list, dl_column + DIVE_TOTALWEIGHT);
+       dive_list.suit = divelist_column(&dive_list, dl_column + DIVE_SUIT);
        dive_list.cylinder = divelist_column(&dive_list, dl_column + DIVE_CYLINDER);
        dive_list.nitrox = divelist_column(&dive_list, dl_column + DIVE_NITROX);
        dive_list.sac = divelist_column(&dive_list, dl_column + DIVE_SAC);
index ccfeb1270c7bb42883acca8e13558ea3f65024c4..71639c9d14b3c0cc7bb4fe1c05183ccbbd62852d 100644 (file)
@@ -309,13 +309,15 @@ static GtkTreeIter *add_weightsystem_type(const char *desc, int weight, GtkTreeI
        model = GTK_TREE_MODEL(weightsystem_model);
        gtk_tree_model_foreach(model, match_desc, (void *)desc);
 
-       if (!found_match) {
-               GtkListStore *store = GTK_LIST_STORE(model);
-
-               gtk_list_store_append(store, iter);
-               gtk_list_store_set(store, iter,
-                       0, desc,
-                       1, weight,
+       if (found_match) {
+               gtk_list_store_set(GTK_LIST_STORE(model), found_match,
+                               WS_WEIGHT, weight,
+                               -1);
+       } else if (desc && desc[0]) {
+               gtk_list_store_append(GTK_LIST_STORE(model), iter);
+               gtk_list_store_set(GTK_LIST_STORE(model), iter,
+                       WS_DESC, desc,
+                       WS_WEIGHT, weight,
                        -1);
                return iter;
        }
@@ -624,6 +626,7 @@ static void record_weightsystem_changes(weightsystem_t *ws, struct ws_widget *we
        GtkComboBox *box;
        int grams;
        double value;
+       GtkTreeIter iter;
 
        /* Ignore uninitialized cylinder widgets */
        box = weightsystem_widget->description;
@@ -639,6 +642,7 @@ static void record_weightsystem_changes(weightsystem_t *ws, struct ws_widget *we
                grams = value * 1000;
        ws->weight.grams = grams;
        ws->description = desc;
+       add_weightsystem_type(desc, grams, &iter);
 }
 
 /*
@@ -745,8 +749,6 @@ static struct ws_info {
        const char *name;
        int grams;
 } ws_info[100] = {
-       /* Need an empty entry for the no weight system case */
-       { "", },
        { "integrated", 0 },
        { "belt", 0 },
        { "ankle", 0 },
index f7d3c500886ad69406efa336547af48daf9c4026..619af2f08ab2aa59125466ce20e3ef8ebaf335f1 100644 (file)
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -348,6 +348,8 @@ OPTIONCALLBACK(otu_toggle, visible_cols.otu)
 OPTIONCALLBACK(sac_toggle, visible_cols.sac)
 OPTIONCALLBACK(nitrox_toggle, visible_cols.nitrox)
 OPTIONCALLBACK(temperature_toggle, visible_cols.temperature)
+OPTIONCALLBACK(totalweight_toggle, visible_cols.totalweight)
+OPTIONCALLBACK(suit_toggle, visible_cols.suit)
 OPTIONCALLBACK(cylinder_toggle, visible_cols.cylinder)
 
 static void event_toggle(GtkWidget *w, gpointer _data)
@@ -434,6 +436,16 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
        gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
        g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(otu_toggle), NULL);
 
+       button = gtk_check_button_new_with_label("Show Weight");
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.totalweight);
+       gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
+       g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(totalweight_toggle), NULL);
+
+       button = gtk_check_button_new_with_label("Show Suit");
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.suit);
+       gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
+       g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(suit_toggle), NULL);
+
        font = gtk_font_button_new_with_font(divelist_font);
        gtk_box_pack_start(GTK_BOX(vbox), font, FALSE, FALSE, 5);
 
@@ -457,6 +469,8 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
                subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(output_units.temperature == FAHRENHEIT));
                subsurface_set_conf("lbs", PREF_BOOL, BOOL_TO_PTR(output_units.weight == LBS));
                subsurface_set_conf("TEMPERATURE", PREF_BOOL, BOOL_TO_PTR(visible_cols.temperature));
+               subsurface_set_conf("TOTALWEIGHT", PREF_BOOL, BOOL_TO_PTR(visible_cols.totalweight));
+               subsurface_set_conf("SUIT", PREF_BOOL, BOOL_TO_PTR(visible_cols.suit));
                subsurface_set_conf("CYLINDER", PREF_BOOL, BOOL_TO_PTR(visible_cols.cylinder));
                subsurface_set_conf("NITROX", PREF_BOOL, BOOL_TO_PTR(visible_cols.nitrox));
                subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac));
@@ -726,6 +740,8 @@ void init_ui(int *argcp, char ***argvp)
        /* an unset key is FALSE - all these are hidden by default */
        visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL));
        visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL));
+       visible_cols.totalweight = PTR_TO_BOOL(subsurface_get_conf("TOTALWEIGHT", PREF_BOOL));
+       visible_cols.suit = PTR_TO_BOOL(subsurface_get_conf("SUIT", PREF_BOOL));
        visible_cols.nitrox = PTR_TO_BOOL(subsurface_get_conf("NITROX", PREF_BOOL));
        visible_cols.otu = PTR_TO_BOOL(subsurface_get_conf("OTU", PREF_BOOL));
        visible_cols.sac = PTR_TO_BOOL(subsurface_get_conf("SAC", PREF_BOOL));
diff --git a/info.c b/info.c
index 842a150014505b1c31e00164efacac964908874f..846d51efc29062412dfe2c5da3656961d9e49476 100644 (file)
--- a/info.c
+++ b/info.c
@@ -19,9 +19,9 @@
 #include "display-gtk.h"
 #include "divelist.h"
 
-static GtkEntry *location, *buddy, *divemaster, *rating;
+static GtkEntry *location, *buddy, *divemaster, *rating, *suit;
 static GtkTextView *notes;
-static GtkListStore *location_list, *people_list, *star_list;
+static GtkListStore *location_list, *people_list, *star_list, *suit_list;
 
 static char *get_text(GtkTextView *view)
 {
@@ -43,12 +43,42 @@ static int text_changed(const char *old, const char *new)
                (!old && strcmp("",new));
 }
 
-static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp)
+static char *skip_space(char *str)
+{
+       if (str) {
+               while (isspace(*str))
+                       str++;
+               if (!*str)
+                       str = NULL;
+       }
+       return str;
+}
+
+/*
+ * Get the string from a combo box.
+ *
+ * The "master" string is the string of the current dive - we only consider it
+ * changed if the old string is either empty, or matches that master string.
+ */
+static char *get_combo_box_entry_text(GtkComboBoxEntry *combo_box, char **textp, char *master)
 {
        char *old = *textp;
        const gchar *new;
        GtkEntry *entry;
 
+       old = skip_space(old);
+       master = skip_space(master);
+
+       /*
+        * If we had a master string, and it doesn't match our old
+        * string, we will always pick the old value (it means that
+        * we're editing another dive's info that already had a
+        * valid value).
+        */
+       if (master && old)
+               if (strcmp(master, old))
+                       return NULL;
+
        entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo_box)));
        new = gtk_entry_get_text(entry);
        while (isspace(*new))
@@ -96,6 +126,7 @@ void show_dive_info(struct dive *dive)
        SET_TEXT_VALUE(divemaster);
        SET_TEXT_VALUE(buddy);
        SET_TEXT_VALUE(location);
+       SET_TEXT_VALUE(suit);
        gtk_entry_set_text(rating, star_strings[dive->rating]);
        gtk_text_buffer_set_text(gtk_text_view_get_buffer(notes),
                dive && dive->notes ? dive->notes : "", -1);
@@ -131,11 +162,12 @@ static int delete_dive_info(struct dive *dive)
 
 static void info_menu_edit_cb(GtkMenuItem *menuitem, gpointer user_data)
 {
-       edit_dive_info(current_dive);
+       edit_multi_dive_info(amount_selected, selectiontracker);
 }
 
 static void info_menu_delete_cb(GtkMenuItem *menuitem, gpointer user_data)
 {
+       /* this needs to delete all the selected dives as well, I guess? */
        delete_dive_info(current_dive);
 }
 
@@ -242,6 +274,8 @@ static gboolean match_string_entry(GtkTreeModel *model, GtkTreePath *path, GtkTr
 
        gtk_tree_model_get(model, iter, 0, &entry, -1);
        cmp = strcmp(entry, string);
+       if (entry)
+               free(entry);
 
        /* Stop. The entry is bigger than the new one */
        if (cmp > 0)
@@ -296,6 +330,11 @@ void add_location(const char *string)
        add_string_list_entry(string, location_list);
 }
 
+void add_suit(const char *string)
+{
+       add_string_list_entry(string, suit_list);
+}
+
 static int get_rating(const char *string)
 {
        int rating_val = 0;
@@ -308,36 +347,42 @@ static int get_rating(const char *string)
 }
 
 struct dive_info {
-       GtkComboBoxEntry *location, *divemaster, *buddy, *rating;
+       GtkComboBoxEntry *location, *divemaster, *buddy, *rating, *suit;
        GtkTextView *notes;
 };
 
-static void save_dive_info_changes(struct dive *dive, struct dive_info *info)
+static void save_dive_info_changes(struct dive *dive, struct dive *master, struct dive_info *info)
 {
        char *old_text, *new_text;
        char *rating_string;
        int changed = 0;
 
-       new_text = get_combo_box_entry_text(info->location, &dive->location);
+       new_text = get_combo_box_entry_text(info->location, &dive->location, master->location);
        if (new_text) {
                add_location(new_text);
                changed = 1;
        }
 
-       new_text = get_combo_box_entry_text(info->divemaster, &dive->divemaster);
+       new_text = get_combo_box_entry_text(info->divemaster, &dive->divemaster, master->divemaster);
        if (new_text) {
                add_people(new_text);
                changed = 1;
        }
 
-       new_text = get_combo_box_entry_text(info->buddy, &dive->buddy);
+       new_text = get_combo_box_entry_text(info->buddy, &dive->buddy, master->buddy);
        if (new_text) {
                add_people(new_text);
                changed = 1;
        }
 
+       new_text = get_combo_box_entry_text(info->suit, &dive->suit, master->suit);
+       if (new_text) {
+               add_suit(new_text);
+               changed = 1;
+       }
+
        rating_string = strdup(star_strings[dive->rating]);
-       new_text = get_combo_box_entry_text(info->rating, &rating_string);
+       new_text = get_combo_box_entry_text(info->rating, &rating_string, star_strings[master->rating]);
        if (new_text) {
                dive->rating = get_rating(rating_string);
                free(rating_string);
@@ -380,6 +425,7 @@ static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info
        gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
 
        info->rating = text_entry(hbox, "Rating", star_list, star_strings[dive->rating]);
+       info->suit = text_entry(hbox, "Suit", suit_list, dive->suit);
 
        /* only show notes if editing a single dive */
        if (multi) {
@@ -428,7 +474,7 @@ int edit_multi_dive_info(int nr, int *indices)
        int success, i;
        GtkWidget *dialog, *vbox;
        struct dive_info info;
-       struct dive *dive;
+       struct dive *master;
 
        if (!nr)
                return 0;
@@ -447,22 +493,34 @@ int edit_multi_dive_info(int nr, int *indices)
         * data is used as the starting point for all selected dives
         * I think it would be better to somehow collect and combine
         * info from all the selected dives */
-       dive = current_dive;
-       dive_info_widget(vbox, dive, &info, (nr > 1));
-       show_dive_equipment(dive, W_IDX_SECONDARY);
-       save_equipment_data(dive);
+       master = current_dive;
+       dive_info_widget(vbox, master, &info, (nr > 1));
+       show_dive_equipment(master, W_IDX_SECONDARY);
+       save_equipment_data(master);
        gtk_widget_show_all(dialog);
        success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
-       if (success)
+       if (success) {
+               /* Update the other non-current dives first */
                for (i = 0; i < nr; i++) {
+                       int idx = indices[i];
+                       struct dive *dive = get_dive(idx);
+
+                       if (!dive || dive == master)
+                               continue;
                        /* copy all "info" fields */
-                       save_dive_info_changes(get_dive(indices[i]), &info);
+                       save_dive_info_changes(dive, master, &info);
                        /* copy the cylinders / weightsystems */
-                       update_equipment_data(get_dive(indices[i]), dive);
+                       update_equipment_data(dive, master);
                        /* this is extremely inefficient... it loops through all
                           dives to find the right one - but we KNOW the index already */
-                       flush_divelist(get_dive(indices[i]));
+                       flush_divelist(dive);
                }
+
+               /* Update the master dive last! */
+               save_dive_info_changes(master, master, &info);
+               update_equipment_data(master, master);
+               flush_divelist(master);
+       }
        gtk_widget_destroy(dialog);
 
        return success;
@@ -619,6 +677,7 @@ GtkWidget *extended_dive_info_widget(void)
        add_string_list_entry(THREE_STARS, star_list);
        add_string_list_entry(FOUR_STARS, star_list);
        add_string_list_entry(FIVE_STARS, star_list);
+       suit_list = gtk_list_store_new(1, G_TYPE_STRING);
 
        gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
        location = text_value(vbox, "Location");
@@ -633,6 +692,7 @@ GtkWidget *extended_dive_info_widget(void)
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
 
        rating = text_value(hbox, "Rating");
+       suit = text_value(hbox, "Suit");
 
        notes = text_view(vbox, "Notes", READ_ONLY);
        return vbox;
index d6fc953a7cbc075bd2317ee24ce8c61314b03aea..a36758ca0e72da72e85904cce1fee4001ff0c025 100644 (file)
@@ -1100,6 +1100,8 @@ static void try_to_fill_dive(struct dive **divep, const char *name, char *buf)
                return;
        if (MATCH(".location", utf8_string, &dive->location))
                return;
+       if (MATCH(".suit", utf8_string, &dive->suit))
+               return;
        if (MATCH(".notes", utf8_string, &dive->notes))
                return;
        if (MATCH(".divemaster", utf8_string, &dive->divemaster))
index 137ed6f88778c2dea942c2dd377b43dea11497d2..7a0eac4975ac9b6e4755e23236407c142f211b24 100644 (file)
--- a/profile.c
+++ b/profile.c
@@ -14,6 +14,7 @@
 #include "color.h"
 
 int selected_dive = 0;
+int *selectiontracker;
 
 typedef enum { STABLE, SLOW, MODERATE, FAST, CRAZY } velocity_t;
 
index ed55c022d4bf971e1d10802cf38c5399830ea98d..37d6d062eabf836f188b8cfc2bcd0b6feae0c6a4 100644 (file)
@@ -183,6 +183,7 @@ static void save_overview(FILE *f, struct dive *dive)
        show_utf8(f, dive->divemaster, "  <divemaster>","</divemaster>\n");
        show_utf8(f, dive->buddy, "  <buddy>","</buddy>\n");
        show_utf8(f, dive->notes, "  <notes>","</notes>\n");
+       show_utf8(f, dive->suit, "  <suit>","</suit>\n");
 }
 
 static void save_cylinder_info(FILE *f, struct dive *dive)