+static void
+gtk_xpaned_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkXPaned *xpaned = GTK_XPANED (widget);
+ gint tl[2], tr[2], bl[2], br[2];
+ gint overhead;
+ gint w[2];
+ int i;
+
+ if (xpaned->top_left_child
+ && gtk_widget_get_visible (xpaned->top_left_child))
+ gtk_widget_get_preferred_width (xpaned->top_left_child, &tl[0], &tl[1]);
+ else
+ tl[0] = tl[1] = 0;
+
+ if (xpaned->top_right_child
+ && gtk_widget_get_visible (xpaned->top_right_child))
+ gtk_widget_get_preferred_width (xpaned->top_right_child, &tr[0], &tr[1]);
+ else
+ tr[0] = tr[1] = 0;
+
+ if (xpaned->bottom_left_child
+ && gtk_widget_get_visible (xpaned->bottom_left_child))
+ gtk_widget_get_preferred_width (xpaned->bottom_left_child, &bl[0], &bl[1]);
+ else
+ bl[0] = bl[1] = 0;
+
+ if (xpaned->bottom_right_child
+ && gtk_widget_get_visible (xpaned->bottom_right_child))
+ gtk_widget_get_preferred_width (xpaned->bottom_right_child,
+ &br[0], &br[1]);
+ else
+ br[0] = br[1] = 0;
+
+ /* add 2 times the set border-width to the GtkXPaneds requisition */
+ overhead = gtk_container_get_border_width (GTK_CONTAINER (xpaned)) * 2;
+
+ /* also add the handle "thickness" to GtkXPaned's width requisition */
+ if (xpaned->top_left_child
+ && gtk_widget_get_visible (xpaned->top_left_child)
+ && xpaned->top_right_child
+ && gtk_widget_get_visible (xpaned->top_right_child)
+ && xpaned->bottom_left_child
+ && gtk_widget_get_visible (xpaned->bottom_left_child)
+ && xpaned->bottom_right_child
+ && gtk_widget_get_visible (xpaned->bottom_right_child))
+ {
+ gint handle_size;
+
+ gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
+ overhead += handle_size;
+ }
+
+ for (i = 0; i < 2; i++)
+ w[i] = (br[i] ? br[i] : MAX (tl[i] + tr[i], bl[i])) + overhead;
+
+ *minimal_width = w[0];
+ *natural_width = w[1];
+}
+
+static void
+gtk_xpaned_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkXPaned *xpaned = GTK_XPANED (widget);
+ gint tl[2], tr[2], bl[2], br[2];
+ gint overhead;
+ gint h[2];
+ int i;
+
+ if (xpaned->top_left_child
+ && gtk_widget_get_visible (xpaned->top_left_child))
+ gtk_widget_get_preferred_height (xpaned->top_left_child, &tl[0], &tl[1]);
+ else
+ tl[0] = tl[1] = 0;
+
+ if (xpaned->top_right_child
+ && gtk_widget_get_visible (xpaned->top_right_child))
+ gtk_widget_get_preferred_height (xpaned->top_right_child, &tr[0], &tr[1]);
+ else
+ tr[0] = tr[1] = 0;
+
+ if (xpaned->bottom_left_child
+ && gtk_widget_get_visible (xpaned->bottom_left_child))
+ gtk_widget_get_preferred_height (xpaned->bottom_left_child,
+ &bl[0], &bl[1]);
+ else
+ bl[0] = bl[1] = 0;
+
+ if (xpaned->bottom_right_child
+ && gtk_widget_get_visible (xpaned->bottom_right_child))
+ gtk_widget_get_preferred_height (xpaned->bottom_right_child,
+ &br[0], &br[1]);
+ else
+ br[0] = br[1] = 0;
+
+ /* add 2 times the set border-width to the GtkXPaneds requisition */
+ overhead = gtk_container_get_border_width (GTK_CONTAINER (xpaned)) * 2;
+
+ /* also add the handle "thickness" to GtkXPaned's height-requisition */
+ if (xpaned->top_left_child
+ && gtk_widget_get_visible (xpaned->top_left_child)
+ && xpaned->top_right_child
+ && gtk_widget_get_visible (xpaned->top_right_child)
+ && xpaned->bottom_left_child
+ && gtk_widget_get_visible (xpaned->bottom_left_child)
+ && xpaned->bottom_right_child
+ && gtk_widget_get_visible (xpaned->bottom_right_child))
+ {
+ gint handle_size;
+
+ gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
+ overhead += handle_size;
+ }
+
+ for (i = 0; i < 2; i++)
+ h[i] = (br[i] ? br[i] : bl[i] + MAX (tl[i], tr[i])) + overhead;
+
+ *minimal_height = h[0];
+ *natural_height = h[1];
+}