]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkpaned.c
Added initial detailed docs for GtkCellArea.
[~andy/gtk] / gtk / gtkpaned.c
index 6d95aa19e2f0f08686a7b8e679cb77f073f49523..7c0958f5d825319eb36c8544ee41518af35ef1fd 100644 (file)
 
 #include "config.h"
 
+#include "gtkpaned.h"
+
 #include "gdk/gdkkeysyms.h"
 #include "gtkbindings.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkorientable.h"
-#include "gtkpaned.h"
 #include "gtkwindow.h"
+
 #include "gtkprivate.h"
 #include "gtkintl.h"
 
 
+/**
+ * SECTION:gtkpaned
+ * @Short_description: Base class for widgets with two adjustable panes
+ * @Title: GtkPaned
+ *
+ * #GtkPaned is the base class for widgets with two panes, arranged either
+ * horizontally (#GtkHPaned) or vertically (#GtkVPaned). Child widgets are
+ * added to the panes of the widget with gtk_paned_pack1() and
+ * gtk_paned_pack2(). The division between the two children is set by default
+ * from the size requests of the children, but it can be adjusted by the
+ * user.
+ *
+ * A paned widget draws a separator between the two child widgets and a
+ * small handle that the user can drag to adjust the division. It does not
+ * draw any relief around the children or around the separator. (The space
+ * in which the separator is called the gutter.) Often, it is useful to put
+ * each child inside a #GtkFrame with the shadow type set to %GTK_SHADOW_IN
+ * so that the gutter appears as a ridge. No separator is drawn if one of
+ * the children is missing.
+ *
+ * Each child has two options that can be set, @resize and @shrink. If
+ * @resize is true, then when the #GtkPaned is resized, that child will
+ * expand or shrink along with the paned widget. If @shrink is true, then
+ * that child can be made smaller than its requisition by the user.
+ * Setting @shrink to %FALSE allows the application to set a minimum size.
+ * If @resize is false for both children, then this is treated as if
+ * @resize is true for both children.
+ *
+ * The application can set the position of the slider as if it were set
+ * by the user, by calling gtk_paned_set_position().
+ *
+ * <example>
+ * <title>Creating a paned widget with minimum sizes.</title>
+ * <programlisting>
+ * GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ * GtkWidget *frame1 = gtk_frame_new (NULL);
+ * GtkWidget *frame2 = gtk_frame_new (NULL);
+ * gtk_frame_set_shadow_type (GTK_FRAME (frame1), GTK_SHADOW_IN);
+ * gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_IN);
+ *
+ * gtk_widget_set_size_request (hpaned, 200, -1);
+ *
+ * gtk_paned_pack1 (GTK_PANED (hpaned), frame1, TRUE, FALSE);
+ * gtk_widget_set_size_request (frame1, 50, -1);
+ *
+ * gtk_paned_pack2 (GTK_PANED (hpaned), frame2, FALSE, FALSE);
+ * gtk_widget_set_size_request (frame2, 50, -1);
+ * </programlisting>
+ * </example>
+ */
 
 struct _GtkPanedPrivate
 {
@@ -117,8 +169,13 @@ static void     gtk_paned_get_child_property    (GtkContainer     *container,
                                                  GParamSpec       *pspec);
 static void     gtk_paned_finalize              (GObject          *object);
 
-static void     gtk_paned_size_request          (GtkWidget        *widget,
-                                                 GtkRequisition   *requisition);
+static void     gtk_paned_get_preferred_width   (GtkWidget        *widget,
+                                                 gint             *minimum,
+                                                 gint             *natural);
+static void     gtk_paned_get_preferred_height  (GtkWidget        *widget,
+                                                 gint             *minimum,
+                                                 gint             *natural);
+
 static void     gtk_paned_size_allocate         (GtkWidget        *widget,
                                                  GtkAllocation    *allocation);
 static void     gtk_paned_realize               (GtkWidget        *widget);
@@ -127,8 +184,8 @@ static void     gtk_paned_map                   (GtkWidget        *widget);
 static void     gtk_paned_unmap                 (GtkWidget        *widget);
 static void     gtk_paned_state_changed         (GtkWidget        *widget,
                                                  GtkStateType      previous_state);
-static gboolean gtk_paned_expose                (GtkWidget        *widget,
-                                                GdkEventExpose   *event);
+static gboolean gtk_paned_draw                  (GtkWidget        *widget,
+                                                cairo_t          *cr);
 static gboolean gtk_paned_enter                 (GtkWidget        *widget,
                                                 GdkEventCrossing *event);
 static gboolean gtk_paned_leave                 (GtkWidget        *widget,
@@ -191,9 +248,9 @@ static void
 add_tab_bindings (GtkBindingSet    *binding_set,
                  GdkModifierType   modifiers)
 {
-  gtk_binding_entry_add_signal (binding_set, GDK_Tab, modifiers,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
                                 "toggle-handle-focus", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, modifiers,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
                                "toggle-handle-focus", 0);
 }
 
@@ -226,13 +283,14 @@ gtk_paned_class_init (GtkPanedClass *class)
   object_class->get_property = gtk_paned_get_property;
   object_class->finalize = gtk_paned_finalize;
 
-  widget_class->size_request = gtk_paned_size_request;
+  widget_class->get_preferred_width = gtk_paned_get_preferred_width;
+  widget_class->get_preferred_height = gtk_paned_get_preferred_height;
   widget_class->size_allocate = gtk_paned_size_allocate;
   widget_class->realize = gtk_paned_realize;
   widget_class->unrealize = gtk_paned_unrealize;
   widget_class->map = gtk_paned_map;
   widget_class->unmap = gtk_paned_unmap;
-  widget_class->expose_event = gtk_paned_expose;
+  widget_class->draw = gtk_paned_draw;
   widget_class->focus = gtk_paned_focus;
   widget_class->enter_notify_event = gtk_paned_enter;
   widget_class->leave_notify_event = gtk_paned_leave;
@@ -250,6 +308,7 @@ gtk_paned_class_init (GtkPanedClass *class)
   container_class->set_focus_child = gtk_paned_set_focus_child;
   container_class->set_child_property = gtk_paned_set_child_property;
   container_class->get_child_property = gtk_paned_get_child_property;
+  gtk_container_class_handle_border_width (container_class);
 
   paned_class->cycle_child_focus = gtk_paned_cycle_child_focus;
   paned_class->toggle_handle_focus = gtk_paned_toggle_handle_focus;
@@ -496,22 +555,22 @@ gtk_paned_class_init (GtkPanedClass *class)
 
   /* F6 and friends */
   gtk_binding_entry_add_signal (binding_set,
-                                GDK_F6, 0,
+                                GDK_KEY_F6, 0,
                                 "cycle-child-focus", 1, 
                                 G_TYPE_BOOLEAN, FALSE);
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_F6, GDK_SHIFT_MASK,
+                               GDK_KEY_F6, GDK_SHIFT_MASK,
                                "cycle-child-focus", 1,
                                G_TYPE_BOOLEAN, TRUE);
 
   /* F8 and friends */
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_F8, 0,
+                               GDK_KEY_F8, 0,
                                "cycle-handle-focus", 1,
                                G_TYPE_BOOLEAN, FALSE);
  
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_F8, GDK_SHIFT_MASK,
+                               GDK_KEY_F8, GDK_SHIFT_MASK,
                                "cycle-handle-focus", 1,
                                G_TYPE_BOOLEAN, TRUE);
  
@@ -522,54 +581,54 @@ gtk_paned_class_init (GtkPanedClass *class)
 
   /* accept and cancel positions */
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_Escape, 0,
+                               GDK_KEY_Escape, 0,
                                "cancel-position", 0);
 
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_Return, 0,
+                               GDK_KEY_Return, 0,
                                "accept-position", 0);
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_ISO_Enter, 0,
+                               GDK_KEY_ISO_Enter, 0,
                                "accept-position", 0);
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_KP_Enter, 0,
+                               GDK_KEY_KP_Enter, 0,
                                "accept-position", 0);
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_space, 0,
+                               GDK_KEY_space, 0,
                                "accept-position", 0);
   gtk_binding_entry_add_signal (binding_set,
-                               GDK_KP_Space, 0,
+                               GDK_KEY_KP_Space, 0,
                                "accept-position", 0);
 
   /* move handle */
-  add_move_binding (binding_set, GDK_Left, 0, GTK_SCROLL_STEP_LEFT);
-  add_move_binding (binding_set, GDK_KP_Left, 0, GTK_SCROLL_STEP_LEFT);
-  add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
-  add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
-
-  add_move_binding (binding_set, GDK_Right, 0, GTK_SCROLL_STEP_RIGHT);
-  add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
-  add_move_binding (binding_set, GDK_KP_Right, 0, GTK_SCROLL_STEP_RIGHT);
-  add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
-
-  add_move_binding (binding_set, GDK_Up, 0, GTK_SCROLL_STEP_UP);
-  add_move_binding (binding_set, GDK_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
-  add_move_binding (binding_set, GDK_KP_Up, 0, GTK_SCROLL_STEP_UP);
-  add_move_binding (binding_set, GDK_KP_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
-  add_move_binding (binding_set, GDK_Page_Up, 0, GTK_SCROLL_PAGE_UP);
-  add_move_binding (binding_set, GDK_KP_Page_Up, 0, GTK_SCROLL_PAGE_UP);
-
-  add_move_binding (binding_set, GDK_Down, 0, GTK_SCROLL_STEP_DOWN);
-  add_move_binding (binding_set, GDK_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
-  add_move_binding (binding_set, GDK_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
-  add_move_binding (binding_set, GDK_KP_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
-  add_move_binding (binding_set, GDK_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
-  add_move_binding (binding_set, GDK_KP_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
-
-  add_move_binding (binding_set, GDK_Home, 0, GTK_SCROLL_START);
-  add_move_binding (binding_set, GDK_KP_Home, 0, GTK_SCROLL_START);
-  add_move_binding (binding_set, GDK_End, 0, GTK_SCROLL_END);
-  add_move_binding (binding_set, GDK_KP_End, 0, GTK_SCROLL_END);
+  add_move_binding (binding_set, GDK_KEY_Left, 0, GTK_SCROLL_STEP_LEFT);
+  add_move_binding (binding_set, GDK_KEY_KP_Left, 0, GTK_SCROLL_STEP_LEFT);
+  add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
+  add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
+
+  add_move_binding (binding_set, GDK_KEY_Right, 0, GTK_SCROLL_STEP_RIGHT);
+  add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
+  add_move_binding (binding_set, GDK_KEY_KP_Right, 0, GTK_SCROLL_STEP_RIGHT);
+  add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
+
+  add_move_binding (binding_set, GDK_KEY_Up, 0, GTK_SCROLL_STEP_UP);
+  add_move_binding (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
+  add_move_binding (binding_set, GDK_KEY_KP_Up, 0, GTK_SCROLL_STEP_UP);
+  add_move_binding (binding_set, GDK_KEY_KP_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
+  add_move_binding (binding_set, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_UP);
+  add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0, GTK_SCROLL_PAGE_UP);
+
+  add_move_binding (binding_set, GDK_KEY_Down, 0, GTK_SCROLL_STEP_DOWN);
+  add_move_binding (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
+  add_move_binding (binding_set, GDK_KEY_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
+  add_move_binding (binding_set, GDK_KEY_KP_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
+  add_move_binding (binding_set, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
+  add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
+
+  add_move_binding (binding_set, GDK_KEY_Home, 0, GTK_SCROLL_START);
+  add_move_binding (binding_set, GDK_KEY_KP_Home, 0, GTK_SCROLL_START);
+  add_move_binding (binding_set, GDK_KEY_End, 0, GTK_SCROLL_END);
+  add_move_binding (binding_set, GDK_KEY_KP_End, 0, GTK_SCROLL_END);
 
   g_type_class_add_private (object_class, sizeof (GtkPanedPrivate));
 }
@@ -789,47 +848,47 @@ gtk_paned_finalize (GObject *object)
 }
 
 static void
-gtk_paned_size_request (GtkWidget      *widget,
-                        GtkRequisition *requisition)
+gtk_paned_get_preferred_size (GtkWidget      *widget,
+                              GtkOrientation  orientation,
+                              gint           *minimum,
+                              gint           *natural)
 {
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = paned->priv;
-  GtkRequisition child_requisition;
-  guint border_width;
+  gint child_min, child_nat;
 
-  requisition->width = 0;
-  requisition->height = 0;
+  *minimum = *natural = 0;
 
   if (priv->child1 && gtk_widget_get_visible (priv->child1))
     {
-      gtk_widget_size_request (priv->child1, &child_requisition);
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        gtk_widget_get_preferred_width (priv->child1, &child_min, &child_nat);
+      else
+        gtk_widget_get_preferred_height (priv->child1, &child_min, &child_nat);
 
-      requisition->height = child_requisition.height;
-      requisition->width = child_requisition.width;
+      *minimum = child_min;
+      *natural = child_nat;
     }
 
   if (priv->child2 && gtk_widget_get_visible (priv->child2))
     {
-      gtk_widget_size_request (priv->child2, &child_requisition);
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        gtk_widget_get_preferred_width (priv->child2, &child_min, &child_nat);
+      else
+        gtk_widget_get_preferred_height (priv->child2, &child_min, &child_nat);
 
-      if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+      if (priv->orientation == orientation)
         {
-          requisition->height = MAX (requisition->height,
-                                     child_requisition.height);
-          requisition->width += child_requisition.width;
+          *minimum += child_min;
+          *natural += child_nat;
         }
       else
         {
-          requisition->width = MAX (requisition->width,
-                                    child_requisition.width);
-          requisition->height += child_requisition.height;
+          *minimum = MAX (*minimum, child_min);
+          *natural = MAX (*natural, child_nat);
         }
     }
 
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (paned));
-  requisition->width += border_width * 2;
-  requisition->height += border_width * 2;
-
   if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
       priv->child2 && gtk_widget_get_visible (priv->child2))
     {
@@ -837,13 +896,30 @@ gtk_paned_size_request (GtkWidget      *widget,
 
       gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
 
-      if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-        requisition->width += handle_size;
-      else
-        requisition->height += handle_size;
+      if (priv->orientation == orientation)
+        {
+          *minimum += handle_size;
+          *natural += handle_size;
+        }
     }
 }
 
+static void
+gtk_paned_get_preferred_width (GtkWidget *widget,
+                               gint      *minimum,
+                               gint      *natural)
+{
+  gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
+}
+
+static void
+gtk_paned_get_preferred_height (GtkWidget *widget,
+                                gint      *minimum,
+                                gint      *natural)
+{
+  gtk_paned_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum, natural);
+}
+
 static void
 flip_child (GtkWidget     *widget,
             GtkAllocation *child_pos)
@@ -865,9 +941,6 @@ gtk_paned_size_allocate (GtkWidget     *widget,
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = paned->priv;
   GtkAllocation widget_allocation;
-  guint border_width;
-
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (paned));
 
   gtk_widget_set_allocation (widget, allocation);
 
@@ -884,8 +957,8 @@ gtk_paned_size_allocate (GtkWidget     *widget,
 
       gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
 
-      gtk_widget_get_child_requisition (priv->child1, &child1_requisition);
-      gtk_widget_get_child_requisition (priv->child2, &child2_requisition);
+      gtk_widget_get_preferred_size (priv->child1, &child1_requisition, NULL);
+      gtk_widget_get_preferred_size (priv->child2, &child2_requisition, NULL);
 
       old_handle_pos = priv->handle_pos;
 
@@ -894,24 +967,22 @@ gtk_paned_size_allocate (GtkWidget     *widget,
       if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
           gtk_paned_calc_position (paned,
-                                   MAX (1, widget_allocation.width
-                                        - handle_size
-                                        - 2 * border_width),
+                                   MAX (1, widget_allocation.width - handle_size),
                                    child1_requisition.width,
                                    child2_requisition.width);
 
-          priv->handle_pos.x = widget_allocation.x + priv->child1_size + border_width;
-          priv->handle_pos.y = widget_allocation.y + border_width;
+          priv->handle_pos.x = widget_allocation.x + priv->child1_size;
+          priv->handle_pos.y = widget_allocation.y;
           priv->handle_pos.width = handle_size;
-          priv->handle_pos.height = MAX (1, widget_allocation.height - 2 * border_width);
+          priv->handle_pos.height = widget_allocation.height;
 
-          child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
+          child1_allocation.height = child2_allocation.height = allocation->height;
           child1_allocation.width = MAX (1, priv->child1_size);
-          child1_allocation.x = widget_allocation.x + border_width;
-          child1_allocation.y = child2_allocation.y = widget_allocation.y + border_width;
+          child1_allocation.x = widget_allocation.x;
+          child1_allocation.y = child2_allocation.y = widget_allocation.y;
 
           child2_allocation.x = child1_allocation.x + priv->child1_size + priv->handle_pos.width;
-          child2_allocation.width = MAX (1, widget_allocation.x + widget_allocation.width - child2_allocation.x - border_width);
+          child2_allocation.width = MAX (1, widget_allocation.x + widget_allocation.width - child2_allocation.x);
 
           if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
             {
@@ -923,24 +994,22 @@ gtk_paned_size_allocate (GtkWidget     *widget,
       else
         {
           gtk_paned_calc_position (paned,
-                                   MAX (1, widget_allocation.height
-                                        - handle_size
-                                        - 2 * border_width),
+                                   MAX (1, widget_allocation.height - handle_size),
                                    child1_requisition.height,
                                    child2_requisition.height);
 
-          priv->handle_pos.x = widget_allocation.x + border_width;
-          priv->handle_pos.y = widget_allocation.y + priv->child1_size + border_width;
-          priv->handle_pos.width = MAX (1, (gint) widget_allocation.width - 2 * border_width);
+          priv->handle_pos.x = widget_allocation.x;
+          priv->handle_pos.y = widget_allocation.y + priv->child1_size;
+          priv->handle_pos.width = widget_allocation.width;
           priv->handle_pos.height = handle_size;
 
-          child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
+          child1_allocation.width = child2_allocation.width = allocation->width;
           child1_allocation.height = MAX (1, priv->child1_size);
-          child1_allocation.x = child2_allocation.x = widget_allocation.x + border_width;
-          child1_allocation.y = widget_allocation.y + border_width;
+          child1_allocation.x = child2_allocation.x = widget_allocation.x;
+          child1_allocation.y = widget_allocation.y;
 
           child2_allocation.y = child1_allocation.y + priv->child1_size + priv->handle_pos.height;
-          child2_allocation.height = MAX (1, widget_allocation.y + widget_allocation.height - child2_allocation.y - border_width);
+          child2_allocation.height = MAX (1, widget_allocation.y + widget_allocation.height - child2_allocation.y);
         }
 
       if (gtk_widget_get_mapped (widget) &&
@@ -1013,10 +1082,10 @@ gtk_paned_size_allocate (GtkWidget     *widget,
 
       gtk_widget_get_allocation (widget, &widget_allocation);
 
-      child_allocation.x = widget_allocation.x + border_width;
-      child_allocation.y = widget_allocation.y + border_width;
-      child_allocation.width = MAX (1, allocation->width - 2 * border_width);
-      child_allocation.height = MAX (1, allocation->height - 2 * border_width);
+      child_allocation.x = widget_allocation.x;
+      child_allocation.y = widget_allocation.y;
+      child_allocation.width = allocation->width;
+      child_allocation.height = allocation->height;
 
       if (priv->child1 && gtk_widget_get_visible (priv->child1))
        gtk_widget_size_allocate (priv->child1, &child_allocation);
@@ -1118,8 +1187,8 @@ gtk_paned_unmap (GtkWidget *widget)
 }
 
 static gboolean
-gtk_paned_expose (GtkWidget      *widget,
-                 GdkEventExpose *event)
+gtk_paned_draw (GtkWidget *widget,
+                cairo_t   *cr)
 {
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = paned->priv;
@@ -1129,6 +1198,9 @@ gtk_paned_expose (GtkWidget      *widget,
       priv->child2 && gtk_widget_get_visible (priv->child2))
     {
       GtkStateType state;
+      GtkAllocation allocation;
+
+      gtk_widget_get_allocation (widget, &allocation);
       
       if (gtk_widget_is_focus (widget))
        state = GTK_STATE_SELECTED;
@@ -1138,16 +1210,18 @@ gtk_paned_expose (GtkWidget      *widget,
        state = gtk_widget_get_state (widget);
 
       gtk_paint_handle (gtk_widget_get_style (widget),
-                        gtk_widget_get_window (widget),
+                        cr,
                        state, GTK_SHADOW_NONE,
-                       &priv->handle_pos, widget, "paned",
-                       priv->handle_pos.x, priv->handle_pos.y,
-                       priv->handle_pos.width, priv->handle_pos.height,
+                       widget, "paned",
+                       priv->handle_pos.x - allocation.x,
+                        priv->handle_pos.y - allocation.y,
+                       priv->handle_pos.width,
+                        priv->handle_pos.height,
                        !priv->orientation);
     }
 
   /* Chain up to draw children */
-  GTK_WIDGET_CLASS (gtk_paned_parent_class)->expose_event (widget, event);
+  GTK_WIDGET_CLASS (gtk_paned_parent_class)->draw (widget, cr);
   
   return FALSE;
 }
@@ -1197,8 +1271,6 @@ update_drag (GtkPaned *paned)
       size = pos;
     }
 
-  size -= gtk_container_get_border_width (GTK_CONTAINER (paned));
-  
   size = CLAMP (size, priv->min_position, priv->max_position);
 
   if (size != priv->child1_size)
@@ -1422,6 +1494,15 @@ gtk_paned_new (GtkOrientation orientation)
                        NULL);
 }
 
+/**
+ * gtk_paned_add1:
+ * @paned: a paned widget
+ * @child: the child to add
+ *
+ * Adds a child to the top or left pane with default parameters. This is
+ * equivalent to
+ * <literal>gtk_paned_pack1 (paned, child, FALSE, TRUE)</literal>.
+ */
 void
 gtk_paned_add1 (GtkPaned  *paned,
                GtkWidget *widget)
@@ -1429,6 +1510,15 @@ gtk_paned_add1 (GtkPaned  *paned,
   gtk_paned_pack1 (paned, widget, FALSE, TRUE);
 }
 
+/**
+ * gtk_paned_add2:
+ * @paned: a paned widget
+ * @child: the child to add
+ *
+ * Adds a child to the bottom or right pane with default parameters. This
+ * is equivalent to
+ * <literal>gtk_paned_pack2 (paned, child, TRUE, TRUE)</literal>.
+ */
 void
 gtk_paned_add2 (GtkPaned  *paned,
                GtkWidget *widget)
@@ -1436,6 +1526,15 @@ gtk_paned_add2 (GtkPaned  *paned,
   gtk_paned_pack2 (paned, widget, TRUE, TRUE);
 }
 
+/**
+ * gtk_paned_pack1:
+ * @paned: a paned widget
+ * @child: the child to add
+ * @resize: should this child expand when the paned widget is resized.
+ * @shrink: can this child be made smaller than its requisition.
+ *
+ * Adds a child to the top or left pane.
+ */
 void
 gtk_paned_pack1 (GtkPaned  *paned,
                 GtkWidget *child,
@@ -1459,6 +1558,15 @@ gtk_paned_pack1 (GtkPaned  *paned,
     }
 }
 
+/**
+ * gtk_paned_pack2:
+ * @paned: a paned widget
+ * @child: the child to add
+ * @resize: should this child expand when the paned widget is resized.
+ * @shrink: can this child be made smaller than its requisition.
+ *
+ * Adds a child to the bottom or right pane.
+ */
 void
 gtk_paned_pack2 (GtkPaned  *paned,
                 GtkWidget *child,
@@ -1632,7 +1740,7 @@ gtk_paned_set_position (GtkPaned *paned,
  * 
  * Obtains the first child of the paned widget.
  * 
- * Return value: first child, or %NULL if it is not set.
+ * Return value: (transfer none): first child, or %NULL if it is not set.
  *
  * Since: 2.4
  **/
@@ -1650,7 +1758,7 @@ gtk_paned_get_child1 (GtkPaned *paned)
  * 
  * Obtains the second child of the paned widget.
  * 
- * Return value: second child, or %NULL if it is not set.
+ * Return value: (transfer none): second child, or %NULL if it is not set.
  *
  * Since: 2.4
  **/
@@ -2352,7 +2460,7 @@ gtk_paned_toggle_handle_focus (GtkPaned *paned)
  * enables the callback to distinguish between the window
  * of the paned, a child and the handle.
  *
- * Return value: the paned's handle window.
+ * Return value: (transfer none): the paned's handle window.
  *
  * Since: 2.20
  **/