changeset 13953:8b2306c64efa

[gaim-migrate @ 16501] Minor adjustments to the packing of child widgets in a box. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 17 Jul 2006 04:30:50 +0000
parents 841a5ffbfee4
children 3cd388613624
files console/gntnotify.c console/libgnt/gntbox.c console/libgnt/gntbox.h console/libgnt/test/focus.c console/libgnt/test/tv.c
diffstat 5 files changed, 33 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntnotify.c	Mon Jul 17 03:45:24 2006 +0000
+++ b/console/gntnotify.c	Mon Jul 17 04:30:50 2006 +0000
@@ -29,6 +29,8 @@
 	window = gnt_box_new(FALSE, TRUE);
 	gnt_box_set_toplevel(GNT_BOX(window), TRUE);
 	gnt_box_set_title(GNT_BOX(window), title);
+	gnt_box_set_fill(GNT_BOX(window), FALSE);
+	gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
 
 	if (primary)
 		gnt_box_add_widget(GNT_BOX(window),
--- a/console/libgnt/gntbox.c	Mon Jul 17 03:45:24 2006 +0000
+++ b/console/libgnt/gntbox.c	Mon Jul 17 04:30:50 2006 +0000
@@ -173,31 +173,30 @@
 		if (maxw < w)
 			maxw = w;
 	}
-	
-	if (box->homogeneous)
+
+	for (iter = box->list; iter; iter = iter->next)
 	{
-		for (iter = box->list; iter; iter = iter->next)
-		{
-			gnt_widget_set_size(GNT_WIDGET(iter->data), maxw, maxh);
-		}
-	}
-	else
-	{
-		for (iter = box->list; iter; iter = iter->next)
+		int w, h;
+		GntWidget *wid = GNT_WIDGET(iter->data);
+
+		gnt_widget_get_size(wid, &w, &h);
+
+		if (box->homogeneous)
 		{
 			if (box->vertical)
-			{
-				int h;
-				gnt_widget_get_size(GNT_WIDGET(iter->data), NULL, &h);
-				gnt_widget_set_size(GNT_WIDGET(iter->data), maxw, h);
-			}
+				h = maxh;
 			else
-			{
-				int w;
-				gnt_widget_get_size(GNT_WIDGET(iter->data), &w, NULL);
-				gnt_widget_set_size(GNT_WIDGET(iter->data), w, maxh);
-			}
+				w = maxw;
 		}
+		if (box->fill)
+		{
+			if (box->vertical)
+				w = maxw;
+			else
+				h = maxh;
+		}
+
+		gnt_widget_set_size(wid, w, h);
 	}
 
 	reposition_children(widget);
@@ -495,6 +494,7 @@
 	box->homogeneous = homo;
 	box->vertical = vert;
 	box->pad = 1;
+	box->fill = TRUE;
 	gnt_widget_set_take_focus(widget, TRUE);
 	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
 	if (vert)
@@ -669,3 +669,8 @@
 	}
 }
 
+void gnt_box_set_fill(GntBox *box, gboolean fill)
+{
+	box->fill = fill;
+}
+
--- a/console/libgnt/gntbox.h	Mon Jul 17 03:45:24 2006 +0000
+++ b/console/libgnt/gntbox.h	Mon Jul 17 04:30:50 2006 +0000
@@ -33,6 +33,7 @@
 
 	gboolean vertical;
 	gboolean homogeneous;
+	gboolean fill;
 	GList *list;		/* List of widgets */
 
 	GntWidget *active;
@@ -85,6 +86,8 @@
 
 void gnt_box_readjust(GntBox *box);
 
+void gnt_box_set_fill(GntBox *box, gboolean fill);
+
 G_END_DECLS
 
 #endif /* GNT_BOX_H */
--- a/console/libgnt/test/focus.c	Mon Jul 17 03:45:24 2006 +0000
+++ b/console/libgnt/test/focus.c	Mon Jul 17 04:30:50 2006 +0000
@@ -32,6 +32,7 @@
 
 	vbox = gnt_box_new(FALSE, FALSE);
 	hbox = gnt_box_new(FALSE, TRUE);
+	gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
 
 	gnt_widget_set_name(vbox, "vbox");
 	gnt_widget_set_name(hbox, "hbox");
--- a/console/libgnt/test/tv.c	Mon Jul 17 03:45:24 2006 +0000
+++ b/console/libgnt/test/tv.c	Mon Jul 17 04:30:50 2006 +0000
@@ -45,7 +45,9 @@
 	hbox = gnt_box_new(FALSE, TRUE);
 	gnt_widget_set_name(hbox, "hbox");
 	gnt_box_set_toplevel(GNT_BOX(hbox), TRUE);
+	gnt_box_set_fill(GNT_BOX(hbox), FALSE);
 	gnt_box_set_title(GNT_BOX(hbox), "Textview test");
+	gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
 
 	entry = gnt_entry_new(NULL);
 	gnt_widget_set_name(entry, "entry");