[gthumb] added ability to search and filter files with a single tag
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] added ability to search and filter files with a single tag
- Date: Sun, 6 Feb 2011 13:02:28 +0000 (UTC)
commit 4fab613540b7a94e15386eec89fb01069b707c66
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Feb 6 14:01:40 2011 +0100
added ability to search and filter files with a single tag
[bug #633884]
extensions/catalogs/gth-organize-task.c | 2 +-
extensions/search/callbacks.c | 2 +-
gthumb/gth-test-category.c | 17 ++++++++++++++---
gthumb/gth-test.h | 1 +
4 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/extensions/catalogs/gth-organize-task.c b/extensions/catalogs/gth-organize-task.c
index cc3bc8b..dbfb07d 100644
--- a/extensions/catalogs/gth-organize-task.c
+++ b/extensions/catalogs/gth-organize-task.c
@@ -376,7 +376,7 @@ add_catalog_for_tag (GthOrganizeTask *self,
gth_search_set_recursive (GTH_SEARCH (catalog), self->priv->recursive);
tag_test = gth_main_get_registered_object (GTH_TYPE_TEST, (self->priv->group_policy == GTH_GROUP_POLICY_TAG) ? "comment::category" : "general::tags");
- gth_test_category_set (GTH_TEST_CATEGORY (tag_test), GTH_TEST_OP_EQUAL, FALSE, tag);
+ gth_test_category_set (GTH_TEST_CATEGORY (tag_test), GTH_TEST_OP_CONTAINS, FALSE, tag);
test_chain = gth_test_chain_new (GTH_MATCH_TYPE_ALL, tag_test, NULL);
gth_search_set_test (GTH_SEARCH (catalog), GTH_TEST_CHAIN (test_chain));
diff --git a/extensions/search/callbacks.c b/extensions/search/callbacks.c
index add3a76..4ef0880 100644
--- a/extensions/search/callbacks.c
+++ b/extensions/search/callbacks.c
@@ -337,7 +337,7 @@ search__gth_organize_task_create_catalog (GthGroupPolicyData *data)
gth_search_set_recursive (GTH_SEARCH (data->catalog), gth_organize_task_get_recursive (data->task));
tag_test = gth_main_get_registered_object (GTH_TYPE_TEST, (policy == GTH_GROUP_POLICY_TAG) ? "comment::category" : "general::tags");
- gth_test_category_set (GTH_TEST_CATEGORY (tag_test), GTH_TEST_OP_EQUAL, FALSE, data->tag);
+ gth_test_category_set (GTH_TEST_CATEGORY (tag_test), GTH_TEST_OP_CONTAINS, FALSE, data->tag);
test_chain = gth_test_chain_new (GTH_MATCH_TYPE_ALL, tag_test, NULL);
gth_search_set_test (GTH_SEARCH (data->catalog), GTH_TEST_CHAIN (test_chain));
diff --git a/gthumb/gth-test-category.c b/gthumb/gth-test-category.c
index a580013..c8c2b4e 100644
--- a/gthumb/gth-test-category.c
+++ b/gthumb/gth-test-category.c
@@ -43,8 +43,9 @@ typedef struct {
GthOpData category_op_data[] = {
- { N_("is"), GTH_TEST_OP_EQUAL, FALSE },
- { N_("is not"), GTH_TEST_OP_EQUAL, TRUE }
+ { N_("is"), GTH_TEST_OP_CONTAINS, FALSE },
+ { N_("is only"), GTH_TEST_OP_CONTAINS_ONLY, FALSE },
+ { N_("is not"), GTH_TEST_OP_CONTAINS, TRUE }
};
@@ -256,6 +257,11 @@ gth_test_category_real_match (GthTest *test,
else
list = NULL;
+ if (test_category->priv->op == GTH_TEST_OP_CONTAINS_ONLY) {
+ if ((list == NULL) || (list->next != NULL))
+ 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;
@@ -330,9 +336,14 @@ gth_test_category_real_load_from_element (DomDomizable *base,
g_object_set (self, "visible", (g_strcmp0 (dom_element_get_attribute (element, "display"), "none") != 0), NULL);
value = dom_element_get_attribute (element, "op");
- if (value != NULL)
+ if (value != NULL) {
self->priv->op = _g_enum_type_get_value_by_nick (GTH_TYPE_TEST_OP, value)->value;
+ /* convert EQUAL to CONTAINS for backward compatibility */
+ if (self->priv->op == GTH_TEST_OP_EQUAL)
+ self->priv->op = GTH_TEST_OP_CONTAINS;
+ }
+
self->priv->negative = g_strcmp0 (dom_element_get_attribute (element, "negative"), "true") == 0;
gth_test_category_set_category (self, NULL);
diff --git a/gthumb/gth-test.h b/gthumb/gth-test.h
index 8295dc7..5429569 100644
--- a/gthumb/gth-test.h
+++ b/gthumb/gth-test.h
@@ -54,6 +54,7 @@ typedef enum {
GTH_TEST_OP_GREATER,
GTH_TEST_OP_CONTAINS,
GTH_TEST_OP_CONTAINS_ALL,
+ GTH_TEST_OP_CONTAINS_ONLY,
GTH_TEST_OP_STARTS_WITH,
GTH_TEST_OP_ENDS_WITH,
GTH_TEST_OP_MATCHES,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]