Re: mblist fixup [PATCH]



Here's a patch (against today's CVS) for some more minor code cleanup in
src/balsa-mblist.c (balsa_mblist_folder_style). Unlike
balsa-mblist-style-patch, this one doesn't change the display or make any
changes outside balsa_mblist_folder_style.

Peter
diff -Nur balsa-cvs/src/balsa-mblist.c balsa-mblist/src/balsa-mblist.c
--- balsa-cvs/src/balsa-mblist.c	Sat Aug 18 08:26:31 2001
+++ balsa-mblist/src/balsa-mblist.c	Tue Aug 21 04:57:12 2001
@@ -1121,85 +1121,54 @@
     BalsaMailboxNode *mbnode;
     LibBalsaMailbox *mailbox;
     GtkStyle *style;
-    static guint32 has_unread = 0; /*FIXME: is this the right initial value?*/
+    static guint32 has_unread = 0; /*FIXME: is this the right initial value? */
+    gboolean show_unread;
+    gboolean now_unread;
 
     mbnode = gtk_ctree_node_get_row_data(ctree, node);
     mailbox = mbnode->mailbox;
     mblist = BALSA_MBLIST(ctree);
 
     /* If we're on a mailbox, it must be shown as unread if it or
-     * any children have unread mail */
+     * any children have unread mail
+     *
+     * first, does it have unread mail? */
     if (mailbox) {
-	gboolean show_unread;
-	gboolean now_unread;
-
 	/* ignore special mailboxes */
-	if (mailbox == balsa_app.sentbox  || mailbox == balsa_app.outbox ||
+	if (mailbox == balsa_app.sentbox || mailbox == balsa_app.outbox ||
 	    mailbox == balsa_app.draftbox || mailbox == balsa_app.trash)
 	    return;
-
-	/* check what this node should look like:
-	 * first, does it have unread mail? */
 	show_unread = mailbox->has_unread_messages;
+    } else
+	show_unread = FALSE;
 
-	if (has_unread & (1 << (GTK_CTREE_ROW(node)->level + 1))) {
-	    /* some child has unread mail */
-	    show_unread = TRUE;
-	    has_unread &= ~(1 << (GTK_CTREE_ROW(node)->level + 1));
-	}
+    if (has_unread & (1 << (GTK_CTREE_ROW(node)->level + 1))) {
+	/* some child has unread mail */
+	show_unread = TRUE;
+	has_unread &= ~(1 << (GTK_CTREE_ROW(node)->level + 1));
+    }
 
-	/* next, how is it shown now? */
-	now_unread = ((mbnode->style & MBNODE_STYLE_NEW_MAIL) != 0);
+    /* next, how is it shown now? */
+    now_unread = ((mbnode->style & MBNODE_STYLE_NEW_MAIL) != 0);
 
-	if (show_unread != now_unread) {
-	    /* we need to make a change */
-	    if (show_unread) {
-	        /* set as unread */
-	        mbnode->style |= MBNODE_STYLE_NEW_MAIL;
-	        style = mblist->unread_mailbox_style;
-	    } else {
-	        /* reset to the vanilla style */
-	        mbnode->style &= ~MBNODE_STYLE_NEW_MAIL;
-	        style = gtk_widget_get_style(GTK_WIDGET(ctree));
-	    }
-	    gtk_ctree_node_set_row_style(ctree, node, style);
+    if (show_unread != now_unread) {
+	/* we need to make a change */
+	if (show_unread) {
+	    /* set as unread */
+	    mbnode->style |= MBNODE_STYLE_NEW_MAIL;
+	    style = mblist->unread_mailbox_style;
+	} else {
+	    /* reset to the vanilla style */
+	    mbnode->style &= ~MBNODE_STYLE_NEW_MAIL;
+	    style = gtk_widget_get_style(GTK_WIDGET(ctree));
 	}
-
-	/* propagate up to next level */
-        if (show_unread)
-	    has_unread |= 1 << (GTK_CTREE_ROW(node)->level);
-
-	return;
-
-    } else {
-        /* We're on a non-mailbox folder here, see if any of the leaves 
-           were displayed as having unread messages, change the style
-           accordingly */
-        if (has_unread & (1 << (GTK_CTREE_ROW(node)->level + 1))) {
-
-            gtk_ctree_node_set_row_style(ctree, node,
-                         mblist->unread_mailbox_style);
-
-            mbnode->style |= MBNODE_STYLE_NEW_MAIL;
-
-            /* If we've reached the top of the tree, reset the counter for
-             * the next branch */
-            if (GTK_CTREE_ROW(node)->parent == NULL) {
-                has_unread = 0;
-            } else {
-            has_unread |= (1 << (GTK_CTREE_ROW(node)->level));
-            has_unread &= ~(1 << (GTK_CTREE_ROW(node)->level + 1));
-            }
-
-        } else if (mbnode->style & MBNODE_STYLE_NEW_MAIL) {
-            /* This folder's style needs to be reset to the vanilla style */
-            style = gtk_widget_get_style(GTK_WIDGET(ctree));
-            gtk_ctree_node_set_row_style(ctree, node, style);
-            mbnode->style &= ~MBNODE_STYLE_NEW_MAIL;
-        }
+	gtk_ctree_node_set_row_style(ctree, node, style);
     }
-}
 
+    /* propagate up to next level */
+    if (show_unread)
+	has_unread |= 1 << (GTK_CTREE_ROW(node)->level);
+}
 
 /* balsa_mblist_core_mailbox
  * 


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