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. |
From: <aar...@us...> - 2006-06-11 00:42:46
|
Revision: 16253 Author: aaronsheldon Date: 2006-06-10 17:42:41 -0700 (Sat, 10 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16253&view=rev Log Message: ----------- Mostly style corrections, but also corrects a bug that causes right-clicking groups to have incorrect behavior. 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-11 00:35:52 UTC (rev 16252) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-11 00:42:41 UTC (rev 16253) @@ -4083,19 +4083,17 @@ GaimGroup *group; int count; gboolean show = FALSE; - gboolean buddy_node_true = FALSE; - GaimBlistNode* bnode; - - - buddy_node_true = GAIM_BLIST_NODE_IS_BUDDY(node); + GaimBlistNode* gnode; + + 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; + gnode = node; + else if (GAIM_BLIST_NODE_IS_BUDDY(node)) + gnode = node->parent->parent; + g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(gnode)); + group = (GaimGroup*)gnode; + if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) count = gaim_blist_get_group_size(group, FALSE); else @@ -4103,13 +4101,13 @@ if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) show = TRUE; - else if (buddy_node_true) + else if (GAIM_BLIST_NODE_IS_BUDDY(node)){ if (buddy_is_displayable((GaimBuddy*)node)) show = TRUE; /* Fallback loop */ - else { + } else { GaimBlistNode *n; - n = bnode->child; + n = gnode->child; while (n && !GAIM_BLIST_NODE_IS_GROUP(n)) { if (GAIM_BLIST_NODE_IS_BUDDY(n)) { if (buddy_is_displayable((GaimBuddy*)n)) { @@ -4120,12 +4118,12 @@ n = gaim_blist_node_next(n, FALSE); } } - + if (show) { char *mark, *esc; GtkTreeIter iter; - if(!insert_node(list, bnode, &iter)) + if(!insert_node(list, gnode, &iter)) return; esc = g_markup_escape_text(group->name, -1); @@ -4138,11 +4136,11 @@ STATUS_ICON_COLUMN, NULL, STATUS_ICON_VISIBLE_COLUMN, FALSE, NAME_COLUMN, mark, - NODE_COLUMN, node, + NODE_COLUMN, gnode, -1); g_free(mark); } else { - gaim_gtk_blist_hide_node(list, bnode); + gaim_gtk_blist_hide_node(list, gnode); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-06-12 04:43:57
|
Revision: 16262 Author: aaronsheldon Date: 2006-06-11 21:43:43 -0700 (Sun, 11 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16262&view=rev Log Message: ----------- Calls update contact with a buddy instead of a contact (faster), switches a check order for to be better in average case, removes the possibility of a double-gtk-blist-update, greatly improves the performance of group-update, and corrects a bunch of style issues. 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-12 04:23:04 UTC (rev 16261) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-12 04:43:43 UTC (rev 16262) @@ -121,6 +121,7 @@ static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node); static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); +static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node); static char *gaim_get_tooltip_text(GaimBlistNode *node, gboolean full); static const char *item_factory_translate_func (const char *path, gpointer func_data); static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); @@ -877,8 +878,7 @@ gtk_main_iteration(); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(gtkblist->treeview), path, NULL, FALSE, 0, 0); - - gaim_gtk_blist_update(NULL, node); + gaim_gtk_blist_update_contact(NULL, node->child); gtk_tree_path_free(path); } @@ -3063,7 +3063,7 @@ if (buddy && gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) - gaim_gtk_blist_update(list, cnode); + gaim_gtk_blist_update_contact(list, (GaimBlistNode*)buddy); } } } @@ -3903,7 +3903,7 @@ while (node) { - if (!GAIM_BLIST_NODE_IS_GROUP(node) && remove) + if (remove && !GAIM_BLIST_NODE_IS_GROUP(node)) gaim_gtk_blist_hide_node(list, node); gaim_gtk_blist_update(list, node); @@ -3995,7 +3995,7 @@ gtkblist->selected_node = new_selection; if(new_selection) gaim_gtk_blist_update(NULL, new_selection); - if(old_selection) + else if(old_selection) gaim_gtk_blist_update(NULL, old_selection); } @@ -4088,7 +4088,9 @@ if (GAIM_BLIST_NODE_IS_GROUP(node)) gnode = node; - else if (GAIM_BLIST_NODE_IS_BUDDY(node)) + else if (GAIM_BLIST_NODE_IS_CONTACT(node)) + gnode = node->parent; + else if (GAIM_BLIST_NODE_IS_BUDDY(node)) //maybe OR'ed with IS_CHAT? gnode = node->parent->parent; g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(gnode)); @@ -4101,23 +4103,9 @@ if (count > 0 || gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")) show = TRUE; - else if (GAIM_BLIST_NODE_IS_BUDDY(node)){ + else if (GAIM_BLIST_NODE_IS_BUDDY(node)){ /* Or chat? */ if (buddy_is_displayable((GaimBuddy*)node)) - show = TRUE; - /* Fallback loop */ - } else { - GaimBlistNode *n; - n = gnode->child; - while (n && !GAIM_BLIST_NODE_IS_GROUP(n)) { - if (GAIM_BLIST_NODE_IS_BUDDY(n)) { - if (buddy_is_displayable((GaimBuddy*)n)) { - show = TRUE; - break; - } - } - n = gaim_blist_node_next(n, FALSE); - } - } + show = TRUE;} if (show) { char *mark, *esc; @@ -4162,7 +4150,8 @@ mark = gaim_gtk_blist_get_name_markup(buddy, selected); if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && - gaim_presence_is_idle(presence)) + gaim_presence_is_idle(presence) && + !gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { time_t idle_secs = gaim_presence_get_idle_time(presence); @@ -4173,7 +4162,6 @@ time(&t); ihrs = (t - idle_secs) / 3600; imin = ((t - idle_secs) / 60) % 60; - if (ihrs > 0) idle = g_strdup_printf("%d:%02d", ihrs, imin); else @@ -4211,41 +4199,41 @@ 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; + GaimBlistNode *cnode; GaimContact *contact; GaimBuddy *buddy; struct _gaim_gtk_blist_node *gtknode; if (GAIM_BLIST_NODE_IS_BUDDY(node)) - bnode = node->parent; + cnode = node->parent; else - bnode = node; + cnode = node; - g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(bnode)); + g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(cnode)); /* First things first, update the group */ if (GAIM_BLIST_NODE_IS_BUDDY(node)) gaim_gtk_blist_update_group(list, node); else - gaim_gtk_blist_update_group(list, bnode->parent); + gaim_gtk_blist_update_group(list, cnode->parent); - contact = (GaimContact*)bnode; + contact = (GaimContact*)cnode; buddy = gaim_contact_get_priority_buddy(contact); if (buddy_is_displayable(buddy)) { GtkTreeIter iter; - if(!insert_node(list, bnode, &iter)) + if(!insert_node(list, cnode, &iter)) return; - gtknode = (struct _gaim_gtk_blist_node *)bnode->ui_data; + gtknode = (struct _gaim_gtk_blist_node *)cnode->ui_data; if(gtknode->contact_expanded) { GdkPixbuf *status; char *mark; - status = gaim_gtk_blist_get_status_icon(bnode, + status = gaim_gtk_blist_get_status_icon(cnode, (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); @@ -4262,10 +4250,10 @@ if(status) g_object_unref(status); } else { - buddy_node(buddy, &iter, bnode); + buddy_node(buddy, &iter, cnode); } } else { - gaim_gtk_blist_hide_node(list, bnode); + gaim_gtk_blist_hide_node(list, cnode); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-06-22 06:00:29
|
Revision: 16305 Author: aaronsheldon Date: 2006-06-21 23:00:25 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16305&view=rev Log Message: ----------- No longer refreshes the GTK Buddy List when it isn't visible, be it iconified, shrunk into the system tray or just stuck behind other windows. When it is brought back to a visible state, an update is quickly done. One small revert and one style/ordering fix. 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-21 15:19:28 UTC (rev 16304) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-22 06:00:25 UTC (rev 16305) @@ -118,6 +118,7 @@ #endif static GaimGtkBuddyList *gtkblist = NULL; +static gboolean gaim_gtk_blist_refresh_timer(GaimBuddyList *list); static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node); static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); @@ -160,8 +161,10 @@ { if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) gtk_blist_obscured = TRUE; - else - gtk_blist_obscured = FALSE; + else if (gtk_blist_obscured) { + gtk_blist_obscured = FALSE; + gaim_gtk_blist_refresh_timer(gaim_get_blist()); + } /* continue to handle event normally */ return FALSE; @@ -172,8 +175,10 @@ if(event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) { if(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", FALSE); - else + else { gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", TRUE); + gaim_gtk_blist_refresh_timer(gaim_get_blist()); + } } if(event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) { @@ -182,7 +187,13 @@ else gaim_prefs_set_bool("/gaim/gtk/blist/list_maximized", FALSE); } - + + /* Refresh gtkblist if un-iconifying */ + if (event->changed_mask & GDK_WINDOW_STATE_ICONIFIED){ + if (!(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)) + gaim_gtk_blist_refresh_timer(gaim_get_blist()); + } + return FALSE; } @@ -3052,6 +3063,9 @@ { GaimBlistNode *gnode, *cnode; + if (gtk_blist_obscured || !GTK_WIDGET_VISIBLE(gtkblist->window)) + return TRUE; + for(gnode = list->root; gnode; gnode = gnode->next) { if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; @@ -3995,7 +4009,7 @@ gtkblist->selected_node = new_selection; if(new_selection) gaim_gtk_blist_update(NULL, new_selection); - else if(old_selection) + if(old_selection) gaim_gtk_blist_update(NULL, old_selection); } @@ -4088,10 +4102,10 @@ if (GAIM_BLIST_NODE_IS_GROUP(node)) gnode = node; + else if (GAIM_BLIST_NODE_IS_BUDDY(node)) /* maybe OR'ed with IS_CHAT? */ + gnode = node->parent->parent; else if (GAIM_BLIST_NODE_IS_CONTACT(node)) gnode = node->parent; - else if (GAIM_BLIST_NODE_IS_BUDDY(node)) //maybe OR'ed with IS_CHAT? - gnode = node->parent->parent; g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(gnode)); group = (GaimGroup*)gnode; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-06-23 16:02:51
|
Revision: 16319 Author: aaronsheldon Date: 2006-06-23 09:02:36 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16319&view=rev Log Message: ----------- Changes to gaim_gtk_blist_get_name_markup which result in profiling indicating a 40%+ improvement in function performance (larger gains when detailed buddy is turned off because it no longer grabs PRPL info first). 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-23 14:30:27 UTC (rev 16318) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-23 16:02:36 UTC (rev 16319) @@ -2875,7 +2875,7 @@ struct _gaim_gtk_blist_node *gtkcontactnode = NULL; char *idletime = NULL, *statustext = NULL; time_t t; - /* XXX Clean up this crap */ + /* XXX Good luck cleaning up this crap */ contact = (GaimContact*)((GaimBlistNode*)b)->parent; if(contact) @@ -2887,11 +2887,6 @@ name = gaim_buddy_get_alias(b); esc = g_markup_escape_text(name, strlen(name)); - prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); - - if (prpl != NULL) - prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); - presence = gaim_buddy_get_presence(b); if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) @@ -2907,6 +2902,11 @@ return esc; } + prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); + + if (prpl != NULL) + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); + if (prpl_info && prpl_info->status_text && b->account->gc) { char *tmp = prpl_info->status_text(b); const char *end; @@ -2957,59 +2957,62 @@ #endif } - if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time") && - gaim_presence_is_idle(presence)) - { - time_t idle_secs = gaim_presence_get_idle_time(presence); + if(!gaim_presence_is_online(presence) && !statustext) + statustext = g_strdup(_("Offline")); + else if (!statustext) + text = g_strdup(esc); + + if (gaim_presence_is_idle(presence)) { + if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")) { + time_t idle_secs = gaim_presence_get_idle_time(presence); - if (idle_secs > 0) { - int ihrs, imin; + if (idle_secs > 0) { + int ihrs, imin; - time(&t); - ihrs = (t - idle_secs) / 3600; - imin = ((t - idle_secs) / 60) % 60; + time(&t); + ihrs = (t - idle_secs) / 3600; + imin = ((t - idle_secs) / 60) % 60; - if (ihrs) - idletime = g_strdup_printf(_("Idle %dh %02dm"), ihrs, imin); + if (ihrs) + idletime = g_strdup_printf(_("Idle %dh %02dm"), ihrs, imin); + else + idletime = g_strdup_printf(_("Idle %dm"), imin); + } else - idletime = g_strdup_printf(_("Idle %dm"), imin); + idletime = g_strdup(_("Idle")); + + if (!selected) + text = g_strdup_printf("<span color='%s'>%s</span>\n" + "<span color='%s' size='smaller'>%s%s%s</span>", + dim_grey(), esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } - else - idletime = g_strdup(_("Idle")); + else if (!selected && !statustext) /* We handle selected text later */ + text = g_strdup_printf("<span color='%s'>%s</span>", dim_grey(), esc); + else if (!selected && !text) + text = g_strdup_printf("<span color='%s'>%s</span>\n" + "<span color='%s' size='smaller'>%s%s%s</span>", + dim_grey(), esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } - if(!gaim_presence_is_online(presence) && !statustext) - statustext = g_strdup(_("Offline")); - - if (statustext == NULL && idletime == NULL) + /* Not idle and not selected */ + else if (!selected && !text) { - if (!selected && gaim_presence_is_idle(presence)) - text = g_strdup_printf("<span color='%s'>%s</span>", dim_grey(), esc); - else - text = g_strdup(esc); + text = g_strdup_printf("%s\n" + "<span color='%s' size='smaller'>%s%s%s</span>", + esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } - else if (!selected) - { - if (gaim_presence_is_idle(presence)) - { - text = g_strdup_printf("<span color='%s'>%s</span>\n" - "<span color='%s' size='smaller'>%s%s%s</span>", - dim_grey(), esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", - statustext != NULL ? statustext : ""); - } - else - { - text = g_strdup_printf("%s\n" - "<span color='%s' size='smaller'>%s%s%s</span>", - esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", - statustext != NULL ? statustext : ""); - } - } - else + + /* It is selected. */ + if ((selected && !text) || (selected && idletime)) text = g_strdup_printf("%s\n" "<span size='smaller'>%s%s%s</span>", esc, @@ -3017,7 +3020,6 @@ (idletime != NULL && statustext != NULL) ? " - " : "", statustext != NULL ? statustext : ""); - g_free(idletime); g_free(statustext); g_free(esc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-06-28 17:28:11
|
Revision: 16367 Author: aaronsheldon Date: 2006-06-28 10:28:06 -0700 (Wed, 28 Jun 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16367&view=rev Log Message: ----------- Formatting (indentation) correction 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-28 16:01:42 UTC (rev 16366) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-06-28 17:28:06 UTC (rev 16367) @@ -3004,21 +3004,21 @@ else if (!selected && !text) { text = g_strdup_printf("%s\n" - "<span color='%s' size='smaller'>%s%s%s</span>", - esc, dim_grey(), - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", - statustext != NULL ? statustext : ""); + "<span color='%s' size='smaller'>%s%s%s</span>", + esc, dim_grey(), + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); } /* It is selected. */ if ((selected && !text) || (selected && idletime)) text = g_strdup_printf("%s\n" - "<span size='smaller'>%s%s%s</span>", - esc, - idletime != NULL ? idletime : "", - (idletime != NULL && statustext != NULL) ? " - " : "", - statustext != NULL ? statustext : ""); + "<span size='smaller'>%s%s%s</span>", + esc, + idletime != NULL ? idletime : "", + (idletime != NULL && statustext != NULL) ? " - " : "", + statustext != NULL ? statustext : ""); g_free(idletime); g_free(statustext); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-09 21:40:31
|
Revision: 16474 Author: aaronsheldon Date: 2006-07-09 14:40:17 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16474&view=rev Log Message: ----------- Compositing icons takes time. Instead of compositing the same icons over and over again, let's store them in a hash table and retrieve them when we need them. This saves a lot of time when we redo the entire buddy list, such as in a "View Offline Buddies" click, or any other preference change. This way we can reuse them instead of constantly regenerating them. This is especially saving when you have many buddies. 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-07-09 16:48:25 UTC (rev 16473) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-09 21:40:17 UTC (rev 16474) @@ -104,6 +104,7 @@ static guint visibility_manager_count = 0; static gboolean gtk_blist_obscured = FALSE; +GHashTable* status_icon_hash_table = NULL; static GList *gaim_gtk_blist_sort_methods = NULL; static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; @@ -2704,7 +2705,7 @@ { GdkPixbuf *scale, *status = NULL; int i, scalesize = 30; - char *filename; + char *filename, *key, *tmp; const char *protoname = NULL; struct _gaim_gtk_blist_node *gtknode = node->ui_data; struct _gaim_gtk_blist_node *gtkbuddynode = NULL; @@ -2714,6 +2715,9 @@ GaimBuddy *buddy = NULL; GaimChat *chat = NULL; + if (!status_icon_hash_table) + status_icon_hash_table = g_hash_table_new (g_str_hash,g_str_equal); + if(GAIM_BLIST_NODE_IS_CONTACT(node)) { if(!gtknode->contact_expanded) { buddy = gaim_contact_get_priority_buddy((GaimContact*)node); @@ -2780,6 +2784,70 @@ emblems[1].filename = emblems[2].filename = emblems[3].filename = NULL; } +/* Begin Generating Lookup Key */ + if (buddy) { + + if (GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) + key = g_strconcat(protoname, "login", NULL); + else if (!GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) + key = g_strconcat(protoname, "logout", NULL); + else + key = g_strdup(protoname); + + presence = gaim_buddy_get_presence(buddy); + if (!GAIM_BUDDY_IS_ONLINE(buddy)) { + tmp = key; + key = g_strconcat(key, "off", NULL); + g_free(tmp); + } else if (gaim_presence_is_idle(presence)) { + tmp = key; + key = g_strconcat(key, "idle", NULL); + g_free(tmp); + } + + if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) { + tmp = key; + key = g_strconcat(key, "blocked", NULL); + g_free(tmp); + } + + if (size == GAIM_STATUS_ICON_SMALL) { + tmp = key; + key = g_strconcat(key, "small", NULL); + g_free(tmp); + } + + for(i=0; i<4; i++) { + if(emblems[i].filename) { + tmp = key; + key = g_strconcat(key, emblems[i].filename, NULL); + g_free(tmp); + } + } + } + /* There are only two options for chat or gaimdude - big or small */ + else if (chat && size == GAIM_STATUS_ICON_SMALL) + key = g_strconcat(protoname, "chat-s", NULL); + else if (chat) + key = g_strconcat(protoname, "chat", NULL); + else if (size == GAIM_STATUS_ICON_SMALL) + key = g_strdup("gaimdude-s"); + else + key = g_strdup("gaimdude"); + +/* End Generating Lookup Key */ + + +/* If we already know this icon, just return it */ + scale = g_hash_table_lookup (status_icon_hash_table, key); + if (scale) { + gdk_pixbuf_ref(scale); + g_free(key); + return scale; + } + +/* Create a new composite icon */ + if(buddy && GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL); } else if(buddy && !GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { @@ -2835,7 +2903,6 @@ } if(buddy) { - presence = gaim_buddy_get_presence(buddy); if (!GAIM_BUDDY_IS_ONLINE(buddy)) gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); @@ -2866,6 +2933,10 @@ } } + /* Insert the new icon into the status icon hash table */ + g_hash_table_insert (status_icon_hash_table, key, scale); + gdk_pixbuf_ref(scale); + return scale; } @@ -3927,7 +3998,10 @@ if (remove && !GAIM_BLIST_NODE_IS_GROUP(node)) gaim_gtk_blist_hide_node(list, node); - gaim_gtk_blist_update(list, node); + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + gaim_gtk_blist_update_contact(list, node); + else if (GAIM_BLIST_NODE_IS_CHAT(node)) + gaim_gtk_blist_update(list, node); node = gaim_blist_node_next(node, FALSE); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-11 00:43:56
|
Revision: 16481 Author: aaronsheldon Date: 2006-07-10 17:43:51 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16481&view=rev Log Message: ----------- Adds the ability to destroy the status_icon_hash_table after a re-do buddy list and reclaim memory. Uses gstrings instead of *chars in get_status_icon. Adds a / delimiter for hash strings. Disables updating the buddy list each and every time a single node is hidden. 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-07-10 23:55:24 UTC (rev 16480) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-11 00:43:51 UTC (rev 16481) @@ -2700,12 +2700,19 @@ int y; }; +static void g_string_destroy(GString *destroyable) +{ + g_string_free(destroyable, TRUE); + return; +} + GdkPixbuf * gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size) { GdkPixbuf *scale, *status = NULL; int i, scalesize = 30; - char *filename, *key, *tmp; + char *filename; + GString *key = g_string_sized_new(16); const char *protoname = NULL; struct _gaim_gtk_blist_node *gtknode = node->ui_data; struct _gaim_gtk_blist_node *gtkbuddynode = NULL; @@ -2716,7 +2723,10 @@ GaimChat *chat = NULL; if (!status_icon_hash_table) - status_icon_hash_table = g_hash_table_new (g_str_hash,g_str_equal); + status_icon_hash_table = g_hash_table_new_full((GHashFunc)g_string_hash, + (GEqualFunc)g_string_equal, + (GDestroyNotify)g_string_destroy, + (GDestroyNotify)gdk_pixbuf_unref); if(GAIM_BLIST_NODE_IS_CONTACT(node)) { if(!gtknode->contact_expanded) { @@ -2788,61 +2798,51 @@ if (buddy) { if (GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) - key = g_strconcat(protoname, "login", NULL); + g_string_append_printf(key, "%s/login", protoname); else if (!GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) - key = g_strconcat(protoname, "logout", NULL); + g_string_append_printf(key, "%s/logout", protoname); else - key = g_strdup(protoname); + key = g_string_append(key, protoname); presence = gaim_buddy_get_presence(buddy); if (!GAIM_BUDDY_IS_ONLINE(buddy)) { - tmp = key; - key = g_strconcat(key, "off", NULL); - g_free(tmp); + key = g_string_append(key, "/off"); } else if (gaim_presence_is_idle(presence)) { - tmp = key; - key = g_strconcat(key, "idle", NULL); - g_free(tmp); + key = g_string_append(key, "/idle"); } if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) { - tmp = key; - key = g_strconcat(key, "blocked", NULL); - g_free(tmp); + key = g_string_append(key, "/priv"); } if (size == GAIM_STATUS_ICON_SMALL) { - tmp = key; - key = g_strconcat(key, "small", NULL); - g_free(tmp); + key = g_string_append(key, "/tiny"); } for(i=0; i<4; i++) { if(emblems[i].filename) { - tmp = key; - key = g_strconcat(key, emblems[i].filename, NULL); - g_free(tmp); + g_string_append_printf(key, "/%s", emblems[i].filename); } } } /* There are only two options for chat or gaimdude - big or small */ else if (chat && size == GAIM_STATUS_ICON_SMALL) - key = g_strconcat(protoname, "chat-s", NULL); + g_string_append_printf(key, "%s-chat-s", protoname); else if (chat) - key = g_strconcat(protoname, "chat", NULL); + g_string_append_printf(key, "%s-chat", protoname); else if (size == GAIM_STATUS_ICON_SMALL) - key = g_strdup("gaimdude-s"); + key = g_string_append(key, "gaimdude-s"); else - key = g_strdup("gaimdude"); + key = g_string_append(key, "gaimdude"); /* End Generating Lookup Key */ /* If we already know this icon, just return it */ - scale = g_hash_table_lookup (status_icon_hash_table, key); + scale = g_hash_table_lookup(status_icon_hash_table, key); if (scale) { gdk_pixbuf_ref(scale); - g_free(key); + g_string_free(key, TRUE); return scale; } @@ -3174,14 +3174,18 @@ if(gtkblist->selected_node == node) gtkblist->selected_node = NULL; - + /* This code seems to be irrelevant. We should not need to update the + * gtkblist before a node is removed and it takes a lot of time to do that. + */ +#if 0 if (get_iter_from_node(node, &iter)) { gtk_tree_store_remove(gtkblist->treemodel, &iter); if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node)) { gaim_gtk_blist_update(list, node->parent); - } - } + } + } +#endif gtk_tree_row_reference_free(gtknode->row); gtknode->row = NULL; } @@ -4004,6 +4008,10 @@ gaim_gtk_blist_update(list, node); node = gaim_blist_node_next(node, FALSE); } + + g_hash_table_destroy(status_icon_hash_table); + status_icon_hash_table = NULL; + } void gaim_gtk_blist_refresh(GaimBuddyList *list) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-11 01:13:00
|
Revision: 16482 Author: aaronsheldon Date: 2006-07-10 18:12:35 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16482&view=rev Log Message: ----------- The previous change broke going offline. Oops. 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-07-11 00:43:51 UTC (rev 16481) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-11 01:12:35 UTC (rev 16482) @@ -3174,18 +3174,13 @@ if(gtkblist->selected_node == node) gtkblist->selected_node = NULL; - /* This code seems to be irrelevant. We should not need to update the - * gtkblist before a node is removed and it takes a lot of time to do that. - */ -#if 0 if (get_iter_from_node(node, &iter)) { gtk_tree_store_remove(gtkblist->treemodel, &iter); if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node)) { gaim_gtk_blist_update(list, node->parent); - } - } -#endif + } + } gtk_tree_row_reference_free(gtknode->row); gtknode->row = NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-13 19:43:41
|
Revision: 16491 Author: aaronsheldon Date: 2006-07-13 12:43:37 -0700 (Thu, 13 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16491&view=rev Log Message: ----------- Bugfix for resorting list with an expanded buddy, now ought to be about twice as fast for resorts since we don't do it twice anymore, no longer does some unncessary updates on buddys. Every call to gaim_gtk_blist_node(...., TRUE) is unchecked to see if FALSE (faster) will work. TRUE matches the old behavior. 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-07-12 23:53:29 UTC (rev 16490) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-13 19:43:37 UTC (rev 16491) @@ -3164,7 +3164,7 @@ return TRUE; } -static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node) +static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node, gboolean update) { struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; GtkTreeIter iter; @@ -3176,8 +3176,8 @@ gtkblist->selected_node = NULL; if (get_iter_from_node(node, &iter)) { gtk_tree_store_remove(gtkblist->treemodel, &iter); - if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) - || GAIM_BLIST_NODE_IS_CHAT(node)) { + if(update && (GAIM_BLIST_NODE_IS_CONTACT(node) || + GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node))) { gaim_gtk_blist_update(list, node->parent); } } @@ -3448,7 +3448,7 @@ gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); } - redo_buddy_list(gaim_get_blist(), TRUE); + redo_buddy_list(gaim_get_blist(), FALSE); #if GTK_CHECK_VERSION(2,6,0) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); #endif @@ -3994,11 +3994,15 @@ while (node) { + /* This is only needed when we're reverting to a non-GTK+ sorted + * status. We shouldn't need to remove otherwise. + */ + if (remove && !GAIM_BLIST_NODE_IS_GROUP(node)) - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, FALSE); if (GAIM_BLIST_NODE_IS_BUDDY(node)) - gaim_gtk_blist_update_contact(list, node); + gaim_gtk_blist_update_buddy(list, node); else if (GAIM_BLIST_NODE_IS_CHAT(node)) gaim_gtk_blist_update(list, node); node = gaim_blist_node_next(node, FALSE); @@ -4060,7 +4064,7 @@ gaim_request_close_with_handle(node); - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, TRUE); if(node->parent) gaim_gtk_blist_update(list, node->parent); @@ -4228,7 +4232,7 @@ -1); g_free(mark); } else { - gaim_gtk_blist_hide_node(list, gnode); + gaim_gtk_blist_hide_node(list, gnode, TRUE); } } @@ -4350,7 +4354,7 @@ buddy_node(buddy, &iter, cnode); } } else { - gaim_gtk_blist_hide_node(list, cnode); + gaim_gtk_blist_hide_node(list, cnode, TRUE); } } @@ -4383,7 +4387,7 @@ buddy_node(buddy, &iter, node); } else { - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, TRUE); } } @@ -4423,7 +4427,7 @@ if(status) g_object_unref(status); } else { - gaim_gtk_blist_hide_node(list, node); + gaim_gtk_blist_hide_node(list, node, TRUE); } } @@ -5353,8 +5357,11 @@ gaim_gtk_blist_sort_method_set("none"); return; } - redo_buddy_list(gaim_get_blist(), TRUE); - + if (!strcmp(id, "none")) { + redo_buddy_list(gaim_get_blist(), TRUE); + } else { + redo_buddy_list(gaim_get_blist(), FALSE); + } } /****************************************** @@ -5919,8 +5926,8 @@ if (gtk_check_menu_item_get_active(checkmenuitem)) { gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH); - - gaim_gtk_blist_sort_method_set(id); + /* This is redundant. I think. */ + /* gaim_gtk_blist_sort_method_set(id); */ gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); gaim_gtk_clear_cursor(gtkblist->window); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aar...@us...> - 2006-07-19 06:47:32
|
Revision: 16519 Author: aaronsheldon Date: 2006-07-18 23:47:26 -0700 (Tue, 18 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16519&view=rev Log Message: ----------- Fixes potential segfaults, especially with completely empty buddy lists. 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-07-18 07:18:23 UTC (rev 16518) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-19 06:47:26 UTC (rev 16519) @@ -4008,8 +4008,11 @@ node = gaim_blist_node_next(node, FALSE); } - g_hash_table_destroy(status_icon_hash_table); - status_icon_hash_table = NULL; + /* There is no hash table if there is nothing in the buddy list to update */ + if (status_icon_hash_table) { + g_hash_table_destroy(status_icon_hash_table); + status_icon_hash_table = NULL; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |