From a2a8032740a38115ffdca3d7356a50196c75a6b7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Fri, 18 Apr 2014 11:47:40 +0200 Subject: [PATCH] fixed potential issue about void* arithmetic added start/stop task support --- NEWS | 5 +++ NEWS.html | 19 ++++++++++- po/fr.gmo | Bin 962 -> 962 bytes po/fr.po | 93 ++++++++++++++++++++++++++++++++++++-------------- po/ptask.pot | 92 +++++++++++++++++++++++++++++++++++-------------- src/Makefile.am | 3 +- src/Makefile.in | 8 ++--- src/glade/ptask.glade | 39 +++++++++++++++++++++ src/list.c | 57 ------------------------------- src/list.h | 26 -------------- src/tw.c | 70 +++++++++++++++++++++++++++++++++++-- src/tw.h | 4 ++- src/ui_taskpanel.c | 2 +- src/ui_tasktree.c | 49 ++++++++++++++++++++++++++ 14 files changed, 319 insertions(+), 148 deletions(-) delete mode 100644 src/list.c delete mode 100644 src/list.h diff --git a/NEWS b/NEWS index a52764b..d8aed7b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ What's New ========== +v0.0.6 +------ + * added contextal menu item in the task tree: task done. + * added start/stop task. + v0.0.5 ------ diff --git a/NEWS.html b/NEWS.html index 8e363b9..8b68f68 100644 --- a/NEWS.html +++ b/NEWS.html @@ -320,6 +320,23 @@ asciidoc.install();
+

v0.0.6

+
+
    +
  • +

    +added contextal menu item in the task tree: task done. +

    +
  • +
  • +

    +added start/stop task. +

    +
  • +
+
+
+

v0.0.5

    @@ -524,7 +541,7 @@ Initial release.

    diff --git a/po/fr.gmo b/po/fr.gmo index 0ed88e700ff0832560210c286e24db33bf3043d9..d3fddc8344e0f94c89e3485ff975bb840d67ab71 100644 GIT binary patch delta 26 hcmX@aeu#a8FcYtduAzm3p`n$bv9^KHW(B52i~w8n22=n5 delta 26 hcmX@aeu#a8FcYt#uA#YtfrXW+nYMx9W(B52i~w9R23!CD diff --git a/po/fr.po b/po/fr.po index 40ef5fe..999d3e9 100644 --- a/po/fr.po +++ b/po/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptask\n" "Report-Msgid-Bugs-To: jeanfi@gmail.com\n" -"POT-Creation-Date: 2014-01-17 08:56+0100\n" +"POT-Creation-Date: 2014-04-18 11:13+0200\n" "PO-Revision-Date: 2012-05-13 18:15+0000\n" "Last-Translator: jeanfi \n" "Language-Team: French <>\n" @@ -78,99 +78,140 @@ msgstr "" msgid "Try `%s --help' for more information.\n" msgstr "" -#: src/glade/ptask.glade:88 +#: src/glade/ptask.glade:11 +#, fuzzy +msgid "Done" +msgstr "Marquer fait" + +#: src/glade/ptask.glade:27 +msgid "Start" +msgstr "" + +#: src/glade/ptask.glade:34 +msgid "Stop" +msgstr "" + +#: src/glade/ptask.glade:100 msgid "Notes directory: " msgstr "" -#: src/glade/ptask.glade:104 +#: src/glade/ptask.glade:116 msgid "Select a directory" msgstr "" -#: src/glade/ptask.glade:130 +#: src/glade/ptask.glade:142 msgid "New Task" msgstr "Nouvelle Tache" -#: src/glade/ptask.glade:189 src/glade/ptask.glade:877 +#: src/glade/ptask.glade:201 src/glade/ptask.glade:916 msgid "Description:" msgstr "Description:" -#: src/glade/ptask.glade:224 src/glade/ptask.glade:955 +#: src/glade/ptask.glade:236 src/glade/ptask.glade:994 msgid "Project:" msgstr "Projet:" -#: src/glade/ptask.glade:259 src/glade/ptask.glade:989 +#: src/glade/ptask.glade:271 src/glade/ptask.glade:1028 msgid "Priority:" msgstr "Priorite:" -#: src/glade/ptask.glade:382 src/glade/ptask.glade:828 +#: src/glade/ptask.glade:325 +msgid "None" +msgstr "" + +#: src/glade/ptask.glade:328 +msgid "Low" +msgstr "" + +#: src/glade/ptask.glade:331 +msgid "Medium" +msgstr "" + +#: src/glade/ptask.glade:334 +msgid "High" +msgstr "" + +#: src/glade/ptask.glade:353 +msgid "pending" +msgstr "" + +#: src/glade/ptask.glade:356 +msgid "completed" +msgstr "" + +#: src/glade/ptask.glade:359 +msgid "deleted" +msgstr "" + +#: src/glade/ptask.glade:421 src/glade/ptask.glade:867 msgid "Id" msgstr "" -#: src/glade/ptask.glade:392 src/glade/ptask.glade:673 -#: src/glade/ptask.glade:747 +#: src/glade/ptask.glade:431 src/glade/ptask.glade:712 +#: src/glade/ptask.glade:786 msgid "Project" msgstr "Projet" -#: src/glade/ptask.glade:402 src/glade/ptask.glade:839 +#: src/glade/ptask.glade:441 src/glade/ptask.glade:878 msgid "UUID" msgstr "" -#: src/glade/ptask.glade:412 src/glade/ptask.glade:733 +#: src/glade/ptask.glade:451 src/glade/ptask.glade:772 msgid "Priority" msgstr "Priorite" -#: src/glade/ptask.glade:422 src/glade/ptask.glade:762 +#: src/glade/ptask.glade:461 src/glade/ptask.glade:801 msgid "Urgency" msgstr "" -#: src/glade/ptask.glade:432 src/glade/ptask.glade:774 +#: src/glade/ptask.glade:471 src/glade/ptask.glade:813 msgid "Creation date" msgstr "" -#: src/glade/ptask.glade:442 src/glade/ptask.glade:786 +#: src/glade/ptask.glade:481 src/glade/ptask.glade:825 msgid "Due" msgstr "" -#: src/glade/ptask.glade:452 src/glade/ptask.glade:798 +#: src/glade/ptask.glade:491 src/glade/ptask.glade:837 msgid "Start date" msgstr "" -#: src/glade/ptask.glade:462 src/glade/ptask.glade:812 +#: src/glade/ptask.glade:501 src/glade/ptask.glade:851 msgid "Description" msgstr "Description" -#: src/glade/ptask.glade:469 src/glade/ptask.glade:489 +#: src/glade/ptask.glade:508 src/glade/ptask.glade:528 msgid "ptask" msgstr "ptask" -#: src/glade/ptask.glade:529 +#: src/glade/ptask.glade:568 msgid "_Help" msgstr "" -#: src/glade/ptask.glade:612 +#: src/glade/ptask.glade:651 msgid "Status:" msgstr "Etat:" -#: src/glade/ptask.glade:684 +#: src/glade/ptask.glade:723 msgid "Count" msgstr "" -#: src/glade/ptask.glade:895 +#: src/glade/ptask.glade:934 msgid "Note:" msgstr "Note:" -#: src/glade/ptask.glade:1029 +#: src/glade/ptask.glade:1068 msgid "Save" msgstr "Sauvegarder" -#: src/glade/ptask.glade:1043 +#: src/glade/ptask.glade:1082 msgid "Cancel" msgstr "Annuler" -#: src/glade/ptask.glade:1057 +#: src/glade/ptask.glade:1096 msgid "Mark Done" msgstr "Marquer fait" -#: src/glade/ptask.glade:1071 +#: src/glade/ptask.glade:1110 msgid "Remove" msgstr "" diff --git a/po/ptask.pot b/po/ptask.pot index 713befb..7c34fa3 100644 --- a/po/ptask.pot +++ b/po/ptask.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: jeanfi@gmail.com\n" -"POT-Creation-Date: 2014-01-17 08:56+0100\n" +"POT-Creation-Date: 2014-04-18 11:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -75,99 +75,139 @@ msgstr "" msgid "Try `%s --help' for more information.\n" msgstr "" -#: src/glade/ptask.glade:88 +#: src/glade/ptask.glade:11 +msgid "Done" +msgstr "" + +#: src/glade/ptask.glade:27 +msgid "Start" +msgstr "" + +#: src/glade/ptask.glade:34 +msgid "Stop" +msgstr "" + +#: src/glade/ptask.glade:100 msgid "Notes directory: " msgstr "" -#: src/glade/ptask.glade:104 +#: src/glade/ptask.glade:116 msgid "Select a directory" msgstr "" -#: src/glade/ptask.glade:130 +#: src/glade/ptask.glade:142 msgid "New Task" msgstr "" -#: src/glade/ptask.glade:189 src/glade/ptask.glade:877 +#: src/glade/ptask.glade:201 src/glade/ptask.glade:916 msgid "Description:" msgstr "" -#: src/glade/ptask.glade:224 src/glade/ptask.glade:955 +#: src/glade/ptask.glade:236 src/glade/ptask.glade:994 msgid "Project:" msgstr "" -#: src/glade/ptask.glade:259 src/glade/ptask.glade:989 +#: src/glade/ptask.glade:271 src/glade/ptask.glade:1028 msgid "Priority:" msgstr "" -#: src/glade/ptask.glade:382 src/glade/ptask.glade:828 +#: src/glade/ptask.glade:325 +msgid "None" +msgstr "" + +#: src/glade/ptask.glade:328 +msgid "Low" +msgstr "" + +#: src/glade/ptask.glade:331 +msgid "Medium" +msgstr "" + +#: src/glade/ptask.glade:334 +msgid "High" +msgstr "" + +#: src/glade/ptask.glade:353 +msgid "pending" +msgstr "" + +#: src/glade/ptask.glade:356 +msgid "completed" +msgstr "" + +#: src/glade/ptask.glade:359 +msgid "deleted" +msgstr "" + +#: src/glade/ptask.glade:421 src/glade/ptask.glade:867 msgid "Id" msgstr "" -#: src/glade/ptask.glade:392 src/glade/ptask.glade:673 -#: src/glade/ptask.glade:747 +#: src/glade/ptask.glade:431 src/glade/ptask.glade:712 +#: src/glade/ptask.glade:786 msgid "Project" msgstr "" -#: src/glade/ptask.glade:402 src/glade/ptask.glade:839 +#: src/glade/ptask.glade:441 src/glade/ptask.glade:878 msgid "UUID" msgstr "" -#: src/glade/ptask.glade:412 src/glade/ptask.glade:733 +#: src/glade/ptask.glade:451 src/glade/ptask.glade:772 msgid "Priority" msgstr "" -#: src/glade/ptask.glade:422 src/glade/ptask.glade:762 +#: src/glade/ptask.glade:461 src/glade/ptask.glade:801 msgid "Urgency" msgstr "" -#: src/glade/ptask.glade:432 src/glade/ptask.glade:774 +#: src/glade/ptask.glade:471 src/glade/ptask.glade:813 msgid "Creation date" msgstr "" -#: src/glade/ptask.glade:442 src/glade/ptask.glade:786 +#: src/glade/ptask.glade:481 src/glade/ptask.glade:825 msgid "Due" msgstr "" -#: src/glade/ptask.glade:452 src/glade/ptask.glade:798 +#: src/glade/ptask.glade:491 src/glade/ptask.glade:837 msgid "Start date" msgstr "" -#: src/glade/ptask.glade:462 src/glade/ptask.glade:812 +#: src/glade/ptask.glade:501 src/glade/ptask.glade:851 msgid "Description" msgstr "" -#: src/glade/ptask.glade:469 src/glade/ptask.glade:489 +#: src/glade/ptask.glade:508 src/glade/ptask.glade:528 msgid "ptask" msgstr "" -#: src/glade/ptask.glade:529 +#: src/glade/ptask.glade:568 msgid "_Help" msgstr "" -#: src/glade/ptask.glade:612 +#: src/glade/ptask.glade:651 msgid "Status:" msgstr "" -#: src/glade/ptask.glade:684 +#: src/glade/ptask.glade:723 msgid "Count" msgstr "" -#: src/glade/ptask.glade:895 +#: src/glade/ptask.glade:934 msgid "Note:" msgstr "" -#: src/glade/ptask.glade:1029 +#: src/glade/ptask.glade:1068 msgid "Save" msgstr "" -#: src/glade/ptask.glade:1043 +#: src/glade/ptask.glade:1082 msgid "Cancel" msgstr "" -#: src/glade/ptask.glade:1057 +#: src/glade/ptask.glade:1096 msgid "Mark Done" msgstr "" -#: src/glade/ptask.glade:1071 +#: src/glade/ptask.glade:1110 msgid "Remove" msgstr "" diff --git a/src/Makefile.am b/src/Makefile.am index e89e1fb..8523ed9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,8 +11,7 @@ LIBS = $(JSON_LIBS) $(GTK_LIBS) bin_PROGRAMS = ptask -ptask_SOURCES = list.c list.h \ - log.c log.h \ +ptask_SOURCES = log.c log.h \ main.c \ note.c note.h \ pio.c pio.h \ diff --git a/src/Makefile.in b/src/Makefile.in index f2427ce..c2a9adc 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -92,8 +92,8 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) -am_ptask_OBJECTS = list.$(OBJEXT) log.$(OBJEXT) main.$(OBJEXT) \ - note.$(OBJEXT) pio.$(OBJEXT) pstr.$(OBJEXT) ptime.$(OBJEXT) \ +am_ptask_OBJECTS = log.$(OBJEXT) main.$(OBJEXT) note.$(OBJEXT) \ + pio.$(OBJEXT) pstr.$(OBJEXT) ptime.$(OBJEXT) \ settings.$(OBJEXT) tw.$(OBJEXT) ui.$(OBJEXT) \ ui_newtask_diag.$(OBJEXT) ui_projecttree.$(OBJEXT) \ ui_taskpanel.$(OBJEXT) ui_tasktree.$(OBJEXT) @@ -361,8 +361,7 @@ SUBDIRS = glade # -export-dynamic is need for defining handlers in the glade file. AM_LDFLAGS = -Wl,--as-needed -export-dynamic AM_CPPFLAGS = -Wall $(GTK_CFLAGS) $(JSON_CFLAGS) -ptask_SOURCES = list.c list.h \ - log.c log.h \ +ptask_SOURCES = log.c log.h \ main.c \ note.c note.h \ pio.c pio.h \ @@ -466,7 +465,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/note.Po@am__quote@ diff --git a/src/glade/ptask.glade b/src/glade/ptask.glade index a4fc97b..984ee9b 100644 --- a/src/glade/ptask.glade +++ b/src/glade/ptask.glade @@ -7,6 +7,10 @@ + + Done + + @@ -19,9 +23,17 @@ + + Start + + + + Stop + + @@ -374,6 +386,33 @@ True False + + tasktree_start + True + False + + + + + tasktree_stop + True + False + + + + + tasktree_done + True + False + + + + + True + False + + + False tasktree_id_visible diff --git a/src/list.c b/src/list.c deleted file mode 100644 index 0b6eb5d..0000000 --- a/src/list.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2010-2013 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include -#include - -#include "list.h" - -int list_length(void **list) -{ - int n; - - if (!list) - return 0; - - n = 0; - while (*list) { - n++; - list++; - } - - return n; -} - -void **list_add(void **list, void *item) -{ - int n; - void **result; - - n = list_length(list); - - result = malloc((n + 1 + 1) * sizeof(void *)); - - if (list) - memcpy(result, list, n * sizeof(void *)); - - result[n] = item; - result[n + 1] = NULL; - - return result; -} diff --git a/src/list.h b/src/list.h deleted file mode 100644 index 39fcb29..0000000 --- a/src/list.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2010-2013 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef _P_LIST_H_ -#define _P_LIST_H_ - -int list_length(void **list); -void **list_add(void **list, void *item); - -#endif diff --git a/src/tw.c b/src/tw.c index 8c68592..df73030 100644 --- a/src/tw.c +++ b/src/tw.c @@ -26,7 +26,6 @@ #include -#include #include #include "note.h" #include @@ -382,7 +381,7 @@ void tw_add(const char *newdesc, const char *prj, const char *prio) log_fct_exit(); } -void tw_done(const char *uuid) +void tw_task_done(const char *uuid) { char *opts; @@ -397,6 +396,36 @@ void tw_done(const char *uuid) free(opts); } +void tw_task_start(const char *uuid) +{ + char *opts; + + opts = malloc(1 + + strlen(uuid) + + strlen(" start") + + 1); + sprintf(opts, " %s start", uuid); + + tw_exec(opts); + + free(opts); +} + +void tw_task_stop(const char *uuid) +{ + char *opts; + + opts = malloc(1 + + strlen(uuid) + + strlen(" stop") + + 1); + sprintf(opts, " %s stop", uuid); + + tw_exec(opts); + + free(opts); +} + void tw_task_remove(const char *uuid) { char *opts; @@ -489,6 +518,41 @@ static struct project *project_new(const char *name, int count) return prj; } +static int projects_length(struct project **list) +{ + int n; + + if (!list) + return 0; + + n = 0; + while (*list) { + n++; + list++; + } + + return n; +} + +static struct project **projects_add(struct project **list, void *item) +{ + int n; + struct project **result; + + n = projects_length(list); + + result = (struct project **)malloc + ((n + 1 + 1) * sizeof(struct project *)); + + if (list) + memcpy(result, list, n * sizeof(struct project *)); + + result[n] = item; + result[n + 1] = NULL; + + return result; +} + struct project **tw_get_projects(struct task **tasks) { struct task **t_cur; @@ -509,7 +573,7 @@ struct project **tw_get_projects(struct task **tasks) } else { prj = project_new(prj_name, 1); - tmp = (struct project **)list_add((void **)prjs, prj); + tmp = projects_add(prjs, prj); free(prjs); prjs = tmp; diff --git a/src/tw.h b/src/tw.h index 6f3c177..6790b96 100644 --- a/src/tw.h +++ b/src/tw.h @@ -43,7 +43,9 @@ struct task **tw_get_all_tasks(const char *status); void tw_modify_description(const char *uuid, const char *newdesc); void tw_modify_project(const char *uuid, const char *newproj); void tw_modify_priority(const char *uuid, const char *priority); -void tw_done(const char *uuid); +void tw_task_done(const char *uuid); +void tw_task_start(const char *uuid); +void tw_task_stop(const char *uuid); void tw_task_remove(const char *); void tw_add(const char *newdesc, const char *prj, const char *prio); void tw_task_list_free(struct task **tasks); diff --git a/src/ui_taskpanel.c b/src/ui_taskpanel.c index 6380268..5edaa54 100644 --- a/src/ui_taskpanel.c +++ b/src/ui_taskpanel.c @@ -203,7 +203,7 @@ void ui_taskpanel_update(struct task *task) int taskdone_clicked_cbk(GtkButton *btn, gpointer data) { if (current_task) { - tw_done(current_task->uuid); + tw_task_done(current_task->uuid); refresh(); } diff --git a/src/ui_tasktree.c b/src/ui_tasktree.c index 6ca61a0..506e8f9 100644 --- a/src/ui_tasktree.c +++ b/src/ui_tasktree.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -428,3 +429,51 @@ void tasktree_visible_activate_cbk(GtkAction *action, gpointer data) gtk_tree_view_column_set_visible(w_cols[id], !b); } } + +void tasktree_done_activate_cbk(GtkAction *action, gpointer data) +{ + struct task *t; + + log_fct_enter(); + + t = ui_tasktree_get_selected_task(); + + if (t) { + tw_task_done(t->uuid); + refresh(); + } + + log_fct_exit(); +} + +void tasktree_start_activate_cbk(GtkAction *action, gpointer data) +{ + struct task *t; + + log_fct_enter(); + + t = ui_tasktree_get_selected_task(); + + if (t) { + tw_task_start(t->uuid); + refresh(); + } + + log_fct_exit(); +} + +void tasktree_stop_activate_cbk(GtkAction *action, gpointer data) +{ + struct task *t; + + log_fct_enter(); + + t = ui_tasktree_get_selected_task(); + + if (t) { + tw_task_stop(t->uuid); + refresh(); + } + + log_fct_exit(); +} -- 2.7.4