[gtk+] paned: Use hfw queries during allocation



commit 4000d65ee3dc19417997750dae754107b5749365
Author: Benjamin Otte <otte redhat com>
Date:   Mon Apr 18 01:50:52 2011 +0200

    paned: Use hfw queries during allocation

 gtk/gtkpaned.c |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index fb8328b..9e87217 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -988,8 +988,6 @@ gtk_paned_size_allocate (GtkWidget     *widget,
   if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
       priv->child2 && gtk_widget_get_visible (priv->child2))
     {
-      GtkRequisition child1_requisition;
-      GtkRequisition child2_requisition;
       GtkAllocation child1_allocation;
       GtkAllocation child2_allocation;
       GtkAllocation priv_child1_allocation;
@@ -998,17 +996,23 @@ gtk_paned_size_allocate (GtkWidget     *widget,
 
       gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
 
-      gtk_widget_get_preferred_size (priv->child1, &child1_requisition, NULL);
-      gtk_widget_get_preferred_size (priv->child2, &child2_requisition, NULL);
-
       old_handle_pos = priv->handle_pos;
 
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
+          gint child1_width, child2_width;
+
+          gtk_widget_get_preferred_width_for_height (priv->child1,
+                                                     allocation->height,
+                                                     &child1_width, NULL);
+          gtk_widget_get_preferred_width_for_height (priv->child2,
+                                                     allocation->height,
+                                                     &child2_width, NULL);
+
           gtk_paned_calc_position (paned,
                                    MAX (1, allocation->width - handle_size),
-                                   child1_requisition.width,
-                                   child2_requisition.width);
+                                   child1_width,
+                                   child2_width);
 
           priv->handle_pos.x = allocation->x + priv->child1_size;
           priv->handle_pos.y = allocation->y;
@@ -1032,10 +1036,19 @@ gtk_paned_size_allocate (GtkWidget     *widget,
         }
       else
         {
+          gint child1_height, child2_height;
+
+          gtk_widget_get_preferred_height_for_width (priv->child1,
+                                                     allocation->width,
+                                                     &child1_height, NULL);
+          gtk_widget_get_preferred_height_for_width (priv->child2,
+                                                     allocation->width,
+                                                     &child2_height, NULL);
+
           gtk_paned_calc_position (paned,
                                    MAX (1, allocation->height - handle_size),
-                                   child1_requisition.height,
-                                   child2_requisition.height);
+                                   child1_height,
+                                   child2_height);
 
           priv->handle_pos.x = allocation->x;
           priv->handle_pos.y = allocation->y + priv->child1_size;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]