e01dcc57a5593abd861a231907aec4c41bc436be
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c
index 8adc375..0fdb659 100644
--- a/gtk/gtkalignment.c
+++ b/gtk/gtkalignment.c
@@ -26,6 +26,7 @@
 
 #include <config.h>
 #include "gtkalignment.h"
+#include "gtkextendedlayout.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
@@ -66,7 +67,11 @@ static void gtk_alignment_get_property (GObject         *object,
                                         GValue          *value,
                                         GParamSpec      *pspec);
 
-G_DEFINE_TYPE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN)
+static void gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+						gtk_alignment_extended_layout_init))
 
 static void
 gtk_alignment_class_init (GtkAlignmentClass *class)
@@ -443,6 +448,7 @@ gtk_alignment_size_allocate (GtkWidget     *widget,
   GtkBin *bin;
   GtkAllocation child_allocation;
   GtkRequisition child_requisition;
+  GtkRequisition child_natural_size;
   gint width, height;
   gint border_width;
   gint padding_horizontal, padding_vertical;
@@ -468,6 +474,18 @@ gtk_alignment_size_allocate (GtkWidget     *widget,
       width = allocation->width - padding_horizontal - 2 * border_width;
       height = allocation->height - padding_vertical - 2 * border_width;
     
+      if (GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (bin->child))
+        {
+          gtk_extended_layout_get_natural_size (GTK_EXTENDED_LAYOUT (bin->child),
+                                                &child_natural_size);
+
+          child_requisition.width = MAX (child_requisition.width, child_natural_size.width);
+          child_requisition.width = MIN (child_requisition.width, width);
+
+          child_requisition.height = MAX (child_requisition.height, child_natural_size.height);
+          child_requisition.height = MIN (child_requisition.height, height);
+        }
+
       if (width > child_requisition.width)
 	child_allocation.width = (child_requisition.width *
 				  (1.0 - alignment->xscale) +
@@ -588,5 +606,39 @@ gtk_alignment_get_padding (GtkAlignment    *alignment,
     *padding_right = priv->padding.right;
 }
 
+static GtkExtendedLayoutFeatures
+gtk_alignment_extended_layout_get_features (GtkExtendedLayout *layout)
+{
+  GtkExtendedLayoutFeatures features;
+
+  features =
+    GTK_EXTENDED_LAYOUT_CLASS (gtk_alignment_parent_class)->
+    get_features (layout);
+
+  return features | GTK_EXTENDED_LAYOUT_PADDING;
+}
+
+static void
+gtk_alignment_extended_layout_get_padding (GtkExtendedLayout *layout,
+                                           GtkBorder         *padding)
+{
+  GtkAlignmentPrivate *priv = GTK_ALIGNMENT_GET_PRIVATE (layout);
+  gint border_width = GTK_CONTAINER (layout)->border_width;
+
+  *padding = priv->padding;
+
+  padding->top += border_width;
+  padding->left += border_width;
+  padding->right += border_width;
+  padding->bottom += border_width;
+}
+
+static void
+gtk_alignment_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+  iface->get_features = gtk_alignment_extended_layout_get_features;
+  iface->get_padding = gtk_alignment_extended_layout_get_padding;
+}
+
 #define __GTK_ALIGNMENT_C__
 #include "gtkaliasdef.c"
