changeset 13980:c9509bd42d7a

[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>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 23 Jul 2006 02:03:19 +0000
parents a71678d2da16
children 91a4cc3ee221
files console/gntaccount.c console/libgnt/gntbox.c console/libgnt/gntwidget.c console/libgnt/gntwidget.h
diffstat 4 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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"));
--- 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));
 
--- 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);
+}
+
--- 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 */