From e27cd0a70c5ed37621312b117606d8db535fc59e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Mon, 15 Oct 2012 11:30:49 +0000 Subject: [PATCH] --- config.status | 9 +- configure | 3 +- configure.ac | 1 + po/Makefile.in | 2 +- src/Makefile.am | 2 + src/Makefile.in | 227 +++++++++++++++++++++++++++++++++++++++++--------- src/glade/Makefile.am | 4 + src/glade/gtask.glade | 70 ++++++++++++++++ src/main.c | 87 +++++++++++++++++-- 9 files changed, 356 insertions(+), 49 deletions(-) create mode 100644 src/glade/Makefile.am create mode 100644 src/glade/gtask.glade diff --git a/config.status b/config.status index 6555504..c47908c 100755 --- a/config.status +++ b/config.status @@ -393,7 +393,7 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " # Files that config.status was made for. -config_files=" Makefile po/Makefile.in src/Makefile tests/Makefile" +config_files=" Makefile po/Makefile.in src/Makefile src/glade/Makefile tests/Makefile" config_commands=" depfiles po-directories" ac_cs_usage="\ @@ -422,7 +422,7 @@ $config_commands Report bugs to . gtask home page: ." -ac_cs_config="" +ac_cs_config="'--prefix=/tmp/p'" ac_cs_version="\ gtask config.status 0.0.x configured by ./configure, generated by GNU Autoconf 2.69, @@ -503,7 +503,7 @@ if $ac_cs_silent; then fi if $ac_cs_recheck; then - set X /bin/bash './configure' $ac_configure_extra_args --no-create --no-recursion + set X /bin/bash './configure' '--prefix=/tmp/p' $ac_configure_extra_args --no-create --no-recursion shift $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 CONFIG_SHELL='/bin/bash' @@ -542,6 +542,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/glade/Makefile") CONFIG_FILES="$CONFIG_FILES src/glade/Makefile" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; @@ -729,7 +730,7 @@ S["libexecdir"]="${exec_prefix}/libexec" S["sbindir"]="${exec_prefix}/sbin" S["bindir"]="${exec_prefix}/bin" S["program_transform_name"]="s,x,x," -S["prefix"]="/usr/local" +S["prefix"]="/tmp/p" S["exec_prefix"]="${prefix}" S["PACKAGE_URL"]="http://wpitchoune.net/gtask" S["PACKAGE_BUGREPORT"]="jeanfi@gmail.com" diff --git a/configure b/configure index d840445..52614bb 100755 --- a/configure +++ b/configure @@ -6679,7 +6679,7 @@ fi -ac_config_files="$ac_config_files Makefile po/Makefile.in src/Makefile tests/Makefile" +ac_config_files="$ac_config_files Makefile po/Makefile.in src/Makefile src/glade/Makefile tests/Makefile" for ac_prog in help2man @@ -7525,6 +7525,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/glade/Makefile") CONFIG_FILES="$CONFIG_FILES src/glade/Makefile" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index 526dca9..8883d10 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,7 @@ AC_CONFIG_FILES([ Makefile po/Makefile.in src/Makefile + src/glade/Makefile tests/Makefile ]) diff --git a/po/Makefile.in b/po/Makefile.in index ae9ec24..b93dffa 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr/local +prefix = /tmp/p exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/Makefile.am b/src/Makefile.am index 3e95660..ef9af98 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS=glade + AM_LDFLAGS = -Wl,--as-needed AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) $(JSON_CFLAGS) diff --git a/src/Makefile.in b/src/Makefile.in index 6e75508..a7e8de7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -76,14 +76,52 @@ CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(gtask_SOURCES) DIST_SOURCES = $(gtask_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir ETAGS = etags CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ @@ -209,10 +247,11 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +SUBDIRS = glade AM_LDFLAGS = -Wl,--as-needed AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) $(JSON_CFLAGS) gtask_SOURCES = main.c -all: all-am +all: all-recursive .SUFFIXES: .SUFFIXES: .c .o .obj @@ -312,6 +351,76 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -322,10 +431,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) mkid -fID $$unique tags: TAGS -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ @@ -344,7 +466,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ fi; \ fi ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ @@ -394,22 +516,48 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done check-am: all-am -check: check-am +check: check-recursive all-am: Makefile $(PROGRAMS) -installdirs: +installdirs: installdirs-recursive +installdirs-am: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ @@ -431,89 +579,92 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -clean: clean-am +clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic mostlyclean-am -distclean: distclean-am +distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive html-am: -info: info-am +info: info-recursive info-am: install-data-am: -install-dvi: install-dvi-am +install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS -install-html: install-html-am +install-html: install-html-recursive install-html-am: -install-info: install-info-am +install-info: install-info-recursive install-info-am: install-man: -install-pdf: install-pdf-am +install-pdf: install-pdf-recursive install-pdf-am: -install-ps: install-ps-am +install-ps: install-ps-recursive install-ps-am: installcheck-am: -maintainer-clean: maintainer-clean-am +maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS #dist_man_MANS = gtask.1 diff --git a/src/glade/Makefile.am b/src/glade/Makefile.am new file mode 100644 index 0000000..2bf16eb --- /dev/null +++ b/src/glade/Makefile.am @@ -0,0 +1,4 @@ +gladedir = $(pkgdatadir) +glade_DATA = gtask.glade + +EXTRA_DIST = $(glade_DATA) diff --git a/src/glade/gtask.glade b/src/glade/gtask.glade new file mode 100644 index 0000000..7d38739 --- /dev/null +++ b/src/glade/gtask.glade @@ -0,0 +1,70 @@ + + + + + + + + + + + + + False + gtask + 640 + 480 + + + True + True + in + + + True + True + True + liststore1 + False + treeviewcolumn1 + 0 + both + True + 1 + + + + + + autosize + 10 + Id + + + + 0 + + + + + + + autosize + 10 + 30 + Description + True + + + + 1 + + + + + + + + + + diff --git a/src/main.c b/src/main.c index ac310b7..c0456c7 100644 --- a/src/main.c +++ b/src/main.c @@ -22,6 +22,14 @@ #include +#include + +struct task { + int id; + char *description; + char *status; +}; + static char *task_exec(char *opts) { FILE *f; @@ -69,25 +77,94 @@ static struct json_object *task_exec_json(char *opts) { struct json_object *o; char *str; - + str = task_exec(opts); if (str) { o = json_tokener_parse(str); free(str); return o; - } + } return NULL; } +static struct task **get_all_tasks() +{ + int i, n; + struct json_object *jtasks, *jtask, *json; + struct task **tasks; + + jtasks = task_exec_json("export"); + + if (!jtasks) + return NULL; + + n = json_object_array_length(jtasks); + + tasks = malloc((n + 1) * sizeof(struct task *)); + + for (i = 0; i < n; i++) { + jtask = json_object_array_get_idx(jtasks, i); + + tasks[i] = malloc(sizeof(struct task)); + + json = json_object_object_get(jtask, "id"); + tasks[i]->id = json_object_get_int(json); + + json = json_object_object_get(jtask, "description"); + tasks[i]->description = strdup(json_object_get_string(json)); + + json = json_object_object_get(jtask, "status"); + tasks[i]->status = strdup(json_object_get_string(json)); + } + + tasks[n] = NULL; + + json_object_put(jtasks); + + return tasks; +} + int main(int argc, char **argv) { - struct json_object *o; + GtkWidget *window; + GtkWidget *treeview; + GtkBuilder *builder; + GtkTreeIter iter; + int i; + GtkTreeModel *model; + struct task **tasks, **tasks_cur; + + gtk_init(NULL, NULL); + builder = gtk_builder_new(); + gtk_builder_add_from_file + (builder, + PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "gtask.glade", + NULL); + window = GTK_WIDGET(gtk_builder_get_object(builder, "window")); + printf("%p\n", window); + + treeview = GTK_WIDGET(gtk_builder_get_object(builder, "treeview")); + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)); + + tasks = get_all_tasks(); + + for (tasks_cur = tasks, i = 0; *tasks_cur; tasks_cur++, i++) { + gtk_list_store_append(GTK_LIST_STORE(model), &iter); + gtk_list_store_set(GTK_LIST_STORE(model), + &iter, + 0, (*tasks_cur)->id, + 1, (*tasks_cur)->description, + -1); + } + + g_object_unref(G_OBJECT(builder)); - o = task_exec_json("export"); + gtk_widget_show_all(window); - printf("%s\n", json_object_to_json_string(o)); + gtk_main(); exit(EXIT_SUCCESS); } -- 2.7.4