]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix the jarring change of window size on expanding the SSH branch of
authorSimon Tatham <anakin@pobox.com>
Fri, 4 Apr 2008 11:37:06 +0000 (11:37 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 4 Apr 2008 11:37:06 +0000 (11:37 +0000)
the configuration tree.

[originally from svn r7968]

unix/gtkdlg.c

index 9f7df3b42be4acee92e151a4f39ad6ba74e0fa1b..12f8c5b98bc49756e729d8b564e4068bff5886cd 100644 (file)
@@ -2412,6 +2412,9 @@ struct selparam {
     GtkWidget *panel;
 #if !GTK_CHECK_VERSION(2,0,0)
     GtkWidget *treeitem;
+#else
+    int depth;
+    GtkTreePath *treepath;
 #endif
     struct Shortcuts shortcuts;
 };
@@ -2991,16 +2994,19 @@ int do_config_box(const char *title, Config *cfg, int midsession,
                treeiterlevels[j] = treeiter;
 
                if (j > 0) {
-                   GtkTreePath *path;
-
-                   path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore),
-                                                  &treeiterlevels[j-1]);
-                   if (j < 2)
-                       gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path,
-                                                FALSE);
-                   else
-                       gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
-                   gtk_tree_path_free(path);
+                   selparams[nselparams].treepath =
+                       gtk_tree_model_get_path(GTK_TREE_MODEL(treestore),
+                                               &treeiterlevels[j-1]);
+                   /*
+                    * We are going to collapse all tree branches
+                    * at depth greater than 2, but not _yet_; see
+                    * the comment at the call to
+                    * gtk_tree_view_collapse_row below.
+                    */
+                   gtk_tree_view_expand_row(GTK_TREE_VIEW(tree),
+                                            selparams[nselparams].treepath,
+                                            FALSE);
+                   selparams[nselparams].depth = j;
                }
 #else
                treeitem = gtk_tree_item_new_with_label(c);
@@ -3044,6 +3050,35 @@ int do_config_box(const char *title, Config *cfg, int midsession,
        }
     }
 
+#if GTK_CHECK_VERSION(2,0,0)
+    {
+       GtkRequisition req;
+       int i;
+
+       /*
+        * We want our tree view to come up with all branches at
+        * depth 2 or more collapsed. However, if we start off
+        * with those branches collapsed, then the tree view's
+        * size request will be calculated based on the width of
+        * the collapsed tree. So instead we start with them all
+        * expanded; then we ask for the current size request,
+        * collapse the relevant rows, and force the width to the
+        * value we just computed. This arranges that the tree
+        * view is wide enough to have all branches expanded
+        * safely.
+        */
+
+       gtk_widget_size_request(tree, &req);
+
+       for (i = 0; i < nselparams; i++)
+           if (selparams[i].depth >= 2)
+               gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree),
+                                          selparams[i].treepath);
+
+       gtk_widget_set_size_request(tree, req.width, -1);
+    }
+#endif
+
 #if GTK_CHECK_VERSION(2,0,0)
     g_signal_connect(G_OBJECT(treeselection), "changed",
                     G_CALLBACK(treeselection_changed), selparams);