worked on task tree panel
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 30 Nov 2013 10:44:24 +0000 (10:44 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 30 Nov 2013 10:44:24 +0000 (10:44 +0000)
refactoring
better logging

config.status
configure
po/Makefile
po/Makefile.in
src/Makefile.in
src/main.c
src/tw.c
src/ui_projecttree.c
src/ui_taskpanel.c [new file with mode: 0644]
src/ui_taskpanel.h [new file with mode: 0644]

index 8bb3d59..b2f5d6f 100755 (executable)
@@ -428,7 +428,7 @@ $config_commands
 Report bugs to <jeanfi@gmail.com>.
 ptask home page: <http://wpitchoune.net/ptask>."
 
-ac_cs_config="'CFLAGS=-O1' '--prefix=/tmp'"
+ac_cs_config="'--prefix=/tmp'"
 ac_cs_version="\
 ptask config.status 0.0.x
 configured by ./configure, generated by GNU Autoconf 2.69,
@@ -438,7 +438,7 @@ Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
-ac_pwd='/home/jporsini/work/wpitchoune/svnpub/ptask/trunk'
+ac_pwd='/home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk'
 srcdir='.'
 INSTALL='/usr/bin/install -c'
 MKDIR_P='/bin/mkdir -p'
@@ -520,7 +520,7 @@ if $ac_cs_silent; then
 fi
 
 if $ac_cs_recheck; then
-  set X /bin/bash './configure'  'CFLAGS=-O1' '--prefix=/tmp' $ac_configure_extra_args --no-create --no-recursion
+  set X /bin/bash './configure'  '--prefix=/tmp' $ac_configure_extra_args --no-create --no-recursion
   shift
   $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
   CONFIG_SHELL='/bin/bash'
@@ -723,7 +723,7 @@ S["GMSGFMT"]="/usr/bin/msgfmt"
 S["MSGFMT"]="/usr/bin/msgfmt"
 S["GETTEXT_MACRO_VERSION"]="0.18"
 S["USE_NLS"]="yes"
-S["CPP"]="gcc -E"
+S["CPP"]="gcc -std=gnu99 -E"
 S["XMKMF"]=""
 S["am__fastdepCC_FALSE"]="#"
 S["am__fastdepCC_TRUE"]=""
@@ -740,8 +740,8 @@ S["EXEEXT"]=""
 S["ac_ct_CC"]="gcc"
 S["CPPFLAGS"]=""
 S["LDFLAGS"]=""
-S["CFLAGS"]="-O1"
-S["CC"]="gcc"
+S["CFLAGS"]="-g -O2"
+S["CC"]="gcc -std=gnu99"
 S["am__untar"]="$${TAR-tar} xf -"
 S["am__tar"]="$${TAR-tar} chof - \"$$tardir\""
 S["AMTAR"]="$${TAR-tar}"
@@ -752,12 +752,12 @@ S["mkdir_p"]="/bin/mkdir -p"
 S["MKDIR_P"]="/bin/mkdir -p"
 S["INSTALL_STRIP_PROGRAM"]="$(install_sh) -c -s"
 S["STRIP"]=""
-S["install_sh"]="${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh"
-S["MAKEINFO"]="${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/missing --run makeinfo"
-S["AUTOHEADER"]="${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/missing --run autoheader"
-S["AUTOMAKE"]="${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/missing --run automake-1.11"
-S["AUTOCONF"]="${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/missing --run autoconf"
-S["ACLOCAL"]="${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/missing --run aclocal-1.11"
+S["install_sh"]="${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh"
+S["MAKEINFO"]="${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/missing --run makeinfo"
+S["AUTOHEADER"]="${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/missing --run autoheader"
+S["AUTOMAKE"]="${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/missing --run automake-1.11"
+S["AUTOCONF"]="${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/missing --run autoconf"
+S["ACLOCAL"]="${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/missing --run aclocal-1.11"
 S["VERSION"]="0.0.x"
 S["PACKAGE"]="ptask"
 S["CYGPATH_W"]="echo"
index d78267b..4732d12 100755 (executable)
--- a/configure
+++ b/configure
@@ -3503,6 +3503,183 @@ else
 fi
 
 
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
+$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
+if ${ac_cv_prog_cc_c99+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <stdio.h>
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+#define debug(...) fprintf (stderr, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  your preprocessor is broken;
+#endif
+#if BIG_OK
+#else
+  your preprocessor is broken;
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static void
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str;
+  int number;
+  float fnumber;
+
+  while (*format)
+    {
+      switch (*format++)
+       {
+       case 's': // string
+         str = va_arg (args_copy, const char *);
+         break;
+       case 'd': // int
+         number = va_arg (args_copy, int);
+         break;
+       case 'f': // float
+         fnumber = va_arg (args_copy, double);
+         break;
+       default:
+         break;
+       }
+    }
+  va_end (args_copy);
+  va_end (args);
+}
+
+int
+main ()
+{
+
+  // Check bool.
+  _Bool success = false;
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  test_varargs ("s, d' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
+         || dynamic_array[ni.number - 1] != 543);
+
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c99" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c99"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c99" != xno; then :
+
+fi
+
+
 if test "x$CC" != xcc; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
index 980102b..db8c0d8 100644 (file)
@@ -34,12 +34,12 @@ INSTALL_DATA = ${INSTALL} -m 644
 # We use $(mkdir_p).
 # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
 # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
-# ${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh does not start with $(SHELL), so we add it.
+# ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh does not start with $(SHELL), so we add it.
 # In automake >= 1.10, /bin/mkdir -p is derived from ${MKDIR_P}, which is defined
 # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
 # versions, $(mkinstalldirs) and $(install_sh) are unused.
-mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh -d
-install_sh = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh
+mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh -d
+install_sh = $(SHELL) ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh
 MKDIR_P = /bin/mkdir -p
 mkdir_p = /bin/mkdir -p
 
index ca508b4..13ef718 100644 (file)
@@ -34,12 +34,12 @@ INSTALL_DATA = ${INSTALL} -m 644
 # We use $(mkdir_p).
 # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
 # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
-# ${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh does not start with $(SHELL), so we add it.
+# ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh does not start with $(SHELL), so we add it.
 # In automake >= 1.10, /bin/mkdir -p is derived from ${MKDIR_P}, which is defined
 # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
 # versions, $(mkinstalldirs) and $(install_sh) are unused.
-mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh -d
-install_sh = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune/svnpub/ptask/trunk/install-sh
+mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh -d
+install_sh = $(SHELL) ${SHELL} /home/jporsini/work.local/wpitchoune/svnpub/ptask/trunk/install-sh
 MKDIR_P = /bin/mkdir -p
 mkdir_p = /bin/mkdir -p
 
index 9b551e6..2187dfa 100644 (file)
@@ -68,7 +68,8 @@ PROGRAMS = $(bin_PROGRAMS)
 am_ptask_OBJECTS = list.$(OBJEXT) log.$(OBJEXT) main.$(OBJEXT) \
        note.$(OBJEXT) pstr.$(OBJEXT) ptime.$(OBJEXT) tw.$(OBJEXT) \
        ui.$(OBJEXT) ui_newtask_diag.$(OBJEXT) \
-       ui_projecttree.$(OBJEXT) ui_tasktree.$(OBJEXT)
+       ui_projecttree.$(OBJEXT) ui_taskpanel.$(OBJEXT) \
+       ui_tasktree.$(OBJEXT)
 ptask_OBJECTS = $(am_ptask_OBJECTS)
 ptask_LDADD = $(LDADD)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -300,6 +301,7 @@ ptask_SOURCES = list.c list.h \
        ui.c ui.h \
        ui_newtask_diag.c ui_newtask_diag.h \
        ui_projecttree.c ui_projecttree.h \
+       ui_taskpanel.c ui_taskpanel.h \
        ui_tasktree.c ui_tasktree.h
 
 dist_man_MANS = ptask.1
@@ -399,6 +401,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_newtask_diag.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_projecttree.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_taskpanel.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_tasktree.Po@am__quote@
 
 .c.o:
index 35b1e4b..4a126d8 100644 (file)
@@ -33,6 +33,7 @@
 #include "tw.h"
 #include <ui.h>
 #include <ui_projecttree.h>
+#include <ui_taskpanel.h>
 #include <ui_tasktree.h>
 
 static const char *program_name;
@@ -161,7 +162,7 @@ void refresh()
        int status;
        const char *project;
 
-       log_debug("refresh");
+       log_fct_enter();
        clear_task_panel();
 
        status = gtk_combo_box_get_active(w_status);
@@ -217,7 +218,7 @@ void refresh()
                gtk_dialog_run(GTK_DIALOG(dialog));
                gtk_widget_destroy(dialog);
        }
-       log_debug("refresh done");
+       log_fct(__func__, "EXIT");
 }
 
 int taskdone_clicked_cbk(GtkButton *btn, gpointer data)
@@ -440,6 +441,7 @@ int main(int argc, char **argv)
                 NULL);
        window = create_window(builder, settings);
 
+       ui_taskpanel_init(builder);
        ui_tasktree_init(builder);
        ui_projecttree_init(builder);
 
index 3e5e55b..01695d5 100644 (file)
--- a/src/tw.c
+++ b/src/tw.c
@@ -426,10 +426,11 @@ struct project **tw_get_projects(struct task **tasks)
        struct project **prjs, **tmp, *prj;
        const char *prj_name;
 
-       log_debug("tw_get_projects()");
+       log_fct_enter();
 
-       prjs = malloc(sizeof(struct project *));
-       *prjs = NULL;
+       prjs = malloc(2 * sizeof(struct project *));
+       prjs[0] = project_new("ALL", 0);
+       prjs[1] = NULL;
 
        for (t_cur = tasks; *t_cur; t_cur++) {
                prj_name = (*t_cur)->project;
@@ -444,7 +445,10 @@ struct project **tw_get_projects(struct task **tasks)
                        free(prjs);
                        prjs = tmp;
                }
+               prjs[0]->count++;
        }
 
+       log_fct_exit();
+
        return prjs;
 }
index a17df32..32e8a3b 100644 (file)
@@ -42,8 +42,9 @@ const char *ui_projecttree_get_project()
        GtkTreeIter iter;
        GtkTreeModel *model;
        GValue value = {0,};
-
-       log_debug("get_selected_project()");
+       const char *prj;
+                                               
+       log_fct_enter();
 
        gtk_tree_view_get_cursor(w_treeview, &path, &cols);
 
@@ -52,10 +53,14 @@ const char *ui_projecttree_get_project()
                gtk_tree_model_get_iter(model, &iter, path);
                gtk_tree_model_get_value(model, &iter, COL_NAME, &value);
 
-               return g_value_get_string(&value);
+               prj = g_value_get_string(&value);
+       } else {
+               prj = NULL;
        }
 
-       return NULL;
+       log_fct_exit();
+
+       return prj;
 }
 
 
@@ -65,7 +70,7 @@ void ui_projecttree_update(struct task **ts)
        GtkTreeModel *model;
        GtkTreeIter iter;
 
-       log_debug("ui_projecttree_update()");
+       log_fct_enter();
 
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
        gtk_list_store_clear(GTK_LIST_STORE(model));
@@ -82,5 +87,7 @@ void ui_projecttree_update(struct task **ts)
        }
 
        tw_project_list_free(prjs);
+
+       log_fct_exit();
 }
 
diff --git a/src/ui_taskpanel.c b/src/ui_taskpanel.c
new file mode 100644 (file)
index 0000000..b3389ba
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2012-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 <log.h>
+#include <ui_taskpanel.h>
+
+void ui_taskpanel_init(GtkBuilder *builder)
+{
+       log_fct(__func__, "ENTER");
+       log_fct(__func__, "EXIT");
+}
diff --git a/src/ui_taskpanel.h b/src/ui_taskpanel.h
new file mode 100644 (file)
index 0000000..1e68ea1
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2012-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 _PTASK_UI_TASKPANEL_H_
+#define _PTASK_UI_TASKPANEL_H_
+
+#include <gtk/gtk.h>
+
+void ui_taskpanel_init(GtkBuilder *);
+
+#endif