Index: gtk/gtkbbox.c
===================================================================
--- gtk/gtkbbox.c	(revision 21797)
+++ gtk/gtkbbox.c	(working copy)
@@ -21,21 +21,25 @@
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 #include "config.h"
+
 #include "gtkbbox.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
 
-enum {
+enum
+{
   PROP_0,
   PROP_LAYOUT_STYLE
 };
 
-enum {
+enum
+{
   CHILD_PROP_0,
   CHILD_PROP_SECONDARY
 };
@@ -48,6 +52,10 @@ static void gtk_button_box_get_property 
 					       guint              prop_id,
 					       GValue            *value,
 					       GParamSpec        *pspec);
+static void gtk_button_box_size_request       (GtkWidget         *widget,
+                                               GtkRequisition    *requisition);
+static void gtk_button_box_size_allocate      (GtkWidget         *widget,
+                                               GtkAllocation     *allocation);
 static void gtk_button_box_set_child_property (GtkContainer      *container,
 					       GtkWidget         *child,
 					       guint              property_id,
@@ -58,31 +66,38 @@ static void gtk_button_box_get_child_pro
 					       guint              property_id,
 					       GValue            *value,
 					       GParamSpec        *pspec);
+static void gtk_button_box_child_requisition  (GtkWidget         *widget,
+                                               gint              *nvis_children,
+                                               gint              *nvis_secondaries,
+                                               gint              *width,
+                                               gint              *height);
 
 #define DEFAULT_CHILD_MIN_WIDTH 85
 #define DEFAULT_CHILD_MIN_HEIGHT 27
 #define DEFAULT_CHILD_IPAD_X 4
 #define DEFAULT_CHILD_IPAD_Y 0
 
+static gint default_spacing      = 30;
+static gint default_layout_style = GTK_BUTTONBOX_EDGE;
+
 G_DEFINE_ABSTRACT_TYPE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX)
 
 static void
 gtk_button_box_class_init (GtkButtonBoxClass *class)
 {
-  GtkWidgetClass *widget_class;
-  GObjectClass *gobject_class;
-  GtkContainerClass *container_class;
-
-  gobject_class = G_OBJECT_CLASS (class);
-  widget_class = (GtkWidgetClass*) class;
-  container_class = (GtkContainerClass*) class;
+  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+  GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
 
   gobject_class->set_property = gtk_button_box_set_property;
   gobject_class->get_property = gtk_button_box_get_property;
 
+  widget_class->size_request = gtk_button_box_size_request;
+  widget_class->size_allocate = gtk_button_box_size_allocate;
+
   container_class->set_child_property = gtk_button_box_set_child_property;
   container_class->get_child_property = gtk_button_box_get_child_property;
-  
+
   /* FIXME we need to override the "spacing" property on GtkBox once
    * libgobject allows that.
    */
@@ -132,7 +147,7 @@ gtk_button_box_class_init (GtkButtonBoxC
 
   gtk_container_class_install_child_property (container_class,
 					      CHILD_PROP_SECONDARY,
-					      g_param_spec_boolean ("secondary", 
+					      g_param_spec_boolean ("secondary",
 								    P_("Secondary"),
 								    P_("If TRUE, the child appears in a secondary group of children, suitable for, e.g., help buttons"),
 								    FALSE,
@@ -156,7 +171,7 @@ gtk_button_box_set_property (GObject    
 			     const GValue    *value,
 			     GParamSpec      *pspec)
 {
-  switch (prop_id) 
+  switch (prop_id)
     {
     case PROP_LAYOUT_STYLE:
       gtk_button_box_set_layout (GTK_BUTTON_BOX (object),
@@ -186,6 +201,308 @@ gtk_button_box_get_property (GObject    
 }
 
 static void
+gtk_button_box_size_request (GtkWidget      *widget,
+                             GtkRequisition *requisition)
+{
+  GtkBox *box = GTK_BOX (widget);
+  GtkButtonBox *bbox = GTK_BUTTON_BOX (widget);
+  GtkOrientation orientation;
+  gint nvis_children;
+  gint child_width;
+  gint child_height;
+  gint spacing;
+  GtkButtonBoxStyle layout;
+
+  orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
+
+  spacing = box->spacing;
+  layout = (bbox->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE ?
+            bbox->layout_style : default_layout_style);
+
+  gtk_button_box_child_requisition (widget,
+                                    &nvis_children,
+                                    NULL,
+                                    &child_width,
+                                    &child_height);
+
+  if (nvis_children == 0)
+    {
+      requisition->width = 0;
+      requisition->height = 0;
+    }
+  else
+    {
+      switch (layout)
+        {
+        case GTK_BUTTONBOX_SPREAD:
+          if (orientation == GTK_ORIENTATION_HORIZONTAL)
+            {
+              requisition->width =
+                nvis_children * child_width + ((nvis_children + 1) * spacing);
+            }
+          else
+            {
+              requisition->height =
+                nvis_children * child_height + ((nvis_children + 1) * spacing);
+            }
+          break;
+        case GTK_BUTTONBOX_EDGE:
+        case GTK_BUTTONBOX_START:
+        case GTK_BUTTONBOX_END:
+        case GTK_BUTTONBOX_CENTER:
+          if (orientation == GTK_ORIENTATION_HORIZONTAL)
+            {
+              requisition->width =
+                nvis_children * child_width + ((nvis_children - 1) * spacing);
+            }
+          else
+            {
+              requisition->height =
+                nvis_children * child_height + ((nvis_children - 1) * spacing);
+            }
+          break;
+        default:
+          g_assert_not_reached ();
+          break;
+        }
+
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        requisition->height = child_height;
+      else
+        requisition->width = child_width;
+    }
+
+  requisition->width += GTK_CONTAINER (box)->border_width * 2;
+  requisition->height += GTK_CONTAINER (box)->border_width * 2;
+}
+
+static void
+gtk_button_box_size_allocate (GtkWidget     *widget,
+                              GtkAllocation *allocation)
+{
+  GtkBox *base_box = GTK_BOX (widget);
+  GtkButtonBox *box = GTK_BUTTON_BOX (widget);
+  GtkOrientation orientation;
+  GtkBoxChild *child;
+  GList *children;
+  GtkAllocation child_allocation;
+  gint nvis_children;
+  gint n_secondaries;
+  gint child_width;
+  gint child_height;
+  gint x = 0;
+  gint y = 0;
+  gint secondary_x = 0;
+  gint secondary_y = 0;
+  gint width = 0;
+  gint height = 0;
+  gint childspace;
+  gint childspacing = 0;
+  GtkButtonBoxStyle layout;
+  gint spacing;
+
+  orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
+
+  spacing = base_box->spacing;
+  layout = (box->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE ?
+            box->layout_style : default_layout_style);
+
+  gtk_button_box_child_requisition (widget,
+                                    &nvis_children,
+                                    &n_secondaries,
+                                    &child_width,
+                                    &child_height);
+  widget->allocation = *allocation;
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    width = allocation->width - GTK_CONTAINER (box)->border_width * 2;
+  else
+    height = allocation->height - GTK_CONTAINER (box)->border_width * 2;
+
+  switch (layout)
+    {
+    case GTK_BUTTONBOX_SPREAD:
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          childspacing = (width - (nvis_children * child_width)) / (nvis_children + 1);
+          x = allocation->x + GTK_CONTAINER (box)->border_width + childspacing;
+          secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
+        }
+      else
+        {
+          childspacing = (height - (nvis_children * child_height)) / (nvis_children + 1);
+          y = allocation->y + GTK_CONTAINER (box)->border_width + childspacing;
+          secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing));
+        }
+      break;
+
+    case GTK_BUTTONBOX_EDGE:
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          if (nvis_children >= 2)
+            {
+              childspacing = (width - (nvis_children * child_width)) / (nvis_children - 1);
+              x = allocation->x + GTK_CONTAINER (box)->border_width;
+              secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
+            }
+          else
+            {
+              /* one or zero children, just center */
+              childspacing = width;
+              x = secondary_x = allocation->x + (allocation->width - child_width) / 2;
+            }
+        }
+      else
+        {
+          if (nvis_children >= 2)
+            {
+              childspacing = (height - (nvis_children * child_height)) / (nvis_children-1);
+              y = allocation->y + GTK_CONTAINER (box)->border_width;
+              secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing));
+            }
+          else
+            {
+              /* one or zero children, just center */
+              childspacing = height;
+              y = secondary_y = allocation->y + (allocation->height - child_height) / 2;
+            }
+        }
+      break;
+
+    case GTK_BUTTONBOX_START:
+      childspacing = spacing;
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          x = allocation->x + GTK_CONTAINER (box)->border_width;
+          secondary_x = allocation->x + allocation->width
+            - child_width * n_secondaries
+            - spacing * (n_secondaries - 1)
+            - GTK_CONTAINER (box)->border_width;
+        }
+      else
+        {
+          y = allocation->y + GTK_CONTAINER (box)->border_width;
+          secondary_y = allocation->y + allocation->height
+            - child_height * n_secondaries
+            - spacing * (n_secondaries - 1)
+            - GTK_CONTAINER (box)->border_width;
+        }
+      break;
+
+    case GTK_BUTTONBOX_END:
+      childspacing = spacing;
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          x = allocation->x + allocation->width
+            - child_width * (nvis_children - n_secondaries)
+            - spacing * (nvis_children - n_secondaries - 1)
+            - GTK_CONTAINER (box)->border_width;
+          secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
+        }
+      else
+        {
+          y = allocation->y + allocation->height
+            - child_height * (nvis_children - n_secondaries)
+            - spacing * (nvis_children - n_secondaries - 1)
+            - GTK_CONTAINER (box)->border_width;
+          secondary_y = allocation->y + GTK_CONTAINER (box)->border_width;
+        }
+      break;
+
+    case GTK_BUTTONBOX_CENTER:
+      childspacing = spacing;
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          x = allocation->x +
+            (allocation->width
+             - (child_width * (nvis_children - n_secondaries)
+                + spacing * (nvis_children - n_secondaries - 1)))/2
+            + (n_secondaries * child_width + n_secondaries * spacing)/2;
+          secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
+        }
+      else
+        {
+          y = allocation->y +
+            (allocation->height
+             - (child_height * (nvis_children - n_secondaries)
+                + spacing * (nvis_children - n_secondaries - 1)))/2
+            + (n_secondaries * child_height + n_secondaries * spacing)/2;
+          secondary_y = allocation->y + GTK_CONTAINER (box)->border_width;
+       }
+      break;
+
+    default:
+      g_assert_not_reached ();
+      break;
+    }
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      y = allocation->y + (allocation->height - child_height) / 2;
+      childspace = child_width + childspacing;
+    }
+  else
+    {
+      x = allocation->x + (allocation->width - child_width) / 2;
+      childspace = child_height + childspacing;
+    }
+
+  children = GTK_BOX (box)->children;
+
+  while (children)
+    {
+      child = children->data;
+      children = children->next;
+
+      if (GTK_WIDGET_VISIBLE (child->widget))
+	{
+	  child_allocation.width = child_width;
+	  child_allocation.height = child_height;
+
+          if (orientation == GTK_ORIENTATION_HORIZONTAL)
+            child_allocation.y = y;
+          else
+            child_allocation.x = x;
+
+	  if (child->is_secondary)
+	    {
+              if (orientation == GTK_ORIENTATION_HORIZONTAL)
+                {
+                  child_allocation.x = secondary_x;
+                  secondary_x += childspace;
+                }
+              else
+                {
+                  child_allocation.y = secondary_y;
+                  secondary_y += childspace;
+                }
+	    }
+	  else
+	    {
+              if (orientation == GTK_ORIENTATION_HORIZONTAL)
+                {
+                  child_allocation.x = x;
+                  x += childspace;
+                }
+              else
+                {
+                  child_allocation.y = y;
+                  y += childspace;
+                }
+            }
+
+	  if (orientation == GTK_ORIENTATION_HORIZONTAL &&
+              gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+            {
+              child_allocation.x = (allocation->x + allocation->width) - (child_allocation.x + child_width - allocation->x);
+            }
+
+	  gtk_widget_size_allocate (child->widget, &child_allocation);
+	}
+    }
+}
+
+static void
 gtk_button_box_set_child_property (GtkContainer    *container,
 				   GtkWidget       *child,
 				   guint            property_id,
@@ -214,8 +531,8 @@ gtk_button_box_get_child_property (GtkCo
   switch (property_id)
     {
     case CHILD_PROP_SECONDARY:
-      g_value_set_boolean (value, 
-			   gtk_button_box_get_child_secondary (GTK_BUTTON_BOX (container), 
+      g_value_set_boolean (value,
+			   gtk_button_box_get_child_secondary (GTK_BUTTON_BOX (container),
 							       child));
       break;
     default:
@@ -226,8 +543,8 @@ gtk_button_box_get_child_property (GtkCo
 
 /* set per widget values for spacing, child size and child internal padding */
 
-void 
-gtk_button_box_set_child_size (GtkButtonBox *widget, 
+void
+gtk_button_box_set_child_size (GtkButtonBox *widget,
                                gint width, gint height)
 {
   g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
@@ -236,7 +553,7 @@ gtk_button_box_set_child_size (GtkButton
   widget->child_min_height = height;
 }
 
-void 
+void
 gtk_button_box_set_child_ipadding (GtkButtonBox *widget,
                                    gint ipad_x, gint ipad_y)
 {
@@ -247,7 +564,7 @@ gtk_button_box_set_child_ipadding (GtkBu
 }
 
 void
-gtk_button_box_set_layout (GtkButtonBox      *widget, 
+gtk_button_box_set_layout (GtkButtonBox      *widget,
                            GtkButtonBoxStyle  layout_style)
 {
   g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
@@ -265,7 +582,7 @@ gtk_button_box_set_layout (GtkButtonBox 
 
 /* get per widget values for spacing, child size and child internal padding */
 
-void 
+void
 gtk_button_box_get_child_size (GtkButtonBox *widget,
                                gint *width, gint *height)
 {
@@ -289,26 +606,26 @@ gtk_button_box_get_child_ipadding (GtkBu
   *ipad_y = widget->child_ipad_y;
 }
 
-GtkButtonBoxStyle 
+GtkButtonBoxStyle
 gtk_button_box_get_layout (GtkButtonBox *widget)
 {
   g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), GTK_BUTTONBOX_SPREAD);
-  
+
   return widget->layout_style;
 }
 
 /**
  * gtk_button_box_get_child_secondary:
  * @widget: a #GtkButtonBox
- * @child: a child of @widget 
- * 
+ * @child: a child of @widget
+ *
  * Returns whether @child should appear in a secondary group of children.
  *
  * Return value: whether @child should appear in a secondary group of children.
  *
  * Since: 2.4
  **/
-gboolean 
+gboolean
 gtk_button_box_get_child_secondary (GtkButtonBox *widget,
 				    GtkWidget    *child)
 {
@@ -354,13 +671,13 @@ gtk_button_box_get_child_secondary (GtkB
  * the other end of the button box from the main children. For the
  * other styles, they appear immediately next to the main children.
  **/
-void 
-gtk_button_box_set_child_secondary (GtkButtonBox *widget, 
+void
+gtk_button_box_set_child_secondary (GtkButtonBox *widget,
 				    GtkWidget    *child,
 				    gboolean      is_secondary)
 {
   GList *list;
-  
+
   g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
   g_return_if_fail (GTK_IS_WIDGET (child));
   g_return_if_fail (child->parent == GTK_WIDGET (widget));
@@ -384,17 +701,18 @@ gtk_button_box_set_child_secondary (GtkB
     gtk_widget_queue_resize (child);
 }
 
-/* Ask children how much space they require and round up 
-   to match minimum size and internal padding.
-   Returns the size each single child should have. */
-void
-_gtk_button_box_child_requisition (GtkWidget *widget,
-                                   int       *nvis_children,
-				   int       *nvis_secondaries,
-                                   int       *width,
-                                   int       *height)
+/* Ask children how much space they require and round up to match
+ * minimum size and internal padding.
+ * Returns the size each single child should have.
+ */
+static void
+gtk_button_box_child_requisition (GtkWidget *widget,
+                                  int       *nvis_children,
+                                  int       *nvis_secondaries,
+                                  int       *width,
+                                  int       *height)
 {
-  GtkButtonBox *bbox;
+  GtkButtonBox *bbox = GTK_BUTTON_BOX (widget);
   GtkBoxChild *child;
   GList *children;
   gint nchildren;
@@ -408,23 +726,19 @@ _gtk_button_box_child_requisition (GtkWi
   gint height_default;
   gint ipad_x_default;
   gint ipad_y_default;
-  
+
   gint child_min_width;
   gint child_min_height;
   gint ipad_x;
   gint ipad_y;
-  
-  g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
-
-  bbox = GTK_BUTTON_BOX (widget);
 
   gtk_widget_style_get (widget,
                         "child-min-width", &width_default,
                         "child-min-height", &height_default,
                         "child-internal-pad-x", &ipad_x_default,
-                        "child-internal-pad-y", &ipad_y_default, 
+                        "child-internal-pad-y", &ipad_y_default,
 			NULL);
-  
+
   child_min_width = bbox->child_min_width   != GTK_BUTTONBOX_DEFAULT
 	  ? bbox->child_min_width : width_default;
   child_min_height = bbox->child_min_height !=GTK_BUTTONBOX_DEFAULT
@@ -438,10 +752,10 @@ _gtk_button_box_child_requisition (GtkWi
   nsecondaries = 0;
   children = GTK_BOX(bbox)->children;
   needed_width = child_min_width;
-  needed_height = child_min_height;  
+  needed_height = child_min_height;
   ipad_w = ipad_x * 2;
   ipad_h = ipad_y * 2;
-  
+
   while (children)
     {
       child = children->data;
@@ -451,7 +765,7 @@ _gtk_button_box_child_requisition (GtkWi
 	{
 	  nchildren += 1;
 	  gtk_widget_size_request (child->widget, &child_requisition);
-	  
+
 	  if (child_requisition.width + ipad_w > needed_width)
 	    needed_width = child_requisition.width + ipad_w;
 	  if (child_requisition.height + ipad_h > needed_height)
@@ -471,5 +785,36 @@ _gtk_button_box_child_requisition (GtkWi
     *height = needed_height;
 }
 
+/* get and set default value for spacing */
+
+gint
+_gtk_button_box_get_spacing_default (void)
+{
+  return default_spacing;
+}
+
+void
+_gtk_button_box_set_spacing_default (gint spacing)
+{
+  default_spacing = spacing;
+}
+
+/* get and set default value for layout style */
+
+GtkButtonBoxStyle
+_gtk_button_box_get_layout_default (void)
+{
+  return default_layout_style;
+}
+
+void
+_gtk_button_box_set_layout_default (GtkButtonBoxStyle layout)
+{
+  g_return_if_fail (layout >= GTK_BUTTONBOX_DEFAULT_STYLE &&
+		    layout <= GTK_BUTTONBOX_CENTER);
+
+  default_layout_style = layout;
+}
+
 #define __GTK_BUTTON_BOX_C__
 #include "gtkaliasdef.c"
Index: gtk/gtkbbox.h
===================================================================
--- gtk/gtkbbox.h	(revision 21797)
+++ gtk/gtkbbox.h	(working copy)
@@ -34,7 +34,7 @@
 #include <gtk/gtkbox.h>
 
 
-G_BEGIN_DECLS  
+G_BEGIN_DECLS
 
 #define GTK_TYPE_BUTTON_BOX             (gtk_button_box_get_type ())
 #define GTK_BUTTON_BOX(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_BUTTON_BOX, GtkButtonBox))
@@ -42,16 +42,17 @@ G_BEGIN_DECLS  
 #define GTK_IS_BUTTON_BOX(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_BUTTON_BOX))
 #define GTK_IS_BUTTON_BOX_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_BUTTON_BOX))
 #define GTK_BUTTON_BOX_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_BUTTON_BOX, GtkButtonBoxClass))
-  
+
 
 #define GTK_BUTTONBOX_DEFAULT -1
- 
+
 typedef struct _GtkButtonBox       GtkButtonBox;
 typedef struct _GtkButtonBoxClass  GtkButtonBoxClass;
 
 struct _GtkButtonBox
 {
   GtkBox box;
+
   gint GSEAL (child_min_width);
   gint GSEAL (child_min_height);
   gint GSEAL (child_ipad_x);
@@ -65,7 +66,8 @@ struct _GtkButtonBoxClass
 };
 
 
-GType gtk_button_box_get_type (void) G_GNUC_CONST;
+GType             gtk_button_box_get_type            (void) G_GNUC_CONST;
+GtkWidget       * gtk_button_box_new                 (GtkOrientation     orientation);
 
 GtkButtonBoxStyle gtk_button_box_get_layout          (GtkButtonBox      *widget);
 void              gtk_button_box_set_layout          (GtkButtonBox      *widget,
@@ -92,14 +94,14 @@ void gtk_button_box_get_child_size     (
 void gtk_button_box_get_child_ipadding (GtkButtonBox *widget,
 					gint         *ipad_x,
 					gint         *ipad_y);
-#endif
+#endif /* GTK_DISABLE_DEPRECATED */
+
+/* Internal methods */
+gint              _gtk_button_box_get_spacing_default (void);
+void              _gtk_button_box_set_spacing_default (gint              spacing);
+GtkButtonBoxStyle _gtk_button_box_get_layout_default  (void);
+void              _gtk_button_box_set_layout_default  (GtkButtonBoxStyle layout);
 
-/* Internal method - do not use. */
-void _gtk_button_box_child_requisition (GtkWidget *widget,
-					int       *nvis_children,
-					int       *nvis_secondaries,
-					int       *width,
-					int       *height);
 G_END_DECLS
 
 #endif /* __GTK_BUTTON_BOX_H__ */
Index: gtk/gtkhbbox.c
===================================================================
--- gtk/gtkhbbox.c	(revision 21797)
+++ gtk/gtkhbbox.c	(working copy)
@@ -21,270 +21,60 @@
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 #include "config.h"
+
 #include "gtkhbbox.h"
+#include "gtkorientable.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
 
 
-static void gtk_hbutton_box_size_request  (GtkWidget      *widget,
-					   GtkRequisition *requisition);
-static void gtk_hbutton_box_size_allocate (GtkWidget      *widget,
-					   GtkAllocation  *allocation);
-
-static gint default_spacing = 30;
-static gint default_layout_style = GTK_BUTTONBOX_EDGE;
-
 G_DEFINE_TYPE (GtkHButtonBox, gtk_hbutton_box, GTK_TYPE_BUTTON_BOX)
 
 static void
 gtk_hbutton_box_class_init (GtkHButtonBoxClass *class)
 {
-  GtkWidgetClass *widget_class;
-
-  widget_class = (GtkWidgetClass*) class;
-
-  widget_class->size_request = gtk_hbutton_box_size_request;
-  widget_class->size_allocate = gtk_hbutton_box_size_allocate;
 }
 
 static void
-gtk_hbutton_box_init (GtkHButtonBox *hbutton_box)
+gtk_hbutton_box_init (GtkHButtonBox *hbbox)
 {
-	/* button_box_init has done everything already */
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (hbbox),
+                                  GTK_ORIENTATION_HORIZONTAL);
 }
 
-GtkWidget*
+GtkWidget *
 gtk_hbutton_box_new (void)
 {
-  GtkHButtonBox *hbutton_box;
-
-  hbutton_box = g_object_new (GTK_TYPE_HBUTTON_BOX, NULL);
-
-  return GTK_WIDGET (hbutton_box);
-}
-
-
-/* set default value for spacing */
-
-void 
-gtk_hbutton_box_set_spacing_default (gint spacing)
-{
-  default_spacing = spacing;
+  return g_object_new (GTK_TYPE_HBUTTON_BOX, NULL);
 }
 
-
-/* set default value for layout style */
-
-void 
-gtk_hbutton_box_set_layout_default (GtkButtonBoxStyle layout)
+gint
+gtk_hbutton_box_get_spacing_default (void)
 {
-  g_return_if_fail (layout >= GTK_BUTTONBOX_DEFAULT_STYLE &&
-		    layout <= GTK_BUTTONBOX_CENTER);
-
-  default_layout_style = layout;
+  return _gtk_button_box_get_spacing_default ();
 }
 
-/* get default value for spacing */
-
-gint 
-gtk_hbutton_box_get_spacing_default (void)
+void
+gtk_hbutton_box_set_spacing_default (gint spacing)
 {
-  return default_spacing;
+  _gtk_button_box_set_spacing_default (spacing);
 }
 
-
-/* get default value for layout style */
-
 GtkButtonBoxStyle
 gtk_hbutton_box_get_layout_default (void)
 {
-  return default_layout_style;
+  return _gtk_button_box_get_layout_default ();
 }
 
-
-  
-static void
-gtk_hbutton_box_size_request (GtkWidget      *widget,
-			      GtkRequisition *requisition)
+void
+gtk_hbutton_box_set_layout_default (GtkButtonBoxStyle layout)
 {
-  GtkBox *box;
-  GtkButtonBox *bbox;
-  gint nvis_children;
-  gint child_width;
-  gint child_height;
-  gint spacing;
-  GtkButtonBoxStyle layout;
-  
-  box = GTK_BOX (widget);
-  bbox = GTK_BUTTON_BOX (widget);
-
-  spacing = box->spacing;
-  layout = bbox->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
-	  ? bbox->layout_style : default_layout_style;
-  
-  _gtk_button_box_child_requisition (widget,
-                                     &nvis_children,
-				     NULL,
-                                     &child_width,
-                                     &child_height);
-
-  if (nvis_children == 0)
-  {
-    requisition->width = 0; 
-    requisition->height = 0;
-  }
-  else
-  {
-    switch (layout)
-    {
-    case GTK_BUTTONBOX_SPREAD:
-      requisition->width =
-	      nvis_children*child_width + ((nvis_children+1)*spacing);
-      break;
-    case GTK_BUTTONBOX_EDGE:
-    case GTK_BUTTONBOX_START:
-    case GTK_BUTTONBOX_END:
-    case GTK_BUTTONBOX_CENTER:
-      requisition->width = nvis_children*child_width + ((nvis_children-1)*spacing);
-      break;
-    default:
-      g_assert_not_reached();
-      break;
-    }
-	  
-    requisition->height = child_height;
-  }
-	  
-  requisition->width += GTK_CONTAINER (box)->border_width * 2;
-  requisition->height += GTK_CONTAINER (box)->border_width * 2;
+  _gtk_button_box_set_layout_default (layout);
 }
 
-
-
-static void
-gtk_hbutton_box_size_allocate (GtkWidget     *widget,
-			       GtkAllocation *allocation)
-{
-  GtkBox *base_box;
-  GtkButtonBox *box;
-  GtkBoxChild *child;
-  GList *children;
-  GtkAllocation child_allocation;
-  gint nvis_children;
-  gint n_secondaries;
-  gint child_width;
-  gint child_height;
-  gint x = 0;
-  gint secondary_x = 0;
-  gint y = 0;
-  gint width;
-  gint childspace;
-  gint childspacing = 0;
-  GtkButtonBoxStyle layout;
-  gint spacing;
-  
-  base_box = GTK_BOX (widget);
-  box = GTK_BUTTON_BOX (widget);
-  spacing = base_box->spacing;
-  layout = box->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
-	  ? box->layout_style : default_layout_style;
-  _gtk_button_box_child_requisition (widget,
-                                     &nvis_children,
-				     &n_secondaries,
-                                     &child_width,
-                                     &child_height);
-  widget->allocation = *allocation;
-  width = allocation->width - GTK_CONTAINER (box)->border_width*2;
-  switch (layout)
-  {
-  case GTK_BUTTONBOX_SPREAD:
-    childspacing = (width - (nvis_children * child_width)) / (nvis_children + 1);
-    x = allocation->x + GTK_CONTAINER (box)->border_width + childspacing;
-    secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
-    break;
-  case GTK_BUTTONBOX_EDGE:
-    if (nvis_children >= 2)
-      {
-	childspacing = (width - (nvis_children * child_width)) / (nvis_children - 1);
-	x = allocation->x + GTK_CONTAINER (box)->border_width;
-	secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
-      }
-    else
-      {
-	/* one or zero children, just center */
-        childspacing = width;
-	x = secondary_x = allocation->x + (allocation->width - child_width) / 2;
-      }
-    break;
-  case GTK_BUTTONBOX_START:
-    childspacing = spacing;
-    x = allocation->x + GTK_CONTAINER (box)->border_width;
-    secondary_x = allocation->x + allocation->width 
-      - child_width * n_secondaries
-      - spacing * (n_secondaries - 1)
-      - GTK_CONTAINER (box)->border_width;
-    break;
-  case GTK_BUTTONBOX_END:
-    childspacing = spacing;
-    x = allocation->x + allocation->width 
-      - child_width * (nvis_children - n_secondaries)
-      - spacing * (nvis_children - n_secondaries - 1)
-      - GTK_CONTAINER (box)->border_width;
-    secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
-    break;
-  case GTK_BUTTONBOX_CENTER:
-    childspacing = spacing;
-    x = allocation->x + 
-      (allocation->width
-       - (child_width * (nvis_children - n_secondaries)
-	  + spacing * (nvis_children - n_secondaries - 1)))/2
-      + (n_secondaries * child_width + n_secondaries * spacing)/2;
-    secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
-    break;
-  default:
-    g_assert_not_reached();
-    break;
-  }
-
-		  
-  y = allocation->y + (allocation->height - child_height) / 2;
-  childspace = child_width + childspacing;
-
-  children = GTK_BOX (box)->children;
-	  
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child->widget))
-	{
-	  child_allocation.width = child_width;
-	  child_allocation.height = child_height;
-	  child_allocation.y = y;
-	  
-	  if (child->is_secondary)
-	    {
-	      child_allocation.x = secondary_x;
-	      secondary_x += childspace;
-	    }
-	  else
-	    {
-	      child_allocation.x = x;
-	      x += childspace;
-	    }
-
-	  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-	    child_allocation.x = (allocation->x + allocation->width) - (child_allocation.x + child_width - allocation->x);
-	  
-	  gtk_widget_size_allocate (child->widget, &child_allocation);
-	}
-    }
-}
-  
 #define __GTK_HBUTTON_BOX_C__
 #include "gtkaliasdef.c"
Index: gtk/gtkhbbox.h
===================================================================
--- gtk/gtkhbbox.h	(revision 21797)
+++ gtk/gtkhbbox.h	(working copy)
@@ -59,18 +59,16 @@ struct _GtkHButtonBoxClass
 };
 
 
-GType      gtk_hbutton_box_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_hbutton_box_new      (void);
+GType       gtk_hbutton_box_get_type (void) G_GNUC_CONST;
+GtkWidget * gtk_hbutton_box_new      (void);
 
-/* buttons can be added by gtk_container_add() */
 
 #ifndef GTK_DISABLE_DEPRECATED
-gint gtk_hbutton_box_get_spacing_default (void);
-GtkButtonBoxStyle gtk_hbutton_box_get_layout_default (void);
-
-void gtk_hbutton_box_set_spacing_default (gint spacing);
-void gtk_hbutton_box_set_layout_default (GtkButtonBoxStyle layout);
-#endif
+gint              gtk_hbutton_box_get_spacing_default (void);
+void              gtk_hbutton_box_set_spacing_default (gint spacing);
+GtkButtonBoxStyle gtk_hbutton_box_get_layout_default  (void);
+void              gtk_hbutton_box_set_layout_default  (GtkButtonBoxStyle layout);
+#endif /* GTK_DISABLE_DEPRECATED */
 
 G_END_DECLS
 
Index: gtk/gtkvbbox.c
===================================================================
--- gtk/gtkvbbox.c	(revision 21797)
+++ gtk/gtkvbbox.c	(working copy)
@@ -21,271 +21,60 @@
  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  */
 
 #include "config.h"
+
+#include "gtkorientable.h"
 #include "gtkvbbox.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
 
 
-static void gtk_vbutton_box_size_request  (GtkWidget      *widget,
-					   GtkRequisition *requisition);
-static void gtk_vbutton_box_size_allocate (GtkWidget      *widget,
-					   GtkAllocation  *allocation);
-
-static gint default_spacing = 10;
-static GtkButtonBoxStyle default_layout_style = GTK_BUTTONBOX_EDGE;
-
 G_DEFINE_TYPE (GtkVButtonBox, gtk_vbutton_box, GTK_TYPE_BUTTON_BOX)
 
 static void
 gtk_vbutton_box_class_init (GtkVButtonBoxClass *class)
 {
-  GtkWidgetClass *widget_class;
-
-  widget_class = (GtkWidgetClass*) class;
-
-  widget_class->size_request = gtk_vbutton_box_size_request;
-  widget_class->size_allocate = gtk_vbutton_box_size_allocate;
 }
 
 static void
-gtk_vbutton_box_init (GtkVButtonBox *vbutton_box)
+gtk_vbutton_box_init (GtkVButtonBox *vbbox)
 {
-  /* button_box_init has done everything allready */
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (vbbox),
+                                  GTK_ORIENTATION_VERTICAL);
 }
 
-GtkWidget*
+GtkWidget *
 gtk_vbutton_box_new (void)
 {
-  GtkVButtonBox *vbutton_box;
-
-  vbutton_box = g_object_new (GTK_TYPE_VBUTTON_BOX, NULL);
-
-  return GTK_WIDGET (vbutton_box);
+  return g_object_new (GTK_TYPE_VBUTTON_BOX, NULL);
 }
 
-
-
-/* set default value for spacing */
-
-void
-gtk_vbutton_box_set_spacing_default (gint spacing)
+gint
+gtk_vbutton_box_get_spacing_default (void)
 {
-  default_spacing = spacing;
+  return _gtk_button_box_get_spacing_default ();
 }
 
-
-/* set default value for layout style */
-
 void
-gtk_vbutton_box_set_layout_default (GtkButtonBoxStyle layout)
-{
-  g_return_if_fail (layout >= GTK_BUTTONBOX_DEFAULT_STYLE &&
-		    layout <= GTK_BUTTONBOX_CENTER);
-
-  default_layout_style = layout;
-}
-
-/* get default value for spacing */
-
-gint
-gtk_vbutton_box_get_spacing_default (void)
+gtk_vbutton_box_set_spacing_default (gint spacing)
 {
-  return default_spacing;
+  _gtk_button_box_set_spacing_default (spacing);
 }
 
-
-
-/* get default value for layout style */
-
 GtkButtonBoxStyle
 gtk_vbutton_box_get_layout_default (void)
 {
-  return default_layout_style;
+  return _gtk_button_box_get_layout_default ();
 }
 
-
-
-
-static void
-gtk_vbutton_box_size_request (GtkWidget      *widget,
-			      GtkRequisition *requisition)
+void
+gtk_vbutton_box_set_layout_default (GtkButtonBoxStyle layout)
 {
-  GtkBox *box;
-  GtkButtonBox *bbox;
-  gint nvis_children;
-  gint child_width;
-  gint child_height;
-  gint spacing;
-  GtkButtonBoxStyle layout;
-  
-  box = GTK_BOX (widget);
-  bbox = GTK_BUTTON_BOX (widget);
-
-  spacing = box->spacing;
-  layout = bbox->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
-	  ? bbox->layout_style : default_layout_style;
-  
-  _gtk_button_box_child_requisition (widget,
-                                     &nvis_children,
-				     NULL,
-                                     &child_width,
-                                     &child_height);
-
-  if (nvis_children == 0)
-    {
-      requisition->width = 0; 
-      requisition->height = 0;
-    }
-  else
-    {
-      switch (layout)
-      {
-      case GTK_BUTTONBOX_SPREAD:
-        requisition->height =
-		nvis_children*child_height + ((nvis_children+1)*spacing);
-	break;
-      case GTK_BUTTONBOX_EDGE:
-      case GTK_BUTTONBOX_START:
-      case GTK_BUTTONBOX_END:
-      case GTK_BUTTONBOX_CENTER:
-        requisition->height =
-		nvis_children*child_height + ((nvis_children-1)*spacing);
-	break;
-      default:
-	    g_assert_not_reached();
-	    break;
-      }
-	  
-      requisition->width = child_width;
-    }
-	  
-  requisition->width += GTK_CONTAINER (box)->border_width * 2;
-  requisition->height += GTK_CONTAINER (box)->border_width * 2;
+  _gtk_button_box_set_layout_default (layout);
 }
 
-
-
-static void
-gtk_vbutton_box_size_allocate (GtkWidget     *widget,
-			       GtkAllocation *allocation)
-{
-  GtkBox *base_box;
-  GtkButtonBox *box;
-  GtkBoxChild *child;
-  GList *children;
-  GtkAllocation child_allocation;
-  gint nvis_children;
-  gint n_secondaries;
-  gint child_width;
-  gint child_height;
-  gint x = 0;
-  gint y = 0;
-  gint secondary_y = 0;
-  gint height;
-  gint childspace;
-  gint childspacing = 0;
-  GtkButtonBoxStyle layout;
-  gint spacing;
-  
-  base_box = GTK_BOX (widget);
-  box = GTK_BUTTON_BOX (widget);
-  spacing = base_box->spacing;
-  layout = box->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
-	  ? box->layout_style : default_layout_style;
-  _gtk_button_box_child_requisition (widget,
-                                     &nvis_children,
-				     &n_secondaries,
-                                     &child_width,
-                                     &child_height);
-  widget->allocation = *allocation;
-  height = allocation->height - GTK_CONTAINER (box)->border_width*2;
-  switch (layout)
-  {
-  case GTK_BUTTONBOX_SPREAD:
-    childspacing = (height - (nvis_children * child_height)) / (nvis_children + 1);
-    y = allocation->y + GTK_CONTAINER (box)->border_width + childspacing;
-    secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing));
-    break;
-  case GTK_BUTTONBOX_EDGE:
-    if (nvis_children >= 2)
-      {
-        childspacing = (height - (nvis_children*child_height)) / (nvis_children-1);
-	y = allocation->y + GTK_CONTAINER (box)->border_width;
-	secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing));
-      }
-    else
-      {
-	/* one or zero children, just center */
-	childspacing = height;
-	y = secondary_y = allocation->y + (allocation->height - child_height) / 2;
-      }
-    break;
-  case GTK_BUTTONBOX_START:
-    childspacing = spacing;
-    y = allocation->y + GTK_CONTAINER (box)->border_width;
-    secondary_y = allocation->y + allocation->height
-      - child_height * n_secondaries
-      - spacing * (n_secondaries - 1)
-      - GTK_CONTAINER (box)->border_width;
-    break;
-  case GTK_BUTTONBOX_END:
-    childspacing = spacing;
-    y = allocation->y + allocation->height 
-      - child_height * (nvis_children - n_secondaries)
-      - spacing * (nvis_children - n_secondaries - 1)
-      - GTK_CONTAINER (box)->border_width;
-    secondary_y = allocation->y + GTK_CONTAINER (box)->border_width;
-    break;
-  case GTK_BUTTONBOX_CENTER:
-    childspacing = spacing;
-    y = allocation->y + 
-      (allocation->height
-       - (child_height * (nvis_children - n_secondaries)
-	  + spacing * (nvis_children - n_secondaries - 1)))/2
-      + (n_secondaries * child_height + n_secondaries * spacing)/2;
-    secondary_y = allocation->y + GTK_CONTAINER (box)->border_width;
-    break;
-  default:
-    g_assert_not_reached();
-    break;
-  }
-		  
-  
-  x = allocation->x + (allocation->width - child_width) / 2;
-  childspace = child_height + childspacing;
-
-  children = GTK_BOX (box)->children;
-	  
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child->widget))
-	{
-	  child_allocation.width = child_width;
-	  child_allocation.height = child_height;
-	  child_allocation.x = x;
-	  
-	  if (child->is_secondary)
-	    {
-	      child_allocation.y = secondary_y;
-	      secondary_y += childspace;
-	    }
-	  else
-	    {
-	      child_allocation.y = y;
-	      y += childspace;
-	    }
-	  
-	  gtk_widget_size_allocate (child->widget, &child_allocation);
-	}
-    }
-}
-  
 #define __GTK_VBBOX_C__
 #include "gtkaliasdef.c"
Index: gtk/gtkvbbox.h
===================================================================
--- gtk/gtkvbbox.h	(revision 21797)
+++ gtk/gtkvbbox.h	(working copy)
@@ -37,7 +37,6 @@
 
 G_BEGIN_DECLS
 
-
 #define GTK_TYPE_VBUTTON_BOX            (gtk_vbutton_box_get_type ())
 #define GTK_VBUTTON_BOX(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_VBUTTON_BOX, GtkVButtonBox))
 #define GTK_VBUTTON_BOX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_VBUTTON_BOX, GtkVButtonBoxClass))
@@ -60,21 +59,17 @@ struct _GtkVButtonBoxClass
 };
 
 
-GType      gtk_vbutton_box_get_type (void) G_GNUC_CONST;
-GtkWidget *gtk_vbutton_box_new      (void);
+GType       gtk_vbutton_box_get_type (void) G_GNUC_CONST;
+GtkWidget * gtk_vbutton_box_new      (void);
 
-/* buttons can be added by gtk_container_add() */
 
 #ifndef GTK_DISABLE_DEPRECATED
-gint gtk_vbutton_box_get_spacing_default (void);
-void gtk_vbutton_box_set_spacing_default (gint spacing);
-
-GtkButtonBoxStyle gtk_vbutton_box_get_layout_default (void);
-void gtk_vbutton_box_set_layout_default (GtkButtonBoxStyle layout);
-#endif
-
+gint              gtk_vbutton_box_get_spacing_default (void);
+void              gtk_vbutton_box_set_spacing_default (gint spacing);
+GtkButtonBoxStyle gtk_vbutton_box_get_layout_default  (void);
+void              gtk_vbutton_box_set_layout_default  (GtkButtonBoxStyle layout);
+#endif /* GTK_DISABLE_DEPRECATED */
 
 G_END_DECLS
 
-
 #endif /* __GTK_VBBOX_H__ */
