[PATCH] Remember pre-existing trip expansion state when autogrouping

Linus Torvalds torvalds at linux-foundation.org
Tue Feb 19 13:12:01 PST 2013


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Tue, 19 Feb 2013 13:05:45 -0800
Subject: [PATCH] Remember pre-existing trip expansion state when autogrouping

This just adds the "remember_tree_state()" and "restore_tree_state()"
calls around the divelist update when autogrouping is turned on: that
way existing expanded groups aren't blindly collapsed.

It makes it much easier to see what autogrouping does if it only groups
a few dives, because the overall state of the divelist isn't radically
changed.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

We should probably aim to do the whole "restore tree state" in 
dive_list_update_dives() unconditionally. Right now, almost all of the 
callers do it, and the two remaining cases (main.c and webservice.c 
should probably do it too.

Then, if we just made the collapse/expand callbacks update the 
trip->expanded flag, we could remove all the "save/restore" state 
entirely, and updating the divelist would just automatically maintain the 
previous state.

However, this patch doesn't do that. This patch just does the minimal "at 
least make autogrouping not collapse currently expanded groups".

 gtk-gui.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gtk-gui.c b/gtk-gui.c
index cd9f7579a7be..a8372af834d7 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -980,7 +980,9 @@ static void autogroup_cb(GtkWidget *w, gpointer data)
 	autogroup = !autogroup;
 	if (! autogroup)
 		remove_autogen_trips();
+	remember_tree_state();
 	dive_list_update_dives();
+	restore_tree_state();
 }
 
 void set_autogroup(gboolean value)
-- 
1.8.1.3.556.gb3310b5



More information about the subsurface mailing list