[PATCH] : small patch to correct balsa-index thinko



	Hi all,
speed improvment of the refresh of balsa-index.
Bye
Manu

--- balsa-1.2.3/src/balsa-index.c	Mon Nov  5 23:22:46 2001
+++ balsa-1.2.3-dev/src/balsa-index.c	Mon Jan 14 15:40:25 2002
@@ -107,6 +115,13 @@
 static void balsa_index_idle_add(gpointer data, gpointer message);
 static gboolean balsa_index_idle_clear(gpointer data);
 static gint balsa_index_most_recent_message(GtkCList * clist);
+static void refresh_size(GtkCTree * ctree,
+			 GtkCTreeNode *node,
+			 gpointer data);
+static void refresh_date(GtkCTree * ctree,
+			 GtkCTreeNode *node,
+			 gpointer data);
+
 
 
 /* mailbox callbacks */
@@ -2270,6 +2331,21 @@
     }
 }
 
+static void
+refresh_size(GtkCTree * ctree,
+	     GtkCTreeNode *node,
+	     gpointer data)
+{
+    gchar *txt_new;
+    LibBalsaMessage * message;
+    
+    message = LIBBALSA_MESSAGE(gtk_ctree_node_get_row_data (ctree, node));
+    txt_new = libbalsa_message_size_to_gchar(message,
+					     GPOINTER_TO_INT(data));
+    gtk_ctree_node_set_text (ctree, node, 6, txt_new);
+    g_free (txt_new);
+}
+
 void
 balsa_index_refresh_size (GtkNotebook *notebook,
 			  GtkNotebookPage *page,
@@ -2277,12 +2353,9 @@
 			  gpointer data)
 {
     BalsaIndex *bindex;
-    LibBalsaMessage * message;
     GtkWidget *index;
     GtkCTreeNode *node;
     GtkCTree *ctree;
-    gchar *txt_new;
-    gint j;
 
     if (page)
 	index = page->child;
@@ -2297,20 +2370,27 @@
         return;
 
     bindex->line_length = balsa_app.line_length;
-
     ctree = GTK_CTREE(bindex->ctree);
-    if (ctree) {
-	j = 0;
-	while ((node = gtk_ctree_node_nth (ctree, j))) {
-	    message = (LibBalsaMessage*)
-		gtk_ctree_node_get_row_data (ctree, node);
-	    txt_new = libbalsa_message_size_to_gchar(message,
-						     bindex->line_length);
-	    gtk_ctree_node_set_text (ctree, node, 6, txt_new);
-	    g_free (txt_new);
-	    j++;
-	}
-    }
+    if (ctree)
+	gtk_ctree_pre_recursive(ctree,
+				NULL,
+				refresh_size,
+				GINT_TO_POINTER(bindex->line_length));
+}
+
+static void
+refresh_date(GtkCTree * ctree,
+	     GtkCTreeNode *node,
+	     gpointer data)
+{
+    LibBalsaMessage * message;
+    gchar *txt_new;
+
+    message = LIBBALSA_MESSAGE(gtk_ctree_node_get_row_data (ctree, node));
+    txt_new = libbalsa_message_date_to_gchar(message,
+					     (gchar*) data);
+    gtk_ctree_node_set_text (ctree, node, 5, txt_new);
+    g_free (txt_new);
 }
 
 void
@@ -2320,12 +2400,9 @@
 			  gpointer data)
 {
     BalsaIndex *bindex;
-    LibBalsaMessage * message;
     GtkWidget *index;
     GtkCTreeNode *node;
     GtkCTree *ctree;
-    gchar *txt_new;
-    gint j;
 
     if (page)
 	index = page->child;
@@ -2343,18 +2420,11 @@
     bindex->date_string = g_strdup (balsa_app.date_string);
 
     ctree = GTK_CTREE(bindex->ctree);
-    if (ctree) {
-	j = 0;
-	while ((node = gtk_ctree_node_nth (ctree, j))) {
-	    message = (LibBalsaMessage*)
-		gtk_ctree_node_get_row_data (ctree, node);
-	    txt_new = libbalsa_message_date_to_gchar(message,
-						     bindex->date_string);
-	    gtk_ctree_node_set_text (ctree, node, 5, txt_new);
-	    g_free (txt_new);
-	    j++;
-	}
-    }
+    if (ctree)	
+	gtk_ctree_pre_recursive(ctree,
+				NULL,
+				refresh_date,
+				bindex->date_string);
 }
 
 static gint


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