changeset 13916:fdf2dbed6faa

[gaim-migrate @ 16418] Make the conversation windows bigger ... which is better *wink*. Use Panel library to manage the windows. Add a window-list that you can use to quickly switch to a window (press Alt+w to bring it up). Get rid of some unused codes. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 04 Jul 2006 01:32:39 +0000
parents e78d113f82db
children 3111c8105199
files console/gntaccount.c console/gntblist.c console/gntblist.h console/gntconv.c console/libgnt/Makefile.am console/libgnt/gntbox.c console/libgnt/gntmain.c console/libgnt/gntwidget.c console/libgnt/test/Makefile console/libgnt/test/multiwin.c
diffstat 10 files changed, 206 insertions(+), 274 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntaccount.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/gntaccount.c	Tue Jul 04 01:32:39 2006 +0000
@@ -38,7 +38,7 @@
 	gnt_widget_set_name(accounts.window, "accounts");
 
 	gnt_box_add_widget(GNT_BOX(accounts.window),
-			gnt_label_new(_("You can enable/disable accounts from the follwing list.")));
+			gnt_label_new(_("You can enable/disable accounts from the following list.")));
 
 	accounts.tree = gnt_tree_new();
 	GNT_WIDGET_SET_FLAGS(accounts.tree, GNT_WIDGET_NO_BORDER);
--- a/console/gntblist.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/gntblist.c	Tue Jul 04 01:32:39 2006 +0000
@@ -355,6 +355,7 @@
 	gnt_box_add_widget(GNT_BOX(box), gnt_label_new(str->str));
 
 	gnt_widget_set_position(box, x, y);
+	GNT_WIDGET_UNSET_FLAGS(box, GNT_WIDGET_CAN_TAKE_FOCUS);
 	gnt_widget_draw(box);
 
 	g_free(title);
@@ -438,6 +439,10 @@
 	g_signal_connect(G_OBJECT(ggblist->tree), "selection_changed", G_CALLBACK(selection_changed), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "key_pressed", G_CALLBACK(key_pressed), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist);
+	g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip),
+				ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+	g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_tooltip),
+				ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 }
 
 void gg_blist_uninit()
@@ -447,4 +452,23 @@
 	ggblist = NULL;
 }
 
+void gg_blist_get_position(int *x, int *y)
+{
+	gnt_widget_get_position(ggblist->window, x, y);
+}
 
+void gg_blist_set_position(int x, int y)
+{
+	gnt_widget_set_position(ggblist->window, x, y);
+}
+
+void gg_blist_get_size(int *width, int *height)
+{
+	gnt_widget_get_size(ggblist->window, width, height);
+}
+
+void gg_blist_set_size(int width, int height)
+{
+	gnt_widget_set_size(ggblist->window, width, height);
+}
+
--- a/console/gntblist.h	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/gntblist.h	Tue Jul 04 01:32:39 2006 +0000
@@ -5,3 +5,12 @@
 void gg_blist_init();
 
 void gg_blist_uninit();
+
+void gg_blist_get_position(int *x, int *y);
+
+void gg_blist_set_position(int x, int y);
+
+void gg_blist_get_size(int *width, int *height);
+
+void gg_blist_set_size(int width, int height);
+
--- a/console/gntconv.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/gntconv.c	Tue Jul 04 01:32:39 2006 +0000
@@ -2,6 +2,7 @@
 #include <util.h>
 
 #include "gntgaim.h"
+#include "gntblist.h"
 #include "gntconv.h"
 
 #include "gnt.h"
@@ -91,10 +92,14 @@
 	GGConv *ggc = g_hash_table_lookup(ggconvs, conv);
 	char *title;
 	GaimConversationType type;
+	int x, width;
 
 	if (ggc)
 		return;
 
+	gg_blist_get_position(&x, NULL);
+	gg_blist_get_size(&width, NULL);
+
 	ggc = g_new0(GGConv, 1);
 	g_hash_table_insert(ggconvs, conv, ggc);
 
@@ -102,25 +107,28 @@
 
 	type = gaim_conversation_get_type(conv);
 	title = g_strdup_printf(_("%s"), gaim_conversation_get_name(conv));
-	ggc->window = gnt_box_new(FALSE, TRUE);
+	ggc->window = gnt_box_new(TRUE, TRUE);
 	gnt_box_set_title(GNT_BOX(ggc->window), title);
 	gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE);
+	gnt_box_set_pad(GNT_BOX(ggc->window), 0);
 	gnt_widget_set_name(ggc->window, title);
 
 	ggc->tv = gnt_text_view_new();
 	gnt_box_add_widget(GNT_BOX(ggc->window), ggc->tv);
 	gnt_widget_set_name(ggc->tv, "conversation-window-textview");
-	gnt_widget_set_size(ggc->tv, getmaxx(stdscr) - 40, getmaxy(stdscr) - 15);
+	gnt_widget_set_size(ggc->tv, getmaxx(stdscr) - 2 - x - width, getmaxy(stdscr) - 4);
 
 	ggc->entry = gnt_entry_new(NULL);
 	gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry);
 	gnt_widget_set_name(ggc->entry, "conversation-window-entry");
-	gnt_widget_set_size(ggc->entry, getmaxx(stdscr) - 40, 1);
 
 	g_signal_connect(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc);
 	g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc);
 
-	gnt_widget_set_position(ggc->window, 32, 0);
+	/* XXX: I am assuming the buddylist is on the leftmost corner.
+	 *      That may not always be correct, since the windows can be moved.
+	 *      It might be an option to remember the position of conv. windows. */
+	gnt_widget_set_position(ggc->window, x + width, 0);
 	gnt_widget_show(ggc->window);
 
 	g_free(title);
--- a/console/libgnt/Makefile.am	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/libgnt/Makefile.am	Tue Jul 04 01:32:39 2006 +0000
@@ -37,7 +37,7 @@
 libgnt_la_LIBADD = \
 	$(GLIB_LIBS) \
 	$(STATIC_LINK_LIBS) \
-	-lncursesw
+	-lncursesw -lpanelw
 
 AM_CPPFLAGS = \
 	$(GLIB_CFLAGS)
--- a/console/libgnt/gntbox.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/libgnt/gntbox.c	Tue Jul 04 01:32:39 2006 +0000
@@ -167,55 +167,6 @@
 	DEBUG;
 }
 
-#if 0
-static GntWidget *
-find_next_focus(GntBox *box)
-{
-	GntWidget *w = box->active;
-	GList *iter;
-
-	if (w == NULL)
-	{
-		return find_focusable_widget(box);
-	}
-
-	while (w && !(iter = g_list_find(box->list, w)))
-		w = w->parent;
-
-	if (!w)
-		box->active = NULL;
-	else if (iter)
-	{
-		GntWidget *next = NULL;
-		
-		while (!next && (iter = iter->next))
-		{
-			if (GNT_IS_BOX(iter->data))
-				next = find_next_focus(iter->data);
-			else
-			{
-				if (GNT_WIDGET_IS_FLAG_SET(iter->data, GNT_WIDGET_CAN_TAKE_FOCUS) &&
-						GNT_WIDGET_IS_FLAG_SET(iter->data, GNT_WIDGET_HAS_FOCUS))
-					next = iter->data;
-				else
-					next = NULL;
-			}
-		}
-		box->active = next;
-	}
-
-	if (box->active == NULL && GNT_WIDGET(box)->parent == NULL)
-	{
-		box->active = find_focusable_widget(box);
-	}
-	
-	if (box->active)
-		GNT_WIDGET_SET_FLAGS(box->active, GNT_WIDGET_HAS_FOCUS);
-
-	return box->active;
-}
-#endif
-
 /* Ensures that the current widget can take focus */
 static GntWidget *
 find_focusable_widget(GntBox *box)
@@ -227,62 +178,6 @@
 		box->active = box->focus->data;
 
 	return box->active;
-
-#if 0
-	for (iter = box->list; iter; iter = iter->next)
-	{
-		w = iter->data;
-		if (GNT_IS_BOX(w))
-		{
-			w = find_focusable_widget(GNT_BOX(w));
-			if (w)
-				break;
-		}
-		else if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS))
-			break;
-	}
-
-	if (iter)
-		box->active = w;
-	else
-		box->active = NULL;
-
-	if (box->active)
-		GNT_WIDGET_SET_FLAGS(box->active, GNT_WIDGET_HAS_FOCUS);
-
-	return box->active;
-
-#if 0
-	if (box->active == NULL && box->list)
-		box->active = box->list->data;
-	else
-		w = box->active;
-
-	total = g_list_length(box->list);
-
-	while (box->active && !GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_CAN_TAKE_FOCUS))
-	{
-		box->active = box->active->next;
-		investigated++;
-	}
-
-	/* Rotate if necessary */
-	if (!box->active && investigated < total)
-	{
-		box->active = box->list;
-		while (investigated < total &&  !GNT_WIDGET_IS_FLAG_SET(box->active->data, GNT_WIDGET_CAN_TAKE_FOCUS))
-		{
-			box->active = box->active->next;
-			investigated++;
-		}
-	}
-
-	if (box->active)
-		gnt_widget_set_focus(box->active->data, TRUE);
-	if (w && w != box->active->data)
-		gnt_widget_set_focus(w, FALSE);
-#endif
-#endif
 }
 
 static gboolean
@@ -335,66 +230,23 @@
 	return FALSE;
 }
 
-#if 0
-static GntWidget *find_focused_widget(GntBox *box)
-{
-	GList *iter;
-
-	for (iter = box->list; iter; iter = iter->next)
-	{
-		GntWidget *w = iter->data;
-		
-		if (GNT_IS_BOX(w))
-		{
-			if ((w = find_focused_widget(GNT_BOX(w))) != NULL)
-				return w;
-		}
-		else
-		{
-			if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_CAN_TAKE_FOCUS) &&
-					GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_HAS_FOCUS))
-				return w;
-		}
-	}
-	return NULL;
-}
-#endif
-
-#if 0
-static void
-gnt_box_set_focus(GntWidget *widget, gboolean set)
-{
-	GntWidget *p = widget;
-
-	while (p->parent)
-		p = p->parent;
-
-	p = find_focused_widget(GNT_BOX(p));
-	if (p)
-		gnt_widget_set_focus(p, set);
-	gnt_widget_draw(widget);
-}
-
 static void
 gnt_box_lost_focus(GntWidget *widget)
 {
-	gnt_box_set_focus(widget, FALSE);
+	GntWidget *w = GNT_BOX(widget)->active;
+	if (w)
+		gnt_widget_set_focus(w, FALSE);
+	gnt_widget_draw(widget);
 }
 
 static void
 gnt_box_gained_focus(GntWidget *widget)
 {
-	GntWidget *p;
-
-	while (widget->parent)
-		widget = widget->parent;
-	
-	p = find_focused_widget(GNT_BOX(widget));
-	GNT_BOX(widget)->active = g_list_find(GNT_BOX(widget)->list, p);
-	if (p)
-		gnt_widget_draw(p);
+	GntWidget *w = GNT_BOX(widget)->active;
+	if (w)
+		gnt_widget_set_focus(w, TRUE);
+	gnt_widget_draw(widget);
 }
-#endif
 
 static void
 gnt_box_destroy(GntWidget *w)
@@ -432,11 +284,8 @@
 	parent_class->size_request = gnt_box_size_request;
 	parent_class->set_position = gnt_box_set_position;
 	parent_class->key_pressed = gnt_box_key_pressed;
-#if 0
-	/* We are going to need this when there are multiple focusble widgets in a box */
 	parent_class->lost_focus = gnt_box_lost_focus;
 	parent_class->gained_focus = gnt_box_gained_focus;
-#endif
 
 	DEBUG;
 }
@@ -513,9 +362,15 @@
 {
 	GntWidget *widget = GNT_WIDGET(box);
 	if (set)
+	{
 		GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
+		GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
+	}
 	else
+	{
 		GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
+		GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
+	}
 }
 
 void gnt_box_sync_children(GntBox *box)
--- a/console/libgnt/gntmain.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/libgnt/gntmain.c	Tue Jul 04 01:32:39 2006 +0000
@@ -1,7 +1,10 @@
+#include <panel.h>
+
 #include "gnt.h"
 #include "gntbox.h"
 #include "gntkeys.h"
 #include "gntcolors.h"
+#include "gnttree.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -18,12 +21,17 @@
 static int Y_MAX;
 
 static GMainLoop *loop;
+static struct
+{
+	GntWidget *window;
+	GntWidget *tree;
+} window_list;
 
 typedef struct
 {
 	GntWidget *me;
-	GList *below;		/* List of widgets below me */
-	GList *above;		/* List of widgets above me */
+
+	PANEL *panel;
 } GntNode;
 
 typedef enum
@@ -32,6 +40,7 @@
 	GNT_KP_MODE_RESIZE,
 	GNT_KP_MODE_MOVE,
 	GNT_KP_MODE_MENU,
+	GNT_KP_MODE_WINDOW_LIST
 } GntKeyPressMode;
 
 static GHashTable *nodes;
@@ -91,19 +100,23 @@
 	GntNode *node = g_hash_table_lookup(nodes, widget);
 	GList *iter;
 
+	g_return_if_fail(focus_list->data == widget);
+
 	if (!node)
 		return;
 
-	for (iter = node->above; iter;)
+	gnt_widget_set_focus(focus_list->data, TRUE);
+	gnt_widget_draw(focus_list->data);
+
+	top_panel(node->panel);
+
+	if (window_list.window)
 	{
-		GntNode *n = iter->data;
-		iter = iter->next;
-		n->below = g_list_remove(n->below, node);
-		n->above = g_list_prepend(n->above, node);
-
-		node->above = g_list_remove(node->above, n);
-		node->below = g_list_prepend(node->below, n);
+		GntNode *nd = g_hash_table_lookup(nodes, window_list.window);
+		top_panel(nd->panel);
 	}
+	update_panels();
+	doupdate();
 }
 
 static void
@@ -178,21 +191,75 @@
 	
 	if (focus_list)
 	{
-		gnt_widget_set_focus(focus_list->data, TRUE);
 		bring_on_top(focus_list->data);
-		gnt_widget_draw(focus_list->data);
 	}
 
 	if (w && (!focus_list || w != focus_list->data))
+	{
 		gnt_widget_set_focus(w, FALSE);
-}		
+	}
+}
+
+static void
+window_list_activate(GntTree *tree, gpointer null)
+{
+	GntWidget *widget = gnt_tree_get_selection_data(GNT_TREE(tree));
+	GntWidget *old;
+
+	if (focus_list)
+		old = focus_list->data;
+
+	focus_list = g_list_find(g_list_first(focus_list), widget);
+	bring_on_top(widget);
+
+	if (old && (!focus_list || old != focus_list->data))
+	{
+		gnt_widget_set_focus(old, FALSE);
+	}
+}
+
+static GntWidget *
+show_window_list()
+{
+	GntWidget *tree, *win;
+	GList *iter;
+	int id;
+
+	if (window_list.window)
+		return window_list.window;
+
+	win = window_list.window = gnt_box_new(FALSE, FALSE);
+	gnt_box_set_toplevel(GNT_BOX(win), TRUE);
+	gnt_box_set_title(GNT_BOX(win), "Window List");
+	gnt_box_set_pad(GNT_BOX(win), 0);
+
+	tree = window_list.tree = gnt_tree_new();
+
+	for (iter = g_list_first(focus_list); iter; iter = iter->next)
+	{
+		GntBox *box = GNT_BOX(iter->data);
+
+		gnt_tree_add_row_after(GNT_TREE(tree), box, box->title, NULL, NULL);
+	}
+
+	gnt_box_add_widget(GNT_BOX(win), tree);
+
+	gnt_widget_set_size(tree, getmaxx(stdscr) / 3, getmaxy(stdscr) / 2);
+	gnt_widget_set_position(win, getmaxx(stdscr) / 3, getmaxy(stdscr) / 4);
+
+	lock_focus_list = 1;
+	gnt_widget_show(win);
+	lock_focus_list = 0;
+
+	g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(window_list_activate), NULL);
+}
 
 static gboolean
 io_invoke(GIOChannel *source, GIOCondition cond, gpointer null)
 {
 	char buffer[256];
+	gboolean ret = FALSE;
 	static GntKeyPressMode mode = GNT_KP_MODE_NORMAL;
-	gboolean ret = FALSE;
 
 	int rd = read(0, buffer, sizeof(buffer) - 1);
 	if (rd < 0)
@@ -251,6 +318,11 @@
 				{
 					mode = GNT_KP_MODE_MOVE;
 				}
+				else if (strcmp(buffer + 1, "w") == 0 && focus_list)
+				{
+					mode = GNT_KP_MODE_WINDOW_LIST;
+					show_window_list();
+				}
 			}
 		}
 	}
@@ -317,6 +389,20 @@
 			mode = GNT_KP_MODE_NORMAL;
 		}
 	}
+	else if (mode == GNT_KP_MODE_WINDOW_LIST && window_list.window)
+	{
+		gnt_widget_key_pressed(window_list.window, buffer);
+
+		if (buffer[0] == '\r' || (buffer[0] == 27 && buffer[1] == 0))
+		{
+			mode = GNT_KP_MODE_NORMAL;
+			lock_focus_list = 1;
+			gnt_widget_destroy(window_list.window);
+			window_list.window = NULL;
+			window_list.tree = NULL;
+			lock_focus_list = 0;
+		}
+	}
 
 	draw_taskbar();
 	refresh();
@@ -373,36 +459,10 @@
 free_node(gpointer data)
 {
 	GntNode *node = data;
-	g_list_free(node->below);
-	g_list_free(node->above);
+	del_panel(node->panel);
 	g_free(node);
 }
 
-static void
-check_intersection(gpointer key, gpointer value, gpointer data)
-{
-	GntNode *n = value;
-	GntNode *nu = data;
-
-	if (value == NULL)
-		return;
-	if (n->me == nu->me)
-		return;
-
-	if (n->me->priv.x + n->me->priv.width < nu->me->priv.x)
-		return;
-	if (nu->me->priv.x + nu->me->priv.width < n->me->priv.x)
-		return;
-
-	if (n->me->priv.y + n->me->priv.height < nu->me->priv.y)
-		return;
-	if (nu->me->priv.y + nu->me->priv.height < n->me->priv.y)
-		return;
-
-	n->above = g_list_prepend(n->above, nu);
-	nu->below = g_list_prepend(nu->below, n);
-}
-
 void gnt_screen_occupy(GntWidget *widget)
 {
 	GntNode *node;
@@ -419,56 +479,41 @@
 	node = g_new0(GntNode, 1);
 	node->me = widget;
 
-	g_hash_table_foreach(nodes, check_intersection, node);
 	g_hash_table_replace(nodes, widget, node);
+
+	if (window_list.window)
+	{
+		if ((GNT_IS_BOX(widget) && GNT_BOX(widget)->title) && window_list.window != widget
+				&& GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_CAN_TAKE_FOCUS))
+			gnt_tree_add_row_after(GNT_TREE(window_list.tree), widget,
+					GNT_BOX(widget)->title, NULL, NULL);
+	}
+
+	update_panels();
+	doupdate();
 }
 
 void gnt_screen_release(GntWidget *widget)
 {
 	WINDOW *win;
 	GList *iter;
-	GntNode *node = g_hash_table_lookup(nodes, widget);
+	GntNode *node;
 
 	gnt_screen_remove_widget(widget);
+	node = g_hash_table_lookup(nodes, widget);
 
 	if (node == NULL)	/* Yay! Nothing to do. */
 		return;
 
-	win = dupwin(widget->window);
-	werase(win);
-
-	/* XXX: This is not going to work.
-	 *      It will be necessary to build a topology and go from there. */
-	for (iter = node->below; iter; iter = iter->next)
-	{
-		GntNode *n = iter->data;
-		GntWidget *w = n->me;
-		int left, right, top, bottom;
+	g_hash_table_remove(nodes, widget);
 
-		left = MAX(widget->priv.x, w->priv.x) - w->priv.x;
-		right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x;
-		
-		top = MAX(widget->priv.y, w->priv.y) - w->priv.y;
-		bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y;
-
-		copywin(w->window, win, top, left,
-					w->priv.y - widget->priv.y + top,
-					w->priv.x - widget->priv.x + left,
-					w->priv.y - widget->priv.y + bottom - 1,
-					w->priv.x - widget->priv.x + right - 1, FALSE);
-		n->above = g_list_remove(n->above, node);
+	if (window_list.window)
+	{
+		gnt_tree_remove(GNT_TREE(window_list.tree), widget);
 	}
 
-	for (iter = node->above; iter; iter = iter->next)
-	{
-		GntNode *n = iter->data;
-		n->below = g_list_remove(n->below, node);
-	}
-
-	wrefresh(win);
-	delwin(win);
-
-	g_hash_table_remove(nodes, widget);
+	update_panels();
+	doupdate();
 }
 
 void gnt_screen_update(GntWidget *widget)
@@ -485,34 +530,17 @@
 	
 	gnt_box_sync_children(GNT_BOX(widget));
 	node = g_hash_table_lookup(nodes, widget);
-
-	win = dupwin(widget->window);
-	
-	if (node && node->above)
-	{
-		/* XXX: Same here: need to build a topology first. */
-		for (iter = node->above; iter; iter = iter->next)
-		{
-			GntNode *n = iter->data;
-			GntWidget *w = n->me;
-			int left, right, top, bottom;
+	if (node && !node->panel)
+		node->panel = new_panel(node->me->window);
 
-			left = MAX(widget->priv.x, w->priv.x) - w->priv.x;
-			right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x;
-			
-			top = MAX(widget->priv.y, w->priv.y) - w->priv.y;
-			bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y;
-
-			copywin(w->window, win, top, left,
-					w->priv.y - widget->priv.y + top,
-					w->priv.x - widget->priv.x + left,
-					w->priv.y - widget->priv.y + bottom - 1,
-					w->priv.x - widget->priv.x + right - 1, FALSE);
-		}
+	if (window_list.window)
+	{
+		GntNode *nd = g_hash_table_lookup(nodes, window_list.window);
+		top_panel(nd->panel);
 	}
 
-	wrefresh(win);
-	delwin(win);
+	update_panels();
+	doupdate();
 }
 
 gboolean gnt_widget_has_focus(GntWidget *widget)
@@ -521,6 +549,9 @@
 	if (!widget)
 		return FALSE;
 
+	if (widget == window_list.window)
+		return TRUE;
+
 	w = widget;
 
 	while (widget->parent)
--- a/console/libgnt/gntwidget.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/libgnt/gntwidget.c	Tue Jul 04 01:32:39 2006 +0000
@@ -326,8 +326,11 @@
 	/* XXX: Need to install properties for these and g_object_notify */
 	wid->priv.x = x;
 	wid->priv.y = y;
+	
+	/* XXX: I am supposed to move_panel ... but that seems to crash */
 	if (wid->window)
 		mvwin(wid->window, y, x);
+
 	g_signal_emit(wid, signals[SIG_POSITION], 0, x, y);
 }
 
--- a/console/libgnt/test/Makefile	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/libgnt/test/Makefile	Tue Jul 04 01:32:39 2006 +0000
@@ -1,11 +1,10 @@
 CC=gcc
 CFLAGS=`pkg-config --cflags gobject-2.0` -g -I../
-LDFLAGS=`pkg-config --libs gobject-2.0` -lncursesw -pg -lgnt -L../
+LDFLAGS=`pkg-config --libs gobject-2.0` -pg -lgnt -L../
 
 EXAMPLES=focus tv multiwin
 
 all:
-	cd .. && make
 	make examples
 
 clean:
--- a/console/libgnt/test/multiwin.c	Mon Jul 03 21:19:56 2006 +0000
+++ b/console/libgnt/test/multiwin.c	Tue Jul 04 01:32:39 2006 +0000
@@ -1,18 +1,20 @@
+#include "gnt.h"
 #include "gntbutton.h"
-#include "gnt.h"
+#include "gntentry.h"
 #include "gntkeys.h"
+#include "gntlabel.h"
 #include "gnttree.h"
 #include "gntbox.h"
 
 gboolean show(GntWidget *w)
 {
-	gnt_widget_draw(w);
-
-	return TRUE;
+	gnt_widget_destroy(w);
+	return FALSE;
 }
 
 int main()
 {
+	freopen(".error", "w", stderr);
 	gnt_init();
 
 	GntWidget *hbox, *tree, *box2;
@@ -36,11 +38,11 @@
 	gnt_box_set_toplevel(GNT_BOX(box2), TRUE);
 	gnt_box_set_title(GNT_BOX(box2), "On top");
 
-	gnt_box_add_widget(GNT_BOX(box2), GNT_WIDGET(gnt_label_new("asdasd")));
+	gnt_box_add_widget(GNT_BOX(box2), gnt_label_new("asdasd"));
 	gnt_box_add_widget(GNT_BOX(box2), gnt_entry_new(NULL));
 
 	gnt_widget_show(hbox);
-	gnt_widget_set_position(box2, 5, 5);
+	gnt_widget_set_position(box2, 35, 15);
 	gnt_widget_show(box2);
 
 	gnt_tree_add_row_after(GNT_TREE(tree), "a", "a", NULL, NULL);
@@ -56,7 +58,8 @@
 	gnt_tree_add_row_after(GNT_TREE(tree), "5", "5", "d", NULL);
 
 	gnt_tree_add_row_after(GNT_TREE(tree), "6", "6", "4", NULL);
-	g_timeout_add(1000, (GSourceFunc)show, hbox);
+
+	g_timeout_add(5000, show, box2);
 
 	gnt_main();