diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-05-19 17:24:57 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-05-19 17:24:57 +0000 |
commit | e3252a4a11cc24ae81dd6dc50dae0851e3145503 (patch) | |
tree | a085a5ba22128a290a2c545f162a671e32766ce4 /libnautilus-extensions | |
parent | 011cfc4c08a2cf15f03facc18aaadc648380405a (diff) | |
download | nautilus-e3252a4a11cc24ae81dd6dc50dae0851e3145503.tar.gz |
A few tweaks to this new class inspired by Darin's
review.
* libnautilus-extensions/nautilus-keep-last-vertical-box.c:
(nautilus_keep_last_vertical_box_new): More comments.
(nautilus_keep_last_vertical_box_size_allocate): More comments.
Also now handles the case where the last item doesn't fit
even all by itself by moving & shrinking it to fit. Previously
the last item would be left at its original position & size in
this case.
Diffstat (limited to 'libnautilus-extensions')
-rw-r--r-- | libnautilus-extensions/nautilus-keep-last-vertical-box.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/libnautilus-extensions/nautilus-keep-last-vertical-box.c b/libnautilus-extensions/nautilus-keep-last-vertical-box.c index 291d2ccc2..473c65f5e 100644 --- a/libnautilus-extensions/nautilus-keep-last-vertical-box.c +++ b/libnautilus-extensions/nautilus-keep-last-vertical-box.c @@ -73,6 +73,12 @@ nautilus_keep_last_vertical_box_new (gint spacing) box = gtk_type_new (nautilus_keep_last_vertical_box_get_type ()); GTK_BOX (box)->spacing = spacing; + + /* If homogeneous is TRUE and there are too many items to fit + * naturally, they will be squashed together to fit in the space. + * We want the ones that don't fit to be not shown at all, so + * we set homogeneous to FALSE. + */ GTK_BOX (box)->homogeneous = FALSE; return GTK_WIDGET (box); @@ -113,10 +119,17 @@ nautilus_keep_last_vertical_box_size_allocate (GtkWidget *widget, child_allocation = child->widget->allocation; - /* Reposition this child so that it does not appear. + /* Reallocate this child's position so that it does not appear. * Setting the width & height to 0 is not enough, as * one pixel is still drawn. Must also move it outside - * visible range. + * visible range. For the cases I've seen, -1, -1 works fine. + * This might not work in all future cases. Alternatively, the + * items that don't fit could be hidden, but that would interfere + * with having other hidden children. + * + * Note that these children are having their size allocated twice, + * once by gtk_vbox_size_allocate and then again here. I don't + * know of any problems with this, but holler if you do. */ tiny_allocation.x = tiny_allocation.y = -1; tiny_allocation.height = tiny_allocation.width = 0; @@ -129,6 +142,17 @@ nautilus_keep_last_vertical_box_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (last_child->widget, &last_child_allocation); break; } + + /* If the special last item still doesn't fit, but we've + * run out of earlier items, then the special last item is + * just too darn tall. Let's squash it down to fit in the box's + * allocation. + */ + if (children == NULL) { + last_child_allocation.y = allocation->y; + last_child_allocation.height = allocation->height; + gtk_widget_size_allocate (last_child->widget, &last_child_allocation); + } } } } |