# HG changeset patch # User Mark Doliner # Date 1104173202 0 # Node ID f7f06cb69d5e6d2a92e2403c12aaa00de508c3eb # Parent dc4475bf718f4143c0e06107e690331900cf4532 [gaim-migrate @ 11689] Working CTRL+F searching for the buddy list. Previously it only found non-idle, non-away people. Not it finds all KINDS of people, and it does a substring search, too. So if you have a buddy "giantgraypanda" you can search for "gray" and this will find them. committer: Tailor Script diff -r dc4475bf718f -r f7f06cb69d5e src/blist.h --- a/src/blist.h Mon Dec 27 08:56:04 2004 +0000 +++ b/src/blist.h Mon Dec 27 18:46:42 2004 +0000 @@ -189,7 +189,7 @@ gboolean show); /**< Hides or unhides the buddy list */ void (*request_add_buddy)(GaimAccount *account, const char *username, const char *group, const char *alias); - void (*request_add_chat)(GaimAccount *account, GaimGroup *group, + void (*request_add_chat)(GaimAccount *account, GaimGroup *group, const char *alias, const char *name); void (*request_add_group)(void); }; diff -r dc4475bf718f -r f7f06cb69d5e src/gtkblist.c --- a/src/gtkblist.c Mon Dec 27 08:56:04 2004 +0000 +++ b/src/gtkblist.c Mon Dec 27 18:46:42 2004 +0000 @@ -3128,7 +3128,14 @@ } } -enum {DRAG_BUDDY, DRAG_ROW, DRAG_VCARD, DRAG_TEXT, DRAG_URI,NUM_TARGETS}; +enum { + DRAG_BUDDY, + DRAG_ROW, + DRAG_VCARD, + DRAG_TEXT, + DRAG_URI, + NUM_TARGETS +}; static char * item_factory_translate_func (const char *path, gpointer func_data) @@ -3147,16 +3154,56 @@ gaim_gtk_blist_sort_method_set(gaim_prefs_get_string("/gaim/gtk/blist/sort_type")); } -static void _prefs_change_redo_list() { +static void _prefs_change_redo_list() +{ redo_buddy_list(gaim_get_blist(), TRUE); } static void _prefs_change_sort_method(const char *pref_name, GaimPrefType type, - gpointer val, gpointer data) { + gpointer val, gpointer data) +{ if(!strcmp(pref_name, "/gaim/gtk/blist/sort_type")) gaim_gtk_blist_sort_method_set(val); } +/* + * "This is so dead sexy." + * "Two thumbs up." + * "Best movie of the year." + * + * This is the function that handles CTRL+F searching in the buddy list. + * It finds the top-most buddy/group/chat/whatever containing the + * entered string. + * + * It's somewhat ineffecient, because we strip all the HTML from the + * "name" column of the buddy list (because the GtkTreeModel does not + * contain the screen name in a non-markedup format). But the alternative + * is to add an extra column to the GtkTreeModel. And this function is + * used rarely, so it shouldn't matter TOO much. + */ +static gboolean +_search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) +{ + gchar *enteredstring; + const gchar *withmarkup; + gchar *nomarkup; + const gchar *normalized; + gboolean result; + + gtk_tree_model_get(model, iter, NAME_COLUMN, &withmarkup, -1); + + enteredstring = g_strdup(gaim_normalize(NULL, key)); + nomarkup = gaim_markup_strip_html(withmarkup); + normalized = gaim_normalize(NULL, nomarkup); + + result = (g_strstr_len(normalized, strlen(normalized), enteredstring) == NULL); + + g_free(enteredstring); + g_free(nomarkup); + + return result; +} + static void gaim_gtk_blist_show(GaimBuddyList *list) { void *handle; @@ -3232,11 +3279,9 @@ gtk_widget_set_name(gtkblist->treeview, "gaim_gtkblist_treeview"); /* Set up selection stuff */ - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); - /* Set up dnd */ gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), GDK_BUTTON1_MASK, ste, 3, @@ -3247,7 +3292,7 @@ g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL); - + g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); /* Tooltips */ @@ -3302,6 +3347,7 @@ /* 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), _search_func, NULL, NULL); gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); diff -r dc4475bf718f -r f7f06cb69d5e src/gtkmain.c --- a/src/gtkmain.c Mon Dec 27 08:56:04 2004 +0000 +++ b/src/gtkmain.c Mon Dec 27 18:46:42 2004 +0000 @@ -636,6 +636,7 @@ gaim_set_blist(gaim_blist_new()); gaim_blist_load(); + /* TODO: Move prefs loading into gaim_prefs_init() */ gaim_prefs_load(); gaim_prefs_update_old(); gaim_gtk_prefs_update_old(); @@ -643,6 +644,7 @@ /* load plugins we had when we quit */ gaim_plugins_load_saved("/gaim/gtk/plugins/loaded"); + /* TODO: Move pounces loading into gaim_pounces_init() */ gaim_pounces_load(); ui_main(); diff -r dc4475bf718f -r f7f06cb69d5e src/util.h --- a/src/util.h Mon Dec 27 08:56:04 2004 +0000 +++ b/src/util.h Mon Dec 27 18:46:42 2004 +0000 @@ -464,7 +464,11 @@ * g_strdup() it. Also, calling normalize() twice in the same line * will lead to problems. * - * @param account The account the string belongs to. + * @param account The account the string belongs to, or NULL if you do + * not know the account. If you use NULL, the string + * will still be normalized, but if the PRPL uses a + * custom normalization function then the string may + * not be normalized correctly. * @param str The string to normalize. * * @return A pointer to the normalized version stored in a static buffer.