Red Hat Bugzilla – Bug 1008821
Gtk should export a function to get default direction of the widgets
Last modified: 2014-09-04 00:31:57 EDT
Description of problem:
Gtk internally uses the following check to decide whether to use RTL or LTR widgets direction:
/* Translate to default:RTL if you want your widgets
* to be RTL, otherwise translate to default:LTR.
* Do *not* translate it to "predefinito:LTR", if it
* it isn't default:LTR or default:RTL it will not work
char *e = _("default:LTR");
if (strcmp (e, "default:RTL")==0)
else if (strcmp (e, "default:LTR"))
g_warning ("Whoever translated default:LTR did so wrongly.\n");
However, if an external tool/library wants to decide whether Gtk would use RTL or LTR, it needs to do the same check, e.g. (in Python):
xlated = gettext.ldgettext("gtk30", "default:LTR")
if xlated == "default:LTR":
This is not a good solution as it depends on an internal implementation of the check used by the Gtk toolkit. If Gtk developers decide to change it or for example just change the particular string used for the check, such a solution will stop working.
Version-Release number of selected component (if applicable):
No function providing information about the default widget direction exported by the Gtk library.
A function hiding the internal implementation.
I understand this information is quite rarely needed, but there are some applications that make use of it (e.g. the Anaconda installer).
Created attachment 798660 [details]
Possible (untested) patch
(In reply to Matthias Clasen from comment #2)
> use gtk_widget_get_text_direction
I wish I could. Output from testing in the installer:
> gtk_widget_get_default_direction tells: LTR
> the right direction: RTL
The problem is that Gtk is initialized before language is chosen in the installer and the value returned by the gtk_widget_get_text_direction function uses some cached value. So, either there has to be a function to get the right (current) value, or gtk_widget_get_text_direction has to be modified to return the right (current) value. Since I have no idea what side effects the latter solution could have, I proposed a patch implementing the former one.
I misunderstood the problem. There is indeed not good way to do this sort of reinitialization right now, short of looking at the 'special' translations yourself.
I'll look at adding a gtk_get_locale_direction() to the API for 3.12, then you can use that instead of duplicating the translation hack.
Works for me, thanks!