From 7000b0c70a409afc427b3012d55366577dc0418e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 6 Dec 2015 16:00:10 +0000 Subject: [PATCH] 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.) --- gtk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk.c b/gtk.c index a8416b0..74b48c1 100644 --- a/gtk.c +++ b/gtk.c @@ -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