[gtk+/native-layout] Revert "Mega commit backing out everything from the native-layout branch that"



commit 16715a662e07d0c79217ec75fe3e87450e8d1d1a
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Fri Jun 11 15:44:56 2010 -0400

    Revert "Mega commit backing out everything from the native-layout branch that"
    
    This reverts commit 2a5272647d0833cb1dd8a9bb1b07a9a96484feae.
    
    Conflicts:
    
    	gtk/gtk.symbols
    	gtk/gtkextendedlayout.c

 gtk/Makefile.am           |    2 +
 gtk/gtk.h                 |    1 +
 gtk/gtk.symbols           |   13 ++
 gtk/gtkcellrenderer.c     |  161 ++++++++++++++++-
 gtk/gtkcellrenderertext.c |   90 +++++++++-
 gtk/gtkcellview.c         |  276 ++++++++++++++++++++++-------
 gtk/gtkcellview.h         |   11 ++
 gtk/gtkcombobox.c         |  439 +++++++++++++++++++++++++++------------------
 gtk/gtkextendedcell.c     |  193 ++++++++++++++++++++
 gtk/gtkextendedcell.h     |   88 +++++++++
 gtk/gtkextendedlayout.h   |    5 +-
 gtk/gtkplug-x11.c         |   27 +++
 gtk/gtkplug.c             |    7 +
 gtk/gtkplugprivate.h      |    3 +
 gtk/gtksocket-x11.c       |   62 +++++++
 gtk/gtksocket.c           |   96 ++++++++++-
 gtk/gtksocketprivate.h    |    4 +
 gtk/gtkspinner.c          |    9 +-
 gtk/gtktreeprivate.h      |    7 +
 gtk/gtktreeview.c         |  213 +++++++++++++++++-----
 gtk/gtktreeviewcolumn.c   |  147 +++++++++++----
 gtk/gtktreeviewcolumn.h   |    4 +
 22 files changed, 1520 insertions(+), 338 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 3e791dc..39b6614 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -214,6 +214,7 @@ gtk_public_h_sources =          \
 	gtkenums.h		\
 	gtkeventbox.h		\
 	gtkexpander.h		\
+	gtkextendedcell.h	\
 	gtkextendedlayout.h	\
 	gtkfilechooser.h        \
 	gtkfilechooserbutton.h  \
@@ -470,6 +471,7 @@ gtk_base_c_sources =            \
 	gtkentrycompletion.c	\
 	gtkeventbox.c		\
 	gtkexpander.c		\
+	gtkextendedcell.c	\
 	gtkextendedlayout.c	\
 	gtkfilechooser.c	\
 	gtkfilechooserbutton.c	\
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 120555b..2076831 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -84,6 +84,7 @@
 #include <gtk/gtkenums.h>
 #include <gtk/gtkeventbox.h>
 #include <gtk/gtkexpander.h>
+#include <gtk/gtkextendedcell.h>
 #include <gtk/gtkextendedlayout.h>
 #include <gtk/gtkfixed.h>
 #include <gtk/gtkfilechooser.h>
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 958ae25..3456634 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -674,6 +674,8 @@ gtk_cell_renderer_toggle_set_radio
 
 #if IN_HEADER(__GTK_CELL_VIEW_H__)
 #if IN_FILE(__GTK_CELL_VIEW_C__)
+gtk_cell_view_get_desired_height_of_row
+gtk_cell_view_get_desired_width_of_row
 gtk_cell_view_get_displayed_row
 gtk_cell_view_get_model
 gtk_cell_view_get_size_of_row
@@ -1217,6 +1219,16 @@ gtk_expander_set_use_underline
 #endif
 #endif
 
+#if IN_HEADER(__GTK_EXTENDED_CELL_H__)
+#if IN_FILE(__GTK_EXTENDED_CELL_C__)
+gtk_extended_cell_get_type G_GNUC_CONST
+gtk_extended_cell_get_desired_height
+gtk_extended_cell_get_desired_width
+gtk_extended_cell_get_height_for_width
+gtk_extended_cell_get_width_for_height
+#endif
+#endif
+
 #if IN_HEADER(__GTK_EXTENDED_LAYOUT_H__)
 #if IN_FILE(__GTK_EXTENDED_LAYOUT_C__)
 gtk_extended_layout_get_type G_GNUC_CONST
@@ -4053,6 +4065,7 @@ gtk_tree_view_column_clicked
 gtk_tree_view_column_focus_cell
 gtk_tree_view_column_get_alignment
 gtk_tree_view_column_get_clickable
+gtk_tree_view_column_get_desired_size
 gtk_tree_view_column_get_expand
 gtk_tree_view_column_get_fixed_width
 gtk_tree_view_column_get_max_width
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c
index 6093719..f4fe476 100644
--- a/gtk/gtkcellrenderer.c
+++ b/gtk/gtkcellrenderer.c
@@ -19,12 +19,15 @@
 
 #include "config.h"
 #include "gtkcellrenderer.h"
+#include "gtkextendedcell.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtkprivate.h"
 #include "gtktreeprivate.h"
 #include "gtkalias.h"
 
+static void gtk_cell_renderer_init          (GtkCellRenderer      *cell);
+static void gtk_cell_renderer_class_init    (GtkCellRendererClass *class);
 static void gtk_cell_renderer_get_property  (GObject              *object,
 					     guint                 param_id,
 					     GValue               *value,
@@ -36,6 +39,28 @@ static void gtk_cell_renderer_set_property  (GObject              *object,
 static void set_cell_bg_color               (GtkCellRenderer      *cell,
 					     GdkColor             *color);
 
+/* Fallback GtkExtendedCell implementation to use remaining ->get_size() implementations */
+static void gtk_cell_renderer_extended_cell_init   (GtkExtendedCellIface *iface);
+static void gtk_cell_renderer_get_desired_width    (GtkExtendedCell   *cell,
+						    GtkWidget         *widget,
+						    gint              *minimum_size,
+						    gint              *natural_size);
+static void gtk_cell_renderer_get_desired_height   (GtkExtendedCell   *cell,
+						    GtkWidget         *widget,
+						    gint              *minimum_size,
+						    gint              *natural_size);
+static void gtk_cell_renderer_get_height_for_width (GtkExtendedCell   *cell,
+						    GtkWidget         *widget,
+						    gint               width,
+						    gint              *minimum_height,
+						    gint              *natural_height);
+static void gtk_cell_renderer_get_width_for_height (GtkExtendedCell   *cell,
+						    GtkWidget         *widget,
+						    gint               height,
+						    gint              *minimum_width,
+						    gint              *natural_width);
+
+
 
 #define GTK_CELL_RENDERER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererPrivate))
 
@@ -72,9 +97,50 @@ enum {
   LAST_SIGNAL
 };
 
-static guint cell_renderer_signals[LAST_SIGNAL] = { 0 };
+static guint  cell_renderer_signals[LAST_SIGNAL] = { 0 };
+
+
+/* Do a manual _get_type() here to avoid a deadlock implementing
+ * the interface which we are a prerequisite of.
+ */
+GType
+gtk_cell_renderer_get_type (void)
+{
+  static GType cell_renderer_type = 0;
+
+  if (G_UNLIKELY (cell_renderer_type == 0))
+    {
+      const GTypeInfo cell_renderer_info =
+      {
+	sizeof (GtkCellRendererClass),
+	NULL,		/* base_init */
+	NULL,           /* base_finalize */
+	(GClassInitFunc) gtk_cell_renderer_class_init,
+	NULL,		/* class_finalize */
+	NULL,		/* class_init */
+	sizeof (GtkCellRenderer),
+	0,		/* n_preallocs */
+	(GInstanceInitFunc) gtk_cell_renderer_init,
+	NULL,		/* value_table */
+      };
+
+      const GInterfaceInfo extended_cell_info =
+      {
+	(GInterfaceInitFunc) gtk_cell_renderer_extended_cell_init,
+	(GInterfaceFinalizeFunc) NULL,
+	NULL /* interface data */
+      };
+
+      cell_renderer_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkCellRenderer",
+						   &cell_renderer_info, G_TYPE_FLAG_ABSTRACT);
+
+      g_type_add_interface_static (cell_renderer_type, GTK_TYPE_EXTENDED_CELL,
+                                   &extended_cell_info) ;
+    }
+
+  return cell_renderer_type;
+}
 
-G_DEFINE_ABSTRACT_TYPE (GtkCellRenderer, gtk_cell_renderer, GTK_TYPE_OBJECT)
 
 static void
 gtk_cell_renderer_init (GtkCellRenderer *cell)
@@ -968,5 +1034,96 @@ gtk_cell_renderer_stop_editing (GtkCellRenderer *cell,
     }
 }
 
+static void
+gtk_cell_renderer_extended_cell_init (GtkExtendedCellIface *iface)
+{
+  iface->get_desired_width     = gtk_cell_renderer_get_desired_width;
+  iface->get_desired_height    = gtk_cell_renderer_get_desired_height;
+
+  iface->get_width_for_height  = gtk_cell_renderer_get_width_for_height;
+  iface->get_height_for_width  = gtk_cell_renderer_get_height_for_width;
+}
+
+static void
+gtk_cell_renderer_get_desired_size (GtkExtendedCell   *cell,
+				    GtkWidget         *widget,
+				    GtkOrientation     orientation,
+				    gint              *minimum_size,
+				    gint              *natural_size)
+{
+  GtkRequisition min_req;
+
+  /* Fallback on the old API to get the size. */
+  if (GTK_CELL_RENDERER_GET_CLASS (cell)->get_size)
+    gtk_cell_renderer_get_size (GTK_CELL_RENDERER (cell), widget, NULL, NULL, NULL,
+				&min_req.width, &min_req.height);
+  else
+    {
+      min_req.width = 0;
+      min_req.height = 0;
+    }
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      if (minimum_size)
+	*minimum_size = min_req.width;
+
+      if (natural_size)
+	*natural_size = min_req.width;
+    }
+  else
+    {
+      if (minimum_size)
+	*minimum_size = min_req.height;
+
+      if (natural_size)
+	*natural_size = min_req.height;
+    }
+}
+
+static void
+gtk_cell_renderer_get_desired_width (GtkExtendedCell   *cell,
+				     GtkWidget         *widget,
+				     gint              *minimum_size,
+				     gint              *natural_size)
+{
+  gtk_cell_renderer_get_desired_size (cell, widget, GTK_ORIENTATION_HORIZONTAL, 
+				      minimum_size, natural_size);
+}
+
+static void
+gtk_cell_renderer_get_desired_height (GtkExtendedCell   *cell,
+				      GtkWidget         *widget,
+				      gint              *minimum_size,
+				      gint              *natural_size)
+{
+  gtk_cell_renderer_get_desired_size (cell, widget, GTK_ORIENTATION_VERTICAL, 
+				      minimum_size, natural_size);
+}
+
+
+static void
+gtk_cell_renderer_get_height_for_width (GtkExtendedCell *cell,
+					GtkWidget       *widget,
+					gint             width,
+					gint            *minimum_height,
+					gint            *natural_height)
+{
+  /* Fall back on the height reported from ->get_size() */
+  gtk_extended_cell_get_desired_height (cell, widget, minimum_height, natural_height);
+}
+
+static void
+gtk_cell_renderer_get_width_for_height (GtkExtendedCell *cell,
+					GtkWidget       *widget,
+					gint             height,
+					gint            *minimum_width,
+					gint            *natural_width)
+{
+  /* Fall back on the width reported from ->get_size() */
+  gtk_extended_cell_get_desired_width (cell, widget, minimum_width, natural_width);
+}
+
+
 #define __GTK_CELL_RENDERER_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 8060ade..859bcc1 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include "gtkcellrenderertext.h"
 #include "gtkeditable.h"
+#include "gtkextendedcell.h"
 #include "gtkentry.h"
 #include "gtkmarshalers.h"
 #include "gtkintl.h"
@@ -61,6 +62,16 @@ static GtkCellEditable *gtk_cell_renderer_text_start_editing (GtkCellRenderer
 							      GdkRectangle         *cell_area,
 							      GtkCellRendererState  flags);
 
+static void       gtk_cell_renderer_text_extended_cell_init (GtkExtendedCellIface  *iface);
+static void       gtk_cell_renderer_text_get_desired_width  (GtkExtendedCell       *cell,
+							     GtkWidget             *widget,
+							     gint                  *minimal_size,
+							     gint                  *desired_size);
+static void       gtk_cell_renderer_text_get_desired_height (GtkExtendedCell       *cell,
+							     GtkWidget             *widget,
+							     gint                  *minimal_size,
+							     gint                  *desired_size);
+
 enum {
   EDITED,
   LAST_SIGNAL
@@ -150,7 +161,9 @@ struct _GtkCellRendererTextPrivate
   GtkWidget *entry;
 };
 
-G_DEFINE_TYPE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_CELL_RENDERER)
+G_DEFINE_TYPE_WITH_CODE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_CELL_RENDERER,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_CELL,
+                                                gtk_cell_renderer_text_extended_cell_init))
 
 static void
 gtk_cell_renderer_text_init (GtkCellRendererText *celltext)
@@ -1930,5 +1943,80 @@ gtk_cell_renderer_text_set_fixed_height_from_font (GtkCellRendererText *renderer
     }
 }
 
+static void
+gtk_cell_renderer_text_extended_cell_init (GtkExtendedCellIface *iface)
+{
+  /* Currently cell renderers do natural widths for ellipsizing text 
+   * but dont yet do height-for-width/width-for-height calculations for
+   * wordwrapping 
+   */
+  iface->get_desired_width  = gtk_cell_renderer_text_get_desired_width;
+  iface->get_desired_height = gtk_cell_renderer_text_get_desired_height;
+}
+
+static void
+gtk_cell_renderer_text_get_desired_size (GtkExtendedCell   *cell,
+					 GtkWidget         *widget,
+					 GtkOrientation     orientation,
+					 gint              *minimal_size,
+					 gint              *desired_size)
+{
+  GtkCellRendererTextPrivate *priv;
+
+  priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell);
+
+  if (minimal_size)
+    {
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+	get_size (GTK_CELL_RENDERER (cell),
+		  widget, NULL, NULL, NULL, NULL,
+		  minimal_size, NULL);
+      else
+	get_size (GTK_CELL_RENDERER (cell),
+		  widget, NULL, NULL, NULL, NULL,
+		  NULL, minimal_size);
+    }
+  
+  if (desired_size)
+    {
+      PangoEllipsizeMode ellipsize;
+      
+      ellipsize = priv->ellipsize;
+      priv->ellipsize = PANGO_ELLIPSIZE_NONE;
+      
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+	get_size (GTK_CELL_RENDERER (cell),
+		  widget, NULL, NULL, NULL, NULL,
+		  desired_size, NULL);
+      else
+	get_size (GTK_CELL_RENDERER (cell),
+		  widget, NULL, NULL, NULL, NULL,
+		  NULL, desired_size);
+
+      priv->ellipsize = ellipsize;
+    }
+}
+
+static void
+gtk_cell_renderer_text_get_desired_width (GtkExtendedCell   *cell,
+					  GtkWidget         *widget,
+					  gint              *minimum_size,
+					  gint              *desired_size)
+{
+  gtk_cell_renderer_text_get_desired_size (cell, widget, GTK_ORIENTATION_HORIZONTAL, 
+					   minimum_size, desired_size);
+}
+
+static void
+gtk_cell_renderer_text_get_desired_height (GtkExtendedCell   *cell,
+					   GtkWidget         *widget,
+					   gint              *minimum_size,
+					   gint              *desired_size)
+{
+  gtk_cell_renderer_text_get_desired_size (cell, widget, GTK_ORIENTATION_VERTICAL, 
+					   minimum_size, desired_size);
+}
+
+
 #define __GTK_CELL_RENDERER_TEXT_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index a269211..aef6a80 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -24,6 +24,8 @@
 #include "gtkintl.h"
 #include "gtkcellrenderertext.h"
 #include "gtkcellrendererpixbuf.h"
+#include "gtkextendedlayout.h"
+#include "gtkextendedcell.h"
 #include "gtkprivate.h"
 #include <gobject/gmarshal.h>
 #include "gtkbuildable.h"
@@ -35,6 +37,7 @@ struct _GtkCellViewCellInfo
   GtkCellRenderer *cell;
 
   gint requested_width;
+  gint natural_width;
   gint real_width;
   guint expand : 1;
   guint pack : 1;
@@ -68,8 +71,6 @@ static void        gtk_cell_view_set_property             (GObject          *obj
                                                            const GValue     *value,
                                                            GParamSpec       *pspec);
 static void        gtk_cell_view_finalize                 (GObject          *object);
-static void        gtk_cell_view_size_request             (GtkWidget        *widget,
-                                                           GtkRequisition   *requisition);
 static void        gtk_cell_view_size_allocate            (GtkWidget        *widget,
                                                            GtkAllocation    *allocation);
 static gboolean    gtk_cell_view_expose                   (GtkWidget        *widget,
@@ -120,6 +121,14 @@ static void       gtk_cell_view_buildable_custom_tag_end       (GtkBuildable
 								const gchar   	      *tagname,
 								gpointer      	      *data);
 
+static void       gtk_cell_view_extended_layout_init           (GtkExtendedLayoutIface *iface);
+static void       gtk_cell_view_get_desired_width              (GtkExtendedLayout      *layout,
+								gint                   *minimum_size,
+								gint                   *natural_size);
+static void       gtk_cell_view_get_desired_height             (GtkExtendedLayout      *layout,
+								gint                   *minimum_size,
+								gint                   *natural_size);
+
 static GtkBuildableIface *parent_buildable_iface;
 
 #define GTK_CELL_VIEW_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_VIEW, GtkCellViewPrivate))
@@ -137,7 +146,10 @@ G_DEFINE_TYPE_WITH_CODE (GtkCellView, gtk_cell_view, GTK_TYPE_WIDGET,
 			 G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
 						gtk_cell_view_cell_layout_init)
 			 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
-						gtk_cell_view_buildable_init))
+						gtk_cell_view_buildable_init)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+						gtk_cell_view_extended_layout_init))
+
 
 static void
 gtk_cell_view_class_init (GtkCellViewClass *klass)
@@ -151,7 +163,6 @@ gtk_cell_view_class_init (GtkCellViewClass *klass)
 
   widget_class->expose_event = gtk_cell_view_expose;
   widget_class->size_allocate = gtk_cell_view_size_allocate;
-  widget_class->size_request = gtk_cell_view_size_request;
 
   /* properties */
   g_object_class_install_property (gobject_class,
@@ -310,52 +321,15 @@ gtk_cell_view_finalize (GObject *object)
 }
 
 static void
-gtk_cell_view_size_request (GtkWidget      *widget,
-                            GtkRequisition *requisition)
-{
-  GList *i;
-  gboolean first_cell = TRUE;
-  GtkCellView *cellview;
-
-  cellview = GTK_CELL_VIEW (widget);
-
-  requisition->width = 0;
-  requisition->height = 0;
-
-  if (cellview->priv->displayed_row)
-    gtk_cell_view_set_cell_data (cellview);
-
-  for (i = cellview->priv->cell_list; i; i = i->next)
-    {
-      gint width, height;
-      GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data;
-
-      if (!info->cell->visible)
-        continue;
-
-      if (!first_cell)
-        requisition->width += cellview->priv->spacing;
-
-      gtk_cell_renderer_get_size (info->cell, widget, NULL, NULL, NULL,
-                                  &width, &height);
-
-      info->requested_width = width;
-      requisition->width += width;
-      requisition->height = MAX (requisition->height, height);
-
-      first_cell = FALSE;
-    }
-}
-
-static void
 gtk_cell_view_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
 {
-  GList *i;
-  gint expand_cell_count = 0;
-  gint full_requested_width = 0;
-  gint extra_space;
   GtkCellView *cellview;
+  GList *i;
+  gint nexpand_cells = 0;
+  gint requested_width = 0;
+  gint natural_width = 0;
+  gint available, natural, extra;
 
   widget->allocation = *allocation;
 
@@ -370,16 +344,20 @@ gtk_cell_view_size_allocate (GtkWidget     *widget,
         continue;
 
       if (info->expand)
-        expand_cell_count++;
+        nexpand_cells++;
 
-      full_requested_width += info->requested_width;
+      requested_width += info->requested_width;
+      natural_width += info->natural_width - info->requested_width;
     }
 
-  extra_space = widget->allocation.width - full_requested_width;
-  if (extra_space < 0)
-    extra_space = 0;
-  else if (extra_space > 0 && expand_cell_count > 0)
-    extra_space /= expand_cell_count;
+  available = MAX (0, widget->allocation.width - requested_width);
+  natural = MIN (available, natural_width);
+  available -= natural;
+
+  if (nexpand_cells > 0)
+    extra = available / nexpand_cells;
+  else
+    extra = 0;
 
   for (i = cellview->priv->cell_list; i; i = i->next)
     {
@@ -388,8 +366,21 @@ gtk_cell_view_size_allocate (GtkWidget     *widget,
       if (!info->cell->visible)
         continue;
 
-      info->real_width = info->requested_width +
-        (info->expand ? extra_space : 0);
+      info->real_width = info->requested_width;
+
+      if (natural_width > 0)
+          info->real_width += natural * (info->natural_width - info->requested_width) / natural_width;
+
+      if (info->expand)
+        {
+          if (nexpand_cells == 1)
+            info->real_width += available;
+          else
+            info->real_width += extra;
+
+         nexpand_cells -= 1;
+         available -= extra;
+       }
     }
 }
 
@@ -580,6 +571,8 @@ gtk_cell_view_cell_layout_pack_start (GtkCellLayout   *layout,
   info->pack = GTK_PACK_START;
 
   cellview->priv->cell_list = g_list_append (cellview->priv->cell_list, info);
+
+  gtk_widget_queue_resize (GTK_WIDGET (cellview));
 }
 
 static void
@@ -600,6 +593,8 @@ gtk_cell_view_cell_layout_pack_end (GtkCellLayout   *layout,
   info->pack = GTK_PACK_END;
 
   cellview->priv->cell_list = g_list_append (cellview->priv->cell_list, info);
+
+  gtk_widget_queue_resize (GTK_WIDGET (cellview));
 }
 
 static void
@@ -979,32 +974,108 @@ gtk_cell_view_get_displayed_row (GtkCellView *cell_view)
  * Return value: %TRUE
  *
  * Since: 2.6
+ * 
+ * Deprecated: 3.0: Use gtk_cell_view_get_desired_width_of_row() and
+ * gtk_cell_view_get_desired_height_of_row() instead.
  */
 gboolean
 gtk_cell_view_get_size_of_row (GtkCellView    *cell_view,
                                GtkTreePath    *path,
                                GtkRequisition *requisition)
 {
-  GtkTreeRowReference *tmp;
   GtkRequisition req;
 
   g_return_val_if_fail (GTK_IS_CELL_VIEW (cell_view), FALSE);
   g_return_val_if_fail (path != NULL, FALSE);
-  g_return_val_if_fail (requisition != NULL, FALSE);
+
+  gtk_cell_view_get_desired_width_of_row (cell_view, path, &req.width, NULL);
+  gtk_cell_view_get_desired_height_of_row (cell_view, path, &req.height, NULL);
+
+  if (requisition)
+    *requisition = req;
+
+  return TRUE;
+}
+
+
+
+static void
+gtk_cell_view_get_desired_size_of_row (GtkCellView     *cell_view,
+				       GtkTreePath     *path,
+				       GtkOrientation   orientation,
+				       gint            *minimum_size,
+				       gint            *natural_size)
+{
+  GtkTreeRowReference *tmp;
 
   tmp = cell_view->priv->displayed_row;
   cell_view->priv->displayed_row =
     gtk_tree_row_reference_new (cell_view->priv->model, path);
 
-  gtk_cell_view_size_request (GTK_WIDGET (cell_view), requisition);
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    gtk_cell_view_get_desired_width (GTK_EXTENDED_LAYOUT (cell_view), minimum_size, natural_size);
+  else
+    gtk_cell_view_get_desired_height (GTK_EXTENDED_LAYOUT (cell_view), minimum_size, natural_size);
 
   gtk_tree_row_reference_free (cell_view->priv->displayed_row);
   cell_view->priv->displayed_row = tmp;
 
-  /* restore actual size info */
-  gtk_cell_view_size_request (GTK_WIDGET (cell_view), &req);
+  /* Restore active size */
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    gtk_cell_view_get_desired_width (GTK_EXTENDED_LAYOUT (cell_view), NULL, NULL);
+  else
+    gtk_cell_view_get_desired_height (GTK_EXTENDED_LAYOUT (cell_view), NULL, NULL);
+}
 
-  return TRUE;
+/**
+ * gtk_cell_view_get_desired_width_of_row:
+ * @cell_view: a #GtkCellView
+ * @path: a #GtkTreePath 
+ * @minimum_size: location to store the minimum size 
+ * @natural_size: location to store the natural size 
+ *
+ * Sets @minimum_size and @natural_size to the width desired by @cell_view 
+ * to display the model row pointed to by @path.
+ * 
+ * Since: 3.0
+ */
+void
+gtk_cell_view_get_desired_width_of_row (GtkCellView     *cell_view,
+					GtkTreePath     *path,
+					gint            *minimum_size,
+					gint            *natural_size)
+{
+  g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
+  g_return_if_fail (path != NULL);
+  g_return_if_fail (minimum_size != NULL || natural_size != NULL);
+
+  gtk_cell_view_get_desired_size_of_row (cell_view, path, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+}
+
+
+/**
+ * gtk_cell_view_get_desired_height_of_row:
+ * @cell_view: a #GtkCellView
+ * @path: a #GtkTreePath 
+ * @minimum_size: location to store the minimum size 
+ * @natural_size: location to store the natural size 
+ *
+ * Sets @minimum_size and @natural_size to the height desired by @cell_view 
+ * to display the model row pointed to by @path.
+ * 
+ * Since: 3.0
+ */
+void
+gtk_cell_view_get_desired_height_of_row (GtkCellView     *cell_view,
+					 GtkTreePath     *path,
+					 gint            *minimum_size,
+					 gint            *natural_size)
+{
+  g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
+  g_return_if_fail (path != NULL);
+  g_return_if_fail (minimum_size != NULL || natural_size != NULL);
+
+  gtk_cell_view_get_desired_size_of_row (cell_view, path, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
 }
 
 /**
@@ -1097,5 +1168,88 @@ gtk_cell_view_buildable_custom_tag_end (GtkBuildable *buildable,
 }
 
 
+static void
+gtk_cell_view_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+  iface->get_desired_width  = gtk_cell_view_get_desired_width;
+  iface->get_desired_height = gtk_cell_view_get_desired_height;
+}
+
+static void
+gtk_cell_view_get_desired_size (GtkExtendedLayout *layout,
+				GtkOrientation     orientation,
+				gint              *minimum_size,
+				gint              *natural_size)
+{
+  GList *i;
+  gint cell_min, cell_nat;
+  gboolean first_cell = TRUE;
+  GtkCellView *cellview = GTK_CELL_VIEW (layout);
+  gint minimum, natural;
+
+  minimum = natural = 0;
+
+  if (cellview->priv->displayed_row)
+    gtk_cell_view_set_cell_data (cellview);
+
+  for (i = cellview->priv->cell_list; i; i = i->next)
+    {
+      GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data;
+
+      if (info->cell->visible)
+        {
+	  
+	  if (!first_cell && orientation == GTK_ORIENTATION_HORIZONTAL)
+	    {
+	      minimum += cellview->priv->spacing;
+	      natural += cellview->priv->spacing;
+	    }
+
+	  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+	    {
+	      gtk_extended_cell_get_desired_width (GTK_EXTENDED_CELL (info->cell),
+						   GTK_WIDGET (cellview), &cell_min, &cell_nat);
+
+	      info->requested_width = cell_min;
+	      info->natural_width   = cell_nat;
+
+	      minimum += info->requested_width;
+	      natural += info->natural_width;
+	    }
+	  else
+	    {
+	      gtk_extended_cell_get_desired_height (GTK_EXTENDED_CELL (info->cell),
+						    GTK_WIDGET (cellview), &cell_min, &cell_nat);
+	      minimum = MAX (minimum, cell_min);
+	      natural = MAX (natural, cell_nat);
+	    }
+	  first_cell = FALSE;
+        }
+    }
+
+  if (minimum_size)
+    *minimum_size = minimum;
+
+  if (natural_size)
+    *natural_size = natural;
+}
+
+static void
+gtk_cell_view_get_desired_width  (GtkExtendedLayout      *layout,
+				  gint                   *minimum_size,
+				  gint                   *natural_size)
+{
+  gtk_cell_view_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+}
+
+static void       
+gtk_cell_view_get_desired_height (GtkExtendedLayout      *layout,
+				  gint                   *minimum_size,
+				  gint                   *natural_size)
+{
+  gtk_cell_view_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+}
+
+
 #define __GTK_CELL_VIEW_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkcellview.h b/gtk/gtkcellview.h
index 06305f9..428b1b2 100644
--- a/gtk/gtkcellview.h
+++ b/gtk/gtkcellview.h
@@ -69,6 +69,17 @@ GtkTreePath      *gtk_cell_view_get_displayed_row       (GtkCellView     *cell_v
 gboolean          gtk_cell_view_get_size_of_row         (GtkCellView     *cell_view,
                                                          GtkTreePath     *path,
                                                          GtkRequisition  *requisition);
+gboolean          gtk_cell_view_get_size_of_row         (GtkCellView     *cell_view,
+                                                         GtkTreePath     *path,
+                                                         GtkRequisition  *requisition);
+void              gtk_cell_view_get_desired_width_of_row(GtkCellView     *cell_view,
+                                                         GtkTreePath     *path,
+                                                         gint            *minimum_size,
+                                                         gint            *natural_size);
+void              gtk_cell_view_get_desired_height_of_row(GtkCellView     *cell_view,
+							  GtkTreePath     *path,
+							  gint            *minimum_size,
+							  gint            *natural_size);
 
 void              gtk_cell_view_set_background_color    (GtkCellView     *cell_view,
                                                          const GdkColor  *color);
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 64c8e05..4daad01 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -38,6 +38,7 @@
 #include "gtktreeselection.h"
 #include "gtkvseparator.h"
 #include "gtkwindow.h"
+#include "gtkextendedlayout.h"
 #include "gtkprivate.h"
 
 #include <gdk/gdkkeysyms.h>
@@ -109,8 +110,9 @@ struct _GtkComboBoxPrivate
   guint scroll_timer;
   guint resize_idle_id;
 
-  gint width;
-  gint height;
+  GtkRequisition minimum_size;
+  GtkRequisition natural_size;
+
   GSList *cells;
 
   guint popup_in_progress : 1;
@@ -280,8 +282,6 @@ static void     gtk_combo_box_remeasure            (GtkComboBox      *combo_box)
 
 static void     gtk_combo_box_unset_model          (GtkComboBox      *combo_box);
 
-static void     gtk_combo_box_size_request         (GtkWidget        *widget,
-                                                    GtkRequisition   *requisition);
 static void     gtk_combo_box_size_allocate        (GtkWidget        *widget,
                                                     GtkAllocation    *allocation);
 static void     gtk_combo_box_forall               (GtkContainer     *container,
@@ -466,8 +466,16 @@ static void     gtk_combo_box_buildable_custom_tag_end       (GtkBuildable  *bui
 							      gpointer      *data);
 
 /* GtkCellEditable method implementations */
-static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
-					 GdkEvent        *event);
+static void     gtk_combo_box_start_editing                  (GtkCellEditable *cell_editable,
+							      GdkEvent        *event);
+
+static void     gtk_combo_box_extended_layout_init           (GtkExtendedLayoutIface *iface);
+static void     gtk_combo_box_get_desired_width              (GtkExtendedLayout      *layout,
+							      gint                   *minimum_size,
+							      gint                   *natural_size);
+static void     gtk_combo_box_get_desired_height             (GtkExtendedLayout      *layout,
+							      gint                   *minimum_size,
+							      gint                   *natural_size);
 
 
 G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
@@ -476,7 +484,9 @@ G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN,
 			 G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
 						gtk_combo_box_cell_editable_init)
 			 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
-						gtk_combo_box_buildable_init))
+						gtk_combo_box_buildable_init)
+			 G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+						gtk_combo_box_extended_layout_init))
 
 
 /* common */
@@ -498,7 +508,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
 
   widget_class = (GtkWidgetClass *)klass;
   widget_class->size_allocate = gtk_combo_box_size_allocate;
-  widget_class->size_request = gtk_combo_box_size_request;
   widget_class->expose_event = gtk_combo_box_expose_event;
   widget_class->scroll_event = gtk_combo_box_scroll_event;
   widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
@@ -935,8 +944,9 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   GTK_BIN (combo_box)->child = priv->cell_view;
   gtk_widget_show (priv->cell_view);
 
-  priv->width = 0;
-  priv->height = 0;
+  memset (&priv->minimum_size, 0x0, sizeof (GtkRequisition));
+  memset (&priv->natural_size, 0x0, sizeof (GtkRequisition));
+
   priv->wrap_width = 0;
 
   priv->active = -1;
@@ -2117,164 +2127,6 @@ gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
   return req.width + padding;
 }
 
-static void
-gtk_combo_box_remeasure (GtkComboBox *combo_box)
-{
-  GtkComboBoxPrivate *priv = combo_box->priv;
-  GtkTreeIter iter;
-  GtkTreePath *path;
-
-  if (!priv->model ||
-      !gtk_tree_model_get_iter_first (priv->model, &iter))
-    return;
-
-  priv->width = 0;
-  priv->height = 0;
-
-  path = gtk_tree_path_new_from_indices (0, -1);
-
-  do
-    {
-      GtkRequisition req;
-
-      if (priv->cell_view)
-	gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (priv->cell_view), 
-                                       path, &req);
-      else
-        {
-          req.width = 0;
-          req.height = 0;
-        }
-
-      priv->width = MAX (priv->width, req.width);
-      priv->height = MAX (priv->height, req.height);
-
-      gtk_tree_path_next (path);
-    }
-  while (gtk_tree_model_iter_next (priv->model, &iter));
-
-  gtk_tree_path_free (path);
-}
-
-static void
-gtk_combo_box_size_request (GtkWidget      *widget,
-                            GtkRequisition *requisition)
-{
-  gint width, height;
-  gint focus_width, focus_pad;
-  gint font_size;
-  gint arrow_size;
-  GtkRequisition bin_req;
-  PangoContext *context;
-  PangoFontMetrics *metrics;
-  PangoFontDescription *font_desc;
-
-  GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
-  GtkComboBoxPrivate *priv = combo_box->priv;
- 
-  /* common */
-  gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
-  gtk_combo_box_remeasure (combo_box);
-  bin_req.width = MAX (bin_req.width, priv->width);
-  bin_req.height = MAX (bin_req.height, priv->height);
-
-  gtk_widget_style_get (GTK_WIDGET (widget),
-			"focus-line-width", &focus_width,
-			"focus-padding", &focus_pad,
-			"arrow-size", &arrow_size,
-			NULL);
-
-  font_desc = GTK_BIN (widget)->child->style->font_desc;
-  context = gtk_widget_get_pango_context (widget);
-  metrics = pango_context_get_metrics (context, font_desc,
-				       pango_context_get_language (context));
-  font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
-			    pango_font_metrics_get_descent (metrics));
-  pango_font_metrics_unref (metrics);
-
-  arrow_size = MAX (arrow_size, font_size);
-
-  gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
-
-  if (!priv->tree_view)
-    {
-      /* menu mode */
-
-      if (priv->cell_view)
-        {
-          GtkRequisition button_req, sep_req, arrow_req;
-          gint border_width, xthickness, ythickness;
-
-          gtk_widget_size_request (priv->button, &button_req);
-	  border_width = GTK_CONTAINER (combo_box)->border_width;
-          xthickness = priv->button->style->xthickness;
-          ythickness = priv->button->style->ythickness;
-
-          bin_req.width = MAX (bin_req.width, priv->width);
-          bin_req.height = MAX (bin_req.height, priv->height);
-
-          gtk_widget_size_request (priv->separator, &sep_req);
-          gtk_widget_size_request (priv->arrow, &arrow_req);
-
-          height = MAX (sep_req.height, arrow_req.height);
-          height = MAX (height, bin_req.height);
-
-          width = bin_req.width + sep_req.width + arrow_req.width;
-
-          height += 2*(border_width + ythickness + focus_width + focus_pad);
-          width  += 2*(border_width + xthickness + focus_width + focus_pad);
-
-          requisition->width = width;
-          requisition->height = height;
-        }
-      else
-        {
-          GtkRequisition but_req;
-
-          gtk_widget_size_request (priv->button, &but_req);
-
-          requisition->width = bin_req.width + but_req.width;
-          requisition->height = MAX (bin_req.height, but_req.height);
-        }
-    }
-  else
-    {
-      /* list mode */
-      GtkRequisition button_req, frame_req;
-
-      /* sample + frame */
-      *requisition = bin_req;
-
-      requisition->width += 2 * focus_width;
-      
-      if (priv->cell_view_frame)
-        {
-	  gtk_widget_size_request (priv->cell_view_frame, &frame_req);
-	  if (priv->has_frame)
-	    {
-	      requisition->width += 2 *
-		(GTK_CONTAINER (priv->cell_view_frame)->border_width +
-		 GTK_WIDGET (priv->cell_view_frame)->style->xthickness);
-	      requisition->height += 2 *
-		(GTK_CONTAINER (priv->cell_view_frame)->border_width +
-		 GTK_WIDGET (priv->cell_view_frame)->style->ythickness);
-	    }
-        }
-
-      /* the button */
-      gtk_widget_size_request (priv->button, &button_req);
-
-      requisition->height = MAX (requisition->height, button_req.height);
-      requisition->width += button_req.width;
-    }
-
-  if (GTK_SHADOW_NONE != priv->shadow_type)
-    {
-      requisition->height += 2 * widget->style->ythickness;
-      requisition->width += 2 * widget->style->xthickness;
-    }
-}
-
 #define GTK_COMBO_BOX_SIZE_ALLOCATE_BUTTON 					\
   gtk_widget_size_request (combo_box->priv->button, &req); 			\
   										\
@@ -3725,14 +3577,14 @@ gtk_combo_box_menu_row_changed (GtkTreeModel *model,
 
   width = gtk_combo_box_calc_requested_width (combo_box, path);
 
-  if (width > priv->width)
+  if (width > priv->minimum_size.width)
     {
       if (priv->cell_view)
 	{
 	  gtk_widget_set_size_request (priv->cell_view, width, -1);
 	  gtk_widget_queue_resize (priv->cell_view);
 	}
-      priv->width = width;
+      priv->minimum_size.width = width;
     }
 }
 
@@ -4240,14 +4092,14 @@ gtk_combo_box_list_row_changed (GtkTreeModel *model,
 
   width = gtk_combo_box_calc_requested_width (combo_box, path);
 
-  if (width > priv->width)
+  if (width > priv->minimum_size.width)
     {
       if (priv->cell_view) 
 	{
 	  gtk_widget_set_size_request (priv->cell_view, width, -1);
 	  gtk_widget_queue_resize (priv->cell_view);
 	}
-      priv->width = width;
+      priv->minimum_size.width = width;
     }
 }
 
@@ -4299,8 +4151,11 @@ gtk_combo_box_cell_layout_pack_start (GtkCellLayout   *layout,
   priv->cells = g_slist_append (priv->cells, info);
 
   if (priv->cell_view)
-    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view),
-                                cell, expand);
+    {
+      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view),
+				  cell, expand);
+
+    }
 
   if (priv->column)
     gtk_tree_view_column_pack_start (priv->column, cell, expand);
@@ -6034,5 +5889,241 @@ gtk_combo_box_buildable_custom_tag_end (GtkBuildable *buildable,
 					    data);
 }
 
+
+static void
+gtk_combo_box_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+  iface->get_desired_width = gtk_combo_box_get_desired_width;
+  iface->get_desired_height = gtk_combo_box_get_desired_height;
+}
+
+static void
+gtk_combo_box_remeasure (GtkComboBox *combo_box)
+{
+  GtkComboBoxPrivate *priv = combo_box->priv;
+  GtkTreeIter iter;
+  GtkTreePath *path;
+
+  if (!priv->model ||
+      !gtk_tree_model_get_iter_first (priv->model, &iter))
+    return;
+
+  memset (&priv->minimum_size, 0x0, sizeof (GtkRequisition));
+  memset (&priv->natural_size, 0x0, sizeof (GtkRequisition));
+
+  path = gtk_tree_path_new_from_indices (0, -1);
+
+  do
+    {
+      GtkRequisition req, nat_req;
+
+      if (priv->cell_view)
+	{
+	  /* XXX FIXME: Currently still not doing height-for-width in cell renderers here */
+	  gtk_cell_view_get_desired_width_of_row (GTK_CELL_VIEW (priv->cell_view), 
+						  path, &req.width, &nat_req.width);
+	  gtk_cell_view_get_desired_height_of_row (GTK_CELL_VIEW (priv->cell_view), 
+						   path, &req.height, &nat_req.height);
+	}
+      else
+        {
+	  memset (&req, 0x0, sizeof (GtkRequisition));
+	  memset (&nat_req, 0x0, sizeof (GtkRequisition));
+        }
+
+      priv->minimum_size.width  = MAX (priv->minimum_size.width,  req.width);
+      priv->minimum_size.height = MAX (priv->minimum_size.height, req.height);
+
+      priv->natural_size.width  = MAX (priv->natural_size.width,  nat_req.width);
+      priv->natural_size.height = MAX (priv->natural_size.height, nat_req.height);
+
+      gtk_tree_path_next (path);
+    }
+  while (gtk_tree_model_iter_next (priv->model, &iter));
+
+  gtk_tree_path_free (path);
+}
+
+
+/* XXX TODO: Split this up into 2 orientations so as
+ * to properly support height-for-width/width-for-height here
+ *
+ */
+static void
+gtk_combo_box_get_desired_size (GtkExtendedLayout *layout,
+				GtkRequisition    *minimum_size,
+				GtkRequisition    *natural_size)
+{
+  GtkComboBox           *combo_box = GTK_COMBO_BOX (layout);
+  GtkComboBoxPrivate    *priv = combo_box->priv;
+  gint                   focus_width, focus_pad;
+  gint                   font_size, arrow_size;
+  GtkRequisition         bin_req, bin_nat_req;
+  PangoContext          *context;
+  PangoFontMetrics      *metrics;
+  PangoFontDescription  *font_desc;
+  GtkWidget             *child;
+
+  child = gtk_bin_get_child (GTK_BIN (layout));
+ 
+  /* common */
+  gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (child), FALSE, &bin_req, &bin_nat_req);
+  gtk_combo_box_remeasure (combo_box);
+
+  bin_req.width      = MAX (bin_req.width,      priv->minimum_size.width);
+  bin_req.height     = MAX (bin_req.height,     priv->minimum_size.height);
+  bin_nat_req.width  = MAX (bin_nat_req.width,  priv->natural_size.width);
+  bin_nat_req.height = MAX (bin_nat_req.height, priv->natural_size.height);
+
+  gtk_widget_style_get (GTK_WIDGET (layout),
+			"focus-line-width", &focus_width,
+			"focus-padding", &focus_pad,
+			"arrow-size", &arrow_size,
+			NULL);
+
+  font_desc = child->style->font_desc;
+  context = gtk_widget_get_pango_context (GTK_WIDGET (layout));
+  metrics = pango_context_get_metrics (context, font_desc,
+				       pango_context_get_language (context));
+  font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
+			    pango_font_metrics_get_descent (metrics));
+  pango_font_metrics_unref (metrics);
+
+  arrow_size = MAX (arrow_size, font_size);
+
+  gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
+
+  if (!priv->tree_view)
+    {
+      /* menu mode */
+	  
+      if (priv->cell_view)
+        {
+          GtkRequisition button_req, sep_req, arrow_req;
+          gint border_width, xthickness, ythickness, xpad, ypad;
+
+          gtk_widget_size_request (priv->button, &button_req);
+	  border_width = GTK_CONTAINER (combo_box)->border_width;
+          xthickness = priv->button->style->xthickness;
+          ythickness = priv->button->style->ythickness;
+
+	  xpad = 2*(border_width + xthickness + focus_width + focus_pad);
+	  ypad = 2*(border_width + ythickness + focus_width + focus_pad);
+
+          gtk_widget_size_request (priv->separator, &sep_req);
+          gtk_widget_size_request (priv->arrow, &arrow_req);
+
+          minimum_size->width  = bin_req.width + sep_req.width + arrow_req.width;
+          minimum_size->height = MAX (sep_req.height, arrow_req.height);
+          minimum_size->height = MAX (minimum_size->height, bin_req.height);
+
+          natural_size->width  = bin_nat_req.width + sep_req.width + arrow_req.width;
+          natural_size->height = MAX (minimum_size->height, bin_nat_req.height);
+
+          minimum_size->width  += xpad;
+          minimum_size->height += ypad;
+          natural_size->width  += xpad;
+          natural_size->height += ypad;
+        }
+      else
+        {
+          GtkRequisition but_req, but_nat_req;
+
+          gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (priv->button), 
+						FALSE, 
+						&but_req, &but_nat_req);
+
+          minimum_size->width  = bin_req.width + but_req.width;
+          minimum_size->height = MAX (bin_req.height, but_req.height);
+
+          natural_size->width  = bin_nat_req.width + but_nat_req.width;
+          natural_size->height = MAX (bin_nat_req.height, but_nat_req.height);
+        }
+    }
+  else
+    {
+      /* list mode */
+      GtkRequisition button_req, button_nat_req, frame_req;
+
+      /* sample + frame */
+      *minimum_size = bin_req;
+      *natural_size = bin_nat_req;
+
+      minimum_size->width += 2 * focus_width;
+      natural_size->width += 2 * focus_width;
+      
+      if (priv->cell_view_frame)
+        {
+	  gtk_widget_size_request (priv->cell_view_frame, &frame_req);
+	  if (priv->has_frame)
+	    {
+	      gint xpad = 2 * (GTK_CONTAINER (priv->cell_view_frame)->border_width +
+			       GTK_WIDGET (priv->cell_view_frame)->style->xthickness);
+	      
+	      gint ypad = 2 * (GTK_CONTAINER (priv->cell_view_frame)->border_width +
+			       GTK_WIDGET (priv->cell_view_frame)->style->ythickness);
+
+	      minimum_size->width  += xpad;
+	      minimum_size->height += ypad;
+	      natural_size->width  += xpad;
+	      natural_size->height += ypad;
+	    }
+        }
+
+      /* the button */
+      gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (priv->button), 
+					    FALSE, 
+					    &button_req, &button_nat_req);
+
+      minimum_size->width += button_req.width;
+      minimum_size->height = MAX (minimum_size->height, button_req.height);
+
+      natural_size->width += button_nat_req.width;
+      natural_size->height = MAX (natural_size->height, button_nat_req.height);
+    }
+
+  if (GTK_SHADOW_NONE != priv->shadow_type)
+    {
+      minimum_size->width  += 2 * GTK_WIDGET (layout)->style->xthickness;
+      minimum_size->height += 2 * GTK_WIDGET (layout)->style->ythickness;
+
+      natural_size->width  += 2 * GTK_WIDGET (layout)->style->xthickness;
+      natural_size->height += 2 * GTK_WIDGET (layout)->style->ythickness;
+    }
+}
+
+static void     
+gtk_combo_box_get_desired_width (GtkExtendedLayout      *layout,
+				 gint                   *minimum_size,
+				 gint                   *natural_size)
+{
+  GtkRequisition minimum, natural;
+
+  gtk_combo_box_get_desired_size (layout, &minimum, &natural);
+
+  if (minimum_size)
+    *minimum_size = minimum.width;
+
+  if (natural_size)
+    *natural_size = natural.width;
+}
+
+static void
+gtk_combo_box_get_desired_height (GtkExtendedLayout      *layout,
+				  gint                   *minimum_size,
+				  gint                   *natural_size)
+{ 
+  GtkRequisition minimum, natural;
+
+  gtk_combo_box_get_desired_size (layout, &minimum, &natural);
+
+  if (minimum_size)
+    *minimum_size = minimum.height;
+
+  if (natural_size)
+    *natural_size = natural.height;
+}
+
+
 #define __GTK_COMBO_BOX_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtkextendedcell.c b/gtk/gtkextendedcell.c
new file mode 100644
index 0000000..67c6bac
--- /dev/null
+++ b/gtk/gtkextendedcell.c
@@ -0,0 +1,193 @@
+/* gtkextendedcell.c
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * Author:
+ *      Tristan Van Berkom <tristan van berkom gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include "gtkcellrenderer.h"
+#include "gtkextendedcell.h"
+#include "gtkintl.h"
+#include "gtkalias.h"
+
+
+#define DEBUG_EXTENDED_CELL 0
+
+GType
+gtk_extended_cell_get_type (void)
+{
+  static GType extended_cell_type = 0;
+
+  if (G_UNLIKELY(!extended_cell_type))
+    {
+      extended_cell_type =
+	g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkExtendedCell"),
+				       sizeof (GtkExtendedCellIface),
+				       NULL, 0, NULL, 0);
+
+      g_type_interface_add_prerequisite (extended_cell_type, GTK_TYPE_CELL_RENDERER);
+    }
+  return extended_cell_type;
+}
+
+/**
+ * gtk_extended_cell_get_desired_width:
+ * @cell: a #GtkExtendedCell instance
+ * @widget: the #GtkWidget this cell will be rendering to
+ * @minimum_size: location to store the minimum size, or %NULL
+ * @natural_size: location to store the natural size, or %NULL
+ *
+ * Retreives a renderer's desired size when rendered to @widget.
+ *
+ * Since: 3.0
+ */
+void
+gtk_extended_cell_get_desired_width (GtkExtendedCell   *cell,
+				     GtkWidget         *widget,
+				     gint              *minimum_size,
+				     gint              *natural_size)
+{
+  GtkExtendedCellIface *iface;
+
+  g_return_if_fail (GTK_IS_EXTENDED_CELL (cell));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (NULL != minimum_size || NULL != natural_size);
+
+  iface = GTK_EXTENDED_CELL_GET_IFACE (cell);
+  iface->get_desired_width (cell, widget, minimum_size, natural_size);
+
+#if DEBUG_EXTENDED_CELL
+  g_message ("%s returning minimum width: %d and natural width: %d",
+	     G_OBJECT_TYPE_NAME (cell), 
+	     minimum_size ? *minimum_size : 20000, 
+	     natural_size ? *natural_size : 20000);
+#endif
+}
+
+
+/**
+ * gtk_extended_cell_get_desired_height:
+ * @cell: a #GtkExtendedCell instance
+ * @widget: the #GtkWidget this cell will be rendering to
+ * @minimum_size: location to store the minimum size, or %NULL
+ * @natural_size: location to store the natural size, or %NULL
+ *
+ * Retreives a renderer's desired size when rendered to @widget.
+ *
+ * Since: 3.0
+ */
+void
+gtk_extended_cell_get_desired_height (GtkExtendedCell   *cell,
+				      GtkWidget         *widget,
+				      gint              *minimum_size,
+				      gint              *natural_size)
+{
+  GtkExtendedCellIface *iface;
+
+  g_return_if_fail (GTK_IS_EXTENDED_CELL (cell));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (NULL != minimum_size || NULL != natural_size);
+
+  iface = GTK_EXTENDED_CELL_GET_IFACE (cell);
+  iface->get_desired_height (cell, widget, minimum_size, natural_size);
+
+#if DEBUG_EXTENDED_CELL
+  g_message ("%s returning minimum height: %d and natural height: %d",
+	     G_OBJECT_TYPE_NAME (cell), 
+	     minimum_size ? *minimum_size : 20000, 
+	     natural_size ? *natural_size : 20000);
+#endif
+}
+
+
+/**
+ * gtk_extended_cell_get_width_for_height:
+ * @cell: a #GtkExtendedCell instance
+ * @height: the size which is available for allocation
+ * @minimum_width: location for storing the minimum size, or %NULL
+ * @natural_width: location for storing the preferred size, or %NULL
+ *
+ * Retreives a cell renderers's desired width if it were rendered to 
+ * @widget with the specified @height.
+ *
+ * Since: 3.0
+ */
+void
+gtk_extended_cell_get_width_for_height (GtkExtendedCell *cell,
+					GtkWidget       *widget,
+					gint             height,
+					gint            *minimum_width,
+					gint            *natural_width)
+{
+  GtkExtendedCellIface *iface;
+
+  g_return_if_fail (GTK_IS_EXTENDED_CELL (cell));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (NULL != minimum_width || NULL != natural_width);
+
+  iface = GTK_EXTENDED_CELL_GET_IFACE (cell);
+  iface->get_width_for_height (cell, widget, height, minimum_width, natural_width);
+
+#if DEBUG_EXTENDED_CELL
+  g_message ("%s width for height: %d is minimum %d and natural: %d",
+	     G_OBJECT_TYPE_NAME (cell), height,
+	     minimum_width ? *minimum_width : 20000, 
+	     natural_width ? *natural_width : 20000);
+#endif
+}
+
+/**
+ * gtk_extended_cell_get_height_for_width:
+ * @cell: a #GtkExtendedCell instance
+ * @width: the size which is available for allocation
+ * @minimum_height: location for storing the minimum size, or %NULL
+ * @natural_height: location for storing the preferred size, or %NULL
+ *
+ * Retreives a cell renderers's desired height if it were rendered to 
+ * @widget with the specified @width.
+ *
+ * Since: 3.0
+ */
+void
+gtk_extended_cell_get_height_for_width (GtkExtendedCell *cell,
+					GtkWidget       *widget,
+					gint             width,
+					gint            *minimum_height,
+					gint            *natural_height)
+{
+  GtkExtendedCellIface *iface;
+
+  g_return_if_fail (GTK_IS_EXTENDED_CELL (cell));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (NULL != minimum_height || NULL != natural_height);
+
+  iface = GTK_EXTENDED_CELL_GET_IFACE (cell);
+  iface->get_height_for_width (cell, widget, width, minimum_height, natural_height);
+
+#if DEBUG_EXTENDED_CELL
+  g_message ("%s height for width: %d is minimum %d and natural: %d",
+	     G_OBJECT_TYPE_NAME (cell), width,
+	     minimum_height ? *minimum_height : 20000, 
+	     natural_height ? *natural_height : 20000);
+#endif
+}
+
+#define __GTK_EXTENDED_CELL_C__
+#include "gtkaliasdef.c"
diff --git a/gtk/gtkextendedcell.h b/gtk/gtkextendedcell.h
new file mode 100644
index 0000000..8bd38f7
--- /dev/null
+++ b/gtk/gtkextendedcell.h
@@ -0,0 +1,88 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2010 Openismus GmbH
+ *
+ * Author:
+ *      Tristan Van Berkom <tristan van berkom gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_EXTENDED_CELL_H__
+#define __GTK_EXTENDED_CELL_H__
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_EXTENDED_CELL            (gtk_extended_cell_get_type ())
+#define GTK_EXTENDED_CELL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXTENDED_CELL, GtkExtendedCell))
+#define GTK_EXTENDED_CELL_CLASS(klass)    ((GtkExtendedCellIface*)g_type_interface_peek ((klass), GTK_TYPE_EXTENDED_CELL))
+#define GTK_IS_EXTENDED_CELL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXTENDED_CELL))
+#define GTK_EXTENDED_CELL_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_EXTENDED_CELL, GtkExtendedCellIface))
+
+typedef struct _GtkExtendedCell           GtkExtendedCell;
+typedef struct _GtkExtendedCellIface      GtkExtendedCellIface;
+
+struct _GtkExtendedCellIface
+{
+  GTypeInterface g_iface;
+
+  /* virtual table */
+
+  void      (* get_desired_width)    (GtkExtendedCell    *cell,
+				      GtkWidget          *widget,
+				      gint               *minimum_size,
+				      gint               *natural_size);
+  void      (* get_desired_height)   (GtkExtendedCell    *cell,
+				      GtkWidget          *widget,
+				      gint               *minimum_size,
+				      gint               *natural_size);
+  void      (* get_width_for_height) (GtkExtendedCell    *cell,
+				      GtkWidget          *widget,
+				      gint                height,
+				      gint               *minimum_width,
+				      gint               *natural_width);
+  void      (* get_height_for_width) (GtkExtendedCell    *cell,
+				      GtkWidget          *widget,
+				      gint                width,
+				      gint               *minimum_height,
+				      gint               *natural_height);
+};
+
+GType gtk_extended_cell_get_type             (void) G_GNUC_CONST;
+
+void  gtk_extended_cell_get_desired_width    (GtkExtendedCell   *cell,
+					      GtkWidget         *widget,
+					      gint              *minimum_size,
+					      gint              *natural_size);
+void  gtk_extended_cell_get_desired_height   (GtkExtendedCell   *cell,
+					      GtkWidget         *widget,
+					      gint              *minimum_size,
+					      gint              *natural_size);
+void  gtk_extended_cell_get_width_for_height (GtkExtendedCell   *cell,
+					      GtkWidget         *widget,
+					      gint               height,
+					      gint              *minimum_width,
+					      gint              *natural_width);
+void  gtk_extended_cell_get_height_for_width (GtkExtendedCell   *cell,
+					      GtkWidget         *widget,
+					      gint               width,
+					      gint              *minimum_height,
+					      gint              *natural_height);
+
+G_END_DECLS
+
+#endif /* __GTK_EXTENDED_CELL_H__ */
diff --git a/gtk/gtkextendedlayout.h b/gtk/gtkextendedlayout.h
index 73ed760..445a78c 100644
--- a/gtk/gtkextendedlayout.h
+++ b/gtk/gtkextendedlayout.h
@@ -1,9 +1,8 @@
 /* GTK - The GIMP Toolkit
- * Copyright (C) 2007-2010 Openismus GmbH
+ * Copyright (C) 2007 Openismus GmbH
  *
- * Authors:
+ * Author:
  *      Mathias Hasselmann <mathias openismus com>
- *      Tristan Van Berkom <tristan van berkom gmail com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c
index d0df6f5..40a635b 100644
--- a/gtk/gtkplug-x11.c
+++ b/gtk/gtkplug-x11.c
@@ -47,6 +47,7 @@
 #include "gtkplugprivate.h"
 
 #include "x11/gdkx.h"
+#include <X11/Xatom.h>
 
 #include "gtkxembed.h"
 #include "gtkalias.h"
@@ -400,3 +401,29 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
 
   return return_val;
 }
+
+void
+_gtk_plug_windowing_publish_natural_size (GtkPlug        *plug,
+					  GtkRequisition *requisition)
+{
+  GtkWidget *widget = GTK_WIDGET (plug);
+  GdkDisplay *display;
+  GdkWindow *window;
+  gint32 data[2];
+  Atom property;
+
+  gtk_widget_realize (widget);
+
+  window = GTK_WIDGET (plug)->window;
+  display = gdk_drawable_get_display (window);
+  property = gdk_x11_get_xatom_by_name_for_display (display, "_GTK_NATURAL_SIZE");
+
+  data[0] = requisition->width;
+  data[1] = requisition->height;
+
+  XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+		   GDK_WINDOW_XWINDOW (window), property,
+                   XA_CARDINAL, 32, PropModeReplace,
+                   (unsigned char*)data, 2);
+}
+
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 52d2b92..340bcb2 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -30,6 +30,7 @@
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkplug.h"
+#include "gtkextendedlayout.h"
 #include "gtkintl.h"
 #include "gtkprivate.h"
 #include "gtkplugprivate.h"
@@ -750,6 +751,8 @@ static void
 gtk_plug_size_allocate (GtkWidget     *widget,
 			GtkAllocation *allocation)
 {
+  GtkBin *bin = GTK_BIN (widget);
+  GtkRequisition natural_size;
   if (gtk_widget_is_toplevel (widget))
     GTK_WIDGET_CLASS (gtk_plug_parent_class)->size_allocate (widget, allocation);
   else
@@ -777,6 +780,10 @@ gtk_plug_size_allocate (GtkWidget     *widget,
 	}
       
     }
+
+  gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (bin->child),
+					TRUE, NULL, &natural_size);
+  _gtk_plug_windowing_publish_natural_size (GTK_PLUG (widget), &natural_size);
 }
 
 static gboolean
diff --git a/gtk/gtkplugprivate.h b/gtk/gtkplugprivate.h
index 74f0374..83dcaaf 100644
--- a/gtk/gtkplugprivate.h
+++ b/gtk/gtkplugprivate.h
@@ -138,4 +138,7 @@ GdkFilterReturn _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
 						 GdkEvent  *event,
 						 gpointer   data);
 
+void _gtk_plug_windowing_publish_natural_size (GtkPlug        *plug,
+                                               GtkRequisition *requisition);
+
 #endif /* __GTK_PLUG_PRIVATE_H__ */
diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c
index 5dbde45..c3f3b5b 100644
--- a/gtk/gtksocket-x11.c
+++ b/gtk/gtksocket-x11.c
@@ -39,6 +39,7 @@
 #include "gtkdnd.h"
 
 #include "x11/gdkx.h"
+#include <X11/Xatom.h>
 
 #ifdef HAVE_XFIXES
 #include <X11/extensions/Xfixes.h>
@@ -123,6 +124,63 @@ _gtk_socket_windowing_size_request (GtkSocket *socket)
 }
 
 void
+_gtk_socket_windowing_get_natural_size (GtkSocket *socket)
+{
+  GtkSocketPrivate *priv;
+  GdkDisplay *display;
+
+  Atom property, type;
+  int format, status;
+
+  unsigned long nitems, bytes_after;
+  unsigned char *data;
+  gint32 *data_long;
+
+  priv = _gtk_socket_get_private (socket);
+
+  priv->natural_width = 1;
+  priv->natural_height = 1;
+
+  if (gtk_widget_get_mapped (GTK_WIDGET (socket)))
+    {
+      display = gdk_drawable_get_display (socket->plug_window);
+      property = gdk_x11_get_xatom_by_name_for_display (display, "_GTK_NATURAL_SIZE");
+
+      gdk_error_trap_push ();
+      status = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
+                                   GDK_WINDOW_XWINDOW (socket->plug_window),
+                                   property, 0, 2, False, XA_CARDINAL,
+                                   &type, &format, &nitems, &bytes_after,
+                                   &data);
+      gdk_error_trap_pop ();
+
+      priv->have_natural_size = TRUE;
+
+      if (Success != status || !type)
+        return;
+
+      if (type != XA_CARDINAL)
+        {
+          g_warning ("_GTK_NATURAL_SIZE property has wrong type: %d\n", (int)type);
+          return;
+        }
+
+      if (nitems < 2)
+        {
+          g_warning ("_GTK_NATURAL_SIZE too short\n");
+          XFree (data);
+          return;
+        }
+
+      data_long = (gint32*) data;
+      priv->natural_width = MAX (1, data_long[0]);
+      priv->natural_height = MAX (1, data_long[1]);
+
+      XFree (data);
+    }
+}
+
+void
 _gtk_socket_windowing_send_key_event (GtkSocket *socket,
 				      GdkEvent  *gdk_event,
 				      gboolean   mask_key_presses)
@@ -602,6 +660,10 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
 		}
 	      return_val = GDK_FILTER_REMOVE;
 	    }
+          else if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_GTK_NATURAL_SIZE"))
+            {
+              _gtk_socket_windowing_get_natural_size (socket);
+            }
 	}
       break;
     case ReparentNotify:
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 5e6a1fb..03e39eb 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -37,6 +37,7 @@
 #include "gtksocket.h"
 #include "gtksocketprivate.h"
 #include "gtkdnd.h"
+#include "gtkextendedlayout.h"
 #include "gtkintl.h"
 
 #include "gtkalias.h"
@@ -138,6 +139,13 @@ static void     gtk_socket_forall               (GtkContainer     *container,
 						 GtkCallback       callback,
 						 gpointer          callback_data);
 
+static void gtk_socket_extended_layout_init     (GtkExtendedLayoutIface *iface);
+static void gtk_socket_get_desired_width        (GtkExtendedLayout      *layout,
+						 gint                   *minimum_size,
+						 gint                   *natural_size);
+static void gtk_socket_get_desired_height       (GtkExtendedLayout      *layout,
+						 gint                   *minimum_size,
+						 gint                   *natural_size);
 
 /* Local data */
 
@@ -169,7 +177,10 @@ _gtk_socket_get_private (GtkSocket *socket)
   return G_TYPE_INSTANCE_GET_PRIVATE (socket, GTK_TYPE_SOCKET, GtkSocketPrivate);
 }
 
-G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER)
+G_DEFINE_TYPE_WITH_CODE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+                                                gtk_socket_extended_layout_init))
+
 
 static void
 gtk_socket_finalize (GObject *object)
@@ -256,6 +267,8 @@ gtk_socket_class_init (GtkSocketClass *class)
 static void
 gtk_socket_init (GtkSocket *socket)
 {
+  GtkSocketPrivate *priv;
+
   socket->request_width = 0;
   socket->request_height = 0;
   socket->current_width = 0;
@@ -270,6 +283,9 @@ gtk_socket_init (GtkSocket *socket)
 
   socket->accel_group = gtk_accel_group_new ();
   g_object_set_data (G_OBJECT (socket->accel_group), I_("gtk-socket"), socket);
+
+  priv = _gtk_socket_get_private (socket);
+  priv->have_natural_size = FALSE;
 }
 
 /**
@@ -1047,5 +1063,83 @@ _gtk_socket_advance_toplevel_focus (GtkSocket        *socket,
     }
 }
 
+static void
+gtk_socket_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+  iface->get_desired_width  = gtk_socket_get_desired_width;
+  iface->get_desired_height = gtk_socket_get_desired_height;
+}
+
+static void
+gtk_socket_get_desired_size (GtkExtendedLayout *layout,
+			     GtkOrientation     orientation,
+			     gint              *minimum_size,
+			     gint              *natural_size)
+{
+  GtkSocket *socket = GTK_SOCKET (layout);
+  GtkSocketPrivate *priv;
+
+  if (socket->plug_widget)
+    {
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+	gtk_extended_layout_get_desired_width (GTK_EXTENDED_LAYOUT (socket->plug_widget),
+					       minimum_size, natural_size); 
+      else
+	gtk_extended_layout_get_desired_height (GTK_EXTENDED_LAYOUT (socket->plug_widget),
+						minimum_size, natural_size); 
+    }
+  else
+    {
+      priv = _gtk_socket_get_private (socket);
+
+      if (socket->is_mapped && !priv->have_natural_size && socket->plug_window)
+        {
+           _gtk_socket_windowing_size_request (socket);
+           _gtk_socket_windowing_get_natural_size (socket);
+        }
+
+      if (socket->is_mapped && priv->have_natural_size)
+	{
+          if (minimum_size)
+            {
+              *minimum_size = 
+		(orientation == GTK_ORIENTATION_HORIZONTAL) ? 
+		MAX (socket->request_width, 1) : MAX (socket->request_height, 1);
+            }
+          if (natural_size)
+            {
+              *natural_size = 
+		(orientation == GTK_ORIENTATION_HORIZONTAL) ? 
+		MAX (priv->natural_width, 1) : MAX (priv->natural_height, 1);
+            }
+        }
+      else
+	{
+          if (minimum_size)
+	    *minimum_size = 1;
+	  
+          if (natural_size)
+	    *natural_size = 1;
+        }
+    }
+}
+
+static void
+gtk_socket_get_desired_width (GtkExtendedLayout *layout,
+			      gint              *minimum_size,
+			      gint              *natural_size)
+{
+  gtk_socket_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+}
+
+static void
+gtk_socket_get_desired_height (GtkExtendedLayout *layout,
+			       gint              *minimum_size,
+			       gint              *natural_size)
+{
+  gtk_socket_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+}
+
+
 #define __GTK_SOCKET_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtksocketprivate.h b/gtk/gtksocketprivate.h
index 44a6c6b..8eda1ae 100644
--- a/gtk/gtksocketprivate.h
+++ b/gtk/gtksocketprivate.h
@@ -31,6 +31,9 @@ typedef struct _GtkSocketPrivate GtkSocketPrivate;
 struct _GtkSocketPrivate
 {
   gint resize_count;
+  gint natural_width;
+  gint natural_height;
+  gboolean have_natural_size;
 };
 
 /* In gtksocket.c: */
@@ -83,6 +86,7 @@ void _gtk_socket_windowing_end_embedding_toplevel (GtkSocket *socket);
  */
 void _gtk_socket_windowing_size_request (GtkSocket *socket);
 
+void _gtk_socket_windowing_get_natural_size (GtkSocket *socket);
 /*
  * _gtk_socket_windowing_send_key_event:
  *
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c
index 736b03f..0f328ac 100644
--- a/gtk/gtkspinner.c
+++ b/gtk/gtkspinner.c
@@ -211,6 +211,8 @@ gtk_spinner_init (GtkSpinner *spinner)
 
   spinner->priv = priv;
 
+  gtk_widget_set_size_request (GTK_WIDGET (spinner), 12, 12);
+
   gtk_widget_set_has_window (GTK_WIDGET (spinner), FALSE);
 }
 
@@ -220,16 +222,9 @@ gtk_spinner_expose (GtkWidget      *widget,
 {
   GtkStateType state_type;
   GtkSpinnerPrivate *priv;
-  int width, height;
 
   priv = GTK_SPINNER (widget)->priv;
 
-  width = widget->allocation.width;
-  height = widget->allocation.height;
-
-  if ((width < 12) || (height <12))
-    gtk_widget_set_size_request (widget, 12, 12);
-
   state_type = GTK_STATE_NORMAL;
   if (!gtk_widget_is_sensitive (widget))
    state_type = GTK_STATE_INSENSITIVE;
diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h
index e8887e0..e3af22e 100644
--- a/gtk/gtktreeprivate.h
+++ b/gtk/gtktreeprivate.h
@@ -77,6 +77,8 @@ enum
   */
 #define TREE_VIEW_COLUMN_DRAG_DEAD_MULTIPLIER(tree_view) (10*TREE_VIEW_HEADER_HEIGHT(tree_view))
 
+#define GTK_TREE_VIEW_COLUMN_GET_PRIVATE(column) (G_TYPE_INSTANCE_GET_PRIVATE ((column), GTK_TYPE_TREE_VIEW_COLUMN, GtkTreeViewColumnPrivate))
+
 typedef struct _GtkTreeViewColumnReorder GtkTreeViewColumnReorder;
 struct _GtkTreeViewColumnReorder
 {
@@ -300,6 +302,11 @@ struct _GtkTreeViewPrivate
   guint search_entry_avoid_unhandled_binding : 1;
 };
 
+struct _GtkTreeViewColumnPrivate
+{
+  gint natural_width;
+};
+
 #ifdef __GNUC__
 
 #define TREE_VIEW_INTERNAL_ASSERT(expr, ret)     G_STMT_START{          \
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c7a5ad7..fcb4f58 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -27,6 +27,7 @@
 #include "gtktreednd.h"
 #include "gtktreeprivate.h"
 #include "gtkcellrenderer.h"
+#include "gtkextendedlayout.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkbuildable.h"
@@ -165,8 +166,6 @@ static void     gtk_tree_view_destroy              (GtkObject        *object);
 static void     gtk_tree_view_realize              (GtkWidget        *widget);
 static void     gtk_tree_view_unrealize            (GtkWidget        *widget);
 static void     gtk_tree_view_map                  (GtkWidget        *widget);
-static void     gtk_tree_view_size_request         (GtkWidget        *widget,
-						    GtkRequisition   *requisition);
 static void     gtk_tree_view_size_allocate        (GtkWidget        *widget,
 						    GtkAllocation    *allocation);
 static gboolean gtk_tree_view_expose               (GtkWidget        *widget,
@@ -471,6 +470,13 @@ static void gtk_tree_view_buildable_add_child (GtkBuildable *tree_view,
 					       GObject     *child,
 					       const gchar *type);
 static void gtk_tree_view_buildable_init      (GtkBuildableIface *iface);
+static void gtk_tree_view_extended_layout_init (GtkExtendedLayoutIface *iface);
+static void gtk_tree_view_get_desired_width    (GtkExtendedLayout *layout,
+						gint              *minimum_size,
+						gint              *natural_size);
+static void gtk_tree_view_get_desired_height   (GtkExtendedLayout *layout,
+						gint              *minimum_size,
+						gint              *natural_size);
 
 
 static gboolean scroll_row_timeout                   (gpointer     data);
@@ -486,7 +492,10 @@ static guint tree_view_signals [LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE_WITH_CODE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER,
 			 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
-						gtk_tree_view_buildable_init))
+						gtk_tree_view_buildable_init)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+                                                gtk_tree_view_extended_layout_init))
+
 
 static void
 gtk_tree_view_class_init (GtkTreeViewClass *class)
@@ -516,7 +525,6 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
   widget_class->map = gtk_tree_view_map;
   widget_class->realize = gtk_tree_view_realize;
   widget_class->unrealize = gtk_tree_view_unrealize;
-  widget_class->size_request = gtk_tree_view_size_request;
   widget_class->size_allocate = gtk_tree_view_size_allocate;
   widget_class->button_press_event = gtk_tree_view_button_press;
   widget_class->button_release_event = gtk_tree_view_button_release;
@@ -2027,37 +2035,6 @@ gtk_tree_view_update_size (GtkTreeView *tree_view)
     tree_view->priv->height = tree_view->priv->tree->root->offset;
 }
 
-static void
-gtk_tree_view_size_request (GtkWidget      *widget,
-			    GtkRequisition *requisition)
-{
-  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
-  GList *tmp_list;
-
-  /* we validate some rows initially just to make sure we have some size. 
-   * In practice, with a lot of static lists, this should get a good width.
-   */
-  do_validate_rows (tree_view, FALSE);
-  gtk_tree_view_size_request_columns (tree_view);
-  gtk_tree_view_update_size (GTK_TREE_VIEW (widget));
-
-  requisition->width = tree_view->priv->width;
-  requisition->height = tree_view->priv->height + TREE_VIEW_HEADER_HEIGHT (tree_view);
-
-  tmp_list = tree_view->priv->children;
-
-  while (tmp_list)
-    {
-      GtkTreeViewChild *child = tmp_list->data;
-      GtkRequisition child_requisition;
-
-      tmp_list = tmp_list->next;
-
-      if (gtk_widget_get_visible (child->widget))
-        gtk_widget_size_request (child->widget, &child_requisition);
-    }
-}
-
 static int
 gtk_tree_view_calculate_width_before_expander (GtkTreeView *tree_view)
 {
@@ -2166,6 +2143,28 @@ gtk_tree_view_get_real_requested_width_from_column (GtkTreeView       *tree_view
   return real_requested_width;
 }
 
+static gint
+gtk_tree_view_get_real_natural_width_from_column (GtkTreeView       *tree_view,
+                                                  GtkTreeViewColumn *column)
+{
+  GtkTreeViewColumnPrivate *column_priv;
+  GtkRequisition button_natural_size;
+  gint column_natural_width;
+
+  column_priv = GTK_TREE_VIEW_COLUMN_GET_PRIVATE (column);
+  column_natural_width = column_priv->natural_width;
+
+  if (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE))
+    {
+      gtk_extended_layout_get_desired_size (GTK_EXTENDED_LAYOUT (column->button),
+					    TRUE, NULL, &button_natural_size);
+
+      column_natural_width = MAX (column_natural_width, button_natural_size.width);
+    }
+
+  return column_natural_width;
+}
+
 /* GtkWidget::size_allocate helper */
 static void
 gtk_tree_view_size_allocate_columns (GtkWidget *widget,
@@ -2175,9 +2174,10 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
   GList *list, *first_column, *last_column;
   GtkTreeViewColumn *column;
   GtkAllocation allocation;
-  gint width = 0;
+  gint width = 0, natural_width = 0;
   gint extra, extra_per_column, extra_for_last;
   gint full_requested_width = 0;
+  gint full_natural_width = 0;
   gint number_of_expand_columns = 0;
   gboolean column_changed = FALSE;
   gboolean rtl;
@@ -2211,6 +2211,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
 	continue;
 
       full_requested_width += gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
+      full_natural_width += gtk_tree_view_get_real_natural_width_from_column (tree_view, column);
 
       if (column->expand)
 	number_of_expand_columns++;
@@ -2235,7 +2236,9 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
     }
   else
     {
+      full_natural_width -= full_requested_width;
       extra = MAX (widget->allocation.width - full_requested_width, 0);
+      natural_width = MIN (extra, full_natural_width);
       extra_for_last = 0;
 
       tree_view->priv->last_extra_space = extra;
@@ -2257,6 +2260,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
        list = (rtl ? list->prev : list->next)) 
     {
       gint real_requested_width = 0;
+      gint real_natural_width = 0;
       gint old_width;
 
       column = list->data;
@@ -2282,10 +2286,14 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
 	}
 
       real_requested_width = gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
+      real_natural_width = gtk_tree_view_get_real_natural_width_from_column (tree_view, column);
+      real_natural_width -= real_requested_width;
 
       allocation.x = width;
       column->width = real_requested_width;
 
+      if (full_natural_width > 0)
+        column->width += natural_width * real_natural_width / full_natural_width;
       if (column->expand)
 	{
 	  if (number_of_expand_columns == 1)
@@ -5712,10 +5720,13 @@ validate_row (GtkTreeView *tree_view,
 
   for (list = tree_view->priv->columns; list; list = list->next)
     {
-      gint tmp_width;
-      gint tmp_height;
+      GtkTreeViewColumnPrivate *column_priv;
+      GtkRequisition requested_size;
+      GtkRequisition natural_size;
+      gint padding;
 
       column = list->data;
+      column_priv = GTK_TREE_VIEW_COLUMN_GET_PRIVATE (column);
 
       if (! column->visible)
 	continue;
@@ -5726,14 +5737,13 @@ validate_row (GtkTreeView *tree_view,
       gtk_tree_view_column_cell_set_cell_data (column, tree_view->priv->model, iter,
 					       GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
 					       node->children?TRUE:FALSE);
-      gtk_tree_view_column_cell_get_size (column,
-					  NULL, NULL, NULL,
-					  &tmp_width, &tmp_height);
+
+      gtk_tree_view_column_get_desired_size (column, &requested_size, &natural_size);
 
       if (!is_separator)
 	{
-          tmp_height += vertical_separator;
-	  height = MAX (height, tmp_height);
+          requested_size.height += vertical_separator;
+	  height = MAX (height, requested_size.height);
 	  height = MAX (height, tree_view->priv->expander_size);
 	}
       else
@@ -5746,26 +5756,31 @@ validate_row (GtkTreeView *tree_view,
 
       if (gtk_tree_view_is_expander_column (tree_view, column))
         {
-	  tmp_width = tmp_width + horizontal_separator + (depth - 1) * tree_view->priv->level_indentation;
+	  padding = horizontal_separator + (depth - 1) * tree_view->priv->level_indentation;
 
 	  if (TREE_VIEW_DRAW_EXPANDERS (tree_view))
-	    tmp_width += depth * tree_view->priv->expander_size;
+	    padding += depth * tree_view->priv->expander_size;
 	}
       else
-	tmp_width = tmp_width + horizontal_separator;
+	padding = horizontal_separator;
 
       if (draw_vgrid_lines)
         {
 	  if (list->data == first_column || list->data == last_column)
-	    tmp_width += grid_line_width / 2.0;
+	    padding += grid_line_width / 2.0;
 	  else
-	    tmp_width += grid_line_width;
+	    padding += grid_line_width;
 	}
 
-      if (tmp_width > column->requested_width)
+      requested_size.width += padding;
+      natural_size.width += padding;
+
+      if (requested_size.width > column->requested_width ||
+          natural_size.width > column_priv->natural_width)
 	{
 	  retval = TRUE;
-	  column->requested_width = tmp_width;
+	  column->requested_width = requested_size.width;
+	  column_priv->natural_width = natural_size.width;
 	}
     }
 
@@ -15653,5 +15668,103 @@ gtk_tree_view_get_tooltip_column (GtkTreeView *tree_view)
   return tree_view->priv->tooltip_column;
 }
 
+
+static void
+gtk_tree_view_get_minimum_size (GtkWidget      *widget,
+				GtkRequisition *requisition)
+{
+  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+  GList *tmp_list;
+
+  /* we validate some rows initially just to make sure we have some size. 
+   * In practice, with a lot of static lists, this should get a good width.
+   */
+  do_validate_rows (tree_view, FALSE);
+  gtk_tree_view_size_request_columns (tree_view);
+  gtk_tree_view_update_size (GTK_TREE_VIEW (widget));
+
+  requisition->width = tree_view->priv->width;
+  requisition->height = tree_view->priv->height + TREE_VIEW_HEADER_HEIGHT (tree_view);
+
+  tmp_list = tree_view->priv->children;
+
+  while (tmp_list)
+    {
+      GtkTreeViewChild *child = tmp_list->data;
+      GtkRequisition child_requisition;
+
+      tmp_list = tmp_list->next;
+
+      if (gtk_widget_get_visible (child->widget))
+        gtk_widget_size_request (child->widget, &child_requisition);
+    }
+}
+
+static void
+gtk_tree_view_extended_layout_init (GtkExtendedLayoutIface *iface)
+{
+  iface->get_desired_width  = gtk_tree_view_get_desired_width;
+  iface->get_desired_height = gtk_tree_view_get_desired_height;
+}
+
+static void
+gtk_tree_view_get_desired_size (GtkExtendedLayout *layout,
+				GtkOrientation     orientation,
+				gint              *minimum_size,
+				gint              *natural_size)
+{
+  GtkTreeView *tree_view;
+  gint natural_width = 0;
+  GList *column_iter;
+  GtkRequisition requisition;
+
+  tree_view = GTK_TREE_VIEW (layout);
+
+  gtk_tree_view_get_minimum_size (GTK_WIDGET (layout), &requisition);
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      for (column_iter = tree_view->priv->columns; column_iter; column_iter = column_iter->next)
+	{
+	  GtkTreeViewColumn *column = column_iter->data;
+	  
+	  if (!column->visible)
+	    continue;
+	  
+	  natural_width += gtk_tree_view_get_real_natural_width_from_column (tree_view, column);
+	}
+
+      if (minimum_size)
+	*minimum_size = requisition.width;
+
+      if (natural_size)
+	*natural_size = MAX (requisition.width, natural_width);
+    }
+  else
+    {
+      if (minimum_size)
+	*minimum_size = requisition.height;
+
+      if (natural_size)
+	*natural_size = requisition.height;
+    }
+}
+
+static void
+gtk_tree_view_get_desired_width (GtkExtendedLayout *layout,
+				 gint              *minimum_size,
+				 gint              *natural_size)
+{
+  gtk_tree_view_get_desired_size (layout, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+}
+
+static void
+gtk_tree_view_get_desired_height (GtkExtendedLayout *layout,
+				 gint              *minimum_size,
+				 gint              *natural_size)
+{
+  gtk_tree_view_get_desired_size (layout, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+}
+
 #define __GTK_TREE_VIEW_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 0d953de..cd40e4b 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -26,6 +26,7 @@
 #include "gtkbutton.h"
 #include "gtkalignment.h"
 #include "gtklabel.h"
+#include "gtkextendedcell.h"
 #include "gtkhbox.h"
 #include "gtkmarshalers.h"
 #include "gtkarrow.h"
@@ -164,6 +165,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkTreeViewColumn, gtk_tree_view_column, GTK_TYPE_OBJEC
 						gtk_tree_view_column_buildable_init))
 
 
+
 static void
 gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
 {
@@ -344,6 +346,8 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
                                                      G_MAXINT,
                                                      -1,
                                                      GTK_PARAM_READWRITE));
+
+  g_type_class_add_private (class, sizeof (GtkTreeViewColumnPrivate));
 }
 
 static void
@@ -2579,25 +2583,13 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
 
 }
 
-/**
- * gtk_tree_view_column_cell_get_size:
- * @tree_column: A #GtkTreeViewColumn.
- * @cell_area: (allow-none): The area a cell in the column will be allocated, or %NULL
- * @x_offset: (allow-none): location to return x offset of a cell relative to @cell_area, or %NULL
- * @y_offset: (allow-none): location to return y offset of a cell relative to @cell_area, or %NULL
- * @width: (allow-none): location to return width needed to render a cell, or %NULL
- * @height: (allow-none): location to return height needed to render a cell, or %NULL
- * 
- * Obtains the width and height needed to render the column.  This is used
- * primarily by the #GtkTreeView.
- **/
-void
-gtk_tree_view_column_cell_get_size (GtkTreeViewColumn  *tree_column,
-				    const GdkRectangle *cell_area,
-				    gint               *x_offset,
-				    gint               *y_offset,
-				    gint               *width,
-				    gint               *height)
+static void
+gtk_tree_view_column_cell_get_real_size (GtkTreeViewColumn  *tree_column,
+					 const GdkRectangle *cell_area,
+					 gint               *x_offset,
+					 gint               *y_offset,
+					 GtkRequisition     *minimal_size,
+					 GtkRequisition     *desired_size)
 {
   GList *list;
   gboolean first_cell = TRUE;
@@ -2605,10 +2597,17 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn  *tree_column,
 
   g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
 
-  if (height)
-    * height = 0;
-  if (width)
-    * width = 0;
+  if (minimal_size)
+    {
+      minimal_size->height = 0;
+      minimal_size->width = 0;
+    }
+
+  if (desired_size)
+    {
+      desired_size->height = 0;
+      desired_size->width = 0;
+    }
 
   gtk_widget_style_get (tree_column->tree_view, "focus-line-width", &focus_line_width, NULL);
   
@@ -2616,33 +2615,79 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn  *tree_column,
     {
       GtkTreeViewColumnCellInfo *info = (GtkTreeViewColumnCellInfo *) list->data;
       gboolean visible;
-      gint new_height = 0;
-      gint new_width = 0;
+      GtkRequisition min_req, nat_req;
+
       g_object_get (info->cell, "visible", &visible, NULL);
 
       if (visible == FALSE)
 	continue;
 
-      if (first_cell == FALSE && width)
-	*width += tree_column->spacing;
+      if (first_cell == FALSE)
+        {
+	  min_req.width += tree_column->spacing;
+	  nat_req.width += tree_column->spacing;
+        }
 
-      gtk_cell_renderer_get_size (info->cell,
-				  tree_column->tree_view,
-				  cell_area,
-				  x_offset,
-				  y_offset,
-				  &new_width,
-				  &new_height);
+      /* XXX TODO: Cell renderers are not really doing height-for-width yet.
+       */
+      gtk_extended_cell_get_desired_width (GTK_EXTENDED_CELL (info->cell),
+					   tree_column->tree_view,
+					   &min_req.width, &nat_req.width);
+      gtk_extended_cell_get_height_for_width (GTK_EXTENDED_CELL (info->cell),
+					      tree_column->tree_view,
+					      nat_req.width,
+					      &min_req.height, &nat_req.height);
+
+      min_req.width += focus_line_width * 2;
+      min_req.height += focus_line_width * 2;
+      nat_req.width += focus_line_width * 2;
+      nat_req.height += focus_line_width * 2;
+
+      info->requested_width = MAX (info->requested_width, min_req.width);
 
-      if (height)
-	* height = MAX (*height, new_height + focus_line_width * 2);
-      info->requested_width = MAX (info->requested_width, new_width + focus_line_width * 2);
-      if (width)
-	* width += info->requested_width;
       first_cell = FALSE;
+
+      if (minimal_size)
+        *minimal_size = min_req;
+
+      if (desired_size)
+        *desired_size = nat_req;
     }
 }
 
+
+/**
+ * gtk_tree_view_column_cell_get_size:
+ * @tree_column: A #GtkTreeViewColumn.
+ * @cell_area: (allow-none): The area a cell in the column will be allocated, or %NULL
+ * @x_offset: (allow-none): location to return x offset of a cell relative to @cell_area, or %NULL
+ * @y_offset: (allow-none): location to return y offset of a cell relative to @cell_area, or %NULL
+ * @width: (allow-none): location to return width needed to render a cell, or %NULL
+ * @height: (allow-none): location to return height needed to render a cell, or %NULL
+ * 
+ * Obtains the width and height needed to render the column.  This is used
+ * primarily by the #GtkTreeView.
+ **/
+void
+gtk_tree_view_column_cell_get_size (GtkTreeViewColumn  *tree_column,
+				    const GdkRectangle *cell_area,
+				    gint               *x_offset,
+				    gint               *y_offset,
+                                    gint               *width,
+                                    gint               *height)
+{
+  GtkRequisition min_req;
+
+  gtk_tree_view_column_cell_get_real_size (tree_column, cell_area,
+                                           x_offset, y_offset, &min_req, NULL);
+
+  if (width)
+    *width = min_req.width;
+
+  if (height)
+    *height = min_req.height;
+}
+
 /* rendering, event handling and rendering focus are somewhat complicated, and
  * quite a bit of code.  Rather than duplicate them, we put them together to
  * keep the code in one place.
@@ -3768,5 +3813,29 @@ gtk_tree_view_column_get_tree_view (GtkTreeViewColumn *tree_column)
   return tree_column->tree_view;
 }
 
+
+/**
+ * gtk_tree_view_column_get_desired_size:
+ * @tree_column: A #GtkTreeViewColumn
+ * @minimum_size: location for storing the minimum size, or %NULL
+ * @natural_size: location for storing the preferred size, or %NULL
+ *
+ *
+ * Retreives @tree_column's minimum and natural size.
+ *
+ * Since: 3.0
+ */
+void
+gtk_tree_view_column_get_desired_size (GtkTreeViewColumn *column,
+				       GtkRequisition    *minimal_size,
+				       GtkRequisition    *desired_size)
+{
+  g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (column));
+
+  gtk_tree_view_column_cell_get_real_size (column,
+                                           NULL, NULL, NULL,
+                                           minimal_size, desired_size);
+}
+
 #define __GTK_TREE_VIEW_COLUMN_C__
 #include "gtkaliasdef.c"
diff --git a/gtk/gtktreeviewcolumn.h b/gtk/gtktreeviewcolumn.h
index 4e72235..249d22d 100644
--- a/gtk/gtktreeviewcolumn.h
+++ b/gtk/gtktreeviewcolumn.h
@@ -51,6 +51,7 @@ typedef enum
 
 typedef struct _GtkTreeViewColumn      GtkTreeViewColumn;
 typedef struct _GtkTreeViewColumnClass GtkTreeViewColumnClass;
+typedef struct _GtkTreeViewColumnPrivate GtkTreeViewColumnPrivate;
 
 typedef void (* GtkTreeCellDataFunc) (GtkTreeViewColumn *tree_column,
 				      GtkCellRenderer   *cell,
@@ -225,6 +226,9 @@ void                    gtk_tree_view_column_cell_get_size       (GtkTreeViewCol
 								  gint                    *y_offset,
 								  gint                    *width,
 								  gint                    *height);
+void                    gtk_tree_view_column_get_desired_size    (GtkTreeViewColumn       *column,
+								  GtkRequisition          *minimal_size,
+								  GtkRequisition          *desired_size);
 gboolean                gtk_tree_view_column_cell_is_visible     (GtkTreeViewColumn       *tree_column);
 void                    gtk_tree_view_column_focus_cell          (GtkTreeViewColumn       *tree_column,
 								  GtkCellRenderer         *cell);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]