gchar *key = list->data;
gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, find_string_in_list(keywords, key),
+ gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, !!find_string_in_list_utf8nocase(keywords, key),
KEYWORD_COLUMN_TEXT, key,
KEYWORD_COLUMN_MARK, bar_pane_keywords_get_mark_text(key), -1);
static void bar_pane_keywords_keyword_set(PaneKeywordsData *pkd, const gchar *keyword, gint active)
{
GList *list;
- gint found;
+ gchar *found;
if (!keyword) return;
list = keyword_list_pull(pkd->keyword_view);
- found = find_string_in_list(list, keyword);
+ found = find_string_in_list_utf8nocase(list, keyword);
- if (active != found)
+ if ((!active && found) || (active && !found))
{
if (found)
{
- GList *work = list;
-
- while (work)
- {
- gchar *key = work->data;
- work = work->next;
-
- if (key && keyword && strcmp(key, keyword) == 0)
- {
- list = g_list_remove(list, key);
- g_free(key);
- }
- }
+ list = g_list_remove(list, found);
+ g_free(found);
}
else
{
}
}
-gboolean find_string_in_list(GList *list, const gchar *string)
+gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string)
{
+ gchar *string_casefold = g_utf8_casefold(string, -1);
+
while (list)
{
gchar *haystack = list->data;
+
+ if (haystack)
+ {
+ gboolean equal;
+ gchar *haystack_casefold = g_utf8_casefold(haystack, -1);
- if (haystack && string && strcmp(haystack, string) == 0) return TRUE;
+ equal = (strcmp(haystack_casefold, string_casefold) == 0);
+ g_free(haystack_casefold);
+ if (equal)
+ {
+ g_free(string_casefold);
+ return haystack;
+ }
+ }
+
list = list->next;
}
-
- return FALSE;
+
+ g_free(string_casefold);
+ return NULL;
}
+
#define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b')
GList *string_to_keywords_list(const gchar *text)
gchar *keyword = g_strndup(begin, l);
/* only add if not already in the list */
- if (find_string_in_list(list, keyword) == FALSE)
+ if (!find_string_in_list_utf8nocase(list, keyword))
list = g_list_append(list, keyword);
else
g_free(keyword);
gboolean metadata_append_string(FileData *fd, const gchar *key, const char *value);
gboolean metadata_append_list(FileData *fd, const gchar *key, const GList *values);
-gboolean find_string_in_list(GList *list, const gchar *keyword);
GList *string_to_keywords_list(const gchar *text);
+gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string);
gboolean meta_data_get_keyword_mark(FileData *fd, gint n, gpointer data);
gboolean meta_data_set_keyword_mark(FileData *fd, gint n, gboolean value, gpointer data);