bb6fdacc44bac960c54985f9e57d13a60e026bfe
diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c
index d6f5d5e..b2f8b3f 100644
--- a/gtk/gtkbin.c
+++ b/gtk/gtkbin.c
@@ -26,6 +26,7 @@
 
 #include <config.h>
 #include "gtkbin.h"
+#include "gtkextendedlayout.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
 
@@ -34,13 +35,16 @@ static void gtk_bin_add         (GtkContainer   *container,
 static void gtk_bin_remove      (GtkContainer   *container,
 			         GtkWidget      *widget);
 static void gtk_bin_forall      (GtkContainer   *container,
-				 gboolean	include_internals,
+				 gboolean        include_internals,
 				 GtkCallback     callback,
 				 gpointer        callback_data);
 static GType gtk_bin_child_type (GtkContainer   *container);
 
+static void  gtk_bin_extended_layout_interface_init (GtkExtendedLayoutIface *iface);
 
-G_DEFINE_ABSTRACT_TYPE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER)
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER,
+                                  G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+						         gtk_bin_extended_layout_interface_init))
 
 static void
 gtk_bin_class_init (GtkBinClass *class)
@@ -69,8 +73,8 @@ gtk_bin_child_type (GtkContainer *container)
 {
   if (!GTK_BIN (container)->child)
     return GTK_TYPE_WIDGET;
-  else
-    return G_TYPE_NONE;
+
+  return G_TYPE_NONE;
 }
 
 static void
@@ -151,5 +155,135 @@ gtk_bin_get_child (GtkBin *bin)
   return bin->child;
 }
 
+static GtkExtendedLayoutFeatures
+gtk_bin_extended_layout_get_features (GtkExtendedLayout *layout)
+{
+  GtkBin *bin = GTK_BIN (layout);
+
+  if (GTK_IS_EXTENDED_LAYOUT (bin->child))
+    {
+      return
+        gtk_extended_layout_get_features (GTK_EXTENDED_LAYOUT (bin->child)) &
+        (GTK_EXTENDED_LAYOUT_HEIGHT_FOR_WIDTH |
+         GTK_EXTENDED_LAYOUT_WIDTH_FOR_HEIGHT |
+         GTK_EXTENDED_LAYOUT_NATURAL_SIZE |
+         GTK_EXTENDED_LAYOUT_BASELINES);
+    }
+
+  return 0;
+}
+
+static gint
+gtk_bin_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
+                                              gint               width)
+{
+  GtkBin *bin = GTK_BIN (layout);
+
+  g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (bin->child), -1);
+
+  layout = GTK_EXTENDED_LAYOUT (bin->child);
+  return gtk_extended_layout_get_height_for_width (layout, width);
+}
+
+static gint
+gtk_bin_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
+                                              gint               height)
+{
+  GtkBin *bin = GTK_BIN (layout);
+
+  g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (bin->child), -1);
+
+  layout = GTK_EXTENDED_LAYOUT (bin->child);
+  return gtk_extended_layout_get_width_for_height (layout, height);
+}
+
+static void
+gtk_bin_extended_layout_get_natural_size (GtkExtendedLayout *layout,
+                                          GtkRequisition    *requisition)
+{
+  GtkBin *bin = GTK_BIN (layout);
+  GtkRequisition minimum_size;
+
+  g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (bin->child));
+
+  gtk_widget_size_request (GTK_WIDGET (layout), &minimum_size);
+  gtk_extended_layout_get_natural_size (GTK_EXTENDED_LAYOUT (bin->child),
+                                        requisition);
+
+  if (GTK_EXTENDED_LAYOUT_HAS_PADDING (layout))
+    {
+      GtkBorder padding;
+
+      gtk_extended_layout_get_padding (layout, &padding);
+
+      requisition->width += padding.left + padding.right;
+      requisition->height += padding.top + padding.bottom;
+    }
+
+  requisition->width = MAX (requisition->width, minimum_size.width);
+  requisition->height = MAX (requisition->height, minimum_size.height);
+}
+
+static gint
+gtk_bin_extended_layout_get_baselines (GtkExtendedLayout  *layout,
+                                       gint              **baselines)
+{
+  GtkBin *bin = GTK_BIN (layout);
+  gint num_lines;
+
+  g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (bin->child), -1);
+
+  num_lines = gtk_extended_layout_get_baselines (
+    GTK_EXTENDED_LAYOUT (bin->child), baselines);
+
+  if (baselines)
+    {
+      gint *baseptr = *baselines;
+      gint *baseend = baseptr + num_lines;
+
+      GtkBorder padding;
+
+      if (GTK_EXTENDED_LAYOUT_HAS_PADDING (bin))
+        gtk_extended_layout_get_padding (layout, &padding);
+      else
+        padding.top = GTK_CONTAINER (bin)->border_width;
+
+      while (baseptr < baseend)
+        *baseptr++ += padding.top;
+    }
+
+  return num_lines;
+}
+
+static void
+gtk_bin_extended_layout_set_baseline_offset (GtkExtendedLayout *layout,
+                                             gint               offset)
+{
+  GtkBin *bin = GTK_BIN (layout);
+
+  g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (bin->child));
+
+  if (GTK_EXTENDED_LAYOUT_HAS_PADDING (layout))
+    {
+      GtkBorder padding;
+
+      gtk_extended_layout_get_padding (layout, &padding);
+      offset -= padding.top;
+    }
+
+  gtk_extended_layout_set_baseline_offset (GTK_EXTENDED_LAYOUT (bin->child), offset);
+}
+
+static void
+gtk_bin_extended_layout_interface_init (GtkExtendedLayoutIface *iface)
+{
+  iface->get_features = gtk_bin_extended_layout_get_features;
+  iface->get_height_for_width = gtk_bin_extended_layout_get_height_for_width;
+  iface->get_width_for_height = gtk_bin_extended_layout_get_width_for_height;
+  iface->get_natural_size = gtk_bin_extended_layout_get_natural_size;
+  iface->get_baselines = gtk_bin_extended_layout_get_baselines;
+  iface->set_baseline_offset = gtk_bin_extended_layout_set_baseline_offset;
+}
+
 #define __GTK_BIN_C__
 #include "gtkaliasdef.c"
