#include <gtk/gtk.h>
#include <log.h>
+#include <ui_projecttree.h>
+#include <ui_taskpanel.h>
#include <ui_tasktree.h>
static GtkTreeView *w_treeview;
COL_DESCRIPTION,
COL_PROJECT,
COL_UUID,
- COL_PRIORITY
+ COL_PRIORITY,
+ COL_URGENCY
};
static int priority_to_int(const char *str)
return 0;
}
+int tasktree_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
+{
+ log_fct_enter();
+
+ ui_taskpanel_update(ui_tasktree_get_selected_task());
+
+ log_fct_exit();
+
+ return FALSE;
+}
+
void ui_tasktree_init(GtkBuilder *builder)
{
GtkTreeModel *model;
g_settings_set_int(settings, "tasks-sort-order", sort_order);
}
+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()
{
return result;
}
-void ui_tasktree_update(struct task **tasks)
+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,
+ COL_URGENCY, (*tasks_cur)->urgency,
+ -1);
+ }
+ }
+
+}
+
+void ui_tasktree_update_filter(const char *prj_filter)
+{
+ ui_tasktree_update(current_tasks, prj_filter);
}