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 318761 - Add alignment property to GtkCellRenderText
Add alignment property to GtkCellRenderText
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.8.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 318763
 
 
Reported: 2005-10-13 12:01 UTC by Ross Burton
Modified: 2011-02-04 16:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add ::alignment property (2.16 KB, patch)
2005-10-13 12:01 UTC, Ross Burton
none Details | Review
Modified test (10.58 KB, text/x-csrc)
2006-03-06 08:44 UTC, Ross Burton
  Details

Description Ross Burton 2005-10-13 12:01:08 UTC
Text cell renderers currently don't have a way of setting the alignment of the
text.   A patch I'm about to submit for IconView needs this, so here it is.
Comment 1 Ross Burton 2005-10-13 12:01:51 UTC
Created attachment 53412 [details] [review]
Add ::alignment property

The property defaults to PANGO_ALIGN_LEFT so there is no change by default.
Comment 2 Matthias Clasen 2006-01-16 18:57:47 UTC
How will this interact with the xalign property thats already there ?
See Federicos tests/testcellrenderertext.c
Comment 3 Ross Burton 2006-02-09 19:17:08 UTC
xalign sets the X offset of the text, but if the text wraps and xalign is set to 0.5, you get left-aligned text starting in the middle of the cell.

By setting x-align to 0 and alignment to CENTER, you get wrapped centered text.
Comment 4 Ross Burton 2006-02-09 19:19:25 UTC
The use case for this is making GtkIconView look like the nautilus icon view, without alignment multi-line labels are left-aligned, which looks odd.
Comment 5 Matthias Clasen 2006-02-10 15:30:04 UTC
Ross, can you add something to testcellrenderertext.c to demonstrate this ?
That would be great 
Comment 6 Ross Burton 2006-03-06 08:44:07 UTC
Created attachment 60745 [details]
Modified test

This test file (backported from HEAD, 2.8 doesn't have it) adds three rows showing what happens if you have xalign 0 and various PangoAlignment.  It does the right thing.

Setting xalign 0.5 or xalign 1.0 produces strange output, as the text is being aligned by both Pango and the align property (which simply moves the box inside the container).

Note that I couldn't seen to get wrap_chars doing the right thing to demonstrate line wrapping though :(
Comment 7 Matthias Clasen 2006-03-14 19:34:38 UTC
Ross, I figured out what the problem with wrap-width is.
The testcase always explicitly sets ellipsize, which has the
side effect of setting ellipsize-set (even if the value is
PANGO_ELLIPSIZE_NONE). And gtkcellrenderertext bases
some behaviour on the value of ellipsize-set. After fixing that,
it turns out that alignment works correctly with wrap-width in RTL
but not in LTR...
Comment 8 Matthias Clasen 2006-03-14 19:45:04 UTC
2006-03-14  Matthias Clasen  <mclasen@redhat.com>

	* tests/testcellrenderertext.c: Add test cases for alignment.

	* gtk/gtkcellrenderertext.c: Add an alignment property,
	and fix some cases where ellipsize_set was being used to
	mean "we're ellipsizing" even when ellipsize was set to NONE.  
	(#318761, Ross Burton)