After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 584662 - RTL locales
RTL locales
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Florian Müllner
gnome-shell-maint
: 605373 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-06-02 21:19 UTC by Dan Winship
Modified: 2011-03-22 18:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[StWidget] add API support for right-to-left UI (2.48 KB, patch)
2009-10-28 17:24 UTC, Abderrahim Kitouni
needs-work Details | Review
[StBoxLayout] now RTL aware (2.59 KB, patch)
2009-10-28 17:25 UTC, Abderrahim Kitouni
needs-work Details | Review
[StTable] now RTL aware (5.62 KB, patch)
2009-10-28 17:25 UTC, Abderrahim Kitouni
reviewed Details | Review
environment.js: set default direction for St widgets (1.02 KB, patch)
2009-10-28 17:26 UTC, Abderrahim Kitouni
reviewed Details | Review
[StWidget] add API support for right-to-left UI (2.62 KB, patch)
2009-11-15 19:47 UTC, Abderrahim Kitouni
committed Details | Review
[StBoxLayout] now RTL aware (2.62 KB, patch)
2009-11-15 19:47 UTC, Abderrahim Kitouni
committed Details | Review
[StTable] now RTL aware (5.68 KB, patch)
2009-11-15 19:47 UTC, Abderrahim Kitouni
committed Details | Review
environment.js: set default direction for St widgets (1.08 KB, patch)
2009-11-15 19:47 UTC, Abderrahim Kitouni
committed Details | Review
calendar.js: switch buttons direction in RTL mode (1.99 KB, patch)
2009-12-26 19:16 UTC, Abderrahim Kitouni
committed Details | Review
statusmenu.js: fix menu position for RTL locales (1.13 KB, patch)
2009-12-26 19:16 UTC, Abderrahim Kitouni
none Details | Review
overview.js: fix manual placement for RTL locales (3.32 KB, patch)
2009-12-26 19:16 UTC, Abderrahim Kitouni
none Details | Review
NOT WORKING: fix hot corner position for RTL locales (3.63 KB, patch)
2009-12-26 19:17 UTC, Abderrahim Kitouni
none Details | Review
panel.js: fix right and left boxes for RTL locales (1.64 KB, patch)
2010-01-22 10:11 UTC, Abderrahim Kitouni
none Details | Review
NOT WORKING: fix hot corner position for RTL locales (2.32 KB, patch)
2010-01-22 10:16 UTC, Abderrahim Kitouni
none Details | Review
[statusmenu] fix menu position for RTL locales (1.13 KB, patch)
2010-01-27 10:43 UTC, Abderrahim Kitouni
committed Details | Review
[overview] fix manual placement for RTL locales (2.42 KB, patch)
2010-01-27 10:46 UTC, Abderrahim Kitouni
committed Details | Review
[panel] fix positions for RTL locales (3.95 KB, patch)
2010-01-27 10:48 UTC, Abderrahim Kitouni
needs-work Details | Review
[panel] fix app icon fading for RTL locales (2.39 KB, patch)
2010-02-10 18:52 UTC, Abderrahim Kitouni
needs-work Details | Review
[windowManager] fix minimize animation for RTL locales (1.37 KB, patch)
2010-02-12 15:02 UTC, Abderrahim Kitouni
committed Details | Review
[overview, StBin] fix workspace controls for RTL locales (1.35 KB, patch)
2010-02-12 15:19 UTC, Abderrahim Kitouni
none Details | Review
[overview] fix workspace controls for RTL locales (996 bytes, patch)
2010-03-01 19:46 UTC, Abderrahim Kitouni
committed Details | Review
[appDisplay] fix AppIconMenu position in RTL locales (1.03 KB, patch)
2010-03-01 19:52 UTC, Abderrahim Kitouni
needs-work Details | Review
[StScrollView] put vertical scrollbar to the left for RTL locales (1.75 KB, patch)
2010-03-01 20:00 UTC, Abderrahim Kitouni
needs-work Details | Review
[panel] WIP: fix ripple animation for RTL locales (1.70 KB, patch)
2010-03-01 20:05 UTC, Abderrahim Kitouni
needs-work Details | Review
st: add rtl and ltr pseudo class selectors (1.69 KB, patch)
2010-11-30 18:37 UTC, Abderrahim Kitouni
needs-work Details | Review
[panel] fix ripple animation for RTL locales (5.66 KB, patch)
2010-11-30 18:40 UTC, Abderrahim Kitouni
none Details | Review
[panel] fix ripple animation for RTL locales (6.06 KB, patch)
2010-11-30 19:42 UTC, Abderrahim Kitouni
committed Details | Review

Description Dan Winship 2009-06-02 21:19:30 UTC
How should gnome-shell look in RTL locales? Assuming we want the standard "flip everything horizontally", we're going to need to patch BigBox to support that, and fix up a lot of other manual actor placement, eg in the overlay.
Comment 1 Abderrahim Kitouni 2009-10-24 14:29:13 UTC
Ok, I have something (mostly) working locally (by hardcoding RTL), it seems it's not very difficult, I have however some questions :

about patching BigBox, should the "flip everything horizontally for rtl locale" logic be in it, or just an inverted horizontal (and vertical) orientation laying components right-to-left (and bottom-to-top). Although it would be less work to do, I don't think that BigBox should be locale-aware (let alone locale-dependent).

about manual placement, the only problem remaining is the _paneContainer, as it doesn't have a fixed width, and connecting to notify::width doesn't seem to work.
(I've added a function to calculate the x coordinate based on (x, width))
Comment 2 Dan Winship 2009-10-24 15:26:22 UTC
(In reply to comment #1)
> about patching BigBox, should the "flip everything horizontally for rtl locale"
> logic be in it, or just an inverted horizontal (and vertical) orientation
> laying components right-to-left (and bottom-to-top). Although it would be less
> work to do, I don't think that BigBox should be locale-aware (let alone
> locale-dependent).

The way this works in Gtk is that a widget can call gtk_widget_get_direction() on itself, which returns GTK_TEXT_DIR_LTR or GTK_TEXT_DIR_RTL (based on the locale), and then the widget can adjust the way it lays things out accordingly. We probably want to do something similar.

> about manual placement, the only problem remaining is the _paneContainer, as it
> doesn't have a fixed width, and connecting to notify::width doesn't seem to
> work.
> (I've added a function to calculate the x coordinate based on (x, width))

Well, a lot of the existing non-StWidget-based layout will eventually be redone using StBoxLayout, StTable, etc. (eg, bug 598463). So I'm not sure how much time we should spend thinking about that stuff now.

Adding something like gtk_widget_get_direction() to StWidget, and making StBoxLayout and StTable use it would definitely be useful though.
Comment 3 Abderrahim Kitouni 2009-10-26 18:37:47 UTC
(In reply to comment #2)
> Well, a lot of the existing non-StWidget-based layout will eventually be redone
> using StBoxLayout, StTable, etc. (eg, bug 598463). So In'm not sure how much
> time we should spend thinking about that stuff now.
> 
> Adding something like gtk_widget_get_direction() to StWidget, and making
> StBoxLayout and StTable use it would definitely be useful though.

Done :-)
well, mostly, what's missing is the logic for get_direction, gtk has a per-widget direction (set_direction/get_direction) and a global direction (set_default_direction/get_default_direction) for widgets that don't have a direction assigned. It is set to either RTL or LTR on startup based on a gettext translation.

so the questions are:
* should st have as much flexibility as gtk or something like get_default_direction is enough? (if it's specific to gnome-shell, I guess the latter)
* how to determine if we want RTL? st doesn't use gettext for now, and hardcoding ar, fa and he will get bug reports as soon as shell is widely used.
the solution I'm leaning towards now is to have a set_direction/get_direction and using the same translation trick as gtk but in the shell (and call set_direction from there).

thoughts?

(and btw, is anyone working on replacing the manual placement in the shell with layout based on StTable, or should I try to tackle it once this problem is sorted out?)
Comment 4 Dan Winship 2009-10-26 20:49:56 UTC
(In reply to comment #3)
> * should st have as much flexibility as gtk or something like
> get_default_direction is enough?

Well... hm... I think looking glass (the debugging console) would want to have LTR directionality even in an RTL locale, since you use it to type javascript, which would be (at least mostly) ASCII. So I guess we have a use case for per-widget directionality override.

> * how to determine if we want RTL? st doesn't use gettext for now, and
> hardcoding ar, fa and he will get bug reports as soon as shell is widely used.
> the solution I'm leaning towards now is to have a set_direction/get_direction
> and using the same translation trick as gtk but in the shell (and call
> set_direction from there).

Well, we'll probably need gettext in St at some point, but maybe not for a while, so that sounds good.

> (and btw, is anyone working on replacing the manual placement in the shell with
> layout based on StTable, or should I try to tackle it once this problem is
> sorted out?)

It's being done in bits and pieces. If you want to tackle a piece, first make sure there isn't a bug open about it already, and then file a bug of your own to "claim" it so we don't duplicate effort.
Comment 5 Colin Walters 2009-10-27 12:13:50 UTC
Note there's a lot of development relating to boxes going on in Clutter 1.2; we may want to consider a rebase to that branch some point relatively soon.
Comment 6 Owen Taylor 2009-10-27 13:07:15 UTC
(In reply to comment #5)
> Note there's a lot of development relating to boxes going on in Clutter 1.2; we
> may want to consider a rebase to that branch some point relatively soon.

There's a balancing job here between:

 - Testing out the new Clutter functionality and makes sure it works for us
 - Having GNOME Shell versions that can be built for and packaged with
   current operating systems

My feeling right now is that we probably want to wait at least another month before doing such a cut-over.
Comment 7 Owen Taylor 2009-10-27 13:14:49 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Well, a lot of the existing non-StWidget-based layout will eventually be redone
> > using StBoxLayout, StTable, etc. (eg, bug 598463). So In'm not sure how much
> > time we should spend thinking about that stuff now.
> > 
> > Adding something like gtk_widget_get_direction() to StWidget, and making
> > StBoxLayout and StTable use it would definitely be useful though.
> 
> Done :-)
> well, mostly, what's missing is the logic for get_direction, gtk has a
> per-widget direction (set_direction/get_direction) and a global direction
> (set_default_direction/get_default_direction) for widgets that don't have a
> direction assigned. It is set to either RTL or LTR on startup based on a
> gettext translation.
> 
> so the questions are:
> * should st have as much flexibility as gtk or something like
> get_default_direction is enough? (if it's specific to gnome-shell, I guess the
> latter)

The canonical case where per-widget directions is useful if you have a box with a arrows to move left and move right [ <= ] [ => ]. If you swap the layout in the box it doesn't make any sense. My guess is that some things like this will come up for the shell

> * how to determine if we want RTL? st doesn't use gettext for now, and
> hardcoding ar, fa and he will get bug reports as soon as shell is widely used.
> the solution I'm leaning towards now is to have a set_direction/get_direction
> and using the same translation trick as gtk but in the shell (and call
> set_direction from there).

That sounds fine to me - you can even use the GTK+ translation domain and avoid adding a shell-specific string to translate - see how calendar:MY is handled in calender.js.
Comment 8 Abderrahim Kitouni 2009-10-27 14:27:08 UTC
(In reply to comment #4)
> Well... hm... I think looking glass (the debugging console) would want to have
> LTR directionality even in an RTL locale, since you use it to type javascript,
> which would be (at least mostly) ASCII. So I guess we have a use case for
> per-widget directionality override.
right now, I've only converted BoxLayout and Table, and it looks fine in the looking glass (with the "introspect" button to the right). I'm not sure if we want to do the same for Entry.

> 
> > (and btw, is anyone working on replacing the manual placement in the shell with
> > layout based on StTable, or should I try to tackle it once this problem is
> > sorted out?)
> 
> It's being done in bits and pieces. If you want to tackle a piece, first make
> sure there isn't a bug open about it already, and then file a bug of your own
> to "claim" it so we don't duplicate effort.
I was talking about the overlay (which is the most visible thing). I'll file a bug once I finish this.

(In reply to comment #7)
> The canonical case where per-widget directions is useful if you have a box with
> a arrows to move left and move right [ <= ] [ => ]. If you swap the layout in
> the box it doesn't make any sense. My guess is that some things like this will
> come up for the shell
I guess we can swap the arrows and have them mean previous and next instead (I think this would also reduce special casing in the code).

Any other argument? ;-p
(I can do it anyway if you think it's useful to have)
Comment 9 Owen Taylor 2009-10-27 15:29:59 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > The canonical case where per-widget directions is useful if you have a box with
> > a arrows to move left and move right [ <= ] [ => ]. If you swap the layout in
> > the box it doesn't make any sense. My guess is that some things like this will
> > come up for the shell
> I guess we can swap the arrows and have them mean previous and next instead (I
> think this would also reduce special casing in the code).
> 
> Any other argument? ;-p
> (I can do it anyway if you think it's useful to have)

I'm talking about arrows that mean "move left" and "move right" in this case, not arrows that mean "next" and "previous". 

The functionality is needed to be complete, we could wait until we hit such a case, but since its only a couple of functions, I'd be favor of just going ahead and adding it now, and making things work just like GTK+ (except for the direction-changed signal, which is a complexity we don't need right now.)
Comment 10 Abderrahim Kitouni 2009-10-28 17:24:46 UTC
Created attachment 146435 [details] [review]
[StWidget] add API support for right-to-left UI
Comment 11 Abderrahim Kitouni 2009-10-28 17:25:28 UTC
Created attachment 146436 [details] [review]
[StBoxLayout] now RTL aware
Comment 12 Abderrahim Kitouni 2009-10-28 17:25:41 UTC
Created attachment 146437 [details] [review]
[StTable] now RTL aware
Comment 13 Abderrahim Kitouni 2009-10-28 17:26:09 UTC
Created attachment 146438 [details] [review]
environment.js: set default direction for St widgets
Comment 14 Dan Winship 2009-11-02 20:15:03 UTC
Comment on attachment 146435 [details] [review]
[StWidget] add API support for right-to-left UI

>+  g_return_if_fail(dir != ST_DIRECTION_NONE);

need a space before the "(". Likewise in many other places in all 4 patches

>+typedef enum {
>+  ST_DIRECTION_NONE,
>+  ST_DIRECTION_LTR,
>+  ST_DIRECTION_RTL
>+} StDirection;

I think I'd prefer "StTextDirection", like with Gtk. You can keep the method names the same though.
Comment 15 Dan Winship 2009-11-02 20:16:50 UTC
Comment on attachment 146436 [details] [review]
[StBoxLayout] now RTL aware

>+      else if (flip)
>+        {
>+          child_box.x1 = (int)(0.5 + next_position);
>+          child_box.x2 = (int)(0.5 + position);

Those two lines are the only difference between the flip and non-flip horizontal cases. It would be better to have just those lines inside the if(flip)/else, and everything else shared between them.
Comment 16 Dan Winship 2009-11-02 20:17:37 UTC
Comment on attachment 146437 [details] [review]
[StTable] now RTL aware

looks good, other than some space-before-( issues
Comment 17 Dan Winship 2009-11-02 20:17:58 UTC
Comment on attachment 146438 [details] [review]
environment.js: set default direction for St widgets

likewise
Comment 18 Abderrahim Kitouni 2009-11-15 19:47:00 UTC
Created attachment 147816 [details] [review]
[StWidget] add API support for right-to-left UI
Comment 19 Abderrahim Kitouni 2009-11-15 19:47:12 UTC
Created attachment 147817 [details] [review]
[StBoxLayout] now RTL aware
Comment 20 Abderrahim Kitouni 2009-11-15 19:47:24 UTC
Created attachment 147818 [details] [review]
[StTable] now RTL aware
Comment 21 Abderrahim Kitouni 2009-11-15 19:47:34 UTC
Created attachment 147819 [details] [review]
environment.js: set default direction for St widgets
Comment 22 Dan Winship 2009-11-16 16:48:00 UTC
Looks good. Thanks for the patches.

Attachment 147816 [details] pushed as a5edc78 - [StWidget] add API support for right-to-left UI
Attachment 147817 [details] pushed as 4e8206d - [StBoxLayout] now RTL aware
Attachment 147818 [details] pushed as 3529b8c - [StTable] now RTL aware
Attachment 147819 [details] pushed as 9ba5ca0 - environment.js: set default direction for St widgets
Comment 23 Abderrahim Kitouni 2009-12-26 19:16:14 UTC
Created attachment 150416 [details] [review]
calendar.js: switch buttons direction in RTL mode

also don't hang if translation of 'calendar:week_start:0' is incorrect
Comment 24 Abderrahim Kitouni 2009-12-26 19:16:34 UTC
Created attachment 150417 [details] [review]
statusmenu.js: fix menu position for RTL locales
Comment 25 Abderrahim Kitouni 2009-12-26 19:16:59 UTC
Created attachment 150418 [details] [review]
overview.js: fix manual placement for RTL locales
Comment 26 Abderrahim Kitouni 2009-12-26 19:17:24 UTC
Created attachment 150419 [details] [review]
NOT WORKING: fix hot corner position for RTL locales
Comment 27 Abderrahim Kitouni 2009-12-26 19:41:13 UTC
(In reply to comment #26)
> Created an attachment (id=150419) [details] [review]
> NOT WORKING: fix hot corner position for RTL locales

This is where I  was able to do, I've left the debugging things: the problem is that here the hot corner is no longer "hot" as soon as it's less than 4 pixels away from the end of screen (so either it's not hot or not a corner)
Comment 28 Owen Taylor 2009-12-26 21:10:20 UTC
Reopening as requested on IRC; in general, I'd suggest not extending bugs once they are closed - just open a new one.
Comment 29 Dan Winship 2010-01-04 14:12:43 UTC
*** Bug 605373 has been marked as a duplicate of this bug. ***
Comment 30 Dan Winship 2010-01-20 22:25:54 UTC
Comment on attachment 150416 [details] [review]
calendar.js: switch buttons direction in RTL mode

Attachment 150416 [details] pushed as 7bb14bd - calendar.js: switch buttons direction in RTL mode
Comment 31 Dan Winship 2010-01-20 22:30:51 UTC
when I run "LANG=ar_SA.UTF8 ./src/gnome-shell", the panel is still in LTR order ("Activities" button on the left, but with the word translated into Arabic), and user menu on the right. Applying the statusmenu and overview patches makes it so that when I click on my username on the right side of the screen, the status menu pops up on the left side, and when I click on "الأنشطة" on the left side of the screen, it opens the overview with the dashboard on the right.

Maybe you've got another patch locally that you forgot to attach here?
Comment 32 Abderrahim Kitouni 2010-01-22 10:08:40 UTC
My fault, the last patch (with a big NOT WORKING warning) needs to be split in two.
Comment 33 Abderrahim Kitouni 2010-01-22 10:11:58 UTC
Created attachment 151992 [details] [review]
panel.js: fix right and left boxes for RTL locales
Comment 34 Abderrahim Kitouni 2010-01-22 10:16:51 UTC
Created attachment 151994 [details] [review]
NOT WORKING: fix hot corner position for RTL locales
Comment 35 Dan Winship 2010-01-22 16:12:26 UTC
(In reply to comment #32)
> My fault, the last patch (with a big NOT WORKING warning) needs to be split in
> two.

oh, i see. Of course, it makes more sense as a single patch once it's working.

(In reply to comment #27)
> > NOT WORKING: fix hot corner position for RTL locales
> 
> This is where I  was able to do, I've left the debugging things: the problem is
> that here the hot corner is no longer "hot" as soon as it's less than 4 pixels
> away from the end of screen (so either it's not hot or not a corner)

It looks like the problem is in the CSS (data/theme/gnome-shell.css):

#panelLeft {
    padding-right: 4px;
}

#panelRight {
    padding-left: 4px;
}

Those end up putting the padding on the wrong side when we flip RTL. (If you change #panelLeft to have padding-left instead, then the hotspot works fine on the corner.)

Should the CSS properties flip automatically? Does HTML set any precedent here?
Comment 36 Abderrahim Kitouni 2010-01-27 10:43:05 UTC
Created attachment 152385 [details] [review]
[statusmenu] fix menu position for RTL locales

I'm sending the latest version of the patches, everything works ok now.
(I still need to fix other things though, e.g. the new workspace view)
Comment 37 Abderrahim Kitouni 2010-01-27 10:46:23 UTC
Created attachment 152386 [details] [review]
[overview] fix manual placement for RTL locales
Comment 38 Abderrahim Kitouni 2010-01-27 10:48:33 UTC
Created attachment 152387 [details] [review]
[panel] fix positions for RTL locales

the [leftBox, rightBox] variables could have a better name, but I couldn't find one. leading/trailing ? activities/status ?
Comment 39 Abderrahim Kitouni 2010-02-10 18:52:12 UTC
Created attachment 153454 [details] [review]
[panel] fix app icon fading for RTL locales

I'm not sure this is the right way to do it, comments welcome
Comment 40 Colin Walters 2010-02-11 19:10:06 UTC
Review of attachment 152387 [details] [review]:

::: js/ui/panel.js
@@ +339,3 @@
+            [leftBox, rightBox] = [rightBox, leftBox];
+        if (St.Widget.get_default_direction () == St.TextDirection.RTL) {
+        let [leftBox, rightBox] = [this._leftBox, this._rightBox];

It's confusing to me that this._leftBox and this._rightBox aren't swapped, but we introduce new variables leftBox and rightBox.

Why not just swap this._leftBox and this._rightBox?
Comment 41 Colin Walters 2010-02-11 19:11:48 UTC
Review of attachment 152385 [details] [review]:

Looks OK
Comment 42 Colin Walters 2010-02-11 19:19:24 UTC
Review of attachment 152386 [details] [review]:

This looks OK.
Comment 43 Colin Walters 2010-02-11 19:22:36 UTC
Review of attachment 153454 [details] [review]:

::: src/shell-drawing.c
@@ +97,3 @@
+            pixel = &pixels[(j + 1) * rowstride - (i + 1) * 4];
+          if (rtl)
+          guchar *pixel;

This will be overwriting random memory.  You want to change fade_start and fade_range (to be 0 and width / 2 respectively)
Comment 44 Abderrahim Kitouni 2010-02-12 14:48:00 UTC
(In reply to comment #40)
> Review of attachment 152387 [details] [review]:
> 
> ::: js/ui/panel.js
> @@ +339,3 @@
> +            [leftBox, rightBox] = [rightBox, leftBox];
> +        if (St.Widget.get_default_direction () == St.TextDirection.RTL) {
> +        let [leftBox, rightBox] = [this._leftBox, this._rightBox];
> 
> It's confusing to me that this._leftBox and this._rightBox aren't swapped, but
> we introduce new variables leftBox and rightBox.
> 
> Why not just swap this._leftBox and this._rightBox?
This may be a solution, I'll try.

(In reply to comment #43)
> Review of attachment 153454 [details] [review]:
> 
> ::: src/shell-drawing.c
> @@ +97,3 @@
> +            pixel = &pixels[(j + 1) * rowstride - (i + 1) * 4];
> +          if (rtl)
> +          guchar *pixel;
> 
> This will be overwriting random memory.  You want to change fade_start and
> fade_range (to be 0 and width / 2 respectively)
I beleive it won't overwrite random memory (my first try did in fact). I beleive I need to go from width/2 down to 0, since the fading isn't uniform (we want to have the edge to be darker than the center). I find this solution is better.
Comment 45 Abderrahim Kitouni 2010-02-12 15:02:09 UTC
Created attachment 153632 [details] [review]
[windowManager] fix minimize animation for RTL locales
Comment 46 Abderrahim Kitouni 2010-02-12 15:19:23 UTC
Created attachment 153633 [details] [review]
[overview, StBin] fix workspace controls for RTL locales
Comment 47 Dan Winship 2010-02-15 14:40:36 UTC
(In reply to comment #40)
> Why not just swap this._leftBox and this._rightBox?

Or really, we should port the panel to use StBoxLayout (bug 598463), and then we don't need to do any special-casing
Comment 48 Abderrahim Kitouni 2010-03-01 17:36:20 UTC
(In reply to comment #47)
> Or really, we should port the panel to use StBoxLayout (bug 598463), and then
> we don't need to do any special-casing
The patch there seems to be already applied, and StBoxLayout cannot do the same as the custom container afaics. (the custom container ensures the calendar is in the absolute center).
Comment 49 Abderrahim Kitouni 2010-03-01 19:46:15 UTC
Created attachment 154966 [details] [review]
[overview] fix workspace controls for RTL locales
Comment 50 Abderrahim Kitouni 2010-03-01 19:52:04 UTC
Created attachment 154967 [details] [review]
[appDisplay] fix AppIconMenu position in RTL locales

Ideas on a better way of handling this are welcome, the problem is that padding isn't included in width
Comment 51 Florian Müllner 2010-03-01 19:57:35 UTC
Review of attachment 154966 [details] [review]:

Looks good.
Comment 52 Abderrahim Kitouni 2010-03-01 20:00:38 UTC
Created attachment 154968 [details] [review]
[StScrollView] put vertical scrollbar to the left for RTL locales
Comment 53 Abderrahim Kitouni 2010-03-01 20:05:32 UTC
Created attachment 154969 [details] [review]
[panel] WIP: fix ripple animation for RTL locales

What's still missing is the flipped icon. (We need to flip a couple other icons as well)
btw, what do you think is the best approach fo this? (websites generally use an alternative stylesheet for rtl, but I'm afraid we will end up with LTR only themes)
Comment 54 Owen Taylor 2010-03-09 17:55:41 UTC
Procedural note: Can we limit this bug report to the patches that are already attached, and file anything additional as new separate bugs? There's always going to be new shell features that need new RTL work, and I don't want to have an infinitely extending bug report.
Comment 55 Owen Taylor 2010-03-09 18:10:22 UTC
(In reply to comment #53)
> Created an attachment (id=154969) [details] [review]
> [panel] WIP: fix ripple animation for RTL locales
> 
> What's still missing is the flipped icon. (We need to flip a couple other icons
> as well)
> btw, what do you think is the best approach fo this? (websites generally use an
> alternative stylesheet for rtl, but I'm afraid we will end up with LTR only
> themes)

I'd imagine that if we went with a separate stylesheet, a theme would consist of two stylesheets:

 shell-default.css
 shell-default-rtl.css

Where the -rtl stylesheet was *only* overrides for RTL. A theme can't be a single file anyways since it needs to contain the images it is referencing. But you are right, there would a tendency for people to copy both files into their theme, and then just ignore the -rtl one and then the theme would be completely broken in RTL until someone fixed it.

The other approach would be to have st_theme_node_set_direction() and then make the :ltr :rtl pseudo-selectors automatically work in the theme code based on the direction of the theme node. So you would add to the stylesheet:

 .ripple-box:rtl {
    background-image: url("upper-right-corner-ripple.png");
 }

The second approach is more elegant, I think. Less like CSS on the web, but on the other hand, our RTL approach is already not like CSS on the web. Does it make sense to you?
Comment 56 Owen Taylor 2010-03-09 19:58:11 UTC
Review of attachment 154967 [details] [review]:

::: js/ui/appDisplay.js
@@ +616,3 @@
         let x, y;
+        if (this._windowContainerBox.get_direction() == St.TextDirection.RTL)
+            x = Math.floor(stageX - this.actor.width - this._windowContainerBox.get_theme_node().get_padding(St.Side.LEFT));

I haven't tried this out, but I don't understand the reasoning here. As I read the code, windowContainerBox is inside this.actor and has equal padding on left and right. So, I'd expect just

 stageX - this.actor.width

should give equal spacing between the menu contents and this._source - why is subtracting the padding necessary?
Comment 57 Owen Taylor 2010-03-09 20:00:09 UTC
Review of attachment 154968 [details] [review]:

This looks right to me, but will be need to be rebased against the extensive StScrollView changes in bug 611740, which I believe change the same lines of code (in a fairly minor way)
Comment 58 Owen Taylor 2010-03-09 20:08:39 UTC
Review of attachment 154969 [details] [review]:

I think this isn't going to result in the ripple being fully at the right of the screen, since:

 let [x, y] = this._hotCorner.get_transformed_position();

Will be the *left* edge of the hot corner actor.

::: js/ui/panel.js
@@ +678,3 @@
+                                       ripple.opacity = 255 * Math.sqrt(ripple._opacity);
+                                       if (rtl)
+                                           ripple.x = x - ripple.width * ripple.scale_x;

Hmm, a little ugly, but I can't think of a better way to do it. Unfortunately, the anchor point support support in Clutter isn't quite good enough to do this.
Comment 59 Abderrahim Kitouni 2010-03-09 20:56:50 UTC
(In reply to comment #54)
> Procedural note: Can we limit this bug report to the patches that are already
> attached, and file anything additional as new separate bugs? There's always
> going to be new shell features that need new RTL work, and I don't want to have
> an infinitely extending bug report.
Seems reasonable, but I think it's good to keep a tracker bug that depends on all such bugs though.

(In reply to comment #55)
> I'd imagine that if we went with a separate stylesheet, a theme would consist
> of two stylesheets:
> 
>  shell-default.css
>  shell-default-rtl.css
> 
> Where the -rtl stylesheet was *only* overrides for RTL. A theme can't be a
> single file anyways since it needs to contain the images it is referencing. But
> you are right, there would a tendency for people to copy both files into their
> theme, and then just ignore the -rtl one and then the theme would be completely
> broken in RTL until someone fixed it.
Right.

> 
> The other approach would be to have st_theme_node_set_direction() and then make
> the :ltr :rtl pseudo-selectors automatically work in the theme code based on
> the direction of the theme node. So you would add to the stylesheet:
> 
>  .ripple-box:rtl {
>     background-image: url("upper-right-corner-ripple.png");
>  }
> 
> The second approach is more elegant, I think. Less like CSS on the web, but on
> the other hand, our RTL approach is already not like CSS on the web. Does it
> make sense to you?
Yes, it does. I'll try to implement this.

(In reply to comment #56)
> I haven't tried this out, but I don't understand the reasoning here. As I read
> the code, windowContainerBox is inside this.actor and has equal padding on left
> and right. So, I'd expect just
> 
>  stageX - this.actor.width
> 
> should give equal spacing between the menu contents and this._source - why is
> subtracting the padding necessary?
As strange as this may sound, this.actor.width contains only the width and not the padding. I don't understand either, it's just that it works like this.

(In reply to comment #57)
> Review of attachment 154968 [details] [review]:
> 
> This looks right to me, but will be need to be rebased against the extensive
> StScrollView changes in bug 611740, which I believe change the same lines of
> code (in a fairly minor way)
I guess it's fine, a git pull --rebase didn't complain.

btw, I still think attachment 153454 [details] [review] is fine, and I'm afraid attachment 153632 [details] [review] was overlooked
Comment 60 Owen Taylor 2010-03-11 20:37:00 UTC
Review of attachment 152387 [details] [review]:

Marking needs-work based on previous comment
Comment 61 Owen Taylor 2010-03-11 20:48:07 UTC
Review of attachment 153454 [details] [review]:

::: src/shell-drawing.c
@@ +97,3 @@
+            pixel = &pixels[(j + 1) * rowstride - (i + 1) * 4];
+          else
+            pixel = &pixels[j * rowstride + i * 4];

Iterating backwards through the pixels seems like an OK approach to me (within the constraints of this already being a pretty inefficient loop). I don't like the style of this expression - althogh rowstride is always 4 * width, we shouldn't be assuming it here. This would be better as:

&pixels[j * rowstride + ((width - 1) - i) * 4]

::: src/shell-drawing.h
@@ +24,3 @@
 	               int                  minute);
 
+ClutterTexture * shell_fade_app_icon (ClutterTexture *source, gboolean rtl);

This needs to be broken onto two lines in the same style as the other declarations in this header.
Comment 62 Owen Taylor 2010-03-11 21:47:39 UTC
Review of attachment 153632 [details] [review]:

Looks good to me


(in general, you really should be trying to provide a commit message body for each commit. Even if it doesn't seem to need it - so this one might be

 Fix minimize animation for RLT locales

 When minimizing a window in RTL corner, animate it moving to the upper
 right corner, not the upper left corner.
Comment 63 Owen Taylor 2010-03-11 21:57:49 UTC
Review of attachment 154968 [details] [review]:

Did apply cleanly, but looking through it, found some more issues:

 - needs to adjust the horizontal position of the horizontal scrollbar and shadow as well (suggest using separate variables for the allocation of the main child widget, and the ClutterAllocationBox used to allocate the other children. Then you can just line up the horizontal scrollbar and shadow with the child's horizontal bounds)

 - Needs to follow the GNU identation style we use in C code:

   - Spaces before opening '('
   - '{' on separate line, indented half way between the two block levels
Comment 64 Owen Taylor 2010-03-11 22:39:44 UTC
Review of attachment 154967 [details] [review]:

::: js/ui/appDisplay.js
@@ +616,3 @@
         let x, y;
+        if (this._windowContainerBox.get_direction() == St.TextDirection.RTL)
+            x = Math.floor(stageX - this.actor.width - this._windowContainerBox.get_theme_node().get_padding(St.Side.LEFT));

The solution to the mystery can be found in AppIconMenu._allocate()

        childBox.x1 = 0;
        childBox.x2 = this._arrowSize;
        childBox.y1 = Math.floor((height / 2) - (this._arrowSize / 2));
        childBox.y2 = childBox.y1 + this._arrowSize;
        this._arrow.allocate(childBox, flags);

(and so forth.) It's offsetting the children as allocated by an "arrow size" (apparently we are currently drawing space instead of an arrow.) So you need to make this part of the code RTL aware as well. What you were doing is compensating for this offset.

Also, in your existing code, fix:

if (this._windowContainerBox.get_direction() == St.TextDirection.RTL)

to be:

if (this.actor.get_direction() == St.TextDirection.RTL)

when removing the offset.
Comment 65 Abderrahim Kitouni 2010-11-29 20:52:50 UTC
After being unable to use the shell for some time because of a clutter bug, I'm slowly starting to follow again on this bug. I don't have much time to patch this now, but here are the bugs I noticed when I tried it (after the overview relayout was merged).

1. workspaces seem to be in inverted order in the overview and using ctrl-alt-arrow for moving moves in the opposite direction of the arrow (outside of the overview, the animations looks correct). (This was filed just now as bug 636083)

2. the ripple animation doesn't show (discussed above). (btw, what's the state of "anchor point support in Clutter"? can it be used instead of this ugly code?). So what's remaining here is only to implement the direction pseudo-selectors.

3. message tray's icons and "hot-corner" are in the lower right corner (should be lower left). (this should probably go in a new bug)

4. menus that show when right-clicking an application in the overview are on the right (and so go out of the screen).

btw, there is a problem with icons here, so I can't confirm whether the app icon fading code got fixed or not.

I'll try to look closer at what needs to be done (and rebase all those needs-work) later (unless someone does it instead :-p).
Comment 66 Florian Müllner 2010-11-29 21:37:10 UTC
(In reply to comment #65)
> 1. workspaces seem to be in inverted order in the overview and using
> ctrl-alt-arrow for moving moves in the opposite direction of the arrow (outside
> of the overview, the animations looks correct). (This was filed just now as bug
> 636083)

The patch in that bug has landed. There are still some remaining issues, which are addressed in bug 634691.


> 4. menus that show when right-clicking an application in the overview are on
> the right (and so go out of the screen).

I attached a patch as part of bug 635645.


> btw, there is a problem with icons here, so I can't confirm whether the app
> icon fading code got fixed or not.

Not as far as I can tell ...
Comment 67 Abderrahim Kitouni 2010-11-30 16:57:32 UTC
Comment on attachment 152387 [details] [review]
[panel] fix positions for RTL locales

fixed in master
Comment 68 Abderrahim Kitouni 2010-11-30 17:16:16 UTC
Comment on attachment 154967 [details] [review]
[appDisplay] fix AppIconMenu position in RTL locales

this is now bug 635645
Comment 69 Abderrahim Kitouni 2010-11-30 18:37:38 UTC
Created attachment 175564 [details] [review]
st: add rtl and ltr pseudo class selectors

(right-to-left and left-to-right respectively). This allows
theme-specific images/padding/border size to be mirrored for RTL locales


I've tried not to touch much code, and so didn't touch StThemeNode as 
suggested above, is this correct?
Comment 70 Abderrahim Kitouni 2010-11-30 18:40:17 UTC
Created attachment 175565 [details] [review]
[panel] fix ripple animation for RTL locales

the animation was invisible because it was going out of screen, also
add a mirrored version of the image to the theme.
(the code is a bit ugly, but I couldn't find a better way)
Comment 71 Dan Winship 2010-11-30 19:28:22 UTC
ahem: comment #54:
> Procedural note: Can we limit this bug report to the patches that are already
> attached, and file anything additional as new separate bugs? There's always
> going to be new shell features that need new RTL work, and I don't want to have
> an infinitely extending bug report.
Comment 72 Abderrahim Kitouni 2010-11-30 19:42:13 UTC
Created attachment 175574 [details] [review]
[panel] fix ripple animation for RTL locales

the animation was invisible because it was going out of screen, also
add a mirrored version of the image to the theme.
(the code is a bit ugly, but I couldn't find a better way)

(forgot to add the new image to Makefile.am)
Comment 73 Abderrahim Kitouni 2010-11-30 20:02:15 UTC
(In reply to comment #71)
> ahem: comment #54:
> > Procedural note: Can we limit this bug report to the patches that are already
> > attached, and file anything additional as new separate bugs? There's always
> > going to be new shell features that need new RTL work, and I don't want to have
> > an infinitely extending bug report.

As I understand it, a new version of a needs-work patch is "already attached".
I'm going to file other things as new bugs (if you prefer filing everything as new bugs, I don't mind)
Comment 74 Abderrahim Kitouni 2010-12-01 10:38:14 UTC
Comment on attachment 153454 [details] [review]
[panel] fix app icon fading for RTL locales

this is now in bug 636201
Comment 75 Dan Winship 2010-12-01 14:02:53 UTC
(In reply to comment #73)
> As I understand it, a new version of a needs-work patch is "already attached".

oh, yeah, sorry, I didn't remember there being a ripple patch before
Comment 76 Florian Müllner 2010-12-17 11:24:54 UTC
Review of attachment 175564 [details] [review]:

While the patch is small and simple and working well in practice, it is missing some corner cases. In fact, by implementing this in StWidget instead of StThemeNode, widgets will _never_ pick up a changed default direction. On the other hand, I'm not sure that adding the functionality to StThemeNode wouldn't miss other cases, so given that in practice I'd expect the default direction to be set early (e.g. before any widgets are created) and only once, having this in StWidget is acceptable in my opinion - the limitation should be documented in a comment though.

::: src/st/st-widget.c
@@ +1305,3 @@
+    st_widget_add_style_pseudo_class (actor, "rtl");
+  else
+    st_widget_add_style_pseudo_class (actor, "ltr");

This is a bit ugly, as st_widget_style_changed() will be called before any "normal" style classes are set. On the other hand, the widget is not yet mapped, so the actual style computation is deferred.

The main problem though is that widgets will miss the rtl/ltr magic if the pseudo_class property is set explicitly (either via g_object_set() or st_widget_set_style_pseudo_class()) - I think overwriting all style automagic is correct in that case *except* when set in the contructor, e.g.

let foo = St.Bar({ pseudo_class: 'baz' });

I would expect automatically assigned pseudo classes to work in this case (and existing ones like :hover, :first-child, :last-child do). You should get the correct behavior if you implement GObjectClass->constructor and set the pseudo class there.

@@ +1421,3 @@
 {
   g_return_if_fail (ST_IS_WIDGET (self));
+  StTextDirection old_dir = st_widget_get_direction (self);

Variables must be declared at the start of a code block, so this should be:

StTextDirection old_dir;

g_return_if_fail (ST_IS_WIDGET (self));

old_dir = st_widget_get_direction (self);
Comment 77 Florian Müllner 2010-12-17 11:53:34 UTC
Review of attachment 175574 [details] [review]:

The patch works fine, but I think that using ClutterGravity looks nicer :-)

::: data/Makefile.am
@@ +25,3 @@
 	theme/close-window.svg			\
 	theme/close.svg				\
 	theme/corner-ripple.png			\

It might be a good idea to rename the file to corner-ripple-ltr.png or use something like corner-ripple-topleft.png/corner-ripple-topright.png.

::: js/ui/panel.js
@@ +925,3 @@
                                         y: y });
         ripple._opacity =  startOpacity;
+        let rtl = ripple.get_direction() == St.TextDirection.RTL;

I think it is more elegant to use

if (St.Widget.get_default_direction() == St.TextDirection.RTL)
    ripple.set_anchor_point_from_gravity(Clutter.Gravity.NORTH_EAST);

to do the positioning - you don't need to modify onUpdate then.
Comment 78 Florian Müllner 2011-02-24 13:03:45 UTC
Comment on attachment 154968 [details] [review]
[StScrollView] put vertical scrollbar to the left for RTL locales

My apologies, but I only noticed the patch in attachment 154968 [details] [review] after opening bug 643156.
Comment 79 Florian Müllner 2011-03-04 01:43:25 UTC
Comment on attachment 175564 [details] [review]
st: add rtl and ltr pseudo class selectors

It would be really helpful to have the :ltr :rtl selectors in 3.0, so I filed an alternative patch in bug 643835. Sorry for hijacking this, but the patch has not been updated for quite some time and the release date is approaching rather quickly.
Comment 80 Florian Müllner 2011-03-22 18:39:29 UTC
Updated attachment 175574 [details] [review] according to my review and pushed as 12fad6f - Fix ripple animation for RTL locales