+
+const char *ui_tasktree_get_task_uuid()
+{
+ struct task *t;
+
+ t = ui_tasktree_get_selected_task();
+
+ if (t)
+ return t->uuid;
+ else
+ return NULL;
+}
+
+struct task *ui_tasktree_get_selected_task()
+{
+ GtkTreePath *path;
+ GtkTreeViewColumn *cols;
+ struct task **tasks_cur, *result;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GValue value = {0,};
+ const char *uuid;
+
+ log_fct_enter();
+
+ result = NULL;
+
+ if (current_tasks) {
+ gtk_tree_view_get_cursor(w_treeview, &path, &cols);
+
+ if (path) {
+ model = gtk_tree_view_get_model(w_treeview);
+ gtk_tree_model_get_iter(model, &iter, path);
+ gtk_tree_model_get_value(model,
+ &iter,
+ COL_UUID,
+ &value);
+
+ uuid = g_value_get_string(&value);
+
+ for (tasks_cur = current_tasks; *tasks_cur; tasks_cur++)
+ if (!strcmp((*tasks_cur)->uuid, uuid))
+ result = *tasks_cur;
+
+ gtk_tree_path_free(path);
+ }
+ }
+
+ log_fct_exit();
+
+ return result;
+}
+
+void ui_tasktree_set_selected_task(const char *uuid)
+{
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GValue value = {0,};
+ const char *c_uuid;
+
+ log_fct_enter();
+
+ if (current_tasks) {
+ model = gtk_tree_view_get_model(w_treeview);
+
+ if (!gtk_tree_model_get_iter_first(model, &iter))
+ return ;
+
+ path = NULL;
+ while (gtk_tree_model_iter_next(model, &iter)) {
+ gtk_tree_model_get_value(model,
+ &iter,
+ COL_UUID,
+ &value);
+ c_uuid = g_value_get_string(&value);
+
+ if (!strcmp(uuid, c_uuid)) {
+ path = gtk_tree_model_get_path(model, &iter);
+ break;
+ }
+
+ g_value_unset(&value);
+ }
+
+ if (!path)
+ path = gtk_tree_path_new_first();
+ gtk_tree_view_set_cursor(w_treeview, path, NULL, FALSE);
+ }
+
+ log_fct_exit();
+}
+
+
+void ui_tasktree_update(struct task **tasks, const char *prj_filter)
+{
+ GtkTreeModel *model;
+ struct task **tasks_cur;
+ struct task *task;
+ GtkTreeIter iter;
+ const char *prj;
+
+ current_tasks = tasks;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
+ gtk_list_store_clear(GTK_LIST_STORE(model));
+
+ if (current_tasks) {
+ for (tasks_cur = current_tasks; *tasks_cur; tasks_cur++) {
+ task = (*tasks_cur);
+
+ if (task->project)
+ prj = task->project;
+ else
+ prj = "";
+
+ if (prj_filter && strcmp(prj, prj_filter))
+ continue;
+
+ gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+
+ gtk_list_store_set(GTK_LIST_STORE(model),
+ &iter,
+ COL_ID, (*tasks_cur)->id,
+ COL_DESCRIPTION,
+ (*tasks_cur)->description,
+ COL_PROJECT, prj,
+ COL_UUID, (*tasks_cur)->uuid,
+ COL_PRIORITY, (*tasks_cur)->priority,
+ -1);
+ }
+ }
+
+}
+
+void ui_tasktree_update_filter(const char *prj_filter)
+{
+ ui_tasktree_update(current_tasks, prj_filter);
+}