[Xfce4-commits] <xfce4-panel:devel> Support rtl in the tasklist.

Nick Schermer noreply at xfce.org
Sat Nov 28 21:02:06 CET 2009


Updating branch refs/heads/devel
         to aad85f6160c71652a38ddd09c7233c02e2890c86 (commit)
       from fccbc7211a0ac4ca8384dfa431eb17cf768ec766 (commit)

commit aad85f6160c71652a38ddd09c7233c02e2890c86
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Nov 28 18:52:45 2009 +0100

    Support rtl in the tasklist.

 plugins/tasklist/tasklist-widget.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index a55b6d6..c331dc2 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -588,6 +588,7 @@ xfce_tasklist_size_allocate (GtkWidget     *widget,
   XfceTasklistChild *child = NULL;
   guint              i;
   GtkAllocation      child_allocation;
+  gboolean           direction_rtl;
 
   /* set widget allocation */
   widget->allocation = *allocation;
@@ -643,6 +644,9 @@ xfce_tasklist_size_allocate (GtkWidget     *widget,
   child_allocation.width = width;
   child_allocation.height = height;
 
+  /* check if this is a rtl widget */
+  direction_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
+
   /* allocate all the children */
   for (li = tasklist->children, i = 0; li != NULL; li = li->next)
     {
@@ -655,18 +659,20 @@ xfce_tasklist_size_allocate (GtkWidget     *widget,
       /* calculate the child position */
       if (tasklist->horizontal)
         {
-          child_allocation.x = (i / rows) * width;
-          child_allocation.y = (i % rows) * height;
+          child_allocation.x = (i / rows) * width + allocation->x;
+          child_allocation.y = (i % rows) * height + allocation->y;
+
+          /* move to the other end of the panel if the direction is rtl */
+          if (G_UNLIKELY (direction_rtl))
+            child_allocation.x = allocation->x + allocation->width
+                - (child_allocation.x - allocation->x) - child_allocation.width;
         }
       else
         {
-          child_allocation.x = (i % rows) * width;
-          child_allocation.y = (i / rows) * height;
+          child_allocation.x = (i % rows) * width + allocation->x;
+          child_allocation.y = (i / rows) * height + allocation->y;
         }
 
-      child_allocation.x += allocation->x;
-      child_allocation.y += allocation->y;
-
       /* allocate the child */
       gtk_widget_size_allocate (child->button, &child_allocation);
 



More information about the Xfce4-commits mailing list