pidgin: d3cb31a7: Search friends by email addresses in the...

sadrul at pidgin.im sadrul at pidgin.im
Thu Jan 28 23:07:22 EST 2010


-----------------------------------------------------------------
Revision: d3cb31a7dfd923b11d6f8964b40f64cf0c2a93dc
Ancestor: 8a2cdbdb048f7cc2b372fcb5a103bf6dda13ee25
Author: Luoh Ren-Shan <lcamel at gmail.com>
Date: 2010-01-29T03:56:00
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d3cb31a7dfd923b11d6f8964b40f64cf0c2a93dc

Modified files:
        COPYRIGHT ChangeLog pidgin/gtkblist.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- COPYRIGHT	b7abf3e6fc2e1887cbd2d870e4b6b5b76d3ff64f
+++ COPYRIGHT	194a0d7650976bca9edf99f2101df570d1a56c02
@@ -379,6 +379,7 @@ Etan Reisner
 R. Ramkumar
 Mart Raudsepp
 Etan Reisner
+Luoh Ren-Shan
 Kristian Rietveld
 Pekka Riikonen
 Tim Ringenbach
============================================================
--- ChangeLog	a0312dcbc26d190d686dff664077db2e2257ddf7
+++ ChangeLog	cf7f200345fcad535213d102b40f2c344c52f948
@@ -40,6 +40,7 @@ version 2.6.6 (??/??/20??):
 	  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:
============================================================
--- pidgin/gtkblist.c	aa7ee78ff2ec9f4bba4b590e953553e41b1855ca
+++ pidgin/gtkblist.c	143427d7f602ddbc24b6b9fde4fc7cbd7216bcb0
@@ -5616,6 +5616,51 @@ pidgin_blist_build_layout(PurpleBuddyLis
 
 }
 
+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 @@ static void pidgin_blist_show(PurpleBudd
 
 	/* 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);


More information about the Commits mailing list