]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkscrolledwindow.c
Deprecate flag macros for toplevel, state, no window and composite child
[~andy/gtk] / gtk / gtkscrolledwindow.c
index 6ef783a36129eb03824a0020276b82b9ed29634e..fb9cd0c704fc94fcf2b82c8e6d8b90de02c36dd3 100644 (file)
  * 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 "config.h"
 #include <math.h>
 #include <gdk/gdkkeysyms.h>
 #include "gtkbindings.h"
@@ -43,9 +43,9 @@
  *   to be best suited to display its contents, including children.
  *   the width and/or height reported from a widget upon size requisition
  *   may be overidden by the user by specifying a width and/or height
- *   other than 0 through gtk_widget_set_usize().
+ *   other than 0 through gtk_widget_set_size_request().
  *
- * a scrolled window needs (for imlementing all three policy types) to
+ * a scrolled window needs (for implementing all three policy types) to
  * request its width and height based on two different rationales.
  * 1)   the user wants the scrolled window to just fit into the space
  *      that it gets allocated for a specifc dimension.
@@ -88,8 +88,7 @@ enum {
   PROP_VSCROLLBAR_POLICY,
   PROP_WINDOW_PLACEMENT,
   PROP_WINDOW_PLACEMENT_SET,
-  PROP_SHADOW_TYPE,
-  PROP_LAST
+  PROP_SHADOW_TYPE
 };
 
 /* Signals */
@@ -100,49 +99,48 @@ enum
   LAST_SIGNAL
 };
 
-static void gtk_scrolled_window_destroy            (GtkObject              *object);
-static void gtk_scrolled_window_finalize           (GObject                *object);
-static void gtk_scrolled_window_set_property       (GObject                *object,
-                                                   guint                   prop_id,
-                                                   const GValue           *value,
-                                                   GParamSpec             *pspec);
-static void gtk_scrolled_window_get_property       (GObject                *object,
-                                                   guint                   prop_id,
-                                                   GValue                 *value,
-                                                   GParamSpec             *pspec);
-
-static void gtk_scrolled_window_screen_changed     (GtkWidget              *widget,
-                                                   GdkScreen              *previous_screen);
-static gint gtk_scrolled_window_expose             (GtkWidget              *widget,
-                                                   GdkEventExpose         *event);
-static void gtk_scrolled_window_size_request       (GtkWidget              *widget,
-                                                   GtkRequisition         *requisition);
-static void gtk_scrolled_window_size_allocate      (GtkWidget              *widget,
-                                                   GtkAllocation          *allocation);
-static gint gtk_scrolled_window_scroll_event       (GtkWidget              *widget,
-                                                   GdkEventScroll         *event);
-static gint gtk_scrolled_window_focus              (GtkWidget              *widget,
-                                                   GtkDirectionType        direction);
-static void gtk_scrolled_window_add                (GtkContainer           *container,
-                                                   GtkWidget              *widget);
-static void gtk_scrolled_window_remove             (GtkContainer           *container,
-                                                   GtkWidget              *widget);
-static void gtk_scrolled_window_forall             (GtkContainer           *container,
-                                                   gboolean                include_internals,
-                                                   GtkCallback             callback,
-                                                   gpointer                callback_data);
-static void gtk_scrolled_window_scroll_child       (GtkScrolledWindow      *scrolled_window,
-                                                   GtkScrollType           scroll,
-                                                   gboolean                horizontal);
-static void gtk_scrolled_window_move_focus_out     (GtkScrolledWindow      *scrolled_window,
-                                                   GtkDirectionType        direction_type);
-
-static void gtk_scrolled_window_relative_allocation(GtkWidget              *widget,
-                                                   GtkAllocation          *allocation);
-static void gtk_scrolled_window_adjustment_changed (GtkAdjustment          *adjustment,
-                                                   gpointer                data);
-
-static void gtk_scrolled_window_update_real_placement (GtkScrolledWindow   *scrolled_window);
+static void     gtk_scrolled_window_destroy            (GtkObject         *object);
+static void     gtk_scrolled_window_set_property       (GObject           *object,
+                                                        guint              prop_id,
+                                                        const GValue      *value,
+                                                        GParamSpec        *pspec);
+static void     gtk_scrolled_window_get_property       (GObject           *object,
+                                                        guint              prop_id,
+                                                        GValue            *value,
+                                                        GParamSpec        *pspec);
+
+static void     gtk_scrolled_window_screen_changed     (GtkWidget         *widget,
+                                                        GdkScreen         *previous_screen);
+static gboolean gtk_scrolled_window_expose             (GtkWidget         *widget,
+                                                        GdkEventExpose    *event);
+static void     gtk_scrolled_window_size_request       (GtkWidget         *widget,
+                                                        GtkRequisition    *requisition);
+static void     gtk_scrolled_window_size_allocate      (GtkWidget         *widget,
+                                                        GtkAllocation     *allocation);
+static gboolean gtk_scrolled_window_scroll_event       (GtkWidget         *widget,
+                                                        GdkEventScroll    *event);
+static gboolean gtk_scrolled_window_focus              (GtkWidget         *widget,
+                                                        GtkDirectionType   direction);
+static void     gtk_scrolled_window_add                (GtkContainer      *container,
+                                                        GtkWidget         *widget);
+static void     gtk_scrolled_window_remove             (GtkContainer      *container,
+                                                        GtkWidget         *widget);
+static void     gtk_scrolled_window_forall             (GtkContainer      *container,
+                                                        gboolean           include_internals,
+                                                        GtkCallback        callback,
+                                                        gpointer           callback_data);
+static gboolean gtk_scrolled_window_scroll_child       (GtkScrolledWindow *scrolled_window,
+                                                        GtkScrollType      scroll,
+                                                        gboolean           horizontal);
+static void     gtk_scrolled_window_move_focus_out     (GtkScrolledWindow *scrolled_window,
+                                                        GtkDirectionType   direction_type);
+
+static void     gtk_scrolled_window_relative_allocation(GtkWidget         *widget,
+                                                        GtkAllocation     *allocation);
+static void     gtk_scrolled_window_adjustment_changed (GtkAdjustment     *adjustment,
+                                                        gpointer           data);
+
+static void  gtk_scrolled_window_update_real_placement (GtkScrolledWindow *scrolled_window);
 
 static guint signals[LAST_SIGNAL] = {0};
 
@@ -158,11 +156,11 @@ add_scroll_binding (GtkBindingSet  *binding_set,
   guint keypad_keyval = keyval - GDK_Left + GDK_KP_Left;
   
   gtk_binding_entry_add_signal (binding_set, keyval, mask,
-                                "scroll_child", 2,
+                                "scroll-child", 2,
                                 GTK_TYPE_SCROLL_TYPE, scroll,
                                G_TYPE_BOOLEAN, horizontal);
   gtk_binding_entry_add_signal (binding_set, keypad_keyval, mask,
-                                "scroll_child", 2,
+                                "scroll-child", 2,
                                 GTK_TYPE_SCROLL_TYPE, scroll,
                                G_TYPE_BOOLEAN, horizontal);
 }
@@ -173,10 +171,10 @@ add_tab_bindings (GtkBindingSet    *binding_set,
                  GtkDirectionType  direction)
 {
   gtk_binding_entry_add_signal (binding_set, GDK_Tab, modifiers,
-                                "move_focus_out", 1,
+                                "move-focus-out", 1,
                                 GTK_TYPE_DIRECTION_TYPE, direction);
   gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, modifiers,
-                                "move_focus_out", 1,
+                                "move-focus-out", 1,
                                 GTK_TYPE_DIRECTION_TYPE, direction);
 }
 
@@ -193,7 +191,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
   widget_class = (GtkWidgetClass*) class;
   container_class = (GtkContainerClass*) class;
 
-  gobject_class->finalize = gtk_scrolled_window_finalize;
   gobject_class->set_property = gtk_scrolled_window_set_property;
   gobject_class->get_property = gtk_scrolled_window_get_property;
 
@@ -280,6 +277,20 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
                                                      GTK_SHADOW_NONE,
                                                       GTK_PARAM_READABLE | GTK_PARAM_WRITABLE));
 
+  /**
+   * GtkScrolledWindow:scrollbars-within-bevel:
+   *
+   * Whether to place scrollbars within the scrolled window's bevel.
+   *
+   * Since: 2.12
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                          g_param_spec_boolean ("scrollbars-within-bevel",
+                                                                P_("Scrollbars within bevel"),
+                                                                P_("Place scrollbars within the scrolled window's bevel"),
+                                                                FALSE,
+                                                                GTK_PARAM_READABLE));
+
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_int ("scrollbar-spacing",
                                                             P_("Scrollbar spacing"),
@@ -306,17 +317,17 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
 
 
   signals[SCROLL_CHILD] =
-    g_signal_new (I_("scroll_child"),
+    g_signal_new (I_("scroll-child"),
                   G_TYPE_FROM_CLASS (object_class),
                   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                   G_STRUCT_OFFSET (GtkScrolledWindowClass, scroll_child),
                   NULL, NULL,
-                  _gtk_marshal_VOID__ENUM_BOOLEAN,
-                  G_TYPE_NONE, 2,
+                  _gtk_marshal_BOOLEAN__ENUM_BOOLEAN,
+                  G_TYPE_BOOLEAN, 2,
                   GTK_TYPE_SCROLL_TYPE,
                  G_TYPE_BOOLEAN);
   signals[MOVE_FOCUS_OUT] =
-    g_signal_new (I_("move_focus_out"),
+    g_signal_new (I_("move-focus-out"),
                   G_TYPE_FROM_CLASS (object_class),
                   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                   G_STRUCT_OFFSET (GtkScrolledWindowClass, move_focus_out),
@@ -364,6 +375,20 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
   gtk_scrolled_window_update_real_placement (scrolled_window);
 }
 
+/**
+ * gtk_scrolled_window_new:
+ * @hadjustment: (allow-none): horizontal adjustment
+ * @vadjustment: (allow-none): vertical adjustment
+ *
+ * Creates a new scrolled window.
+ *
+ * The two arguments are the scrolled window's adjustments; these will be
+ * shared with the scrollbars and the child widget to keep the bars in sync 
+ * with the child. Usually you want to pass %NULL for the adjustments, which 
+ * will cause the scrolled window to create them for you.
+ *
+ * Returns: a new scrolled window
+ */
 GtkWidget*
 gtk_scrolled_window_new (GtkAdjustment *hadjustment,
                         GtkAdjustment *vadjustment)
@@ -376,7 +401,7 @@ gtk_scrolled_window_new (GtkAdjustment *hadjustment,
   if (vadjustment)
     g_return_val_if_fail (GTK_IS_ADJUSTMENT (vadjustment), NULL);
 
-  scrolled_window = gtk_widget_new (GTK_TYPE_SCROLLED_WINDOW,
+  scrolled_window = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
                                    "hadjustment", hadjustment,
                                    "vadjustment", vadjustment,
                                    NULL);
@@ -384,6 +409,13 @@ gtk_scrolled_window_new (GtkAdjustment *hadjustment,
   return scrolled_window;
 }
 
+/**
+ * gtk_scrolled_window_set_hadjustment:
+ * @scrolled_window: a #GtkScrolledWindow
+ * @hadjustment: horizontal scroll adjustment
+ *
+ * Sets the #GtkAdjustment for the horizontal scrollbar.
+ */
 void
 gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window,
                                     GtkAdjustment     *hadjustment)
@@ -438,6 +470,13 @@ gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window,
   g_object_notify (G_OBJECT (scrolled_window), "hadjustment");
 }
 
+/**
+ * gtk_scrolled_window_set_vadjustment:
+ * @scrolled_window: a #GtkScrolledWindow
+ * @vadjustment: vertical scroll adjustment
+ *
+ * Sets the #GtkAdjustment for the vertical scrollbar.
+ */
 void
 gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window,
                                     GtkAdjustment     *vadjustment)
@@ -492,6 +531,16 @@ gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window,
   g_object_notify (G_OBJECT (scrolled_window), "vadjustment");
 }
 
+/**
+ * gtk_scrolled_window_get_hadjustment:
+ * @scrolled_window: a #GtkScrolledWindow
+ *
+ * Returns the horizontal scrollbar's adjustment, used to connect the
+ * horizontal scrollbar to the child widget's horizontal scroll
+ * functionality.
+ *
+ * Returns: the horizontal #GtkAdjustment
+ */
 GtkAdjustment*
 gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window)
 {
@@ -502,6 +551,16 @@ gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window)
          NULL);
 }
 
+/**
+ * gtk_scrolled_window_get_vadjustment:
+ * @scrolled_window: a #GtkScrolledWindow
+ * 
+ * Returns the vertical scrollbar's adjustment, used to connect the
+ * vertical scrollbar to the child widget's vertical scroll
+ * functionality.
+ * 
+ * Returns: the vertical #GtkAdjustment
+ */
 GtkAdjustment*
 gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window)
 {
@@ -550,6 +609,21 @@ gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *scrolled_window)
   return scrolled_window->vscrollbar;
 }
 
+/**
+ * gtk_scrolled_window_set_policy:
+ * @scrolled_window: a #GtkScrolledWindow
+ * @hscrollbar_policy: policy for horizontal bar
+ * @vscrollbar_policy: policy for vertical bar
+ * 
+ * Sets the scrollbar policy for the horizontal and vertical scrollbars.
+ *
+ * The policy determines when the scrollbar should appear; it is a value
+ * from the #GtkPolicyType enumeration. If %GTK_POLICY_ALWAYS, the
+ * scrollbar is always present; if %GTK_POLICY_NEVER, the scrollbar is
+ * never present; if %GTK_POLICY_AUTOMATIC, the scrollbar is present only
+ * if needed (that is, if the slider part of the bar would be smaller
+ * than the trough - the display is larger than the page size).
+ */
 void
 gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
                                GtkPolicyType      hscrollbar_policy,
@@ -577,12 +651,14 @@ gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
 /**
  * gtk_scrolled_window_get_policy:
  * @scrolled_window: a #GtkScrolledWindow
- * @hscrollbar_policy: location to store the policy for the horizontal scrollbar, or %NULL.
- * @vscrollbar_policy: location to store the policy for the horizontal scrollbar, or %NULL.
+ * @hscrollbar_policy: location to store the policy for the horizontal 
+ *     scrollbar, or %NULL.
+ * @vscrollbar_policy: location to store the policy for the vertical
+ *     scrollbar, or %NULL.
  * 
  * Retrieves the current policy values for the horizontal and vertical
  * scrollbars. See gtk_scrolled_window_set_policy().
- **/
+ */
 void
 gtk_scrolled_window_get_policy (GtkScrolledWindow *scrolled_window,
                                GtkPolicyType     *hscrollbar_policy,
@@ -650,13 +726,19 @@ gtk_scrolled_window_set_placement_set (GtkScrolledWindow *scrolled_window,
 /**
  * gtk_scrolled_window_set_placement:
  * @scrolled_window: a #GtkScrolledWindow
+ * @window_placement: position of the child window
  *
  * Sets the placement of the contents with respect to the scrollbars
  * for the scrolled window.
+ * 
+ * The default is %GTK_CORNER_TOP_LEFT, meaning the child is
+ * in the top left, with the scrollbars underneath and to the right.
+ * Other values in #GtkCornerType are %GTK_CORNER_TOP_RIGHT,
+ * %GTK_CORNER_BOTTOM_LEFT, and %GTK_CORNER_BOTTOM_RIGHT.
  *
  * See also gtk_scrolled_window_get_placement() and
  * gtk_scrolled_window_unset_placement().
- **/
+ */
 void
 gtk_scrolled_window_set_placement (GtkScrolledWindow *scrolled_window,
                                   GtkCornerType      window_placement)
@@ -765,30 +847,31 @@ gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolled_window)
 
 static void
 gtk_scrolled_window_destroy (GtkObject *object)
-{
-  GtkScrolledWindow *scrolled_window;
-
-  g_return_if_fail (GTK_IS_SCROLLED_WINDOW (object));
-
-  scrolled_window = GTK_SCROLLED_WINDOW (object);
-
-  gtk_widget_unparent (scrolled_window->hscrollbar);
-  gtk_widget_unparent (scrolled_window->vscrollbar);
-  gtk_widget_destroy (scrolled_window->hscrollbar);
-  gtk_widget_destroy (scrolled_window->vscrollbar);
-
-  GTK_OBJECT_CLASS (gtk_scrolled_window_parent_class)->destroy (object);
-}
-
-static void
-gtk_scrolled_window_finalize (GObject *object)
 {
   GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object);
 
-  g_object_unref (scrolled_window->hscrollbar);
-  g_object_unref (scrolled_window->vscrollbar);
+  if (scrolled_window->hscrollbar)
+    {
+      g_signal_handlers_disconnect_by_func (gtk_range_get_adjustment (GTK_RANGE (scrolled_window->hscrollbar)),
+                                           gtk_scrolled_window_adjustment_changed,
+                                           scrolled_window);
+      gtk_widget_unparent (scrolled_window->hscrollbar);
+      gtk_widget_destroy (scrolled_window->hscrollbar);
+      g_object_unref (scrolled_window->hscrollbar);
+      scrolled_window->hscrollbar = NULL;
+    }
+  if (scrolled_window->vscrollbar)
+    {
+      g_signal_handlers_disconnect_by_func (gtk_range_get_adjustment (GTK_RANGE (scrolled_window->vscrollbar)),
+                                           gtk_scrolled_window_adjustment_changed,
+                                           scrolled_window);
+      gtk_widget_unparent (scrolled_window->vscrollbar);
+      gtk_widget_destroy (scrolled_window->vscrollbar);
+      g_object_unref (scrolled_window->vscrollbar);
+      scrolled_window->vscrollbar = NULL;
+    }
 
-  G_OBJECT_CLASS (gtk_scrolled_window_parent_class)->finalize (object);
+  GTK_OBJECT_CLASS (gtk_scrolled_window_parent_class)->destroy (object);
 }
 
 static void
@@ -825,7 +908,7 @@ gtk_scrolled_window_set_property (GObject      *object,
       break;
     case PROP_WINDOW_PLACEMENT_SET:
       gtk_scrolled_window_set_placement_set (scrolled_window,
-                                            g_value_get_enum (value),
+                                            g_value_get_boolean (value),
                                             TRUE);
       break;
     case PROP_SHADOW_TYPE:
@@ -885,7 +968,7 @@ traverse_container (GtkWidget *widget,
   if (GTK_IS_SCROLLED_WINDOW (widget))
     {
       gtk_scrolled_window_update_real_placement (GTK_SCROLLED_WINDOW (widget));
-      gtk_widget_queue_draw (widget);
+      gtk_widget_queue_resize (widget);
     }
   else if (GTK_IS_CONTAINER (widget))
     gtk_container_forall (GTK_CONTAINER (widget), traverse_container, NULL);
@@ -938,18 +1021,34 @@ static void
 gtk_scrolled_window_paint (GtkWidget    *widget,
                           GdkRectangle *area)
 {
-  GtkAllocation relative_allocation;
   GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
 
   if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
     {
-      gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
-      
-      relative_allocation.x -= widget->style->xthickness;
-      relative_allocation.y -= widget->style->ythickness;
-      relative_allocation.width += 2 * widget->style->xthickness;
-      relative_allocation.height += 2 * widget->style->ythickness;
+      GtkAllocation relative_allocation;
+      gboolean scrollbars_within_bevel;
+
+      gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
       
+      if (!scrollbars_within_bevel)
+        {
+          gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
+
+          relative_allocation.x -= widget->style->xthickness;
+          relative_allocation.y -= widget->style->ythickness;
+          relative_allocation.width += 2 * widget->style->xthickness;
+          relative_allocation.height += 2 * widget->style->ythickness;
+        }
+      else
+        {
+          GtkContainer *container = GTK_CONTAINER (widget);
+
+          relative_allocation.x = container->border_width;
+          relative_allocation.y = container->border_width;
+          relative_allocation.width = widget->allocation.width - 2 * container->border_width;
+          relative_allocation.height = widget->allocation.height - 2 * container->border_width;
+        }
+
       gtk_paint_shadow (widget->style, widget->window,
                        GTK_STATE_NORMAL, scrolled_window->shadow_type,
                        area, widget, "scrolled_window",
@@ -960,7 +1059,7 @@ gtk_scrolled_window_paint (GtkWidget    *widget,
     }
 }
 
-static gint
+static gboolean
 gtk_scrolled_window_expose (GtkWidget      *widget,
                            GdkEventExpose *event)
 {
@@ -968,7 +1067,7 @@ gtk_scrolled_window_expose (GtkWidget      *widget,
     {
       gtk_scrolled_window_paint (widget, &event->area);
 
-      (* GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->expose_event) (widget, event);
+      GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->expose_event (widget, event);
     }
 
   return FALSE;
@@ -1000,7 +1099,7 @@ gtk_scrolled_window_forall (GtkContainer *container,
     }
 }
 
-static void
+static gboolean
 gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
                                  GtkScrollType      scroll,
                                  gboolean           horizontal)
@@ -1049,10 +1148,14 @@ gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
     case GTK_SCROLL_END:
       break;
     default:
-      g_warning ("Invalid scroll type %u for GtkSpinButton::change-value", scroll);
-      return;
+      g_warning ("Invalid scroll type %u for GtkScrolledWindow::scroll-child", scroll);
+      return FALSE;
     }
 
+  if ((horizontal && (!scrolled_window->hscrollbar || !scrolled_window->hscrollbar_visible)) ||
+      (!horizontal && (!scrolled_window->vscrollbar || !scrolled_window->vscrollbar_visible)))
+    return FALSE;
+
   if (horizontal)
     {
       if (scrolled_window->hscrollbar)
@@ -1096,7 +1199,11 @@ gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
       value = CLAMP (value, adjustment->lower, adjustment->upper - adjustment->page_size);
       
       gtk_adjustment_set_value (adjustment, value);
+
+      return TRUE;
     }
+
+  return FALSE;
 }
 
 static void
@@ -1109,13 +1216,13 @@ gtk_scrolled_window_move_focus_out (GtkScrolledWindow *scrolled_window,
    * a flag, then propagating the focus motion to the notebook.
    */
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (scrolled_window));
-  if (!GTK_WIDGET_TOPLEVEL (toplevel))
+  if (!gtk_widget_is_toplevel (toplevel))
     return;
 
   g_object_ref (scrolled_window);
   
   scrolled_window->focus_out = TRUE;
-  g_signal_emit_by_name (toplevel, "move_focus", direction_type);
+  g_signal_emit_by_name (toplevel, "move-focus", direction_type);
   scrolled_window->focus_out = FALSE;
   
   g_object_unref (scrolled_window);
@@ -1283,6 +1390,7 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
   GtkBin *bin;
   GtkAllocation relative_allocation;
   GtkAllocation child_allocation;
+  gboolean scrollbars_within_bevel;
   gint scrollbar_spacing;
   
   g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
@@ -1292,6 +1400,7 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
   bin = GTK_BIN (scrolled_window);
 
   scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
+  gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
 
   priv = GTK_SCROLLED_WINDOW_GET_PRIVATE (scrolled_window);
 
@@ -1381,8 +1490,20 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
 
       if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
        {
-         child_allocation.x -= widget->style->xthickness;
-         child_allocation.width += 2 * widget->style->xthickness;
+          if (!scrollbars_within_bevel)
+            {
+              child_allocation.x -= widget->style->xthickness;
+              child_allocation.width += 2 * widget->style->xthickness;
+            }
+          else if (GTK_CORNER_TOP_RIGHT == priv->real_window_placement ||
+                   GTK_CORNER_TOP_LEFT == priv->real_window_placement)
+            {
+              child_allocation.y -= widget->style->ythickness;
+            }
+          else
+            {
+              child_allocation.y += widget->style->ythickness;
+            }
        }
 
       gtk_widget_size_allocate (scrolled_window->hscrollbar, &child_allocation);
@@ -1421,8 +1542,20 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
 
       if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
        {
-         child_allocation.y -= widget->style->ythickness;
-         child_allocation.height += 2 * widget->style->ythickness;
+          if (!scrollbars_within_bevel)
+            {
+              child_allocation.y -= widget->style->ythickness;
+             child_allocation.height += 2 * widget->style->ythickness;
+            }
+          else if (GTK_CORNER_BOTTOM_LEFT == priv->real_window_placement ||
+                   GTK_CORNER_TOP_LEFT == priv->real_window_placement)
+            {
+              child_allocation.x -= widget->style->xthickness;
+            }
+          else
+            {
+              child_allocation.x += widget->style->xthickness;
+            }
        }
 
       gtk_widget_size_allocate (scrolled_window->vscrollbar, &child_allocation);
@@ -1431,8 +1564,8 @@ gtk_scrolled_window_size_allocate (GtkWidget     *widget,
     gtk_widget_hide (scrolled_window->vscrollbar);
 }
 
-static gint
-gtk_scrolled_window_scroll_event (GtkWidget *widget,
+static gboolean
+gtk_scrolled_window_scroll_event (GtkWidget      *widget,
                                  GdkEventScroll *event)
 {
   GtkWidget *range;
@@ -1462,7 +1595,7 @@ gtk_scrolled_window_scroll_event (GtkWidget *widget,
   return FALSE;
 }
 
-static gint
+static gboolean
 gtk_scrolled_window_focus (GtkWidget        *widget,
                           GtkDirectionType  direction)
 {
@@ -1487,7 +1620,7 @@ gtk_scrolled_window_focus (GtkWidget        *widget,
        return TRUE;
     }
 
-  if (!had_focus_child)
+  if (!had_focus_child && GTK_WIDGET_CAN_FOCUS (widget))
     {
       gtk_widget_grab_focus (widget);
       return TRUE;
@@ -1574,6 +1707,29 @@ gtk_scrolled_window_remove (GtkContainer *container,
   GTK_CONTAINER_CLASS (gtk_scrolled_window_parent_class)->remove (container, child);
 }
 
+/**
+ * gtk_scrolled_window_add_with_viewport:
+ * @scrolled_window: a #GtkScrolledWindow
+ * @child: the widget you want to scroll
+ *
+ * Used to add children without native scrolling capabilities. This
+ * is simply a convenience function; it is equivalent to adding the
+ * unscrollable child to a viewport, then adding the viewport to the
+ * scrolled window. If a child has native scrolling, use
+ * gtk_container_add() instead of this function.
+ *
+ * The viewport scrolls the child by moving its #GdkWindow, and takes
+ * the size of the child to be the size of its toplevel #GdkWindow. 
+ * This will be very wrong for most widgets that support native scrolling;
+ * for example, if you add a widget such as #GtkTreeView with a viewport,
+ * the whole widget will scroll, including the column headings. Thus, 
+ * widgets with native scrolling support should not be used with the 
+ * #GtkViewport proxy.
+ *
+ * A widget supports scrolling natively if the 
+ * set_scroll_adjustments_signal field in #GtkWidgetClass is non-zero,
+ * i.e. has been filled in with a valid signal identifier.
+ */
 void
 gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
                                       GtkWidget         *child)
@@ -1606,7 +1762,7 @@ gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
   gtk_container_add (GTK_CONTAINER (viewport), child);
 }
 
-/**
+/*
  * _gtk_scrolled_window_get_spacing:
  * @scrolled_window: a scrolled window
  * 
@@ -1614,7 +1770,7 @@ gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
  * the scrolled widget. Used by GtkCombo
  * 
  * Return value: the spacing, in pixels.
- **/
+ */
 gint
 _gtk_scrolled_window_get_scrollbar_spacing (GtkScrolledWindow *scrolled_window)
 {