# HG changeset patch # User Luoh Ren-Shan # Date 1264737360 0 # Node ID fff8cf8459c45edb97d047de9680d938200b5ef9 # Parent 45fce067c690ed3147262838361c6bdc54d57b0f Search friends by email addresses in the buddylist. Display names may change, but email addresses are not. I don't like to use mouse and my eyes to search in a buddy list with hundreds of entries. Closes #9322. committer: Sadrul Habib Chowdhury diff -r 45fce067c690 -r fff8cf8459c4 COPYRIGHT --- a/COPYRIGHT Fri Jan 29 01:41:16 2010 +0000 +++ b/COPYRIGHT Fri Jan 29 03:56:00 2010 +0000 @@ -379,6 +379,7 @@ R. Ramkumar Mart Raudsepp Etan Reisner +Luoh Ren-Shan Kristian Rietveld Pekka Riikonen Tim Ringenbach diff -r 45fce067c690 -r fff8cf8459c4 ChangeLog --- a/ChangeLog Fri Jan 29 01:41:16 2010 +0000 +++ b/ChangeLog Fri Jan 29 03:56:00 2010 +0000 @@ -40,6 +40,7 @@ interior-focus style property is diabled. (Gabriel Schulhof) * Correctly handle a multiline text field being required in a request form. (Thanks to Florian Zeitz for finding this problem) + * Search friends by email-addresses in the buddy list. (Luoh Ren-Shan) version 2.6.5 (01/08/2010): libpurple: diff -r 45fce067c690 -r fff8cf8459c4 pidgin/gtkblist.c --- a/pidgin/gtkblist.c Fri Jan 29 01:41:16 2010 +0000 +++ b/pidgin/gtkblist.c Fri Jan 29 03:56:00 2010 +0000 @@ -5616,6 +5616,51 @@ } +static gboolean +pidgin_blist_search_equal_func(GtkTreeModel *model, gint column, + const gchar *key, GtkTreeIter *iter, gpointer data) +{ + PurpleBlistNode *node = NULL; + gboolean res = TRUE; + const char *compare = NULL; + + if (!pidgin_tree_view_search_equal_func(model, column, key, iter, data)) + return FALSE; + + /* If the search string does not match the displayed label, then look + * at the alternate labels for the nodes and search in them. Currently, + * alternate labels that make sense are usernames/email addresses for + * buddies (but only for the ones who don't have a local alias). + */ + + gtk_tree_model_get(model, iter, NODE_COLUMN, &node, -1); + if (!node) + return TRUE; + + compare = NULL; + if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { + PurpleBuddy *b = purple_contact_get_priority_buddy(PURPLE_CONTACT(node)); + if (!purple_buddy_get_local_buddy_alias(b)) + compare = purple_buddy_get_name(b); + } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { + if (!purple_buddy_get_local_buddy_alias(PURPLE_BUDDY(node))) + compare = purple_buddy_get_name(PURPLE_BUDDY(node)); + } + + if (compare) { + char *tmp, *enteredstring; + tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT); + enteredstring = g_utf8_casefold(tmp, -1); + g_free(tmp); + + if (purple_str_has_prefix(compare, enteredstring)) + res = FALSE; + g_free(enteredstring); + } + + return res; +} + static void pidgin_blist_show(PurpleBuddyList *list) { PidginBuddyListPrivate *priv; @@ -5852,7 +5897,8 @@ /* Enable CTRL+F searching */ gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN); - gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), pidgin_tree_view_search_equal_func, NULL, NULL); + gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), + pidgin_blist_search_equal_func, NULL, NULL); gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview);