Reputation: 51
I have been experiencing some really weird problems with gtk_label text positioning.
I have a gtk_label positioned on a fixed container, the label has been set to:
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
However when a single word is present in the label, instead of getting centered it gets left aligned.
If I unset gtk_label_set_line_wrap(GTK_LABEL(label), TRUE)
to FALSE
the word then appears in the center of the label, but I lose wrapping.
How should this be fixed?
Upvotes: 4
Views: 5219
Reputation: 2702
From the documentation (emphasis mine):
gtk_label_set_justify ()
Sets the alignment of the lines in the text of the label relative to each other.
GTK_JUSTIFY_LEFT
is the default value when the widget is first created withgtk_label_new()
. If you instead want to set the alignment of the label as a whole, usegtk_misc_set_alignment()
instead.gtk_label_set_justify()
has no effect on labels containing only a single line.
As suggested in the above quote, you may wish to add a call to the gtk_misc_set_alignment()
function, with its xalign
parameter set to 0.5
, before calling gtk_label_set_justify()
.
Upvotes: 4