[evolution/gnome-2-30] Bug 621839 - Improve auto-selection of messages (take two)



commit 517358b1d51eebaa7d4ad502201e68cb2c7d3349
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jul 10 14:04:43 2010 -0400

    Bug 621839 - Improve auto-selection of messages (take two)
    
    First patch for this bug misunderstood what was being asked for.  It
    auto-selected the newest unread message or else the newest read message,
    but the desired behavior was to select the -oldest- unread message or
    else the newest read message.
    
    ("Newest" and "oldest" being determined by date/time received.)

 mail/message-list.c |   55 ++++++++++++++++++++++++++------------------------
 1 files changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/mail/message-list.c b/mail/message-list.c
index ee15a32..ddbf243 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -121,10 +121,10 @@ struct _MessageListPrivate {
 	GtkTargetList *paste_target_list;
 
 	/* This aids in automatic message selection. */
-	time_t latest_read_date;
-	const gchar *latest_read_uid;
-	time_t latest_unread_date;
-	const gchar *latest_unread_uid;
+	time_t newest_read_date;
+	const gchar *newest_read_uid;
+	time_t oldest_unread_date;
+	const gchar *oldest_unread_uid;
 };
 
 enum {
@@ -704,20 +704,20 @@ message_list_select_uid (MessageList *message_list,
 	 * requested message UID was not found and 'with_fallback' is set,
 	 * try a couple fallbacks:
 	 *
-	 * 1) Most recently received unread message in the list.
-	 * 2) Most recently received read message in the list.
+	 * 1) Oldest unread message in the list, by date received.
+	 * 2) Newest read message in the list, by date received.
 	 */
 	if (message_list->regen || message_list->regen_timeout_id) {
 		g_free (message_list->pending_select_uid);
 		message_list->pending_select_uid = g_strdup (uid);
 		message_list->pending_select_fallback = with_fallback;
 	} else if (with_fallback) {
-		if (node == NULL && priv->latest_unread_uid != NULL)
+		if (node == NULL && priv->oldest_unread_uid != NULL)
 			node = g_hash_table_lookup (
-				uid_nodemap, priv->latest_unread_uid);
-		if (node == NULL && priv->latest_read_uid != NULL)
+				uid_nodemap, priv->oldest_unread_uid);
+		if (node == NULL && priv->newest_read_uid != NULL)
 			node = g_hash_table_lookup (
-				uid_nodemap, priv->latest_read_uid);
+				uid_nodemap, priv->newest_read_uid);
 	}
 
 	if (node) {
@@ -2873,10 +2873,10 @@ clear_tree (MessageList *ml, gboolean tfree)
 	g_hash_table_destroy (ml->uid_nodemap);
 	ml->uid_nodemap = g_hash_table_new (g_str_hash, g_str_equal);
 
-	ml->priv->latest_read_date = 0;
-	ml->priv->latest_read_uid = NULL;
-	ml->priv->latest_unread_date = 0;
-	ml->priv->latest_unread_uid = NULL;
+	ml->priv->newest_read_date = 0;
+	ml->priv->newest_read_uid = NULL;
+	ml->priv->oldest_unread_date = 0;
+	ml->priv->oldest_unread_uid = NULL;
 
 	if (ml->tree_root) {
 		/* we should be frozen already */
@@ -3040,14 +3040,17 @@ ml_uid_nodemap_insert (MessageList *message_list,
 	/* Track the latest seen and unseen messages shown, used in
 	 * fallback heuristics for automatic message selection. */
 	if (flags & CAMEL_MESSAGE_SEEN) {
-		if (date > message_list->priv->latest_read_date) {
-			message_list->priv->latest_read_date = date;
-			message_list->priv->latest_read_uid = uid;
+		if (date > message_list->priv->newest_read_date) {
+			message_list->priv->newest_read_date = date;
+			message_list->priv->newest_read_uid = uid;
 		}
 	} else {
-		if (date > message_list->priv->latest_unread_date) {
-			message_list->priv->latest_unread_date = date;
-			message_list->priv->latest_unread_uid = uid;
+		if (message_list->priv->oldest_unread_date == 0) {
+			message_list->priv->oldest_unread_date = date;
+			message_list->priv->oldest_unread_uid = uid;
+		} else if (date < message_list->priv->oldest_unread_date) {
+			message_list->priv->oldest_unread_date = date;
+			message_list->priv->oldest_unread_uid = uid;
 		}
 	}
 
@@ -3062,14 +3065,14 @@ ml_uid_nodemap_remove (MessageList *message_list,
 
 	uid = camel_message_info_uid (info);
 
-	if (uid == message_list->priv->latest_read_uid) {
-		message_list->priv->latest_read_date = 0;
-		message_list->priv->latest_read_uid = NULL;
+	if (uid == message_list->priv->newest_read_uid) {
+		message_list->priv->newest_read_date = 0;
+		message_list->priv->newest_read_uid = NULL;
 	}
 
-	if (uid == message_list->priv->latest_unread_uid) {
-		message_list->priv->latest_unread_date = 0;
-		message_list->priv->latest_unread_uid = NULL;
+	if (uid == message_list->priv->oldest_unread_uid) {
+		message_list->priv->oldest_unread_date = 0;
+		message_list->priv->oldest_unread_uid = NULL;
 	}
 
 	g_hash_table_remove (message_list->uid_nodemap, uid);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]