diff pidgin/gtkconv.c @ 17162:63a09098b0e8

propagate from branch 'im.pidgin.pidgin' (head faebb5b94eeb15c49559aa2b3c3ce87c9a38a763) to branch 'org.maemo.garage.pidgin.pidgin.dbus_uniq' (head 6771ea465fa274728502a0e7e5d7295deef57e28)
author Gabriel Schulhof <nix@go-nix.ca>
date Fri, 18 May 2007 22:31:37 +0000
parents 150980c9d79d ff7dea1672b3
children
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Thu May 17 07:29:26 2007 +0000
+++ b/pidgin/gtkconv.c	Fri May 18 22:31:37 2007 +0000
@@ -1755,7 +1755,8 @@
 static void
 move_to_next_unread_tab(PidginConversation *gtkconv, gboolean forward)
 {
-	PidginConversation *next_gtkconv = NULL;
+	PidginConversation *next_gtkconv = NULL, *most_active = NULL;
+	PidginUnseenState unseen_state = PIDGIN_UNSEEN_NONE;
 	PidginWindow *win;
 	int initial, i, total, diff;
 
@@ -1771,17 +1772,21 @@
 
 	for (i = (initial + diff) % total; i != initial; i = (i + diff) % total) {
 		next_gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, i);
-		if (next_gtkconv->unseen_state > 0)
-			break;
-	}
-
-	if (i == initial) { /* no new messages */
+		if (next_gtkconv->unseen_state > unseen_state) {
+			most_active = next_gtkconv;
+			unseen_state = most_active->unseen_state;
+			if(PIDGIN_UNSEEN_NICK == unseen_state) /* highest possible state */
+				break;
+		}
+	}
+
+	if (most_active == NULL) { /* no new messages */
 		i = (i + diff) % total;
-		next_gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, i);
-	}
-
-	if (next_gtkconv != NULL && next_gtkconv != gtkconv)
-		pidgin_conv_window_switch_gtkconv(win, next_gtkconv);
+		most_active = pidgin_conv_window_get_gtkconv_at_index(win, i);
+	}
+
+	if (most_active != NULL && most_active != gtkconv)
+		pidgin_conv_window_switch_gtkconv(win, most_active);
 }
 
 static gboolean