Mercurial > audlegacy
changeset 4161:e1e675e7d737
Automated merge with ssh://hg.atheme.org//hg/audacious
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Thu, 10 Jan 2008 02:25:25 -0600 |
parents | 472aaaca02c0 (diff) 65bb64b7747e (current diff) |
children | 0b00f1d21270 |
files | |
diffstat | 1 files changed, 28 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/ui_jumptotrack.c Wed Jan 09 23:38:10 2008 +0300 +++ b/src/audacious/ui_jumptotrack.c Thu Jan 10 02:25:25 2008 -0600 @@ -316,6 +316,21 @@ serial = playlist->serial; // important. --yaz } + +/** + * Normalizes an UTF-8 string to be used in case-insensitive searches. + * + * Returned string should be freed. + */ +static gchar * +normalize_search_string(const gchar * string) +{ + gchar* normalized_string = g_utf8_normalize(string, -1, G_NORMALIZE_NFKD); + gchar* folded_string = g_utf8_casefold(normalized_string, -1); + g_free(normalized_string); + return folded_string; +} + static void ui_jump_to_track_edit_cb(GtkEntry * entry, gpointer user_data) { @@ -336,16 +351,18 @@ gint i = -1; /* Chop the key string into ' '-separated key regex-pattern strings */ - words = g_strsplit(gtk_entry_get_text(entry), " ", 0); + gchar *search_text = normalize_search_string(gtk_entry_get_text(entry)); + words = g_strsplit(search_text, " ", 0); + g_free(search_text); /* create a list of regex using the regex-pattern strings */ while ( words[++i] != NULL ) { regex_t *regex = g_malloc(sizeof(regex_t)); #if defined(USE_REGEX_PCRE) - if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) + if ( regcomp( regex , words[i] , REG_NOSUB | REG_UTF8 ) == 0 ) #else - if ( regcomp( regex , words[i] , REG_NOSUB | REG_ICASE ) == 0 ) + if ( regcomp( regex , words[i] , REG_NOSUB ) == 0 ) #endif regex_list = g_slist_append( regex_list , regex ); } @@ -369,12 +386,14 @@ PlaylistEntry *entry = PLAYLIST_ENTRY(playlist_glist->data); gchar *title = NULL; - if (entry->title) - title = g_strdup(entry->title); - else { + if (entry->title) { + title = normalize_search_string(entry->title); + } else { gchar *realfn = NULL; realfn = g_filename_from_uri(entry->filename, NULL, NULL); - title = str_to_utf8(realfn ? realfn : entry->filename); + gchar *tmp_title = str_to_utf8(realfn ? realfn : entry->filename); + title = normalize_search_string(tmp_title); + g_free(tmp_title); g_free(realfn); realfn = NULL; } @@ -398,6 +417,8 @@ else match = TRUE; + g_free(title); title = NULL; + if (match) { if (entry->title) title = g_strdup(entry->title);