X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtktable.c;h=e484479c8897e52d266cb2ab50f57ae2057a22fe;hb=10ba4fd066042b4335ae45e7560565872f71ba9b;hp=35037b1b172e30d6c888b59e49a5d3a9c04cfbb8;hpb=3f98a849c70ae570b78095cef0152a33ec07c64e;p=~andy%2Fgtk diff --git a/gtk/gtktable.c b/gtk/gtktable.c index 35037b1b1..e484479c8 100644 --- a/gtk/gtktable.c +++ b/gtk/gtktable.c @@ -1357,21 +1357,32 @@ gtk_table_size_allocate_pass1 (GtkTable *table) } } - /* Check to see if we were allocated less width than we requested. + /* Check to see if we were allocated less width than we requested, + * then shrink until we fit the size give. */ - if ((width > real_width) && (nshrink >= 1)) + if (width > real_width) { - width = width - real_width; - - for (col = 0; col < table->ncols; col++) - if (table->cols[col].shrink) - { - extra = width / nshrink; - table->cols[col].allocation = MAX (1, (gint)table->cols[col].allocation - extra); - - width -= extra; - nshrink -= 1; - } + gint total_nshrink = nshrink; + + extra = width - real_width; + while (total_nshrink > 0 && extra > 0) + { + nshrink = total_nshrink; + for (col = 0; col < table->ncols; col++) + if (table->cols[col].shrink) + { + gint allocation = table->cols[col].allocation; + + table->cols[col].allocation = MAX (1, (gint) table->cols[col].allocation - extra / nshrink); + extra -= allocation - table->cols[col].allocation; + nshrink -= 1; + if (table->cols[col].allocation < 2) + { + total_nshrink -= 1; + table->cols[col].shrink = FALSE; + } + } + } } } @@ -1436,20 +1447,31 @@ gtk_table_size_allocate_pass1 (GtkTable *table) } /* Check to see if we were allocated less height than we requested. + * then shrink until we fit the size give. */ - if ((height > real_height) && (nshrink >= 1)) + if (height > real_height) { - height = height - real_height; + gint total_nshrink = nshrink; - for (row = 0; row < table->nrows; row++) - if (table->rows[row].shrink) - { - extra = height / nshrink; - table->rows[row].allocation = MAX (1, (gint)table->rows[row].allocation - extra); - - height -= extra; - nshrink -= 1; - } + extra = height - real_height; + while (total_nshrink > 0 && extra > 0) + { + nshrink = total_nshrink; + for (row = 0; row < table->nrows; row++) + if (table->rows[row].shrink) + { + gint allocation = table->rows[row].allocation; + + table->rows[row].allocation = MAX (1, (gint) table->rows[row].allocation - extra / nshrink); + extra -= allocation - table->rows[row].allocation; + nshrink -= 1; + if (table->rows[row].allocation < 2) + { + total_nshrink -= 1; + table->rows[row].shrink = FALSE; + } + } + } } } }