Mercurial > geeqie
comparison src/metadata.c @ 1715:f1e316c4cc4d
Fix a small problem with casefull keywords
In @1636 I miss one check for keyword case. Now it should be all fixed.
author | mow |
---|---|
date | Sat, 01 Aug 2009 22:37:57 +0000 |
parents | 9fef1cbc556e |
children | 808d4308ca00 |
comparison
equal
deleted
inserted
replaced
1714:21647c5b2420 | 1715:f1e316c4cc4d |
---|---|
657 string_list_free(list); | 657 string_list_free(list); |
658 return ret; | 658 return ret; |
659 } | 659 } |
660 } | 660 } |
661 | 661 |
662 /** | |
663 * \see find_string_in_list | |
664 */ | |
662 gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string) | 665 gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string) |
663 { | 666 { |
664 gchar *string_casefold = g_utf8_casefold(string, -1); | 667 gchar *string_casefold = g_utf8_casefold(string, -1); |
665 | 668 |
666 while (list) | 669 while (list) |
667 { | 670 { |
668 gchar *haystack = list->data; | 671 gchar *haystack = list->data; |
669 | 672 |
670 if (haystack) | 673 if (haystack) |
671 { | 674 { |
672 gboolean equal; | 675 gboolean equal; |
673 gchar *haystack_casefold = g_utf8_casefold(haystack, -1); | 676 gchar *haystack_casefold = g_utf8_casefold(haystack, -1); |
674 | 677 |
679 { | 682 { |
680 g_free(string_casefold); | 683 g_free(string_casefold); |
681 return haystack; | 684 return haystack; |
682 } | 685 } |
683 } | 686 } |
684 | 687 |
685 list = list->next; | 688 list = list->next; |
686 } | 689 } |
687 | 690 |
688 g_free(string_casefold); | 691 g_free(string_casefold); |
689 return NULL; | 692 return NULL; |
690 } | 693 } |
691 | 694 |
695 /** | |
696 * \see find_string_in_list | |
697 */ | |
698 gchar *find_string_in_list_utf8case(GList *list, const gchar *string) | |
699 { | |
700 while (list) | |
701 { | |
702 gchar *haystack = list->data; | |
703 | |
704 if (haystack && strcmp(haystack, string) == 0) | |
705 return haystack; | |
706 | |
707 list = list->next; | |
708 } // while (list) | |
709 | |
710 return NULL; | |
711 } // gchar *find_string_in_list_utf... | |
712 | |
713 /** | |
714 * \brief Find a existent string in a list. | |
715 * | |
716 * This is a switch between find_string_in_list_utf8case and | |
717 * find_string_in_list_utf8nocase to search with or without case for the | |
718 * existence of a string. | |
719 * | |
720 * \param list The list to search in | |
721 * \param string The string to search for | |
722 * \return The string or NULL | |
723 * | |
724 * \see find_string_in_list_utf8case | |
725 * \see find_string_in_list_utf8nocase | |
726 */ | |
727 gchar *find_string_in_list(GList *list, const gchar *string) | |
728 { | |
729 if (options->metadata.keywords_case_sensitive) | |
730 return find_string_in_list_utf8case(list, string); | |
731 else | |
732 return find_string_in_list_utf8nocase(list, string); | |
733 } | |
692 | 734 |
693 #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b') | 735 #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b') |
694 | 736 |
695 GList *string_to_keywords_list(const gchar *text) | 737 GList *string_to_keywords_list(const gchar *text) |
696 { | 738 { |
717 if (l > 0) | 759 if (l > 0) |
718 { | 760 { |
719 gchar *keyword = g_strndup(begin, l); | 761 gchar *keyword = g_strndup(begin, l); |
720 | 762 |
721 /* only add if not already in the list */ | 763 /* only add if not already in the list */ |
722 if (!find_string_in_list_utf8nocase(list, keyword)) | 764 if (!find_string_in_list(list, keyword)) |
723 list = g_list_append(list, keyword); | 765 list = g_list_append(list, keyword); |
724 else | 766 else |
725 g_free(keyword); | 767 g_free(keyword); |
726 } | 768 } |
727 } | 769 } |
1166 GtkTreeIter parent; | 1208 GtkTreeIter parent; |
1167 | 1209 |
1168 if (keyword_get_is_keyword(keyword_tree, &iter)) | 1210 if (keyword_get_is_keyword(keyword_tree, &iter)) |
1169 { | 1211 { |
1170 gchar *name = keyword_get_name(keyword_tree, &iter); | 1212 gchar *name = keyword_get_name(keyword_tree, &iter); |
1171 if (!find_string_in_list_utf8nocase(*kw_list, name)) | 1213 if (!find_string_in_list(*kw_list, name)) |
1172 { | 1214 { |
1173 *kw_list = g_list_append(*kw_list, name); | 1215 *kw_list = g_list_append(*kw_list, name); |
1174 } | 1216 } |
1175 else | 1217 else |
1176 { | 1218 { |
1188 gchar *found; | 1230 gchar *found; |
1189 gchar *name; | 1231 gchar *name; |
1190 if (!keyword_get_is_keyword(keyword_tree, iter)) return; | 1232 if (!keyword_get_is_keyword(keyword_tree, iter)) return; |
1191 | 1233 |
1192 name = keyword_get_name(keyword_tree, iter); | 1234 name = keyword_get_name(keyword_tree, iter); |
1193 found = find_string_in_list_utf8nocase(*kw_list, name); | 1235 found = find_string_in_list(*kw_list, name); |
1194 | 1236 |
1195 if (found) | 1237 if (found) |
1196 { | 1238 { |
1197 *kw_list = g_list_remove(*kw_list, found); | 1239 *kw_list = g_list_remove(*kw_list, found); |
1198 g_free(found); | 1240 g_free(found); |