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 120256 - GtkTextView doesn't honour justification without wrapping
GtkTextView doesn't honour justification without wrapping
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.2.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 124825 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-08-19 15:00 UTC by Felipe Heidrich
Modified: 2011-02-04 16:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase (933 bytes, text/plain)
2003-08-19 15:02 UTC, Felipe Heidrich
Details

Description Felipe Heidrich 2003-08-19 15:00:43 UTC
If GTK_WORD_WRAP is not used CENTER and RIGHT justification doesn't work.

Compile and run the attached test case, the right justification of text
won't work. Uncomment the line that sets GTK_WORD_WRAP, compile and run
again, justification works fine now.

How can I workaround this problem or there is something wrong in my code ?
Comment 1 Felipe Heidrich 2003-08-19 15:02:35 UTC
Created attachment 19349 [details]
Testcase
Comment 2 Havoc Pennington 2003-08-19 15:59:34 UTC
Well justification is with respect to other lines of text, 
so if you only have one line of text, left/center/right justification
are all the same thing. That may be the issue. 

Or there could be a bug. ;-) Try with multiple lines.

Comment 3 Felipe Heidrich 2003-08-19 16:56:21 UTC
Well, I just added multiple lines by changing the line that set the 
text to:
gtk_text_buffer_set_text (buffer, 
        "This text should be rigt alignment.\n
         This text should be rigt alignment.\n
         This text should be rigt alignment.\n", -1);

The bug is still there.

Futher, imagine an user who want to use textview to display (one-line 
or multiple, doesn't matter) some arabic/hebrew text. He would call 
gtk_widget_set_direction() but likely he would not touch the 
justification. The widget would have a wrong RTL layout (text 
aligment on the left instead of on the right) unless word wrap is set.
So, for having the correct RTL layout the user needs to set word 
wrap. IMHO this is just a bug.






Comment 4 Havoc Pennington 2003-08-19 20:51:06 UTC
Yes, this may be broken. I guess if there's no width set on the 
PangoLayout maybe the textview needs to do the justification 
manually or something. Would have to investigate.

Unrelated, are you sure you need to call gtk_widget_set_direction()? 
GTK should be defaulting all widgets to the proper direction 
for the current locale. (And also automatically flipping the 
justification to match widget direction.)


Comment 5 Felipe Heidrich 2003-08-20 15:02:10 UTC
In SWT we set the default direction to LTR, then for each individual 
widget we call gtk_widget_set_direction() and whatever is need to 
give the correct RTL layout.

Several GTK widgets only calling gtk_widget_set_direction() is not 
enough. Some widgets, like GtkCombo, are *very* hard to give the 
correct RTL layout. I know that part of this trouble is because we 
set default direction to LTR, other part is because GTK does not do 
all the work when the RTL flag is set (i.e. scrollbars still need to 
place manually on the left side).
Comment 6 Owen Taylor 2003-08-20 16:33:34 UTC
Trying to make up for deficencies in GTK+'s RTL layout
flipping will very likely just cause your program to break
with future versions of GTK+ where we fix the problems.
Comment 7 Owen Taylor 2003-08-25 22:16:49 UTC
What if you have lines wider than the screen width? Do they
extend the wrap width?

May also be some interaction with bug 118543, which is
about better bidi support for the text widget.
Comment 8 Owen Taylor 2004-03-13 17:47:45 UTC
*** Bug 124825 has been marked as a duplicate of this bug. ***
Comment 9 Owen Taylor 2004-03-13 23:28:32 UTC
I put in a pretty simple change that seems to get justification
working for GTK_WRAP_NONE.

Sat Mar 13 18:13:13 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): When not
        wrapping, do the offset of the line for justification ourselves.
        (#120256, Felipe Heidrich)

Let's hope it doens't break anything... ;-)

It turns out that you want to justify to the widest line, since
that's what you need for RTL text  - you want everything lined
up at the right column when you scroll all the way to the right.

Handling of the horizontal scrollbar isn't really right for
RTL paragraphs, but I'm pretty positive there is a different bug 
about that.