Merge lp:~haggai-eran/unity-greeter/rtl into lp:~robert-ancell/unity-greeter/trunk

Proposed by Haggai Eran
Status: Work in progress
Proposed branch: lp:~haggai-eran/unity-greeter/rtl
Merge into: lp:~robert-ancell/unity-greeter/trunk
Diff against target: 159 lines (+64/-11)
1 file modified
src/user-list.vala (+64/-11)
To merge this branch: bzr merge lp:~haggai-eran/unity-greeter/rtl
Reviewer Review Type Date Requested Status
Robert Ancell Needs Fixing
Review via email: mp+71665@code.launchpad.net

Description of the change

Hi,

I've tried making unity-greeter translatable, and mirror the interface for right-to-left locales. I'm a bit new to vala, so I hope this is right.
I had to change the code that renders text to use Pango, as otherwise Hebrew characters wouldn't render. It seems to have changed how things look a little bit also for the English version.
I don't know if this can be avoided though.

I'll be glad if someone would have a look at this.

Regards,
Haggai

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Hi,

Sorry for the delay in getting back to you. I've just merged another branch that does the translations:
https://code.launchpad.net/~kelemeng/unity-greeter/bug831026/+merge/72457

But the RTL stuff sounds good too. Could you update this branch to have just the RTL changes? I've also asked the design team if they have an opinion on RTL behaviour.

Also, to contribute patches to Unity greeter you need to have signed the contributor agreement [1], can you please look over that?

[1] http://www.canonical.com/contributors

Thanks,
--Robert

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Sure, I'll update my branch. About the contributor agreement, It will probably take me another two weeks to get my employer's approval, since everybody is on vacation right now. I'll tell you when I've signed it.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

See Bug #834386 which I've opened so this issue can be better discussed.

lp:~haggai-eran/unity-greeter/rtl updated
80. By Haggai Eran

Merged trunk changes.

Use pango font descriptor instead of ft2 font face.

81. By Haggai Eran

Fix username position with pango, and use absolute font size.

82. By Haggai Eran

Merged latest version. Use the new pango code.

83. By Haggai Eran

Handle entry ellipsizing according to the directionality.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Hi Haggai,

I just had a play with this, thanks for keeping it up to date!

The main issues seem to be:
- The settings menu (cog) is on the right - it should be moved to the left to match Mika's sketch
- If you have mixed LTR and RTL entries the layout looks confused (I recommend picking one, i.e. if there is any RTL names then flip them all, or perhaps pick the majority).
- The login indicators (arrows beside the name) are still on the left

I'd also recommend replacing some explicit variable types (bool, double) with 'var' as this makes it easier to read.

review: Needs Fixing
lp:~haggai-eran/unity-greeter/rtl updated
84. By Haggai Eran

Merge trunk.

85. By Haggai Eran

Remove some variables types, and unneeded attr_size_new_absolute decleration.

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Hi,

Perhaps we are not testing the greeter the same way, but for me the cog is on the left , and the login indicators are on the right. I've uploaded a screenshot to the bug here: https://bugs.launchpad.net/unity-greeter/+bug/834386/+attachment/2447007/+files/greeter-rtl.png

Are you testing the greeter with an RTL locale?

lp:~haggai-eran/unity-greeter/rtl updated
86. By Haggai Eran

Merge trunk.

87. By Haggai Eran

Align entries according to the global direction, and not based on their individual directions.

Unmerged revisions

87. By Haggai Eran

Align entries according to the global direction, and not based on their individual directions.

86. By Haggai Eran

Merge trunk.

85. By Haggai Eran

Remove some variables types, and unneeded attr_size_new_absolute decleration.

84. By Haggai Eran

Merge trunk.

83. By Haggai Eran

Handle entry ellipsizing according to the directionality.

82. By Haggai Eran

Merged latest version. Use the new pango code.

81. By Haggai Eran

Fix username position with pango, and use absolute font size.

80. By Haggai Eran

Merged trunk changes.

Use pango font descriptor instead of ft2 font face.

79. By Haggai Eran

Move indicator menu to the left on right-to-left locales.

78. By Haggai Eran

Correct the alignment for right-to-left languages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/user-list.vala'
2--- src/user-list.vala 2011-09-28 05:33:51 +0000
3+++ src/user-list.vala 2011-10-01 07:03:23 +0000
4@@ -786,6 +786,14 @@
5 }
6 e.layout = create_pango_layout (label);
7 e.layout.set_font_description (Pango.FontDescription.from_string ("Ubuntu 16"));
8+ e.layout.set_width ((box_width - 2) * grid_size * Pango.SCALE);
9+ e.layout.set_ellipsize (Pango.EllipsizeMode.END);
10+ e.layout.set_height (-1);
11+ // Using the text detected direction to determine alignment. Combined with the fact
12+ // that auto_dir is enabled, this should cause the alignment to only depend on the
13+ // global setting, and not on the text.
14+ var rtl_text = e.layout.get_line_readonly (0).resolved_dir == Pango.Direction.RTL;
15+ e.layout.set_alignment (!rtl_text ? Pango.Alignment.LEFT : Pango.Alignment.RIGHT);
16 e.background = background;
17 e.is_active = is_active;
18
19@@ -998,6 +1006,8 @@
20 private void get_selected_location (out int x, out int y)
21 {
22 x = get_grid_offset (get_allocated_width ()) + grid_size;
23+ if (get_direction() == Gtk.TextDirection.RTL)
24+ x = get_allocated_width () - x - box_width * grid_size;
25 var row = (int) (get_allocated_height () / grid_size - box_height) / 2;
26 y = get_grid_offset (get_allocated_height ()) + row * grid_size;
27 }
28@@ -1075,6 +1085,8 @@
29 if (resized)
30 debug ("Resized to %dx%d", get_allocated_width (), get_allocated_height ());
31
32+ var rtl = get_direction() == Gtk.TextDirection.RTL;
33+
34 Gtk.Requisition natural_size;
35 menubar.get_preferred_size (null, out natural_size);
36 var child_allocation = Gtk.Allocation ();
37@@ -1096,7 +1108,10 @@
38 prompt_entry.size_allocate (child_allocation);
39 login_button.size_allocate (child_allocation);
40
41- child_allocation.x = base_x + box_width * grid_size - grid_size - grid_size / 4;
42+ if (!rtl)
43+ child_allocation.x = base_x + box_width * grid_size - grid_size - grid_size / 4;
44+ else
45+ child_allocation.x = base_x + grid_size / 4;
46 child_allocation.y = base_y + grid_size / 4;
47 child_allocation.width = grid_size;
48 child_allocation.height = grid_size;
49@@ -1114,6 +1129,8 @@
50
51 private void draw_entry (Cairo.Context c, UserEntry entry, double alpha = 0.5)
52 {
53+ var rtl = get_direction() == Gtk.TextDirection.RTL;
54+
55 c.save ();
56
57 if (high_contrast_item.active)
58@@ -1121,15 +1138,28 @@
59
60 if (entry.is_active)
61 {
62- c.move_to (8, grid_size / 2 + 0.5 - 4);
63- c.rel_line_to (5, 4);
64- c.rel_line_to (-5, 4);
65+ if (!rtl)
66+ {
67+ c.move_to (8, grid_size / 2 + 0.5 - 4);
68+ c.rel_line_to (5, 4);
69+ c.rel_line_to (-5, 4);
70+ }
71+ else
72+ {
73+ c.move_to (box_width * grid_size - 8, grid_size / 2 + 0.5 - 4);
74+ c.rel_line_to (-5, 4);
75+ c.rel_line_to (5, 4);
76+ }
77 c.close_path ();
78 c.set_source_rgba (1.0, 1.0, 1.0, alpha);
79 c.fill ();
80 }
81
82- var mask = new Cairo.Pattern.linear (0, 0, grid_size * box_width, 0);
83+ Cairo.Pattern mask;
84+ if (!rtl)
85+ mask = new Cairo.Pattern.linear (0, 0, grid_size * box_width, 0);
86+ else
87+ mask = new Cairo.Pattern.linear (grid_size * box_width, 0, 0, 0);
88 var left = 1.0 - 2.0 / 7;
89 mask.add_color_stop_rgba (left, 1.0, 1.0, 1.0, alpha);
90 mask.add_color_stop_rgba (left + 64.0 / (grid_size * box_width), 1.0, 1.0, 1.0, 0.0);
91@@ -1137,7 +1167,9 @@
92
93 int w, h;
94 entry.layout.get_pixel_size (out w, out h);
95- c.translate (grid_size / 2, grid_size - (grid_size - (h)) / 2 - h);
96+ var x = grid_size / 2;
97+ if (rtl) x += grid_size;
98+ c.translate (x, grid_size - (grid_size - (h)) / 2 - h);
99 c.move_to (0, 0);
100 Pango.cairo_show_layout (c, entry.layout);
101
102@@ -1226,6 +1258,8 @@
103
104 draw_background (c);
105
106+ var rtl = get_direction() == Gtk.TextDirection.RTL;
107+
108 c.save ();
109
110 int base_x, base_y;
111@@ -1288,16 +1322,31 @@
112
113 if (selected_entry.is_active)
114 {
115- c.move_to (8, text_y + h / 2 + 0.5 - 4);
116- c.rel_line_to (5, 4);
117- c.rel_line_to (-5, 4);
118+ if (!rtl)
119+ {
120+ c.move_to (8, text_y + h / 2 + 0.5 - 4);
121+ c.rel_line_to (5, 4);
122+ c.rel_line_to (-5, 4);
123+ }
124+ else
125+ {
126+ c.move_to (box_width * grid_size - 8, text_y + h / 2 + 0.5 - 4);
127+ c.rel_line_to (-5, 4);
128+ c.rel_line_to (5, 4);
129+ }
130 c.close_path ();
131 c.set_source_rgb (1.0, 1.0, 1.0);
132 c.fill ();
133 }
134
135- c.move_to (grid_size / 2, text_y);
136- var mask = new Cairo.Pattern.linear (0, 0, grid_size * box_width, 0);
137+ var x = grid_size / 2;
138+ if (rtl) x += grid_size;
139+ c.move_to (x, text_y);
140+ Cairo.Pattern mask;
141+ if (!rtl)
142+ mask = new Cairo.Pattern.linear (0, 0, grid_size * box_width, 0);
143+ else
144+ mask = new Cairo.Pattern.linear (grid_size * box_width, 0, 0, 0);
145 var left = 1.0 - 2.0 / 7;
146 mask.add_color_stop_rgba (left, 1.0, 1.0, 1.0, 1.0);
147 mask.add_color_stop_rgba (left + 5.4 / (grid_size * box_width), 1.0, 1.0, 1.0, 0.5);
148@@ -1315,7 +1364,11 @@
149 text = error;
150
151 var layout = create_pango_layout (text);
152+ layout.set_width ((grid_size * (box_width - 1)) * Pango.SCALE);
153+ layout.set_ellipsize (Pango.EllipsizeMode.END);
154+ layout.set_height (-1);
155 layout.set_font_description (Pango.FontDescription.from_string ("Ubuntu 10"));
156+ layout.set_alignment (!rtl ? Pango.Alignment.LEFT : Pango.Alignment.RIGHT);
157 int w, h;
158 layout.get_pixel_size (out w, out h);
159 c.move_to (grid_size / 2, grid_size * 1.25 - h);

Subscribers

People subscribed via source and target branches