diff options
-rw-r--r-- | divelist-gtk.c | 6 | ||||
-rw-r--r-- | gtk-gui.c | 21 |
2 files changed, 13 insertions, 14 deletions
diff --git a/divelist-gtk.c b/divelist-gtk.c index 3f96193c5..1a47feb51 100644 --- a/divelist-gtk.c +++ b/divelist-gtk.c @@ -56,6 +56,7 @@ static struct DiveList dive_list; #define LISTSTORE(_dl) GTK_TREE_STORE((_dl).listmodel) short autogroup = FALSE; +static gboolean ignore_selection_changes = FALSE; static gboolean in_set_cursor = FALSE; static gboolean set_selected(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); @@ -780,8 +781,10 @@ static void restore_tree_state(void); void dive_list_update_dives(void) { dive_table.preexisting = dive_table.nr; + ignore_selection_changes = TRUE; gtk_tree_store_clear(TREESTORE(dive_list)); gtk_tree_store_clear(LISTSTORE(dive_list)); + ignore_selection_changes = FALSE; fill_dive_list(); restore_tree_state(); repaint_dive(); @@ -2056,6 +2059,9 @@ static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model) int i, fixup; struct dive *dive; + if (ignore_selection_changes) + return; + gtk_tree_selection_selected_foreach(selection, entry_selected, model); /* @@ -1035,12 +1035,8 @@ static void preferences_dialog(GtkWidget *w, gpointer data) * 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; + if (d->selected && d->dive_tags && DTAG_INVALID) + deselect_dive(j); } prefs.divelist_font = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(font))); set_divelist_font(prefs.divelist_font); @@ -1160,16 +1156,13 @@ static void selecttags_dialog(GtkWidget *w, gpointer data) dive_mask |= (1 << i); /* deselect dives filtered by tags before hiding */ - for_each_dive(i, d) { - if (d->selected && (d->dive_tags & dive_mask) != dive_mask) { - d->selected = 0; - amount_selected--; - } - } - if (amount_selected == 0) - selected_dive = -1; + for_each_dive(i, d) + if (d->selected && (d->dive_tags & dive_mask) != dive_mask) + deselect_dive(i); dive_list_update_dives(); + process_selected_dives(); + show_dive_stats(current_dive); } else { /* restore tags selection from dive_mask */ for (i = 0; i < DTAG_NR; i++) { |