added creation date, due, and start date in the list of tasks.
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 8 Dec 2013 00:31:28 +0000 (00:31 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 8 Dec 2013 00:31:28 +0000 (00:31 +0000)
NEWS
NEWS.html
src/glade/ptask.glade
src/ptime.c
src/ptime.h
src/tw.c
src/tw.h
src/ui_tasktree.c

diff --git a/NEWS b/NEWS
index d00b15d..3ae37c7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ v0.0.5
  * implemented the cancel button of the task panel.
  * added menu.
  * restore position of vertical/horizaton spliters.
+ * added creation date, due, and start date in the list of tasks.
 
 v0.0.4
 ------
index 89e84e3..5e14a0b 100644 (file)
--- a/NEWS.html
+++ b/NEWS.html
@@ -356,6 +356,11 @@ added menu.
 restore position of vertical/horizaton spliters.\r
 </p>\r
 </li>\r
+<li>\r
+<p>\r
+added creation date, due, and start date in the list of tasks.\r
+</p>\r
+</li>\r
 </ul></div>\r
 </div>\r
 </div>\r
@@ -501,7 +506,7 @@ Initial release.
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Last updated 2013-12-07 20:03:29 CET\r
+Last updated 2013-12-07 22:47:54 CET\r
 </div>\r
 </div>\r
 </body>\r
index 1e9db98..4dbc32d 100644 (file)
@@ -1,26 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkListStore" id="prioritystore">
-    <columns>
-      <!-- column-name priority -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">None</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Low</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Medium</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">High</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkDialog" id="diag_tasknew">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
       <action-widget response="0">button2</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" id="prioritystore">
+    <columns>
+      <!-- column-name priority -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">None</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Low</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Medium</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">High</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkListStore" id="projectstore">
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
       <!-- column-name urgency -->
       <column type="gchararray"/>
+      <!-- column-name creation -->
+      <column type="gchararray"/>
+      <!-- column-name due -->
+      <column type="gchararray"/>
+      <!-- column-name start -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkWindow" id="window">
                           </object>
                         </child>
                         <child>
+                          <object class="GtkTreeViewColumn" id="urgency">
+                            <property name="title" translatable="yes">Urgency</property>
+                            <property name="sort_column_id">5</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext9"/>
+                              <attributes>
+                                <attribute name="text">5</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="creation date">
+                            <property name="title" translatable="yes">Creation date</property>
+                            <property name="sort_column_id">6</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext10"/>
+                              <attributes>
+                                <attribute name="text">6</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="Due">
+                            <property name="title" translatable="yes">Due</property>
+                            <property name="sort_column_id">7</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext11"/>
+                              <attributes>
+                                <attribute name="text">7</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                            <property name="title" translatable="yes">Start date</property>
+                            <property name="sort_column_id">8</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext12"/>
+                              <attributes>
+                                <attribute name="text">8</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
                           <object class="GtkTreeViewColumn" id="description">
                             <property name="fixed_width">10</property>
                             <property name="min_width">30</property>
                             </child>
                           </object>
                         </child>
-                        <child>
-                          <object class="GtkTreeViewColumn" id="urgency">
-                            <property name="title" translatable="yes">Urgency</property>
-                            <property name="sort_column_id">5</property>
-                            <child>
-                              <object class="GtkCellRendererText" id="cellrenderertext9"/>
-                              <attributes>
-                                <attribute name="text">5</attribute>
-                              </attributes>
-                            </child>
-                          </object>
-                        </child>
                       </object>
                     </child>
                   </object>
index 34ae92e..2e017fc 100644 (file)
  */
 #include <stdlib.h>
 
-#include "ptime.h"
+#include <log.h>
+#include <ptime.h>
 
-char *time_to_str(time_t *t)
+static char *time_to_str(time_t *t)
 {
        struct tm lt;
        char *str;
@@ -45,3 +46,18 @@ char *get_time_str()
        t = time(NULL);
        return time_to_str(&t);
 }
+
+char *tm_to_str(const struct tm *tm)
+{
+       char *str;
+       size_t s;
+
+       str = malloc(11);
+       s = strftime(str, 11, "%Y/%m/%d", tm);
+
+       if (s)
+               return str;
+
+       log_err("Failed to convert time");
+       return NULL;
+}
index aac8c52..54320a4 100644 (file)
@@ -22,6 +22,6 @@
 #include <time.h>
 
 char *get_time_str();
-char *time_to_str(time_t *t);
+char *tm_to_str(const struct tm *);
 
 #endif
index e48ab59..abc9808 100644 (file)
--- a/src/tw.c
+++ b/src/tw.c
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA
  */
+#define _GNU_SOURCE
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <time.h>
 
 #include <json/json.h>
 
 #include <pstr.h>
 #include "tw.h"
 
+struct tm *parse_time(const char *t)
+{
+       struct tm *tm;
+
+       tm = malloc(sizeof(struct tm));
+       memset(tm, 0, sizeof(struct tm));
+       strptime(t, "%Y%m%dT%H%M%S%Z", tm);
+
+       return tm;
+}
+
 static char *task_exec(char *opts)
 {
        FILE *f;
@@ -206,6 +219,23 @@ struct task **tw_get_all_tasks(const char *status)
                        tasks[i]->urgency = NULL;
 
                tasks[i]->note = note_get(tasks[i]->uuid);
+
+               json = json_object_object_get(jtask, "entry");
+               tasks[i]->entry = parse_time(json_object_get_string(json));
+
+               json = json_object_object_get(jtask, "due");
+               if (json)
+                       tasks[i]->due
+                               = parse_time(json_object_get_string(json));
+               else
+                       tasks[i]->due = NULL;
+
+               json = json_object_object_get(jtask, "start");
+               if (json)
+                       tasks[i]->start
+                               = parse_time(json_object_get_string(json));
+               else
+                       tasks[i]->start = NULL;
        }
 
        tasks[n] = NULL;
@@ -394,6 +424,9 @@ static void task_free(struct task *task)
        free(task->project);
        free(task->priority);
        free(task->urgency);
+       free(task->entry);
+       free(task->due);
+       free(task->start);
 
        free(task);
 }
index a9af11d..6f3c177 100644 (file)
--- a/src/tw.h
+++ b/src/tw.h
@@ -29,6 +29,9 @@ struct task {
        char *project;
        char *priority;
        char *urgency;
+       struct tm *entry;
+       struct tm *due;
+       struct tm *start;
 };
 
 struct project {
index abec583..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>
@@ -34,7 +39,10 @@ enum {
        COL_PROJECT,
        COL_UUID,
        COL_PRIORITY,
-       COL_URGENCY
+       COL_URGENCY,
+       COL_CREATION_DATE,
+       COL_DUE,
+       COL_START
 };
 
 static int priority_to_int(const char *str)
@@ -231,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;
 
@@ -253,14 +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_URGENCY, (*tasks_cur)->urgency,
+                                          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);
+                       }
                }
        }