Mercurial > geeqie.yaz
comparison src/metadata.c @ 1540:286ed7c6cae6
Allow to configure case handling of keywords
Sometimes I use just different case for keywords. This should be
chooseable.
author | mow |
---|---|
date | Sat, 11 Apr 2009 19:51:03 +0000 |
parents | 24a12aa0cb54 |
children | ddb7aefb45cb |
comparison
equal
deleted
inserted
replaced
1539:4df9f4712d1a | 1540:286ed7c6cae6 |
---|---|
852 | 852 |
853 while (TRUE) | 853 while (TRUE) |
854 { | 854 { |
855 if (!(exclude_sibling && sibling && keyword_compare(keyword_tree, &iter, sibling) == 0)) | 855 if (!(exclude_sibling && sibling && keyword_compare(keyword_tree, &iter, sibling) == 0)) |
856 { | 856 { |
857 gchar *iter_casefold = keyword_get_casefold(keyword_tree, &iter); | 857 if (options->metadata.tags_case_sensitive) |
858 ret = strcmp(casefold, iter_casefold) == 0; | 858 { |
859 g_free(iter_casefold); | 859 gchar *iter_name = keyword_get_name(keyword_tree, &iter); |
860 ret = strcmp(name, iter_name) == 0; | |
861 g_free(iter_name); | |
862 } | |
863 else | |
864 { | |
865 gchar *iter_casefold = keyword_get_casefold(keyword_tree, &iter); | |
866 ret = strcmp(casefold, iter_casefold) == 0; | |
867 g_free(iter_casefold); | |
868 } // if (options->metadata.tags_cas... | |
860 } | 869 } |
861 if (ret) | 870 if (ret) |
862 { | 871 { |
863 if (result) *result = iter; | 872 if (result) *result = iter; |
864 break; | 873 break; |
1003 if (!gtk_tree_model_iter_parent(keyword_tree, &parent, &iter)) return TRUE; | 1012 if (!gtk_tree_model_iter_parent(keyword_tree, &parent, &iter)) return TRUE; |
1004 iter = parent; | 1013 iter = parent; |
1005 } | 1014 } |
1006 } | 1015 } |
1007 | 1016 |
1017 static gboolean keyword_tree_is_set_casefull(GtkTreeModel *keyword_tree, GtkTreeIter iter, GList *kw_list) | |
1018 { | |
1019 if (!kw_list) return FALSE; | |
1020 | |
1021 if (!keyword_get_is_keyword(keyword_tree, &iter)) | |
1022 { | |
1023 /* for the purpose of expanding and hiding, a helper is set if it has any children set */ | |
1024 GtkTreeIter child; | |
1025 if (!gtk_tree_model_iter_children(keyword_tree, &child, &iter)) | |
1026 return FALSE; /* this should happen only on empty helpers */ | |
1027 | |
1028 while (TRUE) | |
1029 { | |
1030 if (keyword_tree_is_set_casefull(keyword_tree, child, kw_list)) return TRUE; | |
1031 if (!gtk_tree_model_iter_next(keyword_tree, &child)) return FALSE; | |
1032 } | |
1033 } | |
1034 | |
1035 while (TRUE) | |
1036 { | |
1037 GtkTreeIter parent; | |
1038 | |
1039 if (keyword_get_is_keyword(keyword_tree, &iter)) | |
1040 { | |
1041 GList *work = kw_list; | |
1042 gboolean found = FALSE; | |
1043 gchar *iter_name = keyword_get_name(keyword_tree, &iter); | |
1044 while (work) | |
1045 { | |
1046 const gchar *name = work->data; | |
1047 work = work->next; | |
1048 | |
1049 if (strcmp(iter_name, name) == 0) | |
1050 { | |
1051 found = TRUE; | |
1052 break; | |
1053 } | |
1054 } | |
1055 g_free(iter_name); | |
1056 if (!found) return FALSE; | |
1057 } | |
1058 | |
1059 if (!gtk_tree_model_iter_parent(keyword_tree, &parent, &iter)) return TRUE; | |
1060 iter = parent; | |
1061 } | |
1062 } | |
1063 | |
1008 gboolean keyword_tree_is_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter, GList *kw_list) | 1064 gboolean keyword_tree_is_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter, GList *kw_list) |
1009 { | 1065 { |
1010 gboolean ret; | 1066 gboolean ret; |
1011 GList *casefold_list = NULL; | 1067 GList *casefold_list = NULL; |
1012 GList *work; | 1068 GList *work; |
1013 | 1069 |
1014 work = kw_list; | 1070 if (options->metadata.tags_case_sensitive) |
1015 while (work) | 1071 { |
1016 { | 1072 ret = keyword_tree_is_set_casefull(keyword_tree, *iter, kw_list); |
1017 const gchar *kw = work->data; | 1073 } |
1018 work = work->next; | 1074 else |
1019 | 1075 { |
1020 casefold_list = g_list_prepend(casefold_list, g_utf8_casefold(kw, -1)); | 1076 work = kw_list; |
1021 } | 1077 while (work) |
1022 | 1078 { |
1023 ret = keyword_tree_is_set_casefold(keyword_tree, *iter, casefold_list); | 1079 const gchar *kw = work->data; |
1024 | 1080 work = work->next; |
1025 string_list_free(casefold_list); | 1081 |
1082 casefold_list = g_list_prepend(casefold_list, g_utf8_casefold(kw, -1)); | |
1083 } | |
1084 | |
1085 ret = keyword_tree_is_set_casefold(keyword_tree, *iter, casefold_list); | |
1086 | |
1087 string_list_free(casefold_list); | |
1088 } | |
1089 | |
1026 return ret; | 1090 return ret; |
1027 } | 1091 } |
1028 | 1092 |
1029 void keyword_tree_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList **kw_list) | 1093 void keyword_tree_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList **kw_list) |
1030 { | 1094 { |