+
+static void
+gtk_expander_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkExpander *expander;
+ GtkWidget *child;
+ GtkExpanderPrivate *priv;
+ gint border_width;
+ gint expander_size;
+ gint expander_spacing;
+ gboolean interior_focus;
+ gint focus_width;
+ gint focus_pad;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ expander = GTK_EXPANDER (widget);
+ priv = expander->priv;
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ gtk_widget_style_get (GTK_WIDGET (widget),
+ "interior-focus", &interior_focus,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ "expander-size", &expander_size,
+ "expander-spacing", &expander_spacing,
+ NULL);
+
+ *minimum_size = *natural_size =
+ expander_size + 2 * expander_spacing +
+ 2 * focus_width + 2 * focus_pad;
+
+ if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
+ {
+ gint label_min, label_nat;
+
+ gtk_widget_get_preferred_width (priv->label_widget,
+ &label_min, &label_nat);
+
+ *minimum_size += label_min;
+ *natural_size += label_nat;
+ }
+
+ if (child && gtk_widget_get_child_visible (child))
+ {
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_width (child,
+ &child_min, &child_nat);
+
+ *minimum_size = MAX (*minimum_size, child_min);
+ *natural_size = MAX (*natural_size, child_nat);
+
+ }
+
+ *minimum_size += 2 * border_width;
+ *natural_size += 2 * border_width;
+}
+
+static void
+gtk_expander_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkExpander *expander;
+ GtkWidget *child;
+ GtkExpanderPrivate *priv;
+ gint border_width;
+ gint expander_size;
+ gint expander_spacing;
+ gboolean interior_focus;
+ gint focus_width;
+ gint focus_pad;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ expander = GTK_EXPANDER (widget);
+ priv = expander->priv;
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ gtk_widget_style_get (GTK_WIDGET (widget),
+ "interior-focus", &interior_focus,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ "expander-size", &expander_size,
+ "expander-spacing", &expander_spacing,
+ NULL);
+
+ *minimum_size = *natural_size =
+ interior_focus ? (2 * focus_width + 2 * focus_pad) : 0;
+
+
+ if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
+ {
+ gint label_min, label_nat;
+
+ gtk_widget_get_preferred_height (priv->label_widget,
+ &label_min, &label_nat);
+
+ *minimum_size += label_min;
+ *natural_size += label_nat;
+ }
+
+ *minimum_size = MAX (*minimum_size, expander_size + 2 * expander_spacing);
+ *natural_size = MAX (*natural_size, *minimum_size);
+
+ if (!interior_focus)
+ {
+ gint extra = 2 * focus_width + 2 * focus_pad;
+ *minimum_size += extra;
+ *natural_size += extra;
+ }
+
+ if (child && gtk_widget_get_child_visible (child))
+ {
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_height (child,
+ &child_min, &child_nat);
+
+ *minimum_size += child_min + priv->spacing;
+ *natural_size += child_nat + priv->spacing;
+
+ }
+
+ *minimum_size += 2 * border_width;
+ *natural_size += 2 * border_width;
+}
+
+static void
+gtk_expander_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkExpander *expander;
+ GtkWidget *child;
+ GtkExpanderPrivate *priv;
+ gint border_width;
+ gint expander_size;
+ gint expander_spacing;
+ gboolean interior_focus;
+ gint focus_width;
+ gint focus_pad;
+ gint label_xpad;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ expander = GTK_EXPANDER (widget);
+ priv = expander->priv;
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ gtk_widget_style_get (GTK_WIDGET (widget),
+ "interior-focus", &interior_focus,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ "expander-size", &expander_size,
+ "expander-spacing", &expander_spacing,
+ NULL);
+
+ label_xpad = 2 * border_width + expander_size + 2 * expander_spacing - 2 * focus_width + 2 * focus_pad;
+
+ *minimum_height = *natural_height =
+ interior_focus ? (2 * focus_width + 2 * focus_pad) : 0;
+
+
+ if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
+ {
+ gint label_min, label_nat;
+
+ gtk_widget_get_preferred_height_for_width (priv->label_widget,
+ MAX (width - label_xpad, 1),
+ &label_min, &label_nat);
+
+ *minimum_height += label_min;
+ *natural_height += label_nat;
+ }
+
+ *minimum_height = MAX (*minimum_height, expander_size + 2 * expander_spacing);
+ *natural_height = MAX (*natural_height, *minimum_height);
+
+ if (!interior_focus)
+ {
+ gint extra = 2 * focus_width + 2 * focus_pad;
+ *minimum_height += extra;
+ *natural_height += extra;
+ }
+
+ if (child && gtk_widget_get_child_visible (child))
+ {
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_height_for_width (child,
+ MAX (width - 2 * border_width, 1),
+ &child_min, &child_nat);
+
+ *minimum_height += child_min + priv->spacing;
+ *natural_height += child_nat + priv->spacing;
+ }
+
+ *minimum_height += 2 * border_width;
+ *natural_height += 2 * border_width;
+}
+
+static void
+gtk_expander_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
+}
+
+
+