[gthumb] tag filter: added ability to filter using a regular expression
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] tag filter: added ability to filter using a regular expression
- Date: Sat, 13 Aug 2016 14:42:25 +0000 (UTC)
commit ea10110277f3ae7d9542665361671fd9d1a7f0c7
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Aug 13 16:37:37 2016 +0200
tag filter: added ability to filter using a regular expression
gthumb/gth-test-category.c | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/gthumb/gth-test-category.c b/gthumb/gth-test-category.c
index e9e6c3c..19b3fad 100644
--- a/gthumb/gth-test-category.c
+++ b/gthumb/gth-test-category.c
@@ -45,7 +45,8 @@ typedef struct {
GthOpData category_op_data[] = {
{ N_("is"), GTH_TEST_OP_CONTAINS, FALSE },
{ N_("is only"), GTH_TEST_OP_CONTAINS_ONLY, FALSE },
- { N_("is not"), GTH_TEST_OP_CONTAINS, TRUE }
+ { N_("is not"), GTH_TEST_OP_CONTAINS, TRUE },
+ { N_("matches"), GTH_TEST_OP_MATCHES, FALSE }
};
@@ -281,7 +282,8 @@ gth_test_category_real_match (GthTest *test,
if (test_category->priv->category != NULL) {
GthMetadata *metadata;
GList *list, *scan;
- char *test_category_casefolded;
+ char *test_category_casefolded = NULL;
+ GPatternSpec *pattern = NULL;
list = NULL;
metadata = (GthMetadata *) g_file_info_get_attribute_object (file->info,
gth_test_get_attributes (GTH_TEST (test_category)));
@@ -297,17 +299,33 @@ gth_test_category_real_match (GthTest *test,
return test_category->priv->negative ? GTH_MATCH_YES : GTH_MATCH_NO;
}
- test_category_casefolded = g_utf8_casefold (test_category->priv->category, -1);
for (scan = list; ! result && scan; scan = scan->next) {
- char *category;
-
- category = g_utf8_casefold (scan->data, -1);
- if (g_utf8_collate (category, test_category_casefolded) == 0)
- result = TRUE;
+ char *category = g_utf8_casefold (scan->data, -1);
+
+ switch (test_category->priv->op) {
+ case GTH_TEST_OP_CONTAINS:
+ case GTH_TEST_OP_CONTAINS_ONLY:
+ if (test_category_casefolded == NULL)
+ test_category_casefolded = g_utf8_casefold
(test_category->priv->category, -1);
+ if (g_utf8_collate (category, test_category_casefolded) == 0)
+ result = TRUE;
+ break;
+
+ case GTH_TEST_OP_MATCHES:
+ if (pattern == NULL)
+ pattern = g_pattern_spec_new (test_category->priv->category);
+ result = g_pattern_match_string (pattern, scan->data);
+ break;
+
+ default:
+ break;
+ }
g_free (category);
}
+ if (pattern != NULL)
+ g_pattern_spec_free (pattern);
g_free (test_category_casefolded);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]