changeset 10893:3f85d6fc763a

[gaim-migrate @ 12606] Will (resiak) Thompson fixed control-tab committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 02 May 2005 17:49:37 +0000
parents 175167f62c28
children 1a0e699521c3
files src/gtkconv.c
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Sun May 01 14:00:37 2005 +0000
+++ b/src/gtkconv.c	Mon May 02 17:49:37 2005 +0000
@@ -1591,35 +1591,39 @@
 	GaimGtkConversation *next_gtkconv = NULL;
 	GaimConvWindow *win;
 	GList *l;
-	int index, i;
+	int index, i, found = 0;
 
 	win   = gaim_conversation_get_window(gtkconv->active_conv);
 	index = gtk_notebook_page_num(GTK_NOTEBOOK(GAIM_GTK_WINDOW(win)->notebook), gtkconv->tab_cont);
 
 	/* First check the tabs after this position. */
-	for (i = index; (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) {
+	for (i = index; !found && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) {
 		for (l = next_gtkconv->convs; l; l = l->next) {
 			GaimConversation *c = l->data;
 			if (gaim_conversation_get_unseen(c) > 0)
+			{
+				found = 1;
 				break;
+			}
 		}
 	}
-
-	if (next_gtkconv == NULL) {
-
-		/* Now check before this position. */
-		for (i = index; i >= 0 && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i--) {
+	
+	if (!found) {
+		/* Now check from the beginning up to this position. */
+		for (i = 0; !found && i < index && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) {
 			for (l = next_gtkconv->convs; l; l = l->next) {
 				GaimConversation *c = l->data;
-				if (gaim_conversation_get_unseen(c) > 0)
+				if (gaim_conversation_get_unseen(c) > 0) {
+					found = 1;
 					break;
+				}
 			}
 		}
 
-		if (next_gtkconv == NULL) {
+		if (!found) {
 			/* Okay, just grab the next conversation tab. */
 			if (!(next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index + 1)))
-				next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index - 1);
+				next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, 0);
 				
 		}
 	}