added creation date, due, and start date in the list of tasks.
[ptask.git] / src / ui_tasktree.c
index 7dd4954..8e46c25 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA
  */
+#define _XOPEN_SOURCE
+#include <time.h>
+
+#include <stdlib.h>
 #include <string.h>
 
 #include <gtk/gtk.h>
 
 #include <log.h>
+#include <ptime.h>
 #include <ui_projecttree.h>
+#include <ui_taskpanel.h>
 #include <ui_tasktree.h>
 
 static GtkTreeView *w_treeview;
@@ -32,7 +38,11 @@ enum {
        COL_DESCRIPTION,
        COL_PROJECT,
        COL_UUID,
-       COL_PRIORITY
+       COL_PRIORITY,
+       COL_URGENCY,
+       COL_CREATION_DATE,
+       COL_DUE,
+       COL_START
 };
 
 static int priority_to_int(const char *str)
@@ -74,6 +84,17 @@ static gint priority_cmp(GtkTreeModel *model,
                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;
@@ -218,6 +239,7 @@ void ui_tasktree_update(struct task **tasks, const char *prj_filter)
        struct task *task;
        GtkTreeIter iter;
        const char *prj;
+       char *s;
 
        current_tasks = tasks;
 
@@ -240,13 +262,52 @@ void ui_tasktree_update(struct task **tasks, const char *prj_filter)
 
                        gtk_list_store_set(GTK_LIST_STORE(model),
                                           &iter,
-                                          COL_ID, (*tasks_cur)->id,
+                                          COL_ID,
+                                          (*tasks_cur)->id,
                                           COL_DESCRIPTION,
                                           (*tasks_cur)->description,
-                                          COL_PROJECT, prj,
-                                          COL_UUID, (*tasks_cur)->uuid,
-                                          COL_PRIORITY, (*tasks_cur)->priority,
+                                          COL_PROJECT,
+                                          prj,
+                                          COL_UUID,
+                                          (*tasks_cur)->uuid,
+                                          COL_PRIORITY,
+                                          (*tasks_cur)->priority,
+                                          COL_URGENCY,
+                                          (*tasks_cur)->urgency,
                                           -1);
+
+                       if ((*tasks_cur)->start) {
+                               s = tm_to_str((*tasks_cur)->start);
+                               gtk_list_store_set
+                                       (GTK_LIST_STORE(model),
+                                        &iter,
+                                        COL_START,
+                                        s,
+                                        -1);
+                               free(s);
+                       }
+
+                       if ((*tasks_cur)->due) {
+                               s = tm_to_str((*tasks_cur)->due);
+                               gtk_list_store_set
+                                       (GTK_LIST_STORE(model),
+                                        &iter,
+                                        COL_DUE,
+                                        s,
+                                        -1);
+                               free(s);
+                       }
+
+                       if ((*tasks_cur)->entry) {
+                               s = tm_to_str((*tasks_cur)->entry);
+                               gtk_list_store_set
+                                       (GTK_LIST_STORE(model),
+                                        &iter,
+                                        COL_CREATION_DATE,
+                                        s,
+                                        -1);
+                               free(s);
+                       }
                }
        }