X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_tasktree.c;h=e1440815666e5b463ac6d5d2292f5651b5b616d3;hb=64d52e239f715717646357783d01ff8650dbdb2d;hp=00dd1d39ec7cfdaa9342f55faf78f0bda8b0a604;hpb=fdf70aa967f489ec5d2d32d286d99a63068d81e1;p=ptask.git diff --git a/src/ui_tasktree.c b/src/ui_tasktree.c index 00dd1d3..e144081 100644 --- a/src/ui_tasktree.c +++ b/src/ui_tasktree.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 jeanfi@gmail.com + * Copyright (C) 2012-2016 jeanfi@gmail.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -292,6 +292,51 @@ void ui_tasktree_set_selected_task(const char *uuid) log_fct_exit(); } +static int match_search_keywords(struct task *task) +{ + gchar *desc; + int ret; + char **tags; + gchar *tag; + + if (!search_keywords || !strlen(search_keywords)) + return 1; + + if (!task->description || !strlen(task->description)) + return 0; + + desc = g_ascii_strup(task->description, -1); + + if (strstr(desc, search_keywords)) + ret = 1; + else + ret = 0; + + free(desc); + + if (ret) + return 1; + + tags = task->tags; + if (!tags) + return 0; + + while (*tags) { + tag = g_ascii_strup(*tags, -1); + + if (strstr(tag, search_keywords)) + ret = 1; + + free(tag); + + if (ret) + return 1; + + tags++; + } + + return 0; +} void ui_tasktree_update(struct task **tasks) { @@ -301,8 +346,6 @@ void ui_tasktree_update(struct task **tasks) GtkTreeIter iter; const char *prj, *prj_filter; char *s; - gchar *desc; - int ok; prj_filter = ui_projecttree_get_project(); @@ -323,21 +366,8 @@ void ui_tasktree_update(struct task **tasks) if (prj_filter && strcmp(prj, prj_filter)) continue; - if (search_keywords - && strlen(search_keywords) - && task->description) { - desc = g_ascii_strup(task->description, -1); - - if (strstr(desc, search_keywords)) - ok = 1; - else - ok = 0; - - free(desc); - - if (!ok) - continue; - } + if (!match_search_keywords(task)) + continue; gtk_list_store_append(GTK_LIST_STORE(model), &iter);