# HG changeset patch
# User Sadrul Habib Chowdhury <imadil@gmail.com>
# Date 1153620199 0
# Node ID c9509bd42d7ae67126df4c2fb8ed6346e5db3619
# Parent  a71678d2da160b679e767081bff04fa4b5eba064
[gaim-migrate @ 16542]
Show the mail-notification checkbox in the account-dialog only if
the prpl has support for it.

committer: Tailor Script <tailor@pidgin.im>

diff -r a71678d2da16 -r c9509bd42d7a console/gntaccount.c
--- a/console/gntaccount.c	Sun Jul 23 01:10:06 2006 +0000
+++ b/console/gntaccount.c	Sun Jul 23 02:03:19 2006 +0000
@@ -396,6 +396,10 @@
 	if (dialog->account)
 		gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail),
 				gaim_account_get_check_mail(dialog->account));
+	if (!prplinfo || !(prplinfo->options & OPT_PROTO_MAIL_CHECK))
+		gnt_widget_set_visible(dialog->newmail, FALSE);
+	else
+		gnt_widget_set_visible(dialog->newmail, TRUE);
 
 	if (dialog->remember == NULL)
 		dialog->remember = gnt_check_box_new(_("Remember password"));
diff -r a71678d2da16 -r c9509bd42d7a console/libgnt/gntbox.c
--- a/console/libgnt/gntbox.c	Sun Jul 23 01:10:06 2006 +0000
+++ b/console/libgnt/gntbox.c	Sun Jul 23 02:03:19 2006 +0000
@@ -89,6 +89,8 @@
 
 	for (iter = box->list; iter; iter = iter->next)
 	{
+		if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(iter->data), GNT_WIDGET_INVISIBLE))
+			continue;
 		gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury);
 		gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h);
 		if (box->vertical)
@@ -217,6 +219,7 @@
 static GntWidget *
 find_focusable_widget(GntBox *box)
 {
+	/* XXX: Make sure the widget is visible? */
 	if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL)
 		g_list_foreach(box->list, add_to_focus, box);
 
@@ -229,11 +232,17 @@
 static void
 find_next_focus(GntBox *box)
 {
-	GList *iter = g_list_find(box->focus, box->active);
-	if (iter && iter->next)
-		box->active = iter->next->data;
-	else if (box->focus)
-		box->active = box->focus->data;
+	gpointer last = box->active;
+	do
+	{
+		GList *iter = g_list_find(box->focus, box->active);
+		if (iter && iter->next)
+			box->active = iter->next->data;
+		else if (box->focus)
+			box->active = box->focus->data;
+		if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE))
+			break;
+	} while (box->active != last);
 }
 
 static gboolean
@@ -564,6 +573,9 @@
 		int height, width;
 		int x, y;
 
+		if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE))
+			continue;
+
 		if (GNT_IS_BOX(w))
 			gnt_box_sync_children(GNT_BOX(w));
 
diff -r a71678d2da16 -r c9509bd42d7a console/libgnt/gntwidget.c
--- a/console/libgnt/gntwidget.c	Sun Jul 23 01:10:06 2006 +0000
+++ b/console/libgnt/gntwidget.c	Sun Jul 23 02:03:19 2006 +0000
@@ -329,6 +329,7 @@
 		mvwvline(widget->window, 1, widget->priv.width, ' ', widget->priv.height);
 #endif
 	gnt_screen_release(widget);
+	GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
 	GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_MAPPED);
 }
 
@@ -509,3 +510,11 @@
 	return ret;
 }
 
+void gnt_widget_set_visible(GntWidget *widget, gboolean set)
+{
+	if (set)
+		GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
+	else
+		GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_INVISIBLE);
+}
+
diff -r a71678d2da16 -r c9509bd42d7a console/libgnt/gntwidget.h
--- a/console/libgnt/gntwidget.h	Sun Jul 23 01:10:06 2006 +0000
+++ b/console/libgnt/gntwidget.h	Sun Jul 23 02:03:19 2006 +0000
@@ -39,6 +39,7 @@
 	GNT_WIDGET_URGENT         = 1 << 7,
 	GNT_WIDGET_GROW_X         = 1 << 8,
 	GNT_WIDGET_GROW_Y         = 1 << 9,
+	GNT_WIDGET_INVISIBLE      = 1 << 10,
 } GntWidgetFlags;
 
 /* XXX: I'll have to ask grim what he's using this for in guifications. */
@@ -125,6 +126,9 @@
 void gnt_widget_queue_update(GntWidget *widget);
 
 void gnt_widget_set_take_focus(GntWidget *widget, gboolean set);
+
+void gnt_widget_set_visible(GntWidget *widget, gboolean set);
+
 G_END_DECLS
 
 #endif /* GNT_WIDGET_H */