--- a/gntbox.c Sun Feb 21 00:11:56 2010 +0000
+++ b/gntbox.c Wed Mar 24 02:38:56 2010 +0000
@@ -27,6 +27,9 @@
+#define PROP_LAST_RESIZE_S "last-resize" +#define PROP_SIZE_QUEUED_S "size-queued" @@ -194,7 +197,7 @@
GntBox *box = GNT_BOX(widget);
g_list_foreach(box->list, (GFunc)gnt_widget_size_request, NULL);
for (iter = box->list; iter; iter = iter->next)
@@ -398,6 +401,7 @@
GntBox *box = GNT_BOX(widget);
+ GntWidget *child, *last; @@ -406,67 +410,59 @@
hchange = widget->priv.height - height;
if (wchange == 0 && hchange == 0)
- return TRUE; /* Quit playing games */
+ return TRUE; /* Quit playing games with my size */ - /* XXX: Right now, I am trying to just apply all the changes to
- * just one widget. It should be possible to distribute the
- * changes to all the widgets in the box. */
- for (iter = box->list; iter; iter = iter->next)
+ last = g_object_get_data(G_OBJECT(box), PROP_LAST_RESIZE_S); + /* First, make sure all the widgets will fit into the box after resizing. */ + for (iter = box->list; iter; iter = iter->next) { GntWidget *wid = iter->data;
gnt_widget_get_size(wid, &w, &h);
- if (gnt_widget_confirm_size(wid, w - wchange, h - hchange))
- for (i = box->list; i; i = i->next)
- if (i == iter) continue;
- gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
- if (!gnt_widget_confirm_size(i->data, tw - wchange, th)) {
- /* If we are decreasing the size and the widget is going
- * to be too large to fit into the box, then do not allow
- if (wchange > 0 && tw >= widget->priv.width)
- if (!gnt_widget_confirm_size(i->data, tw, th - hchange)) {
- if (hchange > 0 && th >= widget->priv.height)
- gnt_widget_set_size(wid, w - wchange, h - hchange);
- for (i = box->list; i; i = i->next)
- if (i == iter) continue;
- gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
- gnt_widget_set_size(i->data, tw - wchange, th - hchange);
- g_object_set_data(G_OBJECT(box), "size-queued", wid);
+ if (wid != last && !child && gnt_widget_confirm_size(wid, w - wchange, h - hchange)) {
+ if (!child && (child = last)) { + gnt_widget_get_size(child, &w, &h); + if (!gnt_widget_confirm_size(child, w - wchange, h - hchange)) + g_object_set_data(G_OBJECT(box), PROP_SIZE_QUEUED_S, child); + for (iter = box->list; iter; iter = iter->next) { + GntWidget *wid = iter->data; + gnt_widget_get_size(wid, &w, &h); + /* For a vertical box, if we are changing the width, make sure the widgets + * in the box will fit after resizing the width. */ + w >= child->priv.width && + !gnt_widget_confirm_size(wid, w - wchange, h)) + /* If we are changing the height, make sure the widgets in the box fit after + h >= child->priv.height && + !gnt_widget_confirm_size(wid, w, h - hchange)) + return (child != NULL); @@ -477,16 +473,16 @@
GntBox *box = GNT_BOX(widget);
wchange = widget->priv.width - oldw;
hchange = widget->priv.height - oldh;
- wid = g_object_get_data(G_OBJECT(box), "size-queued");
+ wid = g_object_get_data(G_OBJECT(box), PROP_SIZE_QUEUED_S); gnt_widget_get_size(wid, &tw, &th);
gnt_widget_set_size(wid, tw + wchange, th + hchange);
- g_object_set_data(G_OBJECT(box), "size-queued", NULL);
+ g_object_set_data(G_OBJECT(box), PROP_SIZE_QUEUED_S, NULL); + g_object_set_data(G_OBJECT(box), PROP_LAST_RESIZE_S, wid);