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 736489 - gtk_widget_set_halign does not work for labels with line wrap
gtk_widget_set_halign does not work for labels with line wrap
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
3.13.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-09-11 15:49 UTC by Michael Catanzaro
Modified: 2014-09-18 10:59 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Catanzaro 2014-09-11 15:49:21 UTC
This code creates a label that is line-wrapped and left-aligned:

char *long_string = "...";
GtkWidget *label = gtk_label_new (long_string);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
gtk_widget_show (label);

This works fine, but GtkMisc is deprecated, so I want to replace the call to gtk_misc_set_alignment with gtk_widget_set_halign, the documented replacement:

gtk_widget_set_halign (label, GTK_ALIGN_START);

But this doesn't work. The label widget's allocation is left-aligned, but the text inside the label is shifted towards the center.
Comment 1 Matthias Clasen 2014-09-18 10:59:13 UTC
keep using xalign. it has been undeprecated