Implement align_label for GTK 3.[14,16).

gtk_misc_set_alignment was deprecated in GTK 3.14. But my replacement
code using gtk_label_set_{x,y}align doesn't work there, because that
function wasn't introduced until GTK 3.16, so there are two minor
versions in the middle where a third strategy is needed.

(That middle strategy doesn't permit arbitrary float alignments, but
that's OK, bceause we only actually use multiples of 0.5.)
This commit is contained in:
Simon Tatham
2015-12-06 16:00:10 +00:00
parent 346584bf6e
commit 7000b0c70a

7
gtk.c
View File

@ -1398,6 +1398,13 @@ static void align_label(GtkLabel *label, double x, double y)
#if GTK_CHECK_VERSION(3,16,0)
gtk_label_set_xalign(label, x);
gtk_label_set_yalign(label, y);
#elif GTK_CHECK_VERSION(3,14,0)
gtk_widget_set_halign(GTK_WIDGET(label),
x == 0 ? GTK_ALIGN_START :
x == 1 ? GTK_ALIGN_END : GTK_ALIGN_CENTER);
gtk_widget_set_valign(GTK_WIDGET(label),
y == 0 ? GTK_ALIGN_START :
y == 1 ? GTK_ALIGN_END : GTK_ALIGN_CENTER);
#else
gtk_misc_set_alignment(GTK_MISC(label), x, y);
#endif