changeset 17141:03866cefa848

Patch #1054 from resiak. "Make Ctrl-[Shift-]Tab prefer tabs with higher-valued unseen_states to those which are nearer but have lower values. This has the effect of making Ctrl-Tab ignore conversations with activity like status changes when other tabs have unread messages, and prefer chats where you are hilighted even more. (By an amazing coincidence, this is exactly what meta-a does in irssi.)". This closes #1054. resiak: Thanks!
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 18 May 2007 01:03:53 +0000
parents 3c4280387259
children 43d627d046f6
files pidgin/gtkconv.c
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Thu May 17 22:04:49 2007 +0000
+++ b/pidgin/gtkconv.c	Fri May 18 01:03:53 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