[recipes/list-new: 11/14] Add queries for new and updates recipes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/list-new: 11/14] Add queries for new and updates recipes
- Date: Sat, 25 Feb 2017 05:00:32 +0000 (UTC)
commit 9595747149646ec7c709d6d3562381ac6bdbdfa0
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 24 23:55:34 2017 -0500
Add queries for new and updates recipes
Make it possible to use search terms like
ct:<timestamp> and mt:<timestamp> to find recipes that have
been created or changed after a given time.
src/gr-recipe-store.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index ae18700..699f6a5 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -1661,6 +1661,8 @@ struct _GrRecipeSearch
char **query;
+ GDateTime *timestamp;
+
gulong idle;
GHashTableIter iter;
@@ -1737,6 +1739,10 @@ recipe_matches (GrRecipeSearch *search,
return gr_recipe_store_is_favorite (search->store, recipe);
else if (strcmp (search->query[0], "is:shopping") == 0)
return gr_recipe_store_is_in_shopping (search->store, recipe);
+ if (g_str_has_prefix (search->query[0], "ct:"))
+ return g_date_time_compare (gr_recipe_get_ctime (recipe), search->timestamp) > 0;
+ else if (g_str_has_prefix (search->query[0], "mt:"))
+ return g_date_time_compare (gr_recipe_get_mtime (recipe), search->timestamp) > 0;
else
return gr_recipe_matches (recipe, (const char **)search->query);
}
@@ -1782,6 +1788,13 @@ start_search (GrRecipeSearch *search)
return;
}
+ if (g_str_has_prefix (search->query[0], "ct:") ||
+ g_str_has_prefix (search->query[0], "mt:")) {
+ const char *time = search->query[0] + strlen ("ct:");
+ g_clear_pointer (&search->timestamp, g_date_time_unref);
+ search->timestamp = date_time_from_string (time);
+ }
+
if (search->idle == 0) {
g_hash_table_iter_init (&search->iter, search->store->recipes);
clear_pending (search);
@@ -1930,6 +1943,7 @@ gr_recipe_search_finalize (GObject *object)
stop_search (search);
g_strfreev (search->query);
g_object_unref (search->store);
+ g_clear_pointer (&search->timestamp, g_date_time_unref);
G_OBJECT_CLASS (gr_recipe_search_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]