[gitg] Align author name and date in commit dialog



commit 98c1120a62f4fb9845b45bcee2b62bb1d0688bd9
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sun Jan 5 00:27:05 2014 +0100

    Align author name and date in commit dialog

 gitg/commit/gitg-commit-dialog.vala     |   22 +++++++++++++++++++---
 gitg/resources/ui/gitg-commit-dialog.ui |    4 ++--
 2 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
index fc587cf..3a485eb 100644
--- a/gitg/commit/gitg-commit-dialog.vala
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -297,18 +297,34 @@ class Dialog : Gtk.Dialog
                var name = d_author.get_name();
                var email = d_author.get_email();
 
-               d_label_user.set_label(@"$name <$email>");
+               var s = @"$name <$email>";
+               d_label_user.set_label(s);
+
+               var rtl = (get_style_context().get_state() & Gtk.StateFlags.DIR_RTL) != 0;
+
+               if (rtl == (Pango.find_base_dir(s, -1) != Pango.Direction.RTL))
+               {
+                       d_label_user.xalign = 1.0f;
+               }
 
                var t = d_author.get_time();
                var now = new DateTime.now_local();
+               string date_string;
 
                if (now.difference(t) < TimeSpan.SECOND * 5)
                {
-                       d_label_date.set_label("");
+                       date_string = "";
                }
                else
                {
-                       d_label_date.set_label((new Gitg.Date.for_date_time(t)).for_display());
+                       date_string = (new Gitg.Date.for_date_time(t)).for_display();
+               }
+
+               d_label_date.set_label(date_string);
+
+               if (rtl == (Pango.find_base_dir(date_string, -1) != Pango.Direction.RTL))
+               {
+                       d_label_date.xalign = 1.0f;
                }
 
                var ac = Gitg.AvatarCache.default();
diff --git a/gitg/resources/ui/gitg-commit-dialog.ui b/gitg/resources/ui/gitg-commit-dialog.ui
index c445d9d..7f8a160 100644
--- a/gitg/resources/ui/gitg-commit-dialog.ui
+++ b/gitg/resources/ui/gitg-commit-dialog.ui
@@ -81,9 +81,9 @@
               <object class="GtkLabel" id="label_user">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
                 <property name="valign">end</property>
                 <property name="hexpand">True</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">1</property>
@@ -96,9 +96,9 @@
               <object class="GtkLabel" id="label_date">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
                 <property name="valign">start</property>
                 <property name="hexpand">True</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">1</property>


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