As suggested by Jakub in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8908...
authorJeff Morriss <jeff.morriss.ws@gmail.com>
Fri, 12 Jul 2013 13:56:14 +0000 (13:56 -0000)
committerJeff Morriss <jeff.morriss.ws@gmail.com>
Fri, 12 Jul 2013 13:56:14 +0000 (13:56 -0000)
When auto-expanding previously-expanded children (r50516), only apply
auto-scrolling to the tree the user just expanded (not any of its children
which were auto-expanded).

Also: only expand children of the just-expanded tree, not all instances of
the just-expanded tree.  This prevents expanding, for example, one SCTP chunk's
tree from expanding all other chunks in the same frame.  (Of course moving
between frames will cause the chunks' trees to be expanded.)

svn path=/trunk/; revision=50535

ui/gtk/packet_panes.c

index b14f2fd20c87f2deee61239665ec7f04e7899391..9102344ef947463d03875b2bb5f502577b657d9e 100644 (file)
@@ -194,7 +194,7 @@ redraw_packet_bytes_all(void)
 }
 
 static void
-check_expand_children(GtkTreeView *tree_view, GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter)
+check_expand_children(GtkTreeView *tree_view, GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gboolean scroll_it)
 {
     /* code inspired by gtk_tree_model_foreach_helper */
 
@@ -209,12 +209,12 @@ check_expand_children(GtkTreeView *tree_view, GtkTreeModel *model, GtkTreePath *
             if (tree_expanded(fi->tree_type)) {
                 gtk_tree_view_expand_row(tree_view, path, FALSE);
 
-                if (prefs.gui_auto_scroll_on_expand)
+                if (scroll_it)
                      gtk_tree_view_scroll_to_cell(tree_view, path, NULL, TRUE, (prefs.gui_auto_scroll_percentage/100.0f), 0.0f);
 
                 /* try to expand children only when parent is expanded */
                 gtk_tree_path_down(path);
-                check_expand_children(tree_view, model, path, &child);
+                check_expand_children(tree_view, model, path, &child, scroll_it);
                 gtk_tree_path_up(path);
 
             } else
@@ -227,7 +227,7 @@ check_expand_children(GtkTreeView *tree_view, GtkTreeModel *model, GtkTreePath *
 
 static void
 expand_tree(GtkTreeView *tree_view, GtkTreeIter *iter,
-            GtkTreePath *path _U_, gpointer user_data _U_)
+            GtkTreePath *path, gpointer user_data _U_)
 {
     field_info   *finfo;
     GtkTreeModel *model;
@@ -250,7 +250,9 @@ expand_tree(GtkTreeView *tree_view, GtkTreeIter *iter,
         tree_expanded_set(finfo->tree_type, TRUE);
 
         /* Expand any subtrees that the user had left open */
-        check_expand_children(tree_view, model, path, iter);
+        /* But only do this for subtrees of the just-expanded tree */
+        gtk_tree_path_down(path);
+        check_expand_children(tree_view, model, path, iter, FALSE);
 
     }
 }
@@ -1414,7 +1416,8 @@ proto_tree_draw_resolve(proto_tree *protocol_tree, GtkWidget *tree_view, const e
     /* modified version of gtk_tree_model_foreach */
     path = gtk_tree_path_new_first();
     if (gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path))
-        check_expand_children(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(model), path, &iter);
+        check_expand_children(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(model),
+                              path, &iter, prefs.gui_auto_scroll_on_expand);
     gtk_tree_path_free(path);
 
     g_signal_handlers_unblock_by_func(tree_view, expand_tree, NULL);