How do I right (or otherwise) justify a GtkLabel?

GTK+ FAQ
<<< Previous | Development with GTK+: widget specific questions | Next >>>

# How do I right (or otherwise) justify a GtkLabel?

Are you sure you want to justify the labels? The label class contains the `gtk_label_set_justify()` function that is used to control the justification of a multi-line label.

What you probably want is to set the alignment of the label, ie right align it, center it or left align it. If you want to do this, you should use:

    void gtk_misc_set_alignment (GtkMisc *misc,
                                 gfloat xalign,
                                 gfloat yalign);

where the `xalign` and `yalign` values are floats in [0.00;1.00].

    GtkWidget       *label;

    /* horizontal : left align, vertical : top */
    gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f);

    /* horizontal : centered, vertical : centered */
    gtk_misc_set_alignment(GTK_MISC(label), 0.5f, 0.5f);

    /* horizontal : right align, vertical : bottom */
    gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 1.0f);

<<< Previous | Home | Next >>>
How can I retrieve the text from a GtkMenuItem? | Up | How do I set the background color of a GtkLabel widget?