+
+static void
+gtk_button_get_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkButton *button = GTK_BUTTON (widget);
+ GtkStyleContext *context;
+ GtkWidget *child;
+ GtkBorder default_border;
+ GtkBorder padding;
+ GtkBorder border;
+ gint focus_width;
+ gint focus_pad;
+ gint minimum, natural;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_button_get_props (button, &default_border, NULL,
+ &padding, &border, NULL);
+ gtk_style_context_get_style (context,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ minimum = padding.left + padding.right +
+ border.left + border.right;
+
+ if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
+ minimum += default_border.left + default_border.right;
+ }
+ else
+ {
+ minimum = padding.top + padding.bottom +
+ border.top + border.bottom;
+
+ if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
+ minimum += default_border.top + default_border.bottom;
+ }
+
+ minimum += 2 * (focus_width + focus_pad);
+ natural = minimum;
+
+ if ((child = gtk_bin_get_child (GTK_BIN (button))) &&
+ gtk_widget_get_visible (child))
+ {
+ gint child_min, child_nat;
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+ else
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
+
+ minimum += child_min;
+ natural += child_nat;
+ }
+
+ if (minimum_size)
+ *minimum_size = minimum;
+
+ if (natural_size)
+ *natural_size = natural;
+}
+
+static void
+gtk_button_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ gtk_button_get_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+}
+
+static void
+gtk_button_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ gtk_button_get_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+}
+