Make sure there are no invisible selected dives after import / download
Prior to this commit, gtk often decided to collapse the trip with the selected dive after the user imported or downloaded additional dives. Since Subsurface tracks dives as being selected even after gtk collapses a trip (which clears all selection state as far as gtk is concerned) this could lead to the strange situation that the user could click on a new dive to select it without unselecting the already selected dive - and suddenly edit or delete did things that were entirely unwanted. With this change we explicitly save and then restore the tree state around import and download operations. This ensures that the same dive(s) stay selected and trips stay expanded and therefore avoids the issues described here. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
@@ -1948,7 +1948,7 @@ void add_single_dive(int idx, struct dive *dive)
|
||||
}
|
||||
|
||||
/* remember expanded state */
|
||||
static void remember_tree_state()
|
||||
void remember_tree_state()
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
if (!gtk_tree_model_get_iter_first(TREEMODEL(dive_list), &iter))
|
||||
@@ -1992,7 +1992,7 @@ static gboolean restore_node_state(GtkTreeModel *model, GtkTreePath *path, GtkTr
|
||||
}
|
||||
|
||||
/* restore expanded and selected state */
|
||||
static void restore_tree_state()
|
||||
void restore_tree_state()
|
||||
{
|
||||
gtk_tree_model_foreach(MODEL(dive_list), restore_node_state, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user