/* This method tries to find a feed with unread items in two passes. In the first pass it tries to find one after the currently selected feed (including the selected feed). If there are no such feeds the search is restarted for all feeds. */ static nodePtr feedlist_unread_scan (nodePtr folder) { nodePtr childNode; GSList *selectedIter = NULL; if (SELECTED) selectedIter = g_slist_find(SELECTED->parent->children, SELECTED); else scanState = UNREAD_SCAN_SECOND_PASS; GSList *iter = folder->children; while (iter) { nodePtr node = iter->data; if (node == SELECTED) scanState = UNREAD_SCAN_FOUND_SELECTED; /* feed match if beyond the selected feed or in second pass... */ if ((scanState != UNREAD_SCAN_INIT) && (node->unreadCount > 0) && (NULL == node->children) && !IS_VFOLDER(node)) { return node; } /* folder traversal if we are searching the selected feed which might be a descendant of the folder and if we are beyond the selected feed and the folder contains feeds with unread items... */ if (node->children && (((scanState != UNREAD_SCAN_INIT) && (node->unreadCount > 0)) || (selectedIter && (node_is_ancestor (node, SELECTED))))) { childNode = feedlist_unread_scan (node); if (childNode) return childNode; } iter = g_slist_next (iter); } /* When we come here we didn't find anything from the selected feed down to the end of the feed list. */ if (folder == ROOTNODE) { if (0 == ROOTNODE->unreadCount) { /* this may mean there is nothing more to find */ } else { /* or that there are unread items above the selected feed */ g_assert (scanState != UNREAD_SCAN_SECOND_PASS); scanState = UNREAD_SCAN_SECOND_PASS; return feedlist_unread_scan (ROOTNODE); } } return NULL; }
/** * To be called whenever an itemset was updated. If it is the * displayed itemset it will be merged against the item list * tree view. */ void itemlist_merge_itemset (itemSetPtr itemSet) { gint folder_display_mode; debug_enter ("itemlist_merge_itemset"); debug_start_measurement (DEBUG_GUI); /* No node check when loading search results directly */ if (!itemlist_priv.isSearchResult) { nodePtr node = node_from_id (itemSet->nodeId); if (!itemlist_priv.currentNode) return; /* Nothing to do if nothing is displayed */ if (!IS_VFOLDER (itemlist_priv.currentNode) && (itemlist_priv.currentNode != node) && !node_is_ancestor (itemlist_priv.currentNode, node)) return; /* Nothing to do if the item set does not belong to this node, or this is a search folder */ conf_get_int_value (FOLDER_DISPLAY_MODE, &folder_display_mode); if (IS_FOLDER (itemlist_priv.currentNode) && !folder_display_mode) return; /* Bail out if it is a folder without the recursive display preference set */ debug1 (DEBUG_GUI, "reloading item list with node \"%s\"", node_get_title (node)); } else { /* If we are loading a search result we must never merge anything besides the search items. In fact if we already have items we just return. */ if (itemlist_priv.searchResultComplete) return; itemlist_priv.searchResultComplete = TRUE; } /* merge items into item view */ itemset_foreach (itemSet, itemlist_merge_item); itemview_update (); debug_end_measurement (DEBUG_GUI, "itemlist merge"); debug_exit ("itemlist_merge_itemset"); }
/* Helper method checking if the passed item set is relevant for the currently item list content. */ static gboolean itemlist_itemset_is_valid (itemSetPtr itemSet) { gint folder_display_mode; nodePtr node; node = node_from_id (itemSet->nodeId); if (!itemlist->priv->currentNode) return FALSE; /* Nothing to do if nothing is displayed */ if (!IS_VFOLDER (itemlist->priv->currentNode) && (itemlist->priv->currentNode != node) && !node_is_ancestor (itemlist->priv->currentNode, node)) return FALSE; /* Nothing to do if the item set does not belong to this node, or this is a search folder */ conf_get_int_value (FOLDER_DISPLAY_MODE, &folder_display_mode); if (IS_FOLDER (itemlist->priv->currentNode) && !folder_display_mode) return FALSE; /* Bail out if it is a folder without the recursive display preference set */ debug1 (DEBUG_GUI, "reloading item list with node \"%s\"", node_get_title (node)); return TRUE; }