changeset 15945:92fa7d6e75b0

A few more fixes for resizing.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 27 Mar 2007 03:50:04 +0000
parents 1071320641b9
children 9214184b9d10
files finch/libgnt/gntbox.c finch/libgnt/gntwidget.c
diffstat 2 files changed, 15 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntbox.c	Tue Mar 27 01:38:37 2007 +0000
+++ b/finch/libgnt/gntbox.c	Tue Mar 27 03:50:04 2007 +0000
@@ -352,11 +352,6 @@
 	GntBox *box = GNT_BOX(widget);
 	int wchange, hchange;
 
-	if (widget->priv.width != width && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
-		return FALSE;
-	if (widget->priv.height != height && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
-		return FALSE;
-
 	if (!box->list)
 		return TRUE;
 
@@ -387,13 +382,21 @@
 				gnt_widget_get_size(GNT_WIDGET(i->data), &tw, &th);
 				if (box->vertical)
 				{
-					if (!gnt_widget_confirm_size(i->data, tw - wchange, th))
-						return FALSE;
+					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
+						 * resizing. */
+						if (wchange > 0 && tw >= widget->priv.width)
+							return FALSE;
+					}
 				}
 				else
 				{
-					if (!gnt_widget_confirm_size(i->data, tw, th - hchange))
+					if (!gnt_widget_confirm_size(i->data, tw, th - hchange)) {
+						if (hchange > 0 && th >= widget->priv.height)
+							return FALSE;
 						return FALSE;
+					}
 				}
 			}
 #if 0
@@ -562,17 +565,6 @@
 {
 	b->list = g_list_append(b->list, widget);
 	widget->parent = GNT_WIDGET(b);
-
-	if (b->vertical)
-	{
-		if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
-			GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(b), GNT_WIDGET_GROW_X);
-	}
-	else
-	{
-		if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
-			GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(b), GNT_WIDGET_GROW_Y);
-	}
 }
 
 void gnt_box_set_title(GntBox *b, const char *title)
--- a/finch/libgnt/gntwidget.c	Tue Mar 27 01:38:37 2007 +0000
+++ b/finch/libgnt/gntwidget.c	Tue Mar 27 03:50:04 2007 +0000
@@ -75,11 +75,13 @@
 static gboolean
 gnt_widget_dummy_confirm_size(GntWidget *widget, int width, int height)
 {
+	gboolean shadow;
 	if (width < widget->priv.minw || height < widget->priv.minh)
 		return FALSE;
-	if (widget->priv.width != width && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
+	shadow = gnt_widget_has_shadow(widget);
+	if (widget->priv.width + shadow != width && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_X))
 		return FALSE;
-	if (widget->priv.height != height && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
+	if (widget->priv.height + shadow != height && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_GROW_Y))
 		return FALSE;
 	return TRUE;
 }