libegg r874 - in trunk: . libegg/toolpalette



Author: jap
Date: Sun Jun  1 09:31:43 2008
New Revision: 874
URL: http://svn.gnome.org/viewvc/libegg?rev=874&view=rev

Log:
2008-06-01  Jan Arne Petersen  <jpetersen openismus com>

	Add better support for RTL languages (#535235).

	* libegg/toolpalette/eggtoolitemgroup.c
	  (egg_tool_item_group_header_expose_event_cb): Paint the expander on
	  the opposite side if in RTL mode.
	  (egg_tool_item_group_header_adjust_style): In horizontal orientation
	  turn the label in the other direction in RTL mode.

	* libegg/toolpalette/eggtoolpalette.c
	(egg_tool_palette_size_allocate): Fix RTL mode.



Modified:
   trunk/ChangeLog
   trunk/libegg/toolpalette/eggtoolitemgroup.c
   trunk/libegg/toolpalette/eggtoolpalette.c

Modified: trunk/libegg/toolpalette/eggtoolitemgroup.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolitemgroup.c	(original)
+++ trunk/libegg/toolpalette/eggtoolitemgroup.c	Sun Jun  1 09:31:43 2008
@@ -179,13 +179,18 @@
   GtkExpanderStyle expander_style;
   GtkOrientation orientation;
   gint x, y;
+  GtkTextDirection direction;
 
   orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
   expander_style = group->priv->expander_style;
+  direction = gtk_widget_get_direction (widget);
 
   if (GTK_ORIENTATION_VERTICAL == orientation)
     {
-      x = widget->allocation.x + group->priv->expander_size / 2;
+      if (GTK_TEXT_DIR_RTL == direction)
+        x = widget->allocation.x + widget->allocation.width - group->priv->expander_size / 2;
+      else
+        x = widget->allocation.x + group->priv->expander_size / 2;
       y = widget->allocation.y + widget->allocation.height / 2;
     }
   else
@@ -237,6 +242,7 @@
   GtkWidget *label = gtk_bin_get_child (GTK_BIN (alignment));
   GtkWidget *widget = GTK_WIDGET (group);
   gint dx = 0, dy = 0;
+  GtkTextDirection direction = gtk_widget_get_direction (widget);
 
   gtk_widget_style_get (widget,
                         "header-spacing", &group->priv->header_spacing,
@@ -248,7 +254,10 @@
       case GTK_ORIENTATION_HORIZONTAL:
         dy = group->priv->header_spacing + group->priv->expander_size;
         gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE);
-        gtk_label_set_angle (GTK_LABEL (label), 90);
+        if (GTK_TEXT_DIR_RTL == direction)
+          gtk_label_set_angle (GTK_LABEL (label), -90);
+        else
+          gtk_label_set_angle (GTK_LABEL (label), 90);
         break;
 
       case GTK_ORIENTATION_VERTICAL:

Modified: trunk/libegg/toolpalette/eggtoolpalette.c
==============================================================================
--- trunk/libegg/toolpalette/eggtoolpalette.c	(original)
+++ trunk/libegg/toolpalette/eggtoolpalette.c	Sun Jun  1 09:31:43 2008
@@ -313,8 +313,12 @@
 
   gint min_offset = -1, max_offset = -1;
 
+  gint x;
+
   gint *group_sizes = g_newa(gint, palette->priv->groups_length);
 
+  GtkTextDirection direction = gtk_widget_get_direction (widget);
+
   GTK_WIDGET_CLASS (egg_tool_palette_parent_class)->size_allocate (widget, allocation);
 
   if (GTK_ORIENTATION_VERTICAL == palette->priv->orientation)
@@ -330,9 +334,9 @@
 
   if (adjustment)
     offset = gtk_adjustment_get_value (adjustment);
-
-  child_allocation.x = border_width;
-  child_allocation.y = border_width;
+  if (GTK_ORIENTATION_HORIZONTAL == palette->priv->orientation &&
+      GTK_TEXT_DIR_RTL == direction)
+    offset = -offset;
 
   if (GTK_ORIENTATION_VERTICAL == palette->priv->orientation)
     child_allocation.width = allocation->width - border_width * 2;
@@ -404,11 +408,16 @@
       offset = MIN(MAX (offset, max_offset - limit), min_offset);
     }
 
+  if (remaining_space > 0)
+    offset = 0;
+
+  x = border_width;
+  child_allocation.y = border_width;
+
   if (GTK_ORIENTATION_VERTICAL == palette->priv->orientation)
     child_allocation.y -= offset;
   else
-    child_allocation.x -= offset;
-
+    x -= offset;
 
   for (i = 0; i < palette->priv->groups_length; ++i)
     {
@@ -435,13 +444,19 @@
           else
             child_allocation.width = size;
 
+          if (GTK_ORIENTATION_HORIZONTAL == palette->priv->orientation &&
+              GTK_TEXT_DIR_RTL == direction)
+            child_allocation.x = allocation->width - x - child_allocation.width;
+          else
+            child_allocation.x = x;
+
           gtk_widget_size_allocate (widget, &child_allocation);
           gtk_widget_show (widget);
 
           if (GTK_ORIENTATION_VERTICAL == palette->priv->orientation)
             child_allocation.y += child_allocation.height;
           else
-            child_allocation.x += child_allocation.width;
+            x += child_allocation.width;
         }
       else
         gtk_widget_hide (widget);
@@ -456,10 +471,10 @@
     }
   else
     {
-      child_allocation.x += border_width;
-      child_allocation.x += offset;
+      x += border_width;
+      x += offset;
 
-      page_start = child_allocation.x;
+      page_start = x;
     }
 
   if (adjustment)
@@ -468,11 +483,26 @@
 
       adjustment->page_increment = page_size * 0.9;
       adjustment->step_increment = page_size * 0.1;
-      adjustment->upper = MAX (0, page_start);
       adjustment->page_size = page_size;
+      if (GTK_ORIENTATION_HORIZONTAL == palette->priv->orientation &&
+          GTK_TEXT_DIR_RTL == direction)
+        {
+          adjustment->lower = page_size - MAX (0, page_start);
+          adjustment->upper = page_size;
+
+          offset = -offset;
+
+          value = MAX(offset, adjustment->lower);
+          gtk_adjustment_clamp_page (adjustment, offset, value + page_size);
+        }
+      else
+        {
+          adjustment->lower = 0;
+          adjustment->upper = MAX (0, page_start);
 
-      value = MIN (offset, adjustment->upper - adjustment->page_size);
-      gtk_adjustment_clamp_page (adjustment, value, offset + page_size);
+          value = MIN (offset, adjustment->upper - adjustment->page_size);
+          gtk_adjustment_clamp_page (adjustment, value, offset + page_size);
+        }
 
       gtk_adjustment_changed (adjustment);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]