[Evolution Bug 332765 patch] fix to find_next_undeleted in message-list.c

Christof Krüger <[email protected]> Tue, 13 Mar 2007 14:43:09 +0100
Newsgroups gmane.comp.gnome.evolution.patches
Message-ID <1173793389.19992.10.camel@oxybuntu>
Hello,

I've written a patch for bug 332765 [1] which is an annoyance when you
sort your mails by ascending date and thus having new mails at the very
bottom.

The patch modifies the function find_next_undeleted to continue
searching backwards when no undeleted entry could be found after having
searched in forward direction.

There are some other problems concerning the view port being scrolled
way up, i.e. when switching to "Unread messages" and back to "All
messages". This patch doesn't address it.

Regards,
  Christof Krüger

[1] http://bugzilla.gnome.org/show_bug.cgi?id=332765

_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches
01_fix_selecting_messages_after_deleting.patch (text/x-patch, 1.1 KB)
--- evolution-2.9.92/mail/message-list.c.orig	2007-01-18 13:31:51.000000000 +0100
+++ evolution-2.9.92/mail/message-list.c	2007-03-12 12:42:47.000000000 +0100
@@ -2364,6 +2364,7 @@
 {
 	ETreePath node;
 	int last;
+	int vrow_orig;
 	int vrow;
 	ETree *et = ml->tree;
 	CamelMessageInfo *info;
@@ -2385,10 +2386,10 @@
 	last = e_tree_row_count (ml->tree);
 
 	/* model_to_view_row etc simply dont work for sorted views.  Sigh. */
-	vrow = e_tree_row_of_node (et, node);
+	vrow_orig = e_tree_row_of_node (et, node);
 
 	/* We already checked this node. */
-	vrow ++;
+	vrow = vrow_orig + 1;
 
 	while (vrow < last) {
 		node = e_tree_node_at_row (et, vrow);
@@ -2399,6 +2400,19 @@
 		vrow ++;
 	}
 
+	/* We didn't find any undeleted entries _below_ the currently selected one
+         * so let's try to find one _above_ */
+	vrow = vrow_orig - 1;
+
+	while (vrow >= 0) {
+		node = e_tree_node_at_row (et, vrow);
+		info = get_message_info (ml, node);
+		if (info && (camel_message_info_flags(info) & check) == 0) {
+			return g_strdup (camel_message_info_uid (info));
+		}
+		vrow --;
+	}
+
 	return NULL;
 }