From 0a9ad49f0aaf45a4d89c4ed90ce2c5c6fab154d5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 10 Apr 2013 10:04:50 -0700 Subject: Fix selection handling for invalid dives This is the downside of having to track our own selection state. We now have a class of dives that potentially isn't known to Gtk as we aren't adding them to the TreeView. So we need to make sure that their selection state is consistent by deselecting them (either when they are marked as invalid OR when we change preferences to no longer show invalid dives). And because Gtk sends out another set of selection events when clearing the TreeView (not sure why), we also need to make sure that their selection state isn't reset to selected by mistake when the divelist is recreated. A bit of a pain, but it seems to work now and be consistent. Signed-off-by: Dirk Hohndel --- gtk-gui.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gtk-gui.c') diff --git a/gtk-gui.c b/gtk-gui.c index eb07807b0..1dd73b21d 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -1027,9 +1027,23 @@ static void preferences_dialog(GtkWidget *w, gpointer data) result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { const char *po2_threshold_text, *pn2_threshold_text, *phe_threshold_text, *mod_text, *gflow_text, *gfhigh_text; + int j; + struct dive *d; + /* Make sure to flush any modified old dive data with old units */ update_dive(NULL); + /* if we turned off displaying invalid dives. de-select all + * invalid dives that were selected before hiding them */ + if (oldprefs.display_invalid_dives && !prefs.display_invalid_dives) { + for_each_dive(j, d) + if (d->selected && d->dive_tags && DTAG_INVALID) { + d->selected = 0; + amount_selected--; + } + if (amount_selected == 0) + selected_dive = -1; + } prefs.divelist_font = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(font))); set_divelist_font(prefs.divelist_font); po2_threshold_text = gtk_entry_get_text(GTK_ENTRY(entry_po2)); -- cgit v1.2.3-70-g09d2