summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Sergey Starosek <sergey.starosek@gmail.com>2013-05-17 13:05:43 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-17 08:34:45 -0700
commit2742d59b368e9a039f822eea5686186a27866e18 (patch)
treeb1c87a7382f81f705b4e6cb0df1e8fe87ab850a2 /gtk-gui.c
parente07072f10a130a5e3a3aca8d1d7cf01d917044ed (diff)
downloadsubsurface-2742d59b368e9a039f822eea5686186a27866e18.tar.gz
Fix "Select tags" dialog behavior
* Apply filter only when OK button pressed * Restore tags selection from dive mask when Cancel button pressed * Fix selection logic when selected or all dives are filtered out (hide profile, tooltips, etc.) Not sure whether call to repaint_dive() is required. Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index b8d749858..04f31a9cb 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1130,6 +1130,7 @@ static void selecttags_dialog(GtkWidget *w, gpointer data)
{
int i, result;
GtkWidget *dialog, *frame, *vbox, *table;
+ struct dive *d;
dialog = gtk_dialog_new_with_buttons(_("Only display dives with these tags:"),
GTK_WINDOW(main_window),
@@ -1153,14 +1154,29 @@ static void selecttags_dialog(GtkWidget *w, gpointer data)
gtk_widget_show_all(dialog);
result = gtk_dialog_run(GTK_DIALOG(dialog));
if (result == GTK_RESPONSE_ACCEPT) {
- repaint_dive();
+ dive_mask = 0;
+ for (i = 0; i < DTAG_NR; i++)
+ if (dtag_shown[i])
+ 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;
+
+ dive_list_update_dives();
+ } else {
+ /* restore tags selection from dive_mask */
+ for (i = 0; i < DTAG_NR; i++) {
+ dtag_shown[i] = 1 & dive_mask >> i;
+ }
}
gtk_widget_destroy(dialog);
- dive_mask = 0;
- for (i = 0; i < DTAG_NR; i++)
- if (dtag_shown[i])
- dive_mask |= (1 << i);
- dive_list_update_dives();
}
static void selectevents_dialog(GtkWidget *w, gpointer data)