GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Nov 23, 2014 11:57 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [Solved] Forcing left to right(LTR) GTK window
PostPosted: Mon Apr 11, 2011 5:00 pm 
Offline
Familiar Face

Joined: Mon Apr 11, 2011 4:45 pm
Posts: 9
I have searched it in the web, can't find a good solution.
The problem is that in GTK+ windows is inverted while using Hebrew\Arabic or any RTL(right to left) language translation of GTK+.
I personally think that this is the way it should be.
However, I'm looking for a way(for developing) to force the GTK window be LTR(left to right) even know the user language align is RTL.
Is this thing possible? I can't find it at GTKWindow properties list.


Last edited by Tal on Tue Apr 12, 2011 6:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Forcing left to right(LTR) GTK window
PostPosted: Tue Apr 12, 2011 6:20 pm 
Offline
Familiar Face

Joined: Mon Apr 11, 2011 4:45 pm
Posts: 9
It took me time, but eventually when I almost gave up I found the answer, thanks to this page.
Here it is if anyone want to know(or he searched in Google so much like me):
For all widgets:
Code:
gtk_widget_set_default_direction(GTK_TEXT_DIR_LTR);

For a specific:(If you program an IDE in GTK+(like MonoDevelop), please take a look at this so RTL users won't suffer- especially on the text area...)
Code:
gtk_widget_set_direction(GtkWidget *widget, GTK_TEXT_DIR_LTR);

* Edit: fixed the second code.
Works like a charm, but hard to found...


Last edited by Tal on Thu Apr 14, 2011 10:13 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [Solved] Forcing left to right(LTR) GTK window
PostPosted: Wed Apr 13, 2011 7:25 am 
Offline
Familiar Face

Joined: Mon Apr 11, 2011 4:45 pm
Posts: 9
Thanx... I know it is very common problem for Hebrew/Arabic speakers or for developers which give a damn for those guys...


Top
 Profile  
 
 Post subject: Re: [Solved] Forcing left to right(LTR) GTK window
PostPosted: Thu Apr 14, 2011 10:24 am 
Offline
Familiar Face

Joined: Mon Apr 11, 2011 4:45 pm
Posts: 9
Look, I'm not a GTK expert. I'm just a guy who tried to solve a problem that have occurred to him, and have found the answer.

There is tree values:
GTK_TEXT_DIR_NONE - use the default direction setting.
GTK_TEXT_DIR_LTR - left to right direction for a specific widget.
GTK_TEXT_DIR_RTL - right to left direction for a specific widget.

First, this is work. If you don't believe me and you're LTR(left to right) speaker(At-list in your GTK/desktop setting), try to write this in your code, before you create the window(donn'o if it's work after):
Code:
gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);

This will flip your window to RTL. For example, if you have a menu bar on top, it will began from the right side and not from the left(like English).
But you do right I have a mistake in the second code I gave, see again the change I made above if you want to try it.
The first one over-set(ignore the user setting) the default widget direction only for the current process(i.e. widgets that their direction set to GTK_TEXT_DIR_NONE), and the second(above, not here) set the direction of a specific widget. Again, if you don't believe me, see this from first source:
http://developer.gnome.org/gtk/stable/G ... -direction
http://developer.gnome.org/gtk/stable/G ... -direction


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group