Index: gtk/gtkpaned.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkpaned.h,v
retrieving revision 1.24
diff -u -b -B -p -r1.24 gtkpaned.h
--- gtk/gtkpaned.h	25 Oct 2002 16:28:14 -0000	1.24
+++ gtk/gtkpaned.h	29 Oct 2002 21:39:22 -0000
@@ -127,7 +127,8 @@ void    gtk_paned_set_position    (GtkPa
 void    gtk_paned_compute_position (GtkPaned  *paned,
 				    gint       allocation,
 				    gint       child1_req,
-				    gint       child2_req);
+				    gint       child2_req,
+				    gboolean   inverted);
 
 #ifndef GTK_DISABLE_DEPRECATED
 #define	gtk_paned_gutter_size(p,s)		(void) 0
Index: gtk/gtkpaned.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkpaned.c,v
retrieving revision 1.56
diff -u -b -B -p -r1.56 gtkpaned.c
--- gtk/gtkpaned.c	25 Oct 2002 16:28:13 -0000	1.56
+++ gtk/gtkpaned.c	29 Oct 2002 21:39:23 -0000
@@ -932,28 +932,47 @@ void
 gtk_paned_compute_position (GtkPaned *paned,
 			    gint      allocation,
 			    gint      child1_req,
-			    gint      child2_req)
+			    gint      child2_req,
+			    gboolean  inverted)
 {
-  gint old_position;
+  gint old_position = paned->child1_size;
+  gint req1, req2;
+  gboolean shrink1, shrink2;
+  gboolean resize1, resize2;
   
-  g_return_if_fail (GTK_IS_PANED (paned));
-
-  old_position = paned->child1_size;
+  if (inverted) 
+    {
+      req1 = child2_req;
+      req2 = child1_req;
+      shrink1 = paned->child2_shrink;
+      shrink2 = paned->child1_shrink;
+      resize1 = paned->child2_resize;
+      resize2 = paned->child1_resize;
+    }
+  else 
+    {
+      req1 = child1_req;
+      req2 = child2_req;
+      shrink1 = paned->child1_shrink;
+      shrink2 = paned->child2_shrink;
+      resize1 = paned->child1_resize;
+      resize2 = paned->child2_resize;
+    }
 
-  paned->min_position = paned->child1_shrink ? 0 : child1_req;
+  paned->min_position = shrink1 ? 0 : req1;
 
   paned->max_position = allocation;
-  if (!paned->child2_shrink)
-    paned->max_position = MAX (1, paned->max_position - child2_req);
+  if (!shrink2)
+    paned->max_position = MAX (1, paned->max_position - req2);
 
   if (!paned->position_set)
     {
-      if (paned->child1_resize && !paned->child2_resize)
-	paned->child1_size = MAX (0, allocation - child2_req);
-      else if (!paned->child1_resize && paned->child2_resize)
-	paned->child1_size = child1_req;
-      else if (child1_req + child2_req != 0)
-	paned->child1_size = allocation * ((gdouble)child1_req / (child1_req + child2_req));
+      if (resize1 && !resize2)
+	paned->child1_size = MAX (0, allocation - req2);
+      else if (!resize1 && resize2)
+	paned->child1_size = req1;
+      else if (req1 + req2 != 0)
+	paned->child1_size = allocation * ((gdouble)req1 / (req1 + req2));
       else
 	paned->child1_size = allocation * 0.5;
     }
@@ -964,9 +983,9 @@ gtk_paned_compute_position (GtkPaned *pa
        */
       if (paned->last_allocation > 0)
 	{
-	  if (paned->child1_resize && !paned->child2_resize)
+	  if (resize1 && !resize2)
 	    paned->child1_size += allocation - paned->last_allocation;
-	  else if (!(!paned->child1_resize && paned->child2_resize))
+	  else if (!(!resize1 && resize2))
 	    paned->child1_size = allocation * ((gdouble) paned->child1_size / (paned->last_allocation));
 	}
     }
@@ -975,8 +994,16 @@ gtk_paned_compute_position (GtkPaned *pa
 			      paned->min_position,
 			      paned->max_position);
 
+  if (inverted)
+    {
+      gtk_widget_set_child_visible (paned->child2, paned->child1_size != 0);
+      gtk_widget_set_child_visible (paned->child1, paned->child1_size != allocation);
+    }
+  else
+    {
   gtk_widget_set_child_visible (paned->child1, paned->child1_size != 0);
   gtk_widget_set_child_visible (paned->child2, paned->child1_size != allocation);
+    }
 
   if (paned->child1_size != old_position)
     g_object_notify (G_OBJECT (paned), "position");
Index: gtk/gtkhpaned.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkhpaned.c,v
retrieving revision 1.38
diff -u -b -B -p -r1.38 gtkhpaned.c
--- gtk/gtkhpaned.c	8 Oct 2002 23:07:01 -0000	1.38
+++ gtk/gtkhpaned.c	29 Oct 2002 21:39:23 -0000
@@ -149,8 +149,10 @@ gtk_hpaned_size_allocate (GtkWidget     
   if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
       paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
     {
-      GtkAllocation child1_allocation;
-      GtkAllocation child2_allocation;
+      GtkAllocation left_allocation;
+      GtkAllocation right_allocation;
+      GtkAllocation *child1_allocation;
+      GtkAllocation *child2_allocation;
       GtkRequisition child1_requisition;
       GtkRequisition child2_requisition;
       gint handle_size;
@@ -165,7 +167,8 @@ gtk_hpaned_size_allocate (GtkWidget     
 				       - handle_size
 				       - 2 * border_width),
 				  child1_requisition.width,
-				  child2_requisition.width);
+				  child2_requisition.width,
+				  gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
       
       paned->handle_pos.x = widget->allocation.x + paned->child1_size + border_width;
       paned->handle_pos.y = widget->allocation.y + border_width;
@@ -183,27 +186,38 @@ gtk_hpaned_size_allocate (GtkWidget     
 				  paned->handle_pos.height);
 	}
       
-      child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
-      child1_allocation.width = MAX (1, paned->child1_size);
-      child1_allocation.x = widget->allocation.x + border_width;
-      child1_allocation.y = child2_allocation.y = widget->allocation.y + border_width;
+      left_allocation.height = right_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
+      left_allocation.width = MAX (1, paned->child1_size);
+      left_allocation.x = widget->allocation.x + border_width;
+      left_allocation.y = right_allocation.y = widget->allocation.y + border_width;
       
-      child2_allocation.x = child1_allocation.x + paned->child1_size + paned->handle_pos.width;
-      child2_allocation.width = MAX (1, widget->allocation.x + widget->allocation.width - child2_allocation.x - border_width);
+      right_allocation.x = left_allocation.x + paned->child1_size + paned->handle_pos.width;
+      right_allocation.width = MAX (1, widget->allocation.x + widget->allocation.width - right_allocation.x - border_width);
+
+      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) 
+	{
+	  child1_allocation = &left_allocation; 
+	  child2_allocation = &right_allocation; 
+	}
+      else
+	{
+	  child1_allocation = &right_allocation; 
+	  child2_allocation = &left_allocation; 
+	}
 
       /* Now allocate the childen, making sure, when resizing not to
        * overlap the windows
        */
       if (GTK_WIDGET_MAPPED (widget) &&
-	  paned->child1->allocation.width < child1_allocation.width)
+	  paned->child1->allocation.width < child1_allocation->width)
 	{
-	  gtk_widget_size_allocate (paned->child2, &child2_allocation);
-	  gtk_widget_size_allocate (paned->child1, &child1_allocation);
+	  gtk_widget_size_allocate (paned->child2, child2_allocation);
+	  gtk_widget_size_allocate (paned->child1, child1_allocation);
 	}
       else
 	{
-	  gtk_widget_size_allocate (paned->child1, &child1_allocation);
-	  gtk_widget_size_allocate (paned->child2, &child2_allocation);
+	  gtk_widget_size_allocate (paned->child1, child1_allocation);
+	  gtk_widget_size_allocate (paned->child2, child2_allocation);
 	}
     }
   else
