[gitg] Fix sidebar rendering for RTL



commit 9a8a4687fbea4fe1beaedd18852c4ecd41d1a1c0
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Jan 4 23:21:58 2014 +0100

    Fix sidebar rendering for RTL

 libgitg/gitg-sidebar.vala |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/libgitg/gitg-sidebar.vala b/libgitg/gitg-sidebar.vala
index 9390a89..4646e72 100644
--- a/libgitg/gitg-sidebar.vala
+++ b/libgitg/gitg-sidebar.vala
@@ -329,16 +329,34 @@ public class SidebarRendererText : Gtk.CellRendererText
                }
                else
                {
+                       var rtl = (stx.get_state() & Gtk.StateFlags.DIR_RTL) != 0;
+
                        // render the text with an additional padding
                        Gdk.Rectangle area = cell_area;
-                       area.x += d_pixbuf.width + 3;
+
+                       var pad = d_pixbuf.width + 3;
+
+                       if (rtl)
+                       {
+                               area.width -= pad;
+                       }
+                       else
+                       {
+                               area.x += pad;
+                       }
 
                        base.render(ctx, widget, background_area, area, state);
 
                        // render the pixbuf
                        int yp = (cell_area.height - d_pixbuf.height) / 2;
+                       int x = cell_area.x;
+
+                       if (rtl)
+                       {
+                               x += cell_area.width - d_pixbuf.width;
+                       }
 
-                       stx.render_icon(ctx, d_pixbuf, cell_area.x, cell_area.y + yp);
+                       stx.render_icon(ctx, d_pixbuf, x, cell_area.y + yp);
                }
        }
 }


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