changeset 11490:1ae1454204cd

[gaim-migrate @ 13733] make the type-ahead/ctrl-f searching in the buddy list case insensitive, and add type-ahead/ctrl-f searching to the roomlist (room names only) committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 10 Sep 2005 18:21:27 +0000
parents 63e339161d83
children 26791d1e69ff
files src/gtkblist.c src/gtkroomlist.c
diffstat 2 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Sat Sep 10 17:30:21 2005 +0000
+++ b/src/gtkblist.c	Sat Sep 10 18:21:27 2005 +0000
@@ -3468,19 +3468,20 @@
 	gchar *enteredstring;
 	gchar *withmarkup;
 	gchar *nomarkup;
-	const gchar *normalized;
+	gchar *normalized;
 
 	gtk_tree_model_get(model, iter, column, &withmarkup, -1);
 
-	enteredstring = g_strdup(gaim_normalize(NULL, key));
+	enteredstring = g_utf8_casefold(gaim_normalize(NULL, key), -1);
 	nomarkup = gaim_markup_strip_html(withmarkup);
-	normalized = gaim_normalize(NULL, nomarkup);
+	normalized = g_utf8_casefold(gaim_normalize(NULL, nomarkup), -1);
 
 	result = (g_strstr_len(normalized, strlen(normalized), enteredstring) == NULL);
 
 	g_free(withmarkup);
 	g_free(enteredstring);
 	g_free(nomarkup);
+	g_free(normalized);
 
 	return result;
 }
--- a/src/gtkroomlist.c	Sat Sep 10 17:30:21 2005 +0000
+++ b/src/gtkroomlist.c	Sat Sep 10 18:21:27 2005 +0000
@@ -496,6 +496,25 @@
 		return 1;
 }
 
+static gboolean
+_search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data)
+{
+	gboolean result;
+	gchar *name, *fold, *fkey;
+
+	gtk_tree_model_get(model, iter, column, &name, -1);
+	fold = g_utf8_casefold(name, -1);
+	fkey = g_utf8_casefold(key, -1);
+
+	result = (g_strstr_len(fold, strlen(fold), fkey) == NULL);
+
+	g_free(fold);
+	g_free(fkey);
+	g_free(name);
+
+	return result;
+}
+
 static void gaim_gtk_roomlist_set_fields(GaimRoomlist *list, GList *fields)
 {
 	GaimGtkRoomlist *grl = list->ui_data;
@@ -585,6 +604,11 @@
 	g_signal_connect(G_OBJECT(tree), "button-press-event", G_CALLBACK(room_click_cb), list);
 	g_signal_connect(G_OBJECT(tree), "row-expanded", G_CALLBACK(row_expanded_cb), list);
 	g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK(row_activated_cb), list);
+
+	/* Enable CTRL+F searching */
+	gtk_tree_view_set_search_column(GTK_TREE_VIEW(tree), NAME_COLUMN);
+	gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree), _search_func, NULL, NULL);
+
 }
 
 static gboolean gaim_gtk_progress_bar_pulse(gpointer data)