--- nimbus-0.1.1/gtk-engine/nimbus_style.c.orig	2009-04-21 15:59:37.886017000 +0900
+++ nimbus-0.1.1/gtk-engine/nimbus_style.c	2009-04-22 17:12:55.140243000 +0900
@@ -107,6 +107,19 @@ static void draw_nimbus_box	   (GtkStyle
 
 static GtkStyleClass *parent_class;
 
+static GtkTextDirection
+get_direction (GtkWidget *widget)
+{
+  GtkTextDirection dir;
+
+  if (widget)
+    dir = gtk_widget_get_direction (widget);
+  else
+    dir = GTK_TEXT_DIR_LTR;
+
+  return dir;
+}
+
 static gboolean check_sane_pixbuf_value (int src_x, int src_y, int width, int height, GdkPixbuf *pixbuf)
 {
   /*printf ("checking src_x = %d, int src_y = %d, int width = %d, int height = %d , pixbuf->height = %d, pixbuf->width = %d\n",
@@ -353,6 +366,7 @@ draw_arrow (GtkStyle      *style,
     {
       GList *tmp_list;
       int vsep_offset = 0;
+      int allocation_x, allocation_width;
       GType researched_type = g_type_from_name ("GtkVSeparator");
 
       /* get the vseparator offset if it exists */
@@ -371,21 +385,36 @@ draw_arrow (GtkStyle      *style,
       if (tmp_list)
 	 g_list_free(tmp_list);
 
+      if (get_direction (widget) == GTK_TEXT_DIR_RTL)
+	{
+          allocation_x = widget->allocation.x - vsep_offset;
+          allocation_width = widget->allocation.width + vsep_offset;
+	}
+      else
+	{
+         allocation_x = x - vsep_offset;
+         allocation_width = widget->parent->parent->allocation.x + widget->parent->parent->allocation.width - x + vsep_offset;
+	}
+
       draw_nimbus_box (style, window, state_type, shadow_type, NULL, widget, "combobox_arrow",
 		       rc->arrow_button[state_type],
 		       FALSE,
-		       x - vsep_offset,
+		       allocation_x,
 		       widget->parent->parent->allocation.y,
-		       widget->parent->parent->allocation.x + widget->parent->parent->allocation.width - x + vsep_offset,
+		       allocation_width,
 		       widget->parent->parent->allocation.height,
 		       NIMBUS_SPIN_NONE, GTK_ORIENTATION_HORIZONTAL);
 
+      if (get_direction (widget) == GTK_TEXT_DIR_RTL)
+         allocation_x = (x - vsep_offset) + (allocation_width - vsep_offset - gdk_pixbuf_get_width (rc->combo_arrow[state_type])) / 2;
+      else
+         allocation_x = (x - vsep_offset) + (widget->parent->parent->allocation.x + widget->parent->parent->allocation.width - x + vsep_offset - gdk_pixbuf_get_width (rc->combo_arrow[state_type])) / 2;
       if (rc->combo_arrow[state_type])
 	gdk_draw_pixbuf (window,
 			 get_clipping_gc (window, area),
 			 rc->combo_arrow[state_type],
 			 0,0,
-			 (x - vsep_offset) + (widget->parent->parent->allocation.x + widget->parent->parent->allocation.width - x + vsep_offset - gdk_pixbuf_get_width (rc->combo_arrow[state_type])) / 2,
+			 allocation_x,
 			 widget->parent->parent->allocation.y + (widget->parent->parent->allocation.height - gdk_pixbuf_get_height (rc->combo_arrow[state_type])) / 2 ,
 			 gdk_pixbuf_get_width (rc->combo_arrow[state_type]),
 			 gdk_pixbuf_get_height (rc->combo_arrow[state_type]),
@@ -509,7 +538,10 @@ draw_tab (GtkStyle      *style,
     button_area.width = widget->allocation.width - 2 * border_width;
     button_area.height = widget->allocation.height - 2 * border_width;
 
-    tab_x = button_area.x + button_area.width - 
+    if (get_direction (widget) == GTK_TEXT_DIR_RTL)
+      tab_x = button_area.x;
+    else
+      tab_x = button_area.x + button_area.width - 
 	    indicator_size.width - indicator_spacing.right - indicator_spacing.left - widget->style->xthickness;
 
     draw_nimbus_box (style, window, state_type, shadow_type, area, widget, "option_arrow",
@@ -1115,6 +1147,10 @@ draw_nimbus_box (GtkStyle      *style,
 {
   gboolean draw_top = TRUE, draw_bottom = TRUE, draw_partial_from_start = TRUE;
   NimbusData *rc = NIMBUS_RC_STYLE (style->rc_style)->data;
+  NimbusGradient *gradient;
+  NimbusButtonCorner corners;
+  GtkTextDirection direction = get_direction (widget);
+  GdkPixbuf *pixbuf;
 
   GSList *tmp;
   int drop_shadow_offset = 1;
@@ -1136,61 +1172,133 @@ draw_nimbus_box (GtkStyle      *style,
   tmp = button->gradients;
   while (tmp)
     {
-      nimbus_draw_gradient (window, style, area, (NimbusGradient*)tmp->data,
+      gradient = (NimbusGradient*)tmp->data;
+      corners = gradient->corners;
+
+      if ((direction == GTK_TEXT_DIR_RTL) &&
+          (gradient->corners & CORNER_TOP_LEFT) &&
+          ((gradient->corners & CORNER_TOP_RIGHT) == 0))
+        {
+          gradient->corners ^= CORNER_TOP_LEFT;
+          gradient->corners |= CORNER_TOP_RIGHT;
+        }
+      else if ((direction == GTK_TEXT_DIR_RTL) &&
+          ((gradient->corners & CORNER_TOP_LEFT) == 0) &&
+          (gradient->corners & CORNER_TOP_RIGHT))
+        {
+          gradient->corners |= CORNER_TOP_LEFT;
+          gradient->corners ^= CORNER_TOP_RIGHT;
+        }
+
+      if ((direction == GTK_TEXT_DIR_RTL) &&
+          (gradient->corners & CORNER_BOTTOM_LEFT) &&
+          ((gradient->corners & CORNER_BOTTOM_RIGHT) == NULL))
+        {
+          gradient->corners ^= CORNER_BOTTOM_LEFT;
+          gradient->corners |= CORNER_BOTTOM_RIGHT;
+        }
+      else if ((direction == GTK_TEXT_DIR_RTL) &&
+          ((gradient->corners & CORNER_BOTTOM_LEFT) == NULL) &&
+          (gradient->corners & CORNER_BOTTOM_RIGHT))
+        {
+          gradient->corners |= CORNER_BOTTOM_LEFT;
+          gradient->corners ^= CORNER_BOTTOM_RIGHT;
+        }
+
+      nimbus_draw_gradient (window, style, area, gradient,
 			    x, y, width, height - drop_shadow_offset, 
 			    partial_height, draw_partial_from_start,
 			    orientation, NO_TAB);
+
+      gradient->corners = corners;
       tmp = tmp->next;
     }
      
-  if (button->corner_top_left && draw_top)
+  if (direction == GTK_TEXT_DIR_RTL)
+    pixbuf = button->corner_top_right ?
+             gdk_pixbuf_flip (button->corner_top_right, TRUE) : NULL;
+  else
+    pixbuf = button->corner_top_left;
+
+  if (pixbuf && draw_top)
     gdk_draw_pixbuf (window,
     		 get_clipping_gc (window, area),
-    		 button->corner_top_left,
+    		 pixbuf,
     		 0,0,
     		 x,y,
-    		 gdk_pixbuf_get_width (button->corner_top_left),
-    		 gdk_pixbuf_get_height (button->corner_top_left),
+    		 gdk_pixbuf_get_width (pixbuf),
+    		 gdk_pixbuf_get_height (pixbuf),
     		 GDK_RGB_DITHER_NONE,0,0);
   
-  if (button->corner_top_right && draw_top)
+  if (pixbuf && direction == GTK_TEXT_DIR_RTL)
+    gdk_pixbuf_unref (pixbuf);
+
+  if (direction == GTK_TEXT_DIR_RTL)
+    pixbuf = button->corner_top_left ?
+             gdk_pixbuf_flip (button->corner_top_left, TRUE) : NULL;
+  else
+    pixbuf = button->corner_top_right;
+
+  if (pixbuf && draw_top)
     gdk_draw_pixbuf (window,
     		 get_clipping_gc (window, area),
-    		 button->corner_top_right,
+    		 pixbuf,
     		 0,0,
-    		 x+ width - gdk_pixbuf_get_width (button->corner_top_right),
+    		 x+ width - gdk_pixbuf_get_width (pixbuf),
     		 y,
-    		 gdk_pixbuf_get_width (button->corner_top_right),
-    		 gdk_pixbuf_get_height (button->corner_top_right),
+    		 gdk_pixbuf_get_width (pixbuf),
+    		 gdk_pixbuf_get_height (pixbuf),
     		 GDK_RGB_DITHER_NONE,0,0);
 
-  if (button->corner_bottom_left && draw_bottom)
+  if (pixbuf && direction == GTK_TEXT_DIR_RTL)
+    gdk_pixbuf_unref (pixbuf);
+
+  if (direction == GTK_TEXT_DIR_RTL)
+    pixbuf = button->corner_bottom_right ?
+             gdk_pixbuf_flip (button->corner_bottom_right, TRUE) : NULL;
+  else
+    pixbuf = button->corner_bottom_left;
+
+  if (pixbuf && draw_bottom)
     {
-      bottom_left_c_w = gdk_pixbuf_get_width (button->corner_bottom_left);
+      bottom_left_c_w = gdk_pixbuf_get_width (pixbuf);
       gdk_draw_pixbuf (window,
     		   get_clipping_gc (window, area),
-    		   button->corner_bottom_left,
+    		   pixbuf,
     		   0,0,
     		   x, 
-    		   y + height - gdk_pixbuf_get_height (button->corner_bottom_left),
+    		   y + height - gdk_pixbuf_get_height (pixbuf),
     		   bottom_left_c_w,
-    		   gdk_pixbuf_get_height (button->corner_bottom_left),
+    		   gdk_pixbuf_get_height (pixbuf),
     		   GDK_RGB_DITHER_NONE,0,0);
     }
-  if (button->corner_bottom_right && draw_bottom)
+
+  if (pixbuf && direction == GTK_TEXT_DIR_RTL)
+    gdk_pixbuf_unref (pixbuf);
+
+  if (direction == GTK_TEXT_DIR_RTL)
+    pixbuf = button->corner_bottom_left ?
+             gdk_pixbuf_flip (button->corner_bottom_left, TRUE) : NULL;
+  else
+    pixbuf = button->corner_bottom_right;
+
+  if (pixbuf && draw_bottom)
     {
-      bottom_right_c_w = gdk_pixbuf_get_width (button->corner_bottom_right);
+      bottom_right_c_w = gdk_pixbuf_get_width (pixbuf);
       gdk_draw_pixbuf (window,
     		   get_clipping_gc (window, area),
-    		   button->corner_bottom_right,
+    		   pixbuf,
     		   0,0,
     		   x+ width - bottom_right_c_w, 
-    		   y + height - gdk_pixbuf_get_height (button->corner_bottom_right),			 
+    		   y + height - gdk_pixbuf_get_height (pixbuf),			 
     		   bottom_right_c_w,
-    		   gdk_pixbuf_get_height (button->corner_bottom_right),
+    		   gdk_pixbuf_get_height (pixbuf),
     		   GDK_RGB_DITHER_NONE,0,0);
     }
   
+  if (pixbuf && direction == GTK_TEXT_DIR_RTL)
+    gdk_pixbuf_unref (pixbuf);
+
   if ((state_type != GTK_STATE_INSENSITIVE) && drop_shadow && draw_bottom)
     {
       GdkPixbuf **drop_shadow = NIMBUS_RC_STYLE (style->rc_style)->dark ? rc->dark_drop_shadow : rc->drop_shadow;
