This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

https://bugs.maemo.org/attachment.cgi?id=505&this-to-trick-gnome.orgs.wiki-engine.gif

Overview

This page describe how to enable RTL layouts in Hildon Desktop. By default, the Hildon Desktop doesn't support RTL layouts for both widget layouts and text rendering. This document covers the Sardine and doesn't apply to IT-2007.

It is assumed that we use ar_SA (Saudi Arabia) as the locale code.

Components need update

You need to update the following components, and after that, just restart the desktop.

Posix locales

In order to use RTL locale you should have the RTL locale definitions. You can install locales-extras-arabic or locales-extras-hebrew from Locales Extras project.

Then edit /etc/osso-af-init/locale to reflect your locale. Change the LANG and LC_MESSAGES there. Added a line "export LNAGUAGE=ar_SA.UTF-8:en_GB", replace ar_SA.UTF-8 with the locale you want, this will use English translations as a fallback (except you have a full translation installed).

Gtk+ RTL initialization

A translation file is needed for the RTL locale to get Gtk+ knows that it should render the widget in RTL fashion. Prepare a blank text file and fill it with:

# Compile this to gtk20.mo and put in /usr/share/yourlocale/LC_MESSAGES
#
# Copyright (C) 2006 Nokia Corporation.
#
msgid ""
msgstr ""
"Project-Id-Version: gtk\n"
"Report-Msgid-Bugs-To: mohammad.anwari@nokia.com\n"
"POT-Creation-Date: 2006.06.22 12:40+0300\n"
"PO-Revision-Date: 2006.06.22 12:40+0300\n"
"Last-Translator:\n"
"Language-Team: ar\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "default:LTR"
msgstr "default:RTL"

Save it as gtk20.po, then do msgfmt -cv gtk20.po -o gtk20.mo. The resulting file, gtk20.mo need to be moved to /usr/share/locale/ar/LC_MESSAGES directory.

Hildon Widgets

Patch attached here is needed to get the Hildon widgets to be RTL aware. Warning: the patch is probably incomplete as it is not yet fully tested.

Hildon Desktop

Patch attached here is needed to get the Hildon Desktop to be RTL aware. Warning: the patch is probably incomplete as it is not yet fully tested.

As of hildon-desktop 0.0.29, the patch is already included.

Themes

You need to create a new file (possibly by just copying the files, then modify them) for each theme described below. Then whenever you start the desktop with RTL locale you should switch the theme by pointing the correct theme file.

As the widgets use graphics extensively, you need basically to flip them horizontally. You can pick the ones need flipping. If you use shadows much in your theme then possibly it's necessary to flip most of the graphics so the shadows also in correct position after the flipping. You also may not want to flip the dialog frame images if they are really symmetrical.

Put the flipped graphics files to different name or different path, for example, to images/rtl directory, so you can easily distinguish them.

Matchbox theme

Copy your theme.xml file in the theme directory to theme-rtl.xml and move the original theme.xml to theme-ltr.xml.

Then modify the theme-rtl.xml by fixing the correct file names for flipped images. Probably you don't need to touch the frames images, and just modify these pixmap ids:

Then modify the x coordinates for the main frame, adjust them so it will look nice.

To activate it, put a symbolic link from theme-rtl.xml to theme.xml. If you need to go back to non-RTL locale then point the symbolic link to theme-ltr.xml instead.

Gtk+ theme

Copy your gtkrc and gtkrc.maemo-af-desktop files in the theme directory and give prefix according to your RTL locale id. For example, if your locale is ar_JO then copy the files to gtkrc.ar and gtkrc.maemo-af-desktop.ar respectively. Then modify the copied files by editing the path to graphics files that you have flipped. For some arrow styles, the Gtk+ will automatically switch them. For example when rendering "left" arrow, it picks the "right" arrow and render it. So you need not to use the flipped images here.

It's also advisable to have the style name different from the original name, possibly by having them prefixed with your locale or simply with "rtl" prefix, so it would be possible to mix the RTL theme and non-RTL theme definitions.

style "style-name-rtl"
{
...
}

class "SomeWidget" style "style-name-rtl"

To activate the theme, just edit ~/.osso/current-gtk-theme and ~/.osso/current-gtk-theme.maemo-af-desktop files and put correct path to your RTL rc files there. The file contents would look like this:

#include "/usr/share/themes/plankton/gtk-2.0/gtkrc"
include "/usr/share/themes/plankton/gtk-2.0/gtkrc.ar"

When you want to go back to non RTL locale then just remove the hash mark on the first line and put the hash mark on the second line.

Actually, Gtk+ can picks up the correct rtl theme without editing the files above, if you set the LANG and LC_MESSAGES to an RTL locale. But if you only want to have the RTL for LC_MESSAGES, it won't work.

Icon

You need also to flip the /usr/share/icons/hicolor/26x26/hildon/qgn_list_tasknavigator_appswitcher.png file and give it named as /usr/share/icons/hicolor/26x26/hildon/qgn_list_tasknavigator_appswitcher_rtl.png. This icon is used by Task Navigator for the application switcher functionality. Then also remove /usr/share/icons/hicolor/icon-theme.cache otherwise you won't see the icon.


2024-10-23 10:59