[anjal] Now new mails are sorted as they come. New Messages in threads comes up



commit bfc8b33cacf4b881b368aa375157da72b6413f73
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Thu May 28 21:42:53 2009 +0530

    Now new mails are sorted as they come. New Messages in threads comes up
    as they arrive.
---
 src/em-tree-store.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/em-tree-store.c b/src/em-tree-store.c
index e15e881..5d06f7c 100644
--- a/src/em-tree-store.c
+++ b/src/em-tree-store.c
@@ -727,7 +727,7 @@ emts_insert_info_base(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 /* This is used to incrementally update the model as changes come in.
    It takes some short-cuts since we no longer have the auxillairy place-holders
    to fill out the full root tree.  It will work if messages arrive in the right order however */
-static  void
+static  gboolean
 emts_insert_info_incr(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_folder *f)
 {
 	struct _EMTreeStorePrivate *p = _PRIVATE(emts);
@@ -737,7 +737,8 @@ emts_insert_info_incr(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 	GtkTreePath *path;
 	const CamelSummaryMessageID *mid;
 	const CamelSummaryReferences *references;
-	
+	gboolean ret = FALSE;
+
 	printf("inserting new: '%s'\n", camel_message_info_subject(mi));
 
 	/* Allocating a new node, always 'parent' to root to start with */
@@ -766,11 +767,18 @@ emts_insert_info_incr(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 			if (references->references[j].id.id != 0
 			    && (parent = g_hash_table_lookup(p->id_table, &references->references[j]))
 			    && parent != node) {
+				EMTreeNode *tmpnode;
 				printf(" found parent, reparenting\n");
 				node->parent = parent;
 				//e_dlist_remove((EDListNode *)node);
 				e_dlist_addtail(&parent->children, (EDListNode *)node);
-				
+				tmpnode = parent;
+				while (tmpnode != NULL && tmpnode != emts->root)
+					tmpnode = tmpnode->parent;
+				if (tmpnode != NULL) {
+					tmpnode->latest_uid = mi->uid;
+					ret = TRUE;
+				}
 				break;
 			}
 		}
@@ -791,6 +799,8 @@ emts_insert_info_incr(EMTreeStore *emts, CamelMessageInfo *mi, struct _emts_fold
 		 gtk_tree_model_row_inserted((GtkTreeModel *)emts, path, &iter);
 	printf("Inserted at: %s\n", gtk_tree_path_to_string(path));
 	gtk_tree_path_free(path);
+
+	return ret;
 }
 
 
@@ -1004,6 +1014,7 @@ emts_folder_changed_idle(void *data)
 	struct _EMTreeStorePrivate *p = _PRIVATE(emts);
 	struct _emts_folder *f, *n;
 	int i;
+	gboolean resort = FALSE;
 
 	pthread_mutex_lock(&p->lock);
 	f = (struct _emts_folder *)p->folders.head;
@@ -1015,7 +1026,7 @@ emts_folder_changed_idle(void *data)
 
 			mi = camel_folder_get_message_info (f->folder, uid);
 			if (g_hash_table_lookup(f->uid_table, camel_message_info_uid(mi)) == NULL)
-				emts_insert_info_incr(emts, mi, f);
+				resort = emts_insert_info_incr(emts, mi, f) || resort;
 		}
 
 		for (i=0;i<f->changes->uid_removed->len;i++) {
@@ -1053,7 +1064,9 @@ emts_folder_changed_idle(void *data)
 
 	p->update_id = 0;
 	pthread_mutex_unlock(&p->lock);
-
+	
+	if (resort)
+		em_tree_store_resort (emts);
 	return FALSE;
 }
 



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