From: <aar...@us...> - 2006-06-05 23:16:27
|
Revision: 16222 Author: aaronsheldon Date: 2006-06-05 16:16:19 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16222&view=rev Log Message: ----------- Modified Paths: -------------- branches/soc-2006-blist-efficiency/src/gtkblist.c Modified: branches/soc-2006-blist-efficiency/src/gtkblist.c =================================================================== --- branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-05 23:11:49 UTC (rev 16221) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-05 23:16:19 UTC (rev 16222) @@ -4076,16 +4076,26 @@ return TRUE; } +/*This version of gaim_gtk_blist_update_group can take the original buddy +or a group, but has much better algorithmic performance with a pre-known buddy*/ static void gaim_gtk_blist_update_group(GaimBuddyList *list, GaimBlistNode *node) { GaimGroup *group; int count; gboolean show = FALSE; + gboolean buddy_node_true = FALSE; + GaimBlistNode* bnode; + + + buddy_node_true = GAIM_BLIST_NODE_IS_BUDDY(node); + if (GAIM_BLIST_NODE_IS_GROUP(node)) + bnode = node; + else if (buddy_node_true) + bnode = node->parent->parent; + g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(bnode)); + + group = (GaimGroup*)bnode; - g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node)); - - group = (GaimGroup*)node; - if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) count = gaim_blist_get_group_size(group, FALSE); else @@ -4093,9 +4103,13 @@ if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) show = TRUE; + else if (buddy_node_true) + if (buddy_is_displayable((GaimBuddy*)node)) + show = TRUE; + /* Fallback loop */ else { GaimBlistNode *n; - n = node->child; + n = bnode->child; while (n && !GAIM_BLIST_NODE_IS_GROUP(n)) { if (GAIM_BLIST_NODE_IS_BUDDY(n)) { if (buddy_is_displayable((GaimBuddy*)n)) { @@ -4105,13 +4119,13 @@ } n = gaim_blist_node_next(n, FALSE); } - } - + } + if (show) { char *mark, *esc; GtkTreeIter iter; - if(!insert_node(list, node, &iter)) + if(!insert_node(list, bnode, &iter)) return; esc = g_markup_escape_text(group->name, -1); @@ -4128,7 +4142,7 @@ -1); g_free(mark); } else { - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, bnode); } } @@ -4195,35 +4209,45 @@ g_object_unref(avatar); } - +/* This is a variation on the original gtk_blist_update_contact. Here we + can know in advance which buddy has changed so we can just update that */ static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node) { + GaimBlistNode *bnode; GaimContact *contact; GaimBuddy *buddy; struct _gaim_gtk_blist_node *gtknode; - g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node)); + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + bnode = node->parent; + else + bnode = node; + + g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(bnode)); /* First things first, update the group */ - gaim_gtk_blist_update_group(list, node->parent); + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + gaim_gtk_blist_update_group(list, node); + else + gaim_gtk_blist_update_group(list, bnode->parent); - contact = (GaimContact*)node; + contact = (GaimContact*)bnode; buddy = gaim_contact_get_priority_buddy(contact); - + if (buddy_is_displayable(buddy)) { GtkTreeIter iter; - if(!insert_node(list, node, &iter)) + if(!insert_node(list, bnode, &iter)) return; - gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; + gtknode = (struct _gaim_gtk_blist_node *)bnode->ui_data; if(gtknode->contact_expanded) { GdkPixbuf *status; char *mark; - status = gaim_gtk_blist_get_status_icon(node, + status = gaim_gtk_blist_get_status_icon(bnode, (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); @@ -4240,29 +4264,29 @@ if(status) g_object_unref(status); } else { - buddy_node(buddy, &iter, node); + buddy_node(buddy, &iter, bnode); } } else { - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, bnode); } } + + static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) { - GaimContact *contact; GaimBuddy *buddy; struct _gaim_gtk_blist_node *gtkparentnode; g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); + if (node->parent == NULL) + return; + buddy = (GaimBuddy*)node; - contact = (GaimContact*)node->parent; - - if (contact == NULL) - return; - + /* First things first, update the contact */ - gaim_gtk_blist_update_contact(list, node->parent); + gaim_gtk_blist_update_contact(list, node); gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |