Index: gtk/gtkscalebutton.c
===================================================================
--- gtk/gtkscalebutton.c	(revision 20710)
+++ gtk/gtkscalebutton.c	(working copy)
@@ -49,8 +49,7 @@
 #include "gtkhscale.h"
 #include "gtkvscale.h"
 #include "gtkframe.h"
-#include "gtkhbox.h"
-#include "gtkvbox.h"
+#include "gtkbox.h"
 #include "gtkwindow.h"
 #include "gtkmarshalers.h"
 #include "gtkstock.h"
@@ -87,6 +86,7 @@ enum
 struct _GtkScaleButtonPrivate
 {
   GtkWidget *dock;
+  GtkWidget *box;
   GtkWidget *scale;
   GtkWidget *image;
 
@@ -152,7 +152,7 @@ static void gtk_scale_button_update_icon
 static void gtk_scale_button_scale_value_changed(GtkRange            *range);
 
 /* see below for scale definitions */
-static GtkWidget *gtk_scale_button_scale_box_new(GtkScaleButton      *button);
+static GtkWidget *gtk_scale_button_scale_new    (GtkScaleButton      *button);
 
 static guint signals[LAST_SIGNAL] = { 0, };
 
@@ -332,6 +332,7 @@ static void
 gtk_scale_button_init (GtkScaleButton *button)
 {
   GtkScaleButtonPrivate *priv;
+  GtkWidget *frame;
 
   button->priv = priv = GET_PRIVATE (button);
 
@@ -361,6 +362,17 @@ gtk_scale_button_init (GtkScaleButton *b
 		    G_CALLBACK (cb_dock_grab_broken_event), button);
   gtk_window_set_decorated (GTK_WINDOW (priv->dock), FALSE);
 
+  /* frame */
+  frame = gtk_frame_new (NULL);
+  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+  gtk_container_add (GTK_CONTAINER (priv->dock), frame);
+
+  /* box for scale and +/- buttons */
+  priv->box = g_object_new (GTK_TYPE_BOX,
+                            "orientation", GTK_ORIENTATION_VERTICAL,
+                            NULL);
+  gtk_container_add (GTK_CONTAINER (frame), priv->box);
+
   /* + */
   button->plus_button = gtk_button_new_with_label ("+");
   gtk_button_set_relief (GTK_BUTTON (button->plus_button), GTK_RELIEF_NONE);
@@ -368,6 +380,7 @@ gtk_scale_button_init (GtkScaleButton *b
 		    G_CALLBACK (cb_button_press), button);
   g_signal_connect (button->plus_button, "button-release-event",
 		    G_CALLBACK (cb_button_release), button);
+  gtk_box_pack_start (GTK_BOX (priv->box), button->plus_button, FALSE, FALSE, 0);
 
   /* - */
   button->minus_button = gtk_button_new_with_label ("-");
@@ -376,6 +389,7 @@ gtk_scale_button_init (GtkScaleButton *b
 		   G_CALLBACK (cb_button_press), button);
   g_signal_connect (button->minus_button, "button-release-event",
 		    G_CALLBACK (cb_button_release), button);
+  gtk_box_pack_end (GTK_BOX (priv->box), button->minus_button, FALSE, FALSE, 0);
 
   priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 2, 20, 0));
   g_object_ref_sink (priv->adjustment);
@@ -388,7 +402,6 @@ gtk_scale_button_constructor (GType     
 {
   GObject *object;
   GtkScaleButton *button;
-  GtkWidget *frame, *box;
   GtkScaleButtonPrivate *priv;
 
   object = G_OBJECT_CLASS (gtk_scale_button_parent_class)->constructor (type, n_construct_properties, construct_params);
@@ -397,14 +410,9 @@ gtk_scale_button_constructor (GType     
 
   priv = button->priv;
 
-  /* frame */
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
-  gtk_container_add (GTK_CONTAINER (priv->dock), frame);
-
   /* box with scale and +/- buttons */
-  box = gtk_scale_button_scale_box_new (button);
-  gtk_container_add (GTK_CONTAINER (frame), box);
+  priv->scale = gtk_scale_button_scale_new (button);
+  gtk_container_add (GTK_CONTAINER (priv->box), priv->scale);
 
   /* set button text and size */
   priv->size = GTK_ICON_SIZE_SMALL_TOOLBAR;
@@ -731,27 +739,29 @@ gtk_scale_button_set_orientation (GtkSca
 
       if (priv->scale)
         {
-          GtkWidget *box = priv->scale->parent;
-          GtkWidget *frame = box->parent;
-
-          g_object_ref (button->plus_button);
-          g_object_ref (button->minus_button);
+          gtk_container_remove (GTK_CONTAINER (priv->box), priv->scale);
 
-          gtk_container_remove (GTK_CONTAINER (box), button->plus_button);
-          gtk_container_remove (GTK_CONTAINER (box), button->minus_button);
-          gtk_container_remove (GTK_CONTAINER (box), priv->scale);
-          gtk_container_remove (GTK_CONTAINER (frame), box);
+          g_object_set (priv->box, "orientation", orientation, NULL);
+          gtk_container_child_set (GTK_CONTAINER (priv->box),
+                                   button->plus_button,
+                                   "pack-type",
+                                   orientation == GTK_ORIENTATION_VERTICAL ?
+                                   GTK_PACK_START : GTK_PACK_END,
+                                   NULL);
+          gtk_container_child_set (GTK_CONTAINER (priv->box),
+                                   button->minus_button,
+                                   "pack-type",
+                                   orientation == GTK_ORIENTATION_VERTICAL ?
+                                   GTK_PACK_END : GTK_PACK_START,
+                                   NULL);
 
-          box = gtk_scale_button_scale_box_new (button);
-          gtk_container_add (GTK_CONTAINER (frame), box);
+          priv->scale = gtk_scale_button_scale_new (button);
+          gtk_container_add (GTK_CONTAINER (priv->box), priv->scale);
 
           /* FIXME: without this, the popup window appears as a square
            * after changing the orientation
            */
           gtk_window_resize (GTK_WINDOW (priv->dock), 1, 1);
-
-          g_object_unref (button->plus_button);
-          g_object_unref (button->minus_button);
         }
 
       g_object_notify (G_OBJECT (button), "orientation");
@@ -1332,54 +1342,34 @@ gtk_scale_button_hscale_init (GtkScaleBu
 }
 
 static GtkWidget *
-gtk_scale_button_scale_box_new (GtkScaleButton *button)
+gtk_scale_button_scale_new (GtkScaleButton *button)
 {
   GtkScaleButtonPrivate *priv = button->priv;
   GtkScaleButtonVScale *scale;
-  GtkWidget *box;
 
   if (priv->orientation == GTK_ORIENTATION_VERTICAL)
     {
-      box = gtk_vbox_new (FALSE, 0);
-
       scale = g_object_new (GTK_TYPE_SCALE_BUTTON_VSCALE, NULL);
-      priv->scale = GTK_WIDGET (scale);
 
-      gtk_widget_set_size_request (priv->scale, -1, SCALE_SIZE);
-      gtk_range_set_inverted (GTK_RANGE (priv->scale), TRUE);
-
-      gtk_box_pack_start (GTK_BOX (box), button->plus_button, TRUE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (box), priv->scale, TRUE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (box), button->minus_button, TRUE, FALSE, 0);
+      gtk_widget_set_size_request (GTK_WIDGET (scale), -1, SCALE_SIZE);
+      gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
     }
   else
     {
-      box = gtk_hbox_new (FALSE, 0);
-
       scale = g_object_new (GTK_TYPE_SCALE_BUTTON_HSCALE, NULL);
-      priv->scale = GTK_WIDGET (scale);
-
-      gtk_widget_set_size_request (priv->scale, SCALE_SIZE, -1);
 
-      gtk_box_pack_start (GTK_BOX (box), button->minus_button, TRUE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (box), priv->scale, TRUE, FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (box), button->plus_button, TRUE, FALSE, 0);
+      gtk_widget_set_size_request (GTK_WIDGET (scale), SCALE_SIZE, -1);
     }
 
-  gtk_scale_set_draw_value (GTK_SCALE (priv->scale), FALSE);
+  gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
   gtk_range_set_adjustment (GTK_RANGE (scale),
                             GTK_ADJUSTMENT (priv->adjustment));
   scale->button = button;
 
-  g_signal_connect (priv->scale, "grab-notify",
+  g_signal_connect (scale, "grab-notify",
                     G_CALLBACK (cb_scale_grab_notify), button);
 
-  /* FIXME: without this, the popup window appears as a square
-   * after changing the orientation
-   */
-  gtk_window_resize (GTK_WINDOW (priv->dock), 1, 1);
-
-  return box;
+  return GTK_WIDGET (scale);
 }
 
 static gboolean
