Directional Images

Hello Gtk+ developers,

My native language is an RTL language. I've been examining several RTL
problems in GNOME software recently, and I noticed some recurring

Some of them are related to text alignment and fonts, which I won't talk
about this time because I haven't found a universal solutio. But I think
I did find a solution for images.

It is very common for images where the direction matters, such as
prev/next arrows, to be in the wrong direction when apps run in RTL
locales. So far, a volunteer has been fixing these problems by hand by
sending patches to all GNOME software containing the problem. For
example, the prev/next arrows in Epiphany and in Evolution's
notification-bar bubble.

Here are some related bugs:

Instead of doing it by hand, or trying to teach developers how to make
their apps direction-aware, I found a universal solution which requires
a bit of work once, and will work after that without any developer

The idea is: Directional Images.

Example: An arrow is a directional image. The direction of the arrow
matters. When an arrow icon is rendered in RTL locales, it should be
rendered horizontally flipped, so right becomes left and left becomes

A folder image is a non-directional image. Changing its direction
doesn't make any sense or different in any direction or locale. The same
is true for people's faces, an image of the Earth, a map of a city, etc.

The solution I suggest is to add a "directional" boolean property to
GTK's image class used for icons. The property will be stored as image
metadata, and set by the designer of the image. After that, the code
which renders the menu/toolbar icons will just need to check if the
image is directional and the locale is RTL. If both are true, draw the
image horizontally flipped. Otherwise, draw as usual.

I believe it shouldn't take extra resources, because the drawing loop
will simply need to fill pixels from the other side. No extra processing
is required (unless computing "size - x" in each loop iteration is too
much slower than just "x", which I doubt").

Is it possible? Does it sound a reasonable approach?


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