From 10f0e991dad27cf7ec6467e5b35e70ffaf390e4a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 3 Nov 2010 23:00:05 -0400 Subject: [PATCH] Handle empty button boxes gracefully https://bugzilla.gnome.org/show_bug.cgi?id=633915 --- gtk/gtkbbox.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index ad31d3f779..5fdf837a15 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -774,13 +774,19 @@ gtk_button_box_size_allocate (GtkWidget *widget, x = allocation->x; secondary_x = x + primary_size + n_primaries * childspacing; } - else + else if (nvis_children == 1) { - /* one or zero children, just center */ + /* one child, just center */ childspacing = width; x = secondary_x = allocation->x + (allocation->width - widths[0]) / 2; } + else + { + /* zero children, meh */ + childspacing = width; + x = secondary_x = allocation->x + allocation->width / 2; + } } else { @@ -790,12 +796,18 @@ gtk_button_box_size_allocate (GtkWidget *widget, y = allocation->y; secondary_y = y + primary_size + n_primaries * childspacing; } - else + else if (nvis_children == 1) { - /* one or zero children, just center */ + /* one child, just center */ childspacing = height; y = secondary_y = allocation->y - + (allocation->height - heights[0]) / 2; + + (allocation->height - heights[0]) / 2; + } + else + { + /* zero children, meh */ + childspacing = height; + y = secondary_y = allocation->y + allocation->height / 2; } }