diff -Nru dayfolder-1.4.1/AUTHORS dayfolder-2.0.0/AUTHORS --- dayfolder-1.4.1/AUTHORS 2012-04-06 15:22:56.000000000 +0000 +++ dayfolder-2.0.0/AUTHORS 2013-05-05 23:12:30.000000000 +0000 @@ -1 +0,0 @@ -Zach Burnham [thejambi@gmail.com] \ No newline at end of file diff -Nru dayfolder-1.4.1/Makefile.in dayfolder-2.0.0/Makefile.in --- dayfolder-1.4.1/Makefile.in 2012-06-09 14:37:27.000000000 +0000 +++ dayfolder-2.0.0/Makefile.in 2013-05-11 22:28:13.000000000 +0000 @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -64,6 +81,11 @@ 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 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -336,8 +358,11 @@ -rm -f libtool config.lt install-dayfolderdocDATA: $(dayfolderdoc_DATA) @$(NORMAL_INSTALL) - test -z "$(dayfolderdocdir)" || $(MKDIR_P) "$(DESTDIR)$(dayfolderdocdir)" @list='$(dayfolderdoc_DATA)'; test -n "$(dayfolderdocdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(dayfolderdocdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(dayfolderdocdir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -522,13 +547,10 @@ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || 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; \ @@ -614,7 +636,7 @@ *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir); chmod a+w $(distdir) + chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) diff -Nru dayfolder-1.4.1/aclocal.m4 dayfolder-2.0.0/aclocal.m4 --- dayfolder-1.4.1/aclocal.m4 2012-06-09 14:37:25.000000000 +0000 +++ dayfolder-2.0.0/aclocal.m4 2013-05-11 22:28:12.000000000 +0000 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.11.3 -*- Autoconf -*- +# generated automatically by aclocal 1.11.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, @@ -14,8 +14,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, -[m4_warning([this file was generated for autoconf 2.68. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -1338,7 +1338,14 @@ LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -1702,7 +1709,8 @@ ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else @@ -2526,17 +2534,6 @@ esac ;; -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no @@ -2653,7 +2650,7 @@ ;; # This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no @@ -3269,10 +3266,6 @@ fi ;; -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - haiku*) lt_cv_deplibs_check_method=pass_all ;; @@ -3311,7 +3304,7 @@ ;; # This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; @@ -4063,7 +4056,7 @@ ;; esac ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler @@ -4362,7 +4355,7 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) @@ -6251,9 +6244,6 @@ _LT_TAGVAR(ld_shlibs, $1)=yes ;; - gnu*) - ;; - haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes @@ -6415,7 +6405,7 @@ _LT_TAGVAR(inherit_rpath, $1)=yes ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler @@ -8804,7 +8794,7 @@ [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.3], [], +m4_if([$1], [1.11.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -8820,7 +8810,7 @@ # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.3])dnl +[AM_AUTOMAKE_VERSION([1.11.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) diff -Nru dayfolder-1.4.1/config.sub dayfolder-2.0.0/config.sub --- dayfolder-1.4.1/config.sub 2012-03-30 20:31:00.000000000 +0000 +++ dayfolder-2.0.0/config.sub 2013-05-05 23:32:15.000000000 +0000 @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. -timestamp='2012-02-10' +timestamp='2012-04-18' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -225,6 +225,12 @@ -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -1537,6 +1543,9 @@ c4x-* | tic4x-*) os=-coff ;; + hexagon-*) + os=-elf + ;; tic54x-*) os=-coff ;; diff -Nru dayfolder-1.4.1/configure dayfolder-2.0.0/configure --- dayfolder-1.4.1/configure 2012-06-09 14:37:28.000000000 +0000 +++ dayfolder-2.0.0/configure 2013-05-11 22:28:14.000000000 +0000 @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for dayfolder 1.4.1. +# Generated by GNU Autoconf 2.69 for dayfolder 2.0.0. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -134,6 +132,31 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -167,7 +190,8 @@ else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -220,21 +244,25 @@ if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -336,6 +364,14 @@ } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -457,6 +493,10 @@ chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -491,16 +531,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -512,28 +552,8 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -627,8 +647,8 @@ # Identity of this package. PACKAGE_NAME='dayfolder' PACKAGE_TARNAME='dayfolder' -PACKAGE_VERSION='1.4.1' -PACKAGE_STRING='dayfolder 1.4.1' +PACKAGE_VERSION='2.0.0' +PACKAGE_STRING='dayfolder 2.0.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1272,8 +1292,6 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1359,7 +1377,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dayfolder 1.4.1 to adapt to many kinds of systems. +\`configure' configures dayfolder 2.0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1429,7 +1447,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dayfolder 1.4.1:";; + short | recursive ) echo "Configuration of dayfolder 2.0.0:";; esac cat <<\_ACEOF @@ -1541,10 +1559,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dayfolder configure 1.4.1 -generated by GNU Autoconf 2.68 +dayfolder configure 2.0.0 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1620,7 +1638,7 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1819,8 +1837,8 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dayfolder $as_me 1.4.1, which was -generated by GNU Autoconf 2.68. Invocation command line was +It was created by dayfolder $as_me 2.0.0, which was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2239,7 +2257,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2408,7 +2426,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2448,7 +2466,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2499,7 +2517,7 @@ test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -2552,7 +2570,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2638,7 +2656,7 @@ # Define the identity of the package. PACKAGE='dayfolder' - VERSION='1.4.1' + VERSION='2.0.0' cat >>confdefs.h <<_ACEOF @@ -2741,7 +2759,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2781,7 +2799,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2834,7 +2852,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2875,7 +2893,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2933,7 +2951,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2977,7 +2995,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3423,8 +3441,7 @@ /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3889,7 +3906,7 @@ for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue + as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in @@ -3965,7 +3982,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4031,7 +4048,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4098,7 +4115,7 @@ for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue + as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in @@ -4354,7 +4371,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4398,7 +4415,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4587,7 +4604,8 @@ ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else @@ -4822,7 +4840,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4862,7 +4880,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4988,10 +5006,6 @@ fi ;; -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - haiku*) lt_cv_deplibs_check_method=pass_all ;; @@ -5030,7 +5044,7 @@ ;; # This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; @@ -5168,7 +5182,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5208,7 +5222,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5312,7 +5326,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5356,7 +5370,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5481,7 +5495,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5521,7 +5535,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5580,7 +5594,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5620,7 +5634,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6128,7 +6142,14 @@ LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -6269,7 +6290,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6309,7 +6330,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6389,7 +6410,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6429,7 +6450,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6481,7 +6502,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6521,7 +6542,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6573,7 +6594,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6613,7 +6634,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6665,7 +6686,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6705,7 +6726,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6757,7 +6778,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6797,7 +6818,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7953,7 +7974,7 @@ lt_prog_compiler_static='-non_shared' ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) @@ -10123,17 +10144,6 @@ esac ;; -gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no @@ -10250,7 +10260,7 @@ ;; # This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu) +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no @@ -11316,7 +11326,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_VALAC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11395,7 +11405,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11438,7 +11448,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11497,24 +11507,12 @@ pkg_cv_DAYFOLDER_CFLAGS="$DAYFOLDER_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 \""; } >&5 - ($PKG_CONFIG --exists --print-errors "gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 ") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_DAYFOLDER_CFLAGS=`$PKG_CONFIG --cflags "gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 " 2>/dev/null` + pkg_cv_DAYFOLDER_CFLAGS=`$PKG_CONFIG --cflags "gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -11526,24 +11524,12 @@ pkg_cv_DAYFOLDER_LIBS="$DAYFOLDER_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 \""; } >&5 - ($PKG_CONFIG --exists --print-errors "gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 ") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_DAYFOLDER_LIBS=`$PKG_CONFIG --libs "gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 " 2>/dev/null` + pkg_cv_DAYFOLDER_LIBS=`$PKG_CONFIG --libs "gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -11564,26 +11550,14 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - DAYFOLDER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 " 2>&1` + DAYFOLDER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0" 2>&1` else - DAYFOLDER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 " 2>&1` + DAYFOLDER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$DAYFOLDER_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -gtk+-3.0 ) were not met: + as_fn_error $? "Package requirements (gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0) were not met: $DAYFOLDER_PKG_ERRORS @@ -12042,16 +12016,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -12111,28 +12085,16 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -12153,8 +12115,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dayfolder $as_me 1.4.1, which was -generated by GNU Autoconf 2.68. Invocation command line was +This file was extended by dayfolder $as_me 2.0.0, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -12219,11 +12181,11 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dayfolder config.status 1.4.1 -configured by $0, generated by GNU Autoconf 2.68, +dayfolder config.status 2.0.0 +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +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." @@ -12314,7 +12276,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff -Nru dayfolder-1.4.1/configure.ac dayfolder-2.0.0/configure.ac --- dayfolder-1.4.1/configure.ac 2012-06-09 14:37:16.000000000 +0000 +++ dayfolder-2.0.0/configure.ac 2013-05-11 22:25:46.000000000 +0000 @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl Created by Anjuta application wizard. -AC_INIT(dayfolder, 1.4.1) +AC_INIT(dayfolder, 2.0.0) AC_CONFIG_HEADERS([config.h]) @@ -19,11 +19,7 @@ AM_PROG_VALAC([0.10.0]) -PKG_CHECK_MODULES(DAYFOLDER, gdk-3.0 -gtk+-3.0 -gee-1.0 -appindicator3-0.1 -[gtk+-3.0 ]) +PKG_CHECK_MODULES(DAYFOLDER, [gtk+-3.0 appindicator3-0.1 gio-2.0 gee-1.0 gdk-3.0 gtk+-3.0 glib-2.0]) AC_OUTPUT([ diff -Nru dayfolder-1.4.1/debian/README.Debian dayfolder-2.0.0/debian/README.Debian --- dayfolder-1.4.1/debian/README.Debian 2012-06-09 14:47:23.000000000 +0000 +++ dayfolder-2.0.0/debian/README.Debian 2013-05-12 01:22:29.000000000 +0000 @@ -3,4 +3,4 @@ - -- Zach Burnham Sat, 09 Jun 2012 10:47:21 -0400 + -- Zach Burnham Sat, 11 May 2013 21:22:27 -0400 diff -Nru dayfolder-1.4.1/debian/changelog dayfolder-2.0.0/debian/changelog --- dayfolder-1.4.1/debian/changelog 2012-06-09 14:50:33.000000000 +0000 +++ dayfolder-2.0.0/debian/changelog 2013-05-12 01:29:03.000000000 +0000 @@ -1,6 +1,6 @@ -dayfolder (1.4.1-1) precise; urgency=low +dayfolder (2.0.0-2) precise; urgency=low * Overview of Changes - - Add button that links to page to support DayFolder and announce DayFolderPro. + - DayFolder 2.0 release! - -- Zach Burnham Sat, 09 Jun 2012 10:47:21 -0400 + -- Zach Burnham Sat, 11 May 2013 21:22:27 -0400 diff -Nru dayfolder-1.4.1/debian/control dayfolder-2.0.0/debian/control --- dayfolder-1.4.1/debian/control 2012-06-09 14:52:54.000000000 +0000 +++ dayfolder-2.0.0/debian/control 2013-05-12 01:26:44.000000000 +0000 @@ -11,7 +11,7 @@ valac-0.16 (>= 0.16.0), cmake (>= 2.8.7) Standards-Version: 3.9.2 -Homepage: http://zburnham.co.cc/dayfolder/ +Homepage: http://burnsoftware.wordpress.com/dayfolder/ #Vcs-Git: git://git.debian.org/collab-maint/dayfolder.git #Vcs-Browser: http://git.debian.org/?p=collab-maint/dayfolder.git;a=summary @@ -19,4 +19,4 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: DayFolder to clean your desktop. - DayFolder helps you organize and clean the files on your desktop or other folders. + DayFolder helps you organize and clean the files on your desktop or other folders. \ No newline at end of file diff -Nru dayfolder-1.4.1/debian/copyright dayfolder-2.0.0/debian/copyright --- dayfolder-1.4.1/debian/copyright 2012-06-09 14:47:23.000000000 +0000 +++ dayfolder-2.0.0/debian/copyright 2013-05-12 01:22:29.000000000 +0000 @@ -14,7 +14,7 @@ # If you want to use GPL v2 or later for the /debian/* files use # the following clauses, or change it to suit. Delete these two lines Files: debian/* -Copyright: 2012 Zach Burnham +Copyright: 2013 Zach Burnham License: GPL-2+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru dayfolder-1.4.1/debian/dayfolder.desktop dayfolder-2.0.0/debian/dayfolder.desktop --- dayfolder-1.4.1/debian/dayfolder.desktop 2012-06-09 14:51:08.000000000 +0000 +++ dayfolder-2.0.0/debian/dayfolder.desktop 2012-10-28 01:06:54.000000000 +0000 @@ -1,5 +1,5 @@ [Desktop Entry] -Version=1.4.1 +Version=0.0.0 Type=Application Terminal=false Icon[en_US]=dayfolder diff -Nru dayfolder-1.4.1/debian/manpage.1.ex dayfolder-2.0.0/debian/manpage.1.ex --- dayfolder-1.4.1/debian/manpage.1.ex 2012-06-09 14:47:23.000000000 +0000 +++ dayfolder-2.0.0/debian/manpage.1.ex 2013-05-12 01:22:29.000000000 +0000 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH DAYFOLDER SECTION "June 9, 2012" +.TH DAYFOLDER SECTION "May 11, 2013" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: diff -Nru dayfolder-1.4.1/debian/manpage.sgml.ex dayfolder-2.0.0/debian/manpage.sgml.ex --- dayfolder-1.4.1/debian/manpage.sgml.ex 2012-06-09 14:47:23.000000000 +0000 +++ dayfolder-2.0.0/debian/manpage.sgml.ex 2013-05-12 01:22:29.000000000 +0000 @@ -20,7 +20,7 @@ FIRSTNAME"> SURNAME"> - June 9, 2012"> + May 11, 2013"> SECTION"> diff -Nru dayfolder-1.4.1/depcomp dayfolder-2.0.0/depcomp --- dayfolder-1.4.1/depcomp 2012-04-02 17:37:09.000000000 +0000 +++ dayfolder-2.0.0/depcomp 2013-05-05 23:32:15.000000000 +0000 @@ -1,10 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2011-12-04.11; # UTC +scriptversion=2012-03-27.16; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, -# 2011 Free Software Foundation, Inc. +# 2011, 2012 Free Software Foundation, Inc. # 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 @@ -28,7 +28,7 @@ case $1 in '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) @@ -40,8 +40,8 @@ Environment variables: depmode Dependency tracking mode. - source Source file read by `PROGRAMS ARGS'. - object Object file output by `PROGRAMS ARGS'. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. @@ -57,6 +57,12 @@ ;; esac +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' + if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 @@ -102,6 +108,12 @@ depmode=msvc7 fi +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what @@ -156,15 +168,14 @@ ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the `deleted header file' problem. +## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. - tr ' ' ' -' < "$tmpdepfile" | -## Some versions of gcc put a space before the `:'. On the theory + tr ' ' "$nl" < "$tmpdepfile" | +## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. @@ -203,18 +214,15 @@ # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like `#:fec' to the end of the + # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. - tr ' ' ' -' < "$tmpdepfile" \ + tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr ' -' ' ' >> "$depfile" + tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. - tr ' ' ' -' < "$tmpdepfile" \ + tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else @@ -226,10 +234,17 @@ rm -f "$tmpdepfile" ;; +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts `$object:' at the + # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` @@ -259,12 +274,11 @@ test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then - # Each line is of the form `foo.o: dependent.h'. + # Each line is of the form 'foo.o: dependent.h'. # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. + # '$object: dependent.h' and one to simply 'dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile @@ -275,23 +289,26 @@ ;; icc) - # Intel's C compiler understands `-MD -MF file'. However on - # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. + # However on + # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h - # which is wrong. We want: + # which is wrong. We want # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using \ : + # and will wrap long lines using '\': # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... - + # tcc 0.9.26 (FIXME still under development at the moment of writing) + # will emit a similar output, but also prepend the continuation lines + # with horizontal tabulation characters. "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : @@ -300,15 +317,21 @@ exit $stat fi rm -f "$depfile" - # Each line is of the form `foo.o: dependent.h', - # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Each line is of the form 'foo.o: dependent.h', + # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. # Do two passes, one to just change these to - # `$object: dependent.h' and one to simply `dependent.h:'. - sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | - sed -e 's/$/ :/' >> "$depfile" + # '$object: dependent.h' and one to simply 'dependent.h:'. + sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ + < "$tmpdepfile" > "$depfile" + sed ' + s/[ '"$tab"'][ '"$tab"']*/ /g + s/^ *// + s/ *\\*$// + s/^[^:]*: *// + /^$/d + /:$/d + s/$/ :/ + ' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; @@ -344,7 +367,7 @@ done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add `dependent.h:' lines. + # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// @@ -359,9 +382,9 @@ tru64) # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in `foo.d' instead, so we check for that too. + # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= @@ -407,8 +430,7 @@ done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - # That's a tab and a space in the []. - sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi @@ -443,11 +465,11 @@ p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g -s/\(.*\)/ \1 \\/p +s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { - s/.*/ / + s/.*/'"$tab"'/ G p }' >> "$depfile" @@ -478,7 +500,7 @@ shift fi - # Remove `-o $object'. + # Remove '-o $object'. IFS=" " for arg do @@ -498,15 +520,14 @@ done test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for `:' + # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: - # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | - sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" - tr ' ' ' -' < "$tmpdepfile" | \ + tr ' ' "$nl" < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" @@ -562,8 +583,7 @@ # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' ' -' | \ + sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" @@ -583,7 +603,7 @@ shift fi - # Remove `-o $object'. + # Remove '-o $object'. IFS=" " for arg do @@ -652,8 +672,8 @@ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" - echo " " >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; diff -Nru dayfolder-1.4.1/ltmain.sh dayfolder-2.0.0/ltmain.sh --- dayfolder-1.4.1/ltmain.sh 2012-05-20 17:32:51.000000000 +0000 +++ dayfolder-2.0.0/ltmain.sh 2013-05-05 23:32:11.000000000 +0000 @@ -70,7 +70,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.2ubuntu1 # automake: $automake_version # autoconf: $autoconf_version # @@ -80,7 +80,7 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1ubuntu1" +VERSION="2.4.2 Debian-2.4.2-1.2ubuntu1" TIMESTAMP="" package_revision=1.3337 diff -Nru dayfolder-1.4.1/src/DayFolderClass.c dayfolder-2.0.0/src/DayFolderClass.c --- dayfolder-1.4.1/src/DayFolderClass.c 2012-05-20 17:33:24.000000000 +0000 +++ dayfolder-2.0.0/src/DayFolderClass.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,244 +0,0 @@ -/* DayFolderClass.c generated by valac 0.14.2, the Vala compiler - * generated from DayFolderClass.vala, do not modify */ - -/***** Testing methods *****/ - -#include -#include -#include -#include -#include -#include - - -#define DAYFOLDER_TYPE_DAY_FOLDER (dayfolder_day_folder_get_type ()) -#define DAYFOLDER_DAY_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DAY_FOLDER, dayfolderDayFolder)) -#define DAYFOLDER_DAY_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_DAY_FOLDER, dayfolderDayFolderClass)) -#define DAYFOLDER_IS_DAY_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DAY_FOLDER)) -#define DAYFOLDER_IS_DAY_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_DAY_FOLDER)) -#define DAYFOLDER_DAY_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_DAY_FOLDER, dayfolderDayFolderClass)) - -typedef struct _dayfolderDayFolder dayfolderDayFolder; -typedef struct _dayfolderDayFolderClass dayfolderDayFolderClass; -typedef struct _dayfolderDayFolderPrivate dayfolderDayFolderPrivate; -#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) -#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) -#define _g_free0(var) (var = (g_free (var), NULL)) - -struct _dayfolderDayFolder { - GObject parent_instance; - dayfolderDayFolderPrivate * priv; -}; - -struct _dayfolderDayFolderClass { - GObjectClass parent_class; -}; - - -static gpointer dayfolder_day_folder_parent_class = NULL; - -GType dayfolder_day_folder_get_type (void) G_GNUC_CONST; -enum { - DAYFOLDER_DAY_FOLDER_DUMMY_PROPERTY -}; -dayfolderDayFolder* dayfolder_day_folder_new (void); -dayfolderDayFolder* dayfolder_day_folder_construct (GType object_type); -void dayfolder_user_data_initializeUserData (void); -void dayfolder_day_folder_run (dayfolderDayFolder* self); -static void dayfolder_day_folder_createTodaysFolder (dayfolderDayFolder* self); -static void dayfolder_day_folder_cleanDesktop (dayfolderDayFolder* self); -const gchar* dayfolder_user_data_get_dayFolderDirPath (void); -const gchar* dayfolder_user_data_get_sourcePath (void); -static void dayfolder_day_folder_processFile (dayfolderDayFolder* self, GFileInfo* file); -void zystem_zystem_println (const gchar* s); -gboolean dayfolder_user_data_ruleExistsForFileExt (const gchar* ext); -gchar* dayfolder_file_utility_getFileExtension (GFileInfo* file); -void dayfolder_user_data_runFileExtRule (GFileInfo* file); -void dayfolder_file_utility_moveFile (GFileInfo* file, const gchar* destDir, gboolean isFileExtRule); -static void dayfolder_day_folder_createRules (dayfolderDayFolder* self); - - -/** - * Constructor. - */ -dayfolderDayFolder* dayfolder_day_folder_construct (GType object_type) { - dayfolderDayFolder * self = NULL; - self = (dayfolderDayFolder*) g_object_new (object_type, NULL); - dayfolder_user_data_initializeUserData (); - return self; -} - - -dayfolderDayFolder* dayfolder_day_folder_new (void) { - return dayfolder_day_folder_construct (DAYFOLDER_TYPE_DAY_FOLDER); -} - - -/** - * Make sure that today's folder is created, then clean the desktop. - */ -void dayfolder_day_folder_run (dayfolderDayFolder* self) { - g_return_if_fail (self != NULL); - dayfolder_day_folder_createTodaysFolder (self); - dayfolder_day_folder_cleanDesktop (self); -} - - -/** - * Create today's folder in the DayFolder directory. - */ -static void dayfolder_day_folder_createTodaysFolder (dayfolderDayFolder* self) { - const gchar* _tmp0_; - const gchar* _tmp1_; - g_return_if_fail (self != NULL); - _tmp0_ = dayfolder_user_data_get_dayFolderDirPath (); - _tmp1_ = _tmp0_; - g_mkdir_with_parents (_tmp1_, 0775); -} - - -/** - * Clean the desktop! - */ -static void dayfolder_day_folder_cleanDesktop (dayfolderDayFolder* self) { - GError * _inner_error_ = NULL; - g_return_if_fail (self != NULL); - { - const gchar* _tmp0_; - const gchar* _tmp1_; - GFile* _tmp2_ = NULL; - GFile* desktop; - GFile* _tmp3_; - GFileEnumerator* _tmp4_ = NULL; - GFileEnumerator* enumerator; - GFileInfo* fileInfo = NULL; - _tmp0_ = dayfolder_user_data_get_sourcePath (); - _tmp1_ = _tmp0_; - _tmp2_ = g_file_new_for_path (_tmp1_); - desktop = _tmp2_; - _tmp3_ = desktop; - _tmp4_ = g_file_enumerate_children (_tmp3_, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &_inner_error_); - enumerator = _tmp4_; - if (_inner_error_ != NULL) { - _g_object_unref0 (desktop); - goto __catch2_g_error; - } - while (TRUE) { - GFileEnumerator* _tmp5_; - GFileInfo* _tmp6_ = NULL; - GFileInfo* _tmp7_; - GFileInfo* _tmp8_; - GFileInfo* _tmp9_; - _tmp5_ = enumerator; - _tmp6_ = g_file_enumerator_next_file (_tmp5_, NULL, &_inner_error_); - _tmp7_ = _tmp6_; - if (_inner_error_ != NULL) { - _g_object_unref0 (fileInfo); - _g_object_unref0 (enumerator); - _g_object_unref0 (desktop); - goto __catch2_g_error; - } - _g_object_unref0 (fileInfo); - fileInfo = _tmp7_; - _tmp8_ = fileInfo; - if (!(_tmp8_ != NULL)) { - break; - } - _tmp9_ = fileInfo; - dayfolder_day_folder_processFile (self, _tmp9_); - } - _g_object_unref0 (fileInfo); - _g_object_unref0 (enumerator); - _g_object_unref0 (desktop); - } - goto __finally2; - __catch2_g_error: - { - GError* e = NULL; - FILE* _tmp10_; - GError* _tmp11_; - const gchar* _tmp12_; - e = _inner_error_; - _inner_error_ = NULL; - _tmp10_ = stderr; - _tmp11_ = e; - _tmp12_ = _tmp11_->message; - fprintf (_tmp10_, "Error in DayFolder.cleanDesktop(): %s\n", _tmp12_); - _g_error_free0 (e); - } - __finally2: - if (_inner_error_ != NULL) { - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return; - } - zystem_zystem_println ("Finished cleaning directory"); -} - - -/** - * Process the passed file. - */ -static void dayfolder_day_folder_processFile (dayfolderDayFolder* self, GFileInfo* file) { - GFileInfo* _tmp0_; - gchar* _tmp1_ = NULL; - gchar* _tmp2_; - gboolean _tmp3_ = FALSE; - gboolean _tmp4_; - g_return_if_fail (self != NULL); - g_return_if_fail (file != NULL); - _tmp0_ = file; - _tmp1_ = dayfolder_file_utility_getFileExtension (_tmp0_); - _tmp2_ = _tmp1_; - _tmp3_ = dayfolder_user_data_ruleExistsForFileExt (_tmp2_); - _tmp4_ = _tmp3_; - _g_free0 (_tmp2_); - if (_tmp4_) { - GFileInfo* _tmp5_; - _tmp5_ = file; - dayfolder_user_data_runFileExtRule (_tmp5_); - } else { - GFileInfo* _tmp6_; - const gchar* _tmp7_; - const gchar* _tmp8_; - _tmp6_ = file; - _tmp7_ = dayfolder_user_data_get_dayFolderDirPath (); - _tmp8_ = _tmp7_; - dayfolder_file_utility_moveFile (_tmp6_, _tmp8_, FALSE); - } -} - - -/** - * Create rules that will be run. Eventually rules will be created based on settings. - */ -static void dayfolder_day_folder_createRules (dayfolderDayFolder* self) { - g_return_if_fail (self != NULL); -} - - -static void dayfolder_day_folder_class_init (dayfolderDayFolderClass * klass) { - dayfolder_day_folder_parent_class = g_type_class_peek_parent (klass); -} - - -static void dayfolder_day_folder_instance_init (dayfolderDayFolder * self) { -} - - -/** - * This is the main DayFolder logic starting point. - */ -GType dayfolder_day_folder_get_type (void) { - static volatile gsize dayfolder_day_folder_type_id__volatile = 0; - if (g_once_init_enter (&dayfolder_day_folder_type_id__volatile)) { - static const GTypeInfo g_define_type_info = { sizeof (dayfolderDayFolderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dayfolder_day_folder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (dayfolderDayFolder), 0, (GInstanceInitFunc) dayfolder_day_folder_instance_init, NULL }; - GType dayfolder_day_folder_type_id; - dayfolder_day_folder_type_id = g_type_register_static (G_TYPE_OBJECT, "dayfolderDayFolder", &g_define_type_info, 0); - g_once_init_leave (&dayfolder_day_folder_type_id__volatile, dayfolder_day_folder_type_id); - } - return dayfolder_day_folder_type_id__volatile; -} - - - diff -Nru dayfolder-1.4.1/src/DayFolderClass.vala dayfolder-2.0.0/src/DayFolderClass.vala --- dayfolder-1.4.1/src/DayFolderClass.vala 2012-05-20 16:41:03.000000000 +0000 +++ dayfolder-2.0.0/src/DayFolderClass.vala 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -using GLib; -using Gee; - -using zystem; - -namespace dayfolder { - -/** - * This is the main DayFolder logic starting point. - */ -class DayFolder : Object { - - /** - * Constructor. - */ - public DayFolder() { - - // Create the UserData - UserData.initializeUserData(); - - // For development... - //createRules(); - } - - /** - * Make sure that today's folder is created, then clean the desktop. - */ - public void run() { - createTodaysFolder(); - cleanDesktop(); - } - - /** - * Create today's folder in the DayFolder directory. - */ - private void createTodaysFolder(){ - // Create the directory. This method doesn't care if it exists already or not. - GLib.DirUtils.create_with_parents(UserData.dayFolderDirPath, 0775); - } - - /** - * Clean the desktop! - */ - private void cleanDesktop(){ - - try { - File desktop = File.new_for_path(UserData.sourcePath); - FileEnumerator enumerator = desktop.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME, 0); - FileInfo fileInfo; - - // Go through the files - while((fileInfo = enumerator.next_file()) != null) { - processFile(fileInfo); - } - } catch(Error e) { - stderr.printf ("Error in DayFolder.cleanDesktop(): %s\n", e.message); - } - - Zystem.println("Finished cleaning directory"); - } - - /** - * Process the passed file. - */ - private void processFile(FileInfo file){ - // Check if rule exists for this type of file - if(UserData.ruleExistsForFileExt(FileUtility.getFileExtension(file))) { - UserData.runFileExtRule(file); - } else { - // Move to dayfolder - FileUtility.moveFile(file, UserData.dayFolderDirPath); - } - - } - - - - /***** Testing methods *****/ - - /** - * Create rules that will be run. Eventually rules will be created based on settings. - */ - private void createRules() { - // Create some rules in the Rule Manager - /*ruleManager.addFileExtRule(".deb", "Other/Installers", true); - ruleManager.addFileExtRule(".iso", "Other/isos", true);*/ - } - -} - -} \ No newline at end of file diff -Nru dayfolder-1.4.1/src/DfMonitor.c dayfolder-2.0.0/src/DfMonitor.c --- dayfolder-1.4.1/src/DfMonitor.c 1970-01-01 00:00:00.000000000 +0000 +++ dayfolder-2.0.0/src/DfMonitor.c 2013-05-11 22:28:22.000000000 +0000 @@ -0,0 +1,31 @@ +/* DfMonitor.c generated by valac 0.18.1, the Vala compiler + * generated from DfMonitor.vala, do not modify */ + +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + +#include +#include + + + + + + + diff -Nru dayfolder-1.4.1/src/DfMonitor.vala dayfolder-2.0.0/src/DfMonitor.vala --- dayfolder-1.4.1/src/DfMonitor.vala 1970-01-01 00:00:00.000000000 +0000 +++ dayfolder-2.0.0/src/DfMonitor.vala 2013-05-11 22:28:05.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + +/**using zystem; + +using GLib; + +namespace dayfolder { + +public class DfMonitor : Object { + + private File monitoredFile; + + public DfMonitor(string filePath) { + // + monitoredFile = File.new_for_path(filePath); + //FileMonitor mon = file.monitor_file(GLib.FileMonitorFlags.NONE); + //mon.changed.connect(onChange); + Zystem.debug("Created the DfMonitor"); + } + + public FileMonitor getFileMonitor() { + //return monitoredFile.monitor_file(GLib.FileMonitorFlags.NONE); + return monitoredFile.monitor_directory(GLib.FileMonitorFlags.NONE); + } + + public void onChange() { + // + Zystem.debug("THE DFMONITOR Monitored File FILE HAS BEEN CHANGED! ALERT THE MEDIA!"); + } + + + +} + +}*/ diff -Nru dayfolder-1.4.1/src/FileUtility.c dayfolder-2.0.0/src/FileUtility.c --- dayfolder-1.4.1/src/FileUtility.c 2012-05-22 23:16:17.000000000 +0000 +++ dayfolder-2.0.0/src/FileUtility.c 2013-05-11 22:28:22.000000000 +0000 @@ -1,13 +1,31 @@ -/* FileUtility.c generated by valac 0.14.2, the Vala compiler +/* FileUtility.c generated by valac 0.18.1, the Vala compiler * generated from FileUtility.vala, do not modify */ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ #include #include -#include #include #include #include +#include #define DAYFOLDER_TYPE_FILE_UTILITY (dayfolder_file_utility_get_type ()) @@ -21,8 +39,6 @@ typedef struct _dayfolderFileUtilityClass dayfolderFileUtilityClass; typedef struct _dayfolderFileUtilityPrivate dayfolderFileUtilityPrivate; #define _g_free0(var) (var = (g_free (var), NULL)) -#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) -#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL))) struct _dayfolderFileUtility { GObject parent_instance; @@ -40,96 +56,13 @@ enum { DAYFOLDER_FILE_UTILITY_DUMMY_PROPERTY }; -void dayfolder_file_utility_moveFile (GFileInfo* file, const gchar* destDir, gboolean isFileExtRule); -static gchar* dayfolder_file_utility_addTimestampToFilePath (const gchar* filePath, gboolean isFileExtRule); -const gchar* dayfolder_user_data_get_sourcePath (void); void dayfolder_file_utility_createFolder (const gchar* dirPath); gchar* dayfolder_file_utility_getFileExtension (GFileInfo* file); -gboolean dayfolder_user_data_isDailyDfType (void); -gboolean dayfolder_user_data_isWeeklyDfType (void); -gboolean dayfolder_user_data_isMonthlyDfType (void); +gchar* dayfolder_file_utility_pathCombine (const gchar* pathStart, const gchar* pathEnd); dayfolderFileUtility* dayfolder_file_utility_new (void); dayfolderFileUtility* dayfolder_file_utility_construct (GType object_type); -void dayfolder_file_utility_moveFile (GFileInfo* file, const gchar* destDir, gboolean isFileExtRule) { - const gchar* _tmp0_; - gchar* _tmp1_; - gchar* _tmp2_; - GFileInfo* _tmp3_; - const gchar* _tmp4_ = NULL; - gchar* _tmp5_; - gchar* _tmp6_; - gchar* fileDestPath; - const gchar* _tmp7_; - GFile* _tmp8_ = NULL; - GFile* destFile; - GFile* _tmp9_; - gboolean _tmp10_ = FALSE; - GFile* _tmp16_; - gboolean _tmp17_ = FALSE; - g_return_if_fail (file != NULL); - g_return_if_fail (destDir != NULL); - _tmp0_ = destDir; - _tmp1_ = g_strconcat (_tmp0_, "/", NULL); - _tmp2_ = _tmp1_; - _tmp3_ = file; - _tmp4_ = g_file_info_get_name (_tmp3_); - _tmp5_ = g_strconcat (_tmp2_, _tmp4_, NULL); - _tmp6_ = _tmp5_; - _g_free0 (_tmp2_); - fileDestPath = _tmp6_; - _tmp7_ = fileDestPath; - _tmp8_ = g_file_new_for_path (_tmp7_); - destFile = _tmp8_; - _tmp9_ = destFile; - _tmp10_ = g_file_query_exists (_tmp9_, NULL); - if (_tmp10_) { - const gchar* _tmp11_; - gboolean _tmp12_; - gchar* _tmp13_ = NULL; - const gchar* _tmp14_; - GFile* _tmp15_ = NULL; - _tmp11_ = fileDestPath; - _tmp12_ = isFileExtRule; - _tmp13_ = dayfolder_file_utility_addTimestampToFilePath (_tmp11_, _tmp12_); - _g_free0 (fileDestPath); - fileDestPath = _tmp13_; - _tmp14_ = fileDestPath; - _tmp15_ = g_file_new_for_path (_tmp14_); - _g_object_unref0 (destFile); - destFile = _tmp15_; - } - _tmp16_ = destFile; - _tmp17_ = g_file_query_exists (_tmp16_, NULL); - if (!_tmp17_) { - const gchar* _tmp18_; - const gchar* _tmp19_; - gchar* _tmp20_; - gchar* _tmp21_; - GFileInfo* _tmp22_; - const gchar* _tmp23_ = NULL; - gchar* _tmp24_; - gchar* _tmp25_; - const gchar* _tmp26_; - _tmp18_ = dayfolder_user_data_get_sourcePath (); - _tmp19_ = _tmp18_; - _tmp20_ = g_strconcat (_tmp19_, "/", NULL); - _tmp21_ = _tmp20_; - _tmp22_ = file; - _tmp23_ = g_file_info_get_name (_tmp22_); - _tmp24_ = g_strconcat (_tmp21_, _tmp23_, NULL); - _tmp25_ = _tmp24_; - _tmp26_ = fileDestPath; - g_rename (_tmp25_, _tmp26_); - _g_free0 (_tmp25_); - _g_free0 (_tmp21_); - } - _g_object_unref0 (destFile); - _g_free0 (fileDestPath); -} - - /** * Create a folder (or make sure it exists). */ @@ -295,103 +228,17 @@ } -/** - * Get the file path with the unique timestamp inserted at end of - * filename before file extension. - */ -static gchar* dayfolder_file_utility_addTimestampToFilePath (const gchar* filePath, gboolean isFileExtRule) { +gchar* dayfolder_file_utility_pathCombine (const gchar* pathStart, const gchar* pathEnd) { gchar* result = NULL; - GDateTime* _tmp0_; - GDateTime* dateTime; + const gchar* _tmp0_; const gchar* _tmp1_; - const gchar* _tmp2_; - gint _tmp3_ = 0; - gchar* _tmp4_ = NULL; - gchar* pathPrefix; - const gchar* _tmp5_; - const gchar* _tmp6_; - gint _tmp7_ = 0; - gchar* _tmp8_ = NULL; - gchar* fileExt; - gchar* _tmp9_; - gchar* timestamp; - gboolean _tmp10_; - const gchar* _tmp22_; - const gchar* _tmp23_; - gchar* _tmp24_; - gchar* _tmp25_; - const gchar* _tmp26_; - gchar* _tmp27_; - gchar* _tmp28_; - g_return_val_if_fail (filePath != NULL, NULL); - _tmp0_ = g_date_time_new_now_local (); - dateTime = _tmp0_; - _tmp1_ = filePath; - _tmp2_ = filePath; - _tmp3_ = string_last_index_of (_tmp2_, ".", 0); - _tmp4_ = string_substring (_tmp1_, (glong) 0, (glong) _tmp3_); - pathPrefix = _tmp4_; - _tmp5_ = filePath; - _tmp6_ = filePath; - _tmp7_ = string_last_index_of (_tmp6_, ".", 0); - _tmp8_ = string_substring (_tmp5_, (glong) _tmp7_, (glong) (-1)); - fileExt = _tmp8_; - _tmp9_ = g_strdup ("_"); - timestamp = _tmp9_; - _tmp10_ = isFileExtRule; - if (_tmp10_) { - GDateTime* _tmp11_; - gchar* _tmp12_ = NULL; - _tmp11_ = dateTime; - _tmp12_ = g_date_time_format (_tmp11_, "_%Y%m%d_%H%M%S"); - _g_free0 (timestamp); - timestamp = _tmp12_; - } else { - gboolean _tmp13_ = FALSE; - _tmp13_ = dayfolder_user_data_isDailyDfType (); - if (_tmp13_) { - GDateTime* _tmp14_; - gchar* _tmp15_ = NULL; - _tmp14_ = dateTime; - _tmp15_ = g_date_time_format (_tmp14_, "_%H%M%S"); - _g_free0 (timestamp); - timestamp = _tmp15_; - } else { - gboolean _tmp16_ = FALSE; - gboolean _tmp17_ = FALSE; - gboolean _tmp19_; - _tmp17_ = dayfolder_user_data_isWeeklyDfType (); - if (_tmp17_) { - _tmp16_ = TRUE; - } else { - gboolean _tmp18_ = FALSE; - _tmp18_ = dayfolder_user_data_isMonthlyDfType (); - _tmp16_ = _tmp18_; - } - _tmp19_ = _tmp16_; - if (_tmp19_) { - GDateTime* _tmp20_; - gchar* _tmp21_ = NULL; - _tmp20_ = dateTime; - _tmp21_ = g_date_time_format (_tmp20_, "_%d_%H%M%S"); - _g_free0 (timestamp); - timestamp = _tmp21_; - } - } - } - _tmp22_ = pathPrefix; - _tmp23_ = timestamp; - _tmp24_ = g_strconcat (_tmp22_, _tmp23_, NULL); - _tmp25_ = _tmp24_; - _tmp26_ = fileExt; - _tmp27_ = g_strconcat (_tmp25_, _tmp26_, NULL); - _tmp28_ = _tmp27_; - _g_free0 (_tmp25_); - result = _tmp28_; - _g_free0 (timestamp); - _g_free0 (fileExt); - _g_free0 (pathPrefix); - _g_date_time_unref0 (dateTime); + gchar* _tmp2_ = NULL; + g_return_val_if_fail (pathStart != NULL, NULL); + g_return_val_if_fail (pathEnd != NULL, NULL); + _tmp0_ = pathStart; + _tmp1_ = pathEnd; + _tmp2_ = g_build_path (G_DIR_SEPARATOR_S, _tmp0_, _tmp1_, NULL); + result = _tmp2_; return result; } diff -Nru dayfolder-1.4.1/src/FileUtility.vala dayfolder-2.0.0/src/FileUtility.vala --- dayfolder-1.4.1/src/FileUtility.vala 2012-05-22 23:16:00.000000000 +0000 +++ dayfolder-2.0.0/src/FileUtility.vala 2013-05-11 22:20:19.000000000 +0000 @@ -1,3 +1,21 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ using zystem; @@ -8,25 +26,6 @@ */ class FileUtility : GLib.Object { - /* - * Actually move the file to where it's supposed to go. - */ - public static void moveFile(FileInfo file, string destDir, bool isFileExtRule = false) { - string fileDestPath = destDir + "/" + file.get_name(); - var destFile = File.new_for_path(fileDestPath); - - // If file already exists, add timestamp to file name - if (destFile.query_exists()) { - fileDestPath = addTimestampToFilePath(fileDestPath, isFileExtRule); - destFile = File.new_for_path(fileDestPath); - } - - // Only move the file if destination file does not exist. We don't want to write over any files. - if (!destFile.query_exists()) { - GLib.FileUtils.rename(UserData.sourcePath + "/" + file.get_name(), fileDestPath); - } - } - /** * Create a folder (or make sure it exists). */ @@ -43,29 +42,11 @@ return fileName.substring(fileName.last_index_of(".")); } - /** - * Get the file path with the unique timestamp inserted at end of - * filename before file extension. - */ - private static string addTimestampToFilePath(string filePath, bool isFileExtRule) { - DateTime dateTime = new GLib.DateTime.now_local(); - - string pathPrefix = filePath.substring(0, filePath.last_index_of(".")); - string fileExt = filePath.substring(filePath.last_index_of(".")); - string timestamp = "_"; - - if (isFileExtRule) { - timestamp = dateTime.format("_%Y%m%d_%H%M%S"); - } else if (UserData.isDailyDfType()) { - timestamp = dateTime.format("_%H%M%S"); - } else if (UserData.isWeeklyDfType() || UserData.isMonthlyDfType()) { - timestamp = dateTime.format("_%d_%H%M%S"); - } - - return pathPrefix + timestamp + fileExt; + public static string pathCombine(string pathStart, string pathEnd) { + return Path.build_path(Path.DIR_SEPARATOR_S, pathStart, pathEnd); } } -} \ No newline at end of file +} diff -Nru dayfolder-1.4.1/src/Makefile.am dayfolder-2.0.0/src/Makefile.am --- dayfolder-1.4.1/src/Makefile.am 2012-04-15 20:23:00.000000000 +0000 +++ dayfolder-2.0.0/src/Makefile.am 2013-05-11 21:55:41.000000000 +0000 @@ -3,28 +3,24 @@ ## Created by Anjuta -uidir = $(datadir)/dayfolder/ui -ui_DATA = dayfolder.ui \ - dfSettings.ui - AM_CPPFLAGS = \ - -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ - -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ $(DAYFOLDER_CFLAGS) AM_CFLAGS =\ -Wall\ -g -VALAFLAGS = \ - --pkg gtk+-3.0 --pkg gee-1.0 --pkg appindicator3-0.1 --pkg gdk-3.0 - bin_PROGRAMS = dayfolder dayfolder_SOURCES = \ - dayfolder.vala config.vapi DayFolderClass.vala Rules.vala UserData.vala UserSettingsManager.vala Zystem.vala FileUtility.vala + dayfolder.vala config.vapi DfMonitor.vala FileUtility.vala MonitoredDirectory.vala Rules.vala TestFileMonitor.vala UserData.vala UserSettingsManager.vala Zystem.vala + +dayfolder_VALAFLAGS = --pkg appindicator3-0.1 --pkg gio-2.0 --pkg gee-1.0 --pkg gdk-3.0 --pkg gtk+-3.0 --pkg glib-2.0 \ + --pkg gtk+-3.0 dayfolder_LDFLAGS = \ -Wl,--export-dynamic @@ -32,10 +28,3 @@ dayfolder_LDADD = $(DAYFOLDER_LIBS) -EXTRA_DIST = $(ui_DATA) - -# Remove ui directory on uninstall -uninstall-local: - -rm -r $(uidir) - -rm -r $(datadir)/dayfolder - diff -Nru dayfolder-1.4.1/src/Makefile.in dayfolder-2.0.0/src/Makefile.in --- dayfolder-1.4.1/src/Makefile.in 2012-06-09 14:37:27.000000000 +0000 +++ dayfolder-2.0.0/src/Makefile.in 2013-05-11 22:28:13.000000000 +0000 @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -15,8 +15,24 @@ @SET_MAKE@ - VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -37,9 +53,9 @@ host_triplet = @host@ bin_PROGRAMS = dayfolder$(EXEEXT) subdir = src -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - DayFolderClass.c FileUtility.c Rules.c UserData.c \ - UserSettingsManager.c Zystem.c dayfolder.c \ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in DfMonitor.c \ + FileUtility.c MonitoredDirectory.c Rules.c TestFileMonitor.c \ + UserData.c UserSettingsManager.c Zystem.c dayfolder.c \ dayfolder_vala.stamp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac @@ -49,12 +65,12 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(uidir)" +am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_dayfolder_OBJECTS = dayfolder.$(OBJEXT) DayFolderClass.$(OBJEXT) \ - Rules.$(OBJEXT) UserData.$(OBJEXT) \ - UserSettingsManager.$(OBJEXT) Zystem.$(OBJEXT) \ - FileUtility.$(OBJEXT) +am_dayfolder_OBJECTS = dayfolder.$(OBJEXT) DfMonitor.$(OBJEXT) \ + FileUtility.$(OBJEXT) MonitoredDirectory.$(OBJEXT) \ + Rules.$(OBJEXT) TestFileMonitor.$(OBJEXT) UserData.$(OBJEXT) \ + UserSettingsManager.$(OBJEXT) Zystem.$(OBJEXT) dayfolder_OBJECTS = $(am_dayfolder_OBJECTS) am__DEPENDENCIES_1 = dayfolder_DEPENDENCIES = $(am__DEPENDENCIES_1) @@ -99,34 +115,11 @@ am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(dayfolder_SOURCES) DIST_SOURCES = $(dayfolder_SOURCES) -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -DATA = $(ui_DATA) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -250,31 +243,26 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -uidir = $(datadir)/dayfolder/ui -ui_DATA = dayfolder.ui \ - dfSettings.ui - AM_CPPFLAGS = \ - -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ - -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ $(DAYFOLDER_CFLAGS) AM_CFLAGS = \ -Wall\ -g -VALAFLAGS = \ - --pkg gtk+-3.0 --pkg gee-1.0 --pkg appindicator3-0.1 --pkg gdk-3.0 - dayfolder_SOURCES = \ - dayfolder.vala config.vapi DayFolderClass.vala Rules.vala UserData.vala UserSettingsManager.vala Zystem.vala FileUtility.vala + dayfolder.vala config.vapi DfMonitor.vala FileUtility.vala MonitoredDirectory.vala Rules.vala TestFileMonitor.vala UserData.vala UserSettingsManager.vala Zystem.vala + +dayfolder_VALAFLAGS = --pkg appindicator3-0.1 --pkg gio-2.0 --pkg gee-1.0 --pkg gdk-3.0 --pkg gtk+-3.0 --pkg glib-2.0 \ + --pkg gtk+-3.0 dayfolder_LDFLAGS = \ -Wl,--export-dynamic dayfolder_LDADD = $(DAYFOLDER_LIBS) -EXTRA_DIST = $(ui_DATA) all: all-am .SUFFIXES: @@ -311,8 +299,11 @@ $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ @@ -362,9 +353,11 @@ distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DayFolderClass.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DfMonitor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileUtility.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MonitoredDirectory.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Rules.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TestFileMonitor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserData.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserSettingsManager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Zystem.Po@am__quote@ @@ -395,7 +388,17 @@ @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ fi -$(srcdir)/DayFolderClass.c: $(srcdir)/dayfolder_vala.stamp +$(srcdir)/DfMonitor.c: $(srcdir)/dayfolder_vala.stamp + @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi + @if test -f $@; then :; else \ + $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ + fi +$(srcdir)/FileUtility.c: $(srcdir)/dayfolder_vala.stamp + @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi + @if test -f $@; then :; else \ + $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ + fi +$(srcdir)/MonitoredDirectory.c: $(srcdir)/dayfolder_vala.stamp @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ @@ -405,29 +408,29 @@ @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ fi -$(srcdir)/UserData.c: $(srcdir)/dayfolder_vala.stamp +$(srcdir)/TestFileMonitor.c: $(srcdir)/dayfolder_vala.stamp @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ fi -$(srcdir)/UserSettingsManager.c: $(srcdir)/dayfolder_vala.stamp +$(srcdir)/UserData.c: $(srcdir)/dayfolder_vala.stamp @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ fi -$(srcdir)/Zystem.c: $(srcdir)/dayfolder_vala.stamp +$(srcdir)/UserSettingsManager.c: $(srcdir)/dayfolder_vala.stamp @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ fi -$(srcdir)/FileUtility.c: $(srcdir)/dayfolder_vala.stamp +$(srcdir)/Zystem.c: $(srcdir)/dayfolder_vala.stamp @if test -f $@; then :; else rm -f $(srcdir)/dayfolder_vala.stamp; fi @if test -f $@; then :; else \ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/dayfolder_vala.stamp; \ fi -$(srcdir)/dayfolder_vala.stamp: $(dayfolder_SOURCES) +$(srcdir)/dayfolder_vala.stamp: dayfolder.vala config.vapi DfMonitor.vala FileUtility.vala MonitoredDirectory.vala Rules.vala TestFileMonitor.vala UserData.vala UserSettingsManager.vala Zystem.vala $(AM_V_at)rm -f $@ && echo stamp > $@-t - $(AM_V_VALAC)$(am__cd) $(srcdir) && $(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS) -C $(dayfolder_SOURCES) + $(AM_V_VALAC)$(am__cd) $(srcdir) && $(VALAC) $(dayfolder_VALAFLAGS) $(VALAFLAGS) -C dayfolder.vala config.vapi DfMonitor.vala FileUtility.vala MonitoredDirectory.vala Rules.vala TestFileMonitor.vala UserData.vala UserSettingsManager.vala Zystem.vala $(AM_V_at)mv -f $@-t $@ mostlyclean-libtool: @@ -435,24 +438,6 @@ clean-libtool: -rm -rf .libs _libs -install-uiDATA: $(ui_DATA) - @$(NORMAL_INSTALL) - test -z "$(uidir)" || $(MKDIR_P) "$(DESTDIR)$(uidir)" - @list='$(ui_DATA)'; test -n "$(uidir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(uidir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(uidir)" || exit $$?; \ - done - -uninstall-uiDATA: - @$(NORMAL_UNINSTALL) - @list='$(ui_DATA)'; test -n "$(uidir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(uidir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -538,9 +523,9 @@ done check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) $(DATA) +all-am: Makefile $(PROGRAMS) installdirs: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(uidir)"; do \ + for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -573,9 +558,11 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." - -rm -f DayFolderClass.c + -rm -f DfMonitor.c -rm -f FileUtility.c + -rm -f MonitoredDirectory.c -rm -f Rules.c + -rm -f TestFileMonitor.c -rm -f UserData.c -rm -f UserSettingsManager.c -rm -f Zystem.c @@ -603,7 +590,7 @@ info-am: -install-data-am: install-uiDATA +install-data-am: install-dvi: install-dvi-am @@ -649,7 +636,7 @@ ps-am: -uninstall-am: uninstall-binPROGRAMS uninstall-local uninstall-uiDATA +uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip @@ -661,18 +648,12 @@ 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 install-uiDATA installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS uninstall-local \ - uninstall-uiDATA - + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS -# Remove ui directory on uninstall -uninstall-local: - -rm -r $(uidir) - -rm -r $(datadir)/dayfolder # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru dayfolder-1.4.1/src/MonitoredDirectory.c dayfolder-2.0.0/src/MonitoredDirectory.c --- dayfolder-1.4.1/src/MonitoredDirectory.c 1970-01-01 00:00:00.000000000 +0000 +++ dayfolder-2.0.0/src/MonitoredDirectory.c 2013-05-11 22:28:22.000000000 +0000 @@ -0,0 +1,1448 @@ +/* MonitoredDirectory.c generated by valac 0.18.1, the Vala compiler + * generated from MonitoredDirectory.vala, do not modify */ + +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ +/********************************************* + * + ******************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define DAYFOLDER_TYPE_MONITORED_DIRECTORY (dayfolder_monitored_directory_get_type ()) +#define DAYFOLDER_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory)) +#define DAYFOLDER_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_MONITORED_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) + +typedef struct _dayfolderMonitoredDirectory dayfolderMonitoredDirectory; +typedef struct _dayfolderMonitoredDirectoryClass dayfolderMonitoredDirectoryClass; +typedef struct _dayfolderMonitoredDirectoryPrivate dayfolderMonitoredDirectoryPrivate; + +#define DAYFOLDER_TYPE_DF_RULE (dayfolder_df_rule_get_type ()) +#define DAYFOLDER_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRule)) +#define DAYFOLDER_IS_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DF_RULE)) +#define DAYFOLDER_DF_RULE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRuleIface)) + +typedef struct _dayfolderDfRule dayfolderDfRule; +typedef struct _dayfolderDfRuleIface dayfolderDfRuleIface; +#define _g_free0(var) (var = (g_free (var), NULL)) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +#define DAYFOLDER_TYPE_FILE_CONTAINS_RULE (dayfolder_file_contains_rule_get_type ()) +#define DAYFOLDER_FILE_CONTAINS_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRule)) +#define DAYFOLDER_FILE_CONTAINS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRuleClass)) +#define DAYFOLDER_IS_FILE_CONTAINS_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE)) +#define DAYFOLDER_IS_FILE_CONTAINS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_CONTAINS_RULE)) +#define DAYFOLDER_FILE_CONTAINS_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRuleClass)) + +typedef struct _dayfolderFileContainsRule dayfolderFileContainsRule; +typedef struct _dayfolderFileContainsRuleClass dayfolderFileContainsRuleClass; +#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL))) +#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) + +struct _dayfolderMonitoredDirectory { + GObject parent_instance; + dayfolderMonitoredDirectoryPrivate * priv; +}; + +struct _dayfolderMonitoredDirectoryClass { + GObjectClass parent_class; +}; + +struct _dayfolderDfRuleIface { + GTypeInterface parent_iface; + gboolean (*processFile) (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); + const gchar* (*get_criteriaString) (dayfolderDfRule* self); + void (*set_criteriaString) (dayfolderDfRule* self, const gchar* value); + const gchar* (*get_destinationDir) (dayfolderDfRule* self); + void (*set_destinationDir) (dayfolderDfRule* self, const gchar* value); +}; + +struct _dayfolderMonitoredDirectoryPrivate { + gchar* _dirPath; + gchar* _fileExtRulesGroup; + gboolean _useDayFolder; + gchar* _dfRootPath; + gboolean _moveDirs; + gchar* _dfType; + gchar* _dayFolderDirPath; + GeeHashMap* rulesMap; +}; + + +static gpointer dayfolder_monitored_directory_parent_class = NULL; + +GType dayfolder_monitored_directory_get_type (void) G_GNUC_CONST; +GType dayfolder_df_rule_get_type (void) G_GNUC_CONST; +#define DAYFOLDER_MONITORED_DIRECTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryPrivate)) +enum { + DAYFOLDER_MONITORED_DIRECTORY_DUMMY_PROPERTY, + DAYFOLDER_MONITORED_DIRECTORY_DIR_PATH, + DAYFOLDER_MONITORED_DIRECTORY_FILE_EXT_RULES_GROUP, + DAYFOLDER_MONITORED_DIRECTORY_USE_DAY_FOLDER, + DAYFOLDER_MONITORED_DIRECTORY_DF_ROOT_PATH, + DAYFOLDER_MONITORED_DIRECTORY_MOVE_DIRS, + DAYFOLDER_MONITORED_DIRECTORY_DF_TYPE, + DAYFOLDER_MONITORED_DIRECTORY_DAY_FOLDER_DIR_PATH +}; +#define DAYFOLDER_MONITORED_DIRECTORY_useDayFolderKey "useDayFolder" +#define DAYFOLDER_MONITORED_DIRECTORY_dfRootPathKey "dfRootPath" +#define DAYFOLDER_MONITORED_DIRECTORY_sourcePathKey "sourcePath" +#define DAYFOLDER_MONITORED_DIRECTORY_moveDirsKey "moveDirs" +#define DAYFOLDER_MONITORED_DIRECTORY_dfTypeKey "dfType" +dayfolderMonitoredDirectory* dayfolder_monitored_directory_new (const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType); +dayfolderMonitoredDirectory* dayfolder_monitored_directory_construct (GType object_type, const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType); +static void dayfolder_monitored_directory_set_dirPath (dayfolderMonitoredDirectory* self, const gchar* value); +static void dayfolder_monitored_directory_set_fileExtRulesGroup (dayfolderMonitoredDirectory* self, const gchar* value); +void dayfolder_monitored_directory_set_useDayFolder (dayfolderMonitoredDirectory* self, gboolean value); +static void dayfolder_monitored_directory_set_dfRootPath (dayfolderMonitoredDirectory* self, const gchar* value); +void dayfolder_monitored_directory_set_moveDirs (dayfolderMonitoredDirectory* self, gboolean value); +static void dayfolder_monitored_directory_set_dfType (dayfolderMonitoredDirectory* self, const gchar* value); +void dayfolder_monitored_directory_setDfRootPath (dayfolderMonitoredDirectory* self, const gchar* rootPath); +void dayfolder_monitored_directory_setDfType (dayfolderMonitoredDirectory* self, const gchar* type); +void dayfolder_monitored_directory_addFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria, const gchar* destDir); +dayfolderFileContainsRule* dayfolder_file_contains_rule_new (const gchar* criteria, const gchar* destinationDir); +dayfolderFileContainsRule* dayfolder_file_contains_rule_construct (GType object_type, const gchar* criteria, const gchar* destinationDir); +GType dayfolder_file_contains_rule_get_type (void) G_GNUC_CONST; +const gchar* dayfolder_df_rule_get_criteriaString (dayfolderDfRule* self); +void dayfolder_monitored_directory_removeFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria); +GeeArrayList* dayfolder_monitored_directory_getFileRules (dayfolderMonitoredDirectory* self); +void zystem_zystem_debug (const gchar* s); +gchar* dayfolder_monitored_directory_getFileRuleDest (dayfolderMonitoredDirectory* self, const gchar* criteria); +const gchar* dayfolder_df_rule_get_destinationDir (dayfolderDfRule* self); +gboolean dayfolder_monitored_directory_ruleExistsForCriteria (dayfolderMonitoredDirectory* self, const gchar* criteria); +static void dayfolder_monitored_directory_setDayFolderDirPath (dayfolderMonitoredDirectory* self); +const gchar* dayfolder_monitored_directory_get_dirPath (dayfolderMonitoredDirectory* self); +const gchar* dayfolder_monitored_directory_get_dfType (dayfolderMonitoredDirectory* self); +#define DAYFOLDER_USER_DATA_dfTypeDaily "D" +#define DAYFOLDER_USER_DATA_dfTypeWeekly "W" +#define DAYFOLDER_USER_DATA_dfTypeMonthly "M" +const gchar* dayfolder_monitored_directory_get_dfRootPath (dayfolderMonitoredDirectory* self); +static void dayfolder_monitored_directory_set_dayFolderDirPath (dayfolderMonitoredDirectory* self, const gchar* value); +gboolean dayfolder_monitored_directory_isDailyDfType (dayfolderMonitoredDirectory* self); +gboolean dayfolder_monitored_directory_isWeeklyDfType (dayfolderMonitoredDirectory* self); +gboolean dayfolder_monitored_directory_isMonthlyDfType (dayfolderMonitoredDirectory* self); +void dayfolder_monitored_directory_printDebug (dayfolderMonitoredDirectory* self); +void dayfolder_monitored_directory_runCleanup (dayfolderMonitoredDirectory* self); +static void dayfolder_monitored_directory_createTodaysFolder (dayfolderMonitoredDirectory* self); +static void dayfolder_monitored_directory_processFile (dayfolderMonitoredDirectory* self, GFileInfo* file); +const gchar* dayfolder_monitored_directory_get_dayFolderDirPath (dayfolderMonitoredDirectory* self); +void zystem_zystem_debugFileInfo (GFileInfo* file); +gboolean dayfolder_df_rule_processFile (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); +static gboolean dayfolder_monitored_directory_fileShouldMoveToDayFolder (dayfolderMonitoredDirectory* self, GFileInfo* file); +void dayfolder_monitored_directory_moveFile (dayfolderMonitoredDirectory* self, GFileInfo* file, const gchar* destDir); +gboolean dayfolder_monitored_directory_get_useDayFolder (dayfolderMonitoredDirectory* self); +gboolean dayfolder_monitored_directory_get_moveDirs (dayfolderMonitoredDirectory* self); +static gchar* dayfolder_monitored_directory_addTimestampToFilePath (dayfolderMonitoredDirectory* self, const gchar* filePath, gboolean isFileExtRule); +const gchar* dayfolder_monitored_directory_get_fileExtRulesGroup (dayfolderMonitoredDirectory* self); +static void dayfolder_monitored_directory_finalize (GObject* obj); +static void _vala_dayfolder_monitored_directory_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void _vala_dayfolder_monitored_directory_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); + + +/** + * Constructor. + */ +dayfolderMonitoredDirectory* dayfolder_monitored_directory_construct (GType object_type, const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType) { + dayfolderMonitoredDirectory * self = NULL; + const gchar* _tmp0_; + const gchar* _tmp1_; + gchar* _tmp2_; + gchar* _tmp3_; + gboolean _tmp4_; + const gchar* _tmp5_; + gboolean _tmp6_; + const gchar* _tmp7_; + GeeHashMap* _tmp8_; + g_return_val_if_fail (dirPath != NULL, NULL); + g_return_val_if_fail (dfRootPath != NULL, NULL); + g_return_val_if_fail (dfType != NULL, NULL); + self = (dayfolderMonitoredDirectory*) g_object_new (object_type, NULL); + _tmp0_ = dirPath; + dayfolder_monitored_directory_set_dirPath (self, _tmp0_); + _tmp1_ = dirPath; + _tmp2_ = g_strconcat (_tmp1_, "FileExtRules", NULL); + _tmp3_ = _tmp2_; + dayfolder_monitored_directory_set_fileExtRulesGroup (self, _tmp3_); + _g_free0 (_tmp3_); + _tmp4_ = useDayFolder; + dayfolder_monitored_directory_set_useDayFolder (self, _tmp4_); + _tmp5_ = dfRootPath; + dayfolder_monitored_directory_set_dfRootPath (self, _tmp5_); + _tmp6_ = moveDirs; + dayfolder_monitored_directory_set_moveDirs (self, _tmp6_); + _tmp7_ = dfType; + dayfolder_monitored_directory_set_dfType (self, _tmp7_); + _tmp8_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, DAYFOLDER_TYPE_DF_RULE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL); + _g_object_unref0 (self->priv->rulesMap); + self->priv->rulesMap = _tmp8_; + return self; +} + + +dayfolderMonitoredDirectory* dayfolder_monitored_directory_new (const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType) { + return dayfolder_monitored_directory_construct (DAYFOLDER_TYPE_MONITORED_DIRECTORY, dirPath, useDayFolder, dfRootPath, moveDirs, dfType); +} + + +/** + * Set the dfRootPath. + */ +void dayfolder_monitored_directory_setDfRootPath (dayfolderMonitoredDirectory* self, const gchar* rootPath) { + const gchar* _tmp0_; + g_return_if_fail (self != NULL); + g_return_if_fail (rootPath != NULL); + _tmp0_ = rootPath; + dayfolder_monitored_directory_set_dfRootPath (self, _tmp0_); +} + + +/** + * Set the dfType. + */ +void dayfolder_monitored_directory_setDfType (dayfolderMonitoredDirectory* self, const gchar* type) { + const gchar* _tmp0_; + g_return_if_fail (self != NULL); + g_return_if_fail (type != NULL); + _tmp0_ = type; + dayfolder_monitored_directory_set_dfType (self, _tmp0_); +} + + +/** + * Add a FileRule for this monitored directory. + */ +void dayfolder_monitored_directory_addFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria, const gchar* destDir) { + const gchar* _tmp0_; + const gchar* _tmp1_; + dayfolderFileContainsRule* _tmp2_; + dayfolderFileContainsRule* rule; + GeeHashMap* _tmp3_; + const gchar* _tmp4_; + const gchar* _tmp5_; + g_return_if_fail (self != NULL); + g_return_if_fail (criteria != NULL); + g_return_if_fail (destDir != NULL); + _tmp0_ = criteria; + _tmp1_ = destDir; + _tmp2_ = dayfolder_file_contains_rule_new (_tmp0_, _tmp1_); + rule = _tmp2_; + _tmp3_ = self->priv->rulesMap; + _tmp4_ = dayfolder_df_rule_get_criteriaString ((dayfolderDfRule*) rule); + _tmp5_ = _tmp4_; + gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, _tmp5_, (dayfolderDfRule*) rule); + _g_object_unref0 (rule); +} + + +/** + * Remove the FileRule. + */ +void dayfolder_monitored_directory_removeFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria) { + GeeHashMap* _tmp0_; + const gchar* _tmp1_; + g_return_if_fail (self != NULL); + g_return_if_fail (criteria != NULL); + _tmp0_ = self->priv->rulesMap; + _tmp1_ = criteria; + gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp1_, NULL); +} + + +/** + * Returns list of all file rules. + */ +GeeArrayList* dayfolder_monitored_directory_getFileRules (dayfolderMonitoredDirectory* self) { + GeeArrayList* result = NULL; + GeeArrayList* _tmp0_; + GeeArrayList* list; + g_return_val_if_fail (self != NULL, NULL); + zystem_zystem_debug ("In MonitoredDirectory.getFileRules()"); + _tmp0_ = gee_array_list_new (DAYFOLDER_TYPE_DF_RULE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + list = _tmp0_; + { + GeeHashMap* _tmp1_; + GeeCollection* _tmp2_; + GeeCollection* _tmp3_; + GeeCollection* _tmp4_; + GeeIterator* _tmp5_ = NULL; + GeeIterator* _tmp6_; + GeeIterator* _rule_it; + _tmp1_ = self->priv->rulesMap; + _tmp2_ = gee_abstract_map_get_values ((GeeMap*) _tmp1_); + _tmp3_ = _tmp2_; + _tmp4_ = _tmp3_; + _tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_); + _tmp6_ = _tmp5_; + _g_object_unref0 (_tmp4_); + _rule_it = _tmp6_; + while (TRUE) { + GeeIterator* _tmp7_; + gboolean _tmp8_ = FALSE; + GeeIterator* _tmp9_; + gpointer _tmp10_ = NULL; + dayfolderDfRule* rule; + GeeArrayList* _tmp11_; + dayfolderDfRule* _tmp12_; + _tmp7_ = _rule_it; + _tmp8_ = gee_iterator_next (_tmp7_); + if (!_tmp8_) { + break; + } + _tmp9_ = _rule_it; + _tmp10_ = gee_iterator_get (_tmp9_); + rule = (dayfolderDfRule*) _tmp10_; + _tmp11_ = list; + _tmp12_ = rule; + gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, _tmp12_); + _g_object_unref0 (rule); + } + _g_object_unref0 (_rule_it); + } + result = list; + return result; +} + + +/** + * Return the FileRule's destination. + */ +gchar* dayfolder_monitored_directory_getFileRuleDest (dayfolderMonitoredDirectory* self, const gchar* criteria) { + gchar* result = NULL; + GeeHashMap* _tmp0_; + const gchar* _tmp1_; + gpointer _tmp2_ = NULL; + dayfolderDfRule* _tmp3_; + const gchar* _tmp4_; + const gchar* _tmp5_; + gchar* _tmp6_; + gchar* _tmp7_; + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (criteria != NULL, NULL); + _tmp0_ = self->priv->rulesMap; + _tmp1_ = criteria; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + _tmp3_ = (dayfolderDfRule*) _tmp2_; + _tmp4_ = dayfolder_df_rule_get_destinationDir (_tmp3_); + _tmp5_ = _tmp4_; + _tmp6_ = g_strdup (_tmp5_); + _tmp7_ = _tmp6_; + _g_object_unref0 (_tmp3_); + result = _tmp7_; + return result; +} + + +/** + * Return if a rule exists for a file extension exists. + */ +gboolean dayfolder_monitored_directory_ruleExistsForCriteria (dayfolderMonitoredDirectory* self, const gchar* criteria) { + gboolean result = FALSE; + GeeHashMap* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_ = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (criteria != NULL, FALSE); + _tmp0_ = self->priv->rulesMap; + _tmp1_ = criteria; + _tmp2_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp1_); + result = _tmp2_; + return result; +} + + +/** + * Sets dayFolderDirPath variable to today's dayFolder directory. This is based on the dfType, + * and determines the path to the daily, weekly, or monthly folder. + */ +static void dayfolder_monitored_directory_setDayFolderDirPath (dayfolderMonitoredDirectory* self) { + const gchar* _tmp0_; + gchar* _tmp1_; + gchar* _tmp2_; + GDateTime* _tmp3_; + GDateTime* dateTime; + gchar* _tmp4_; + gchar* directoryName; + const gchar* _tmp5_; + const gchar* _tmp29_; + const gchar* _tmp30_; + gchar* _tmp31_ = NULL; + gchar* _tmp32_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->_dirPath; + _tmp1_ = g_strconcat ("Generating DayFolderDirPath for ", _tmp0_, NULL); + _tmp2_ = _tmp1_; + zystem_zystem_debug (_tmp2_); + _g_free0 (_tmp2_); + _tmp3_ = g_date_time_new_now_local (); + dateTime = _tmp3_; + _tmp4_ = g_strdup (""); + directoryName = _tmp4_; + _tmp5_ = self->priv->_dfType; + if (g_strcmp0 (_tmp5_, DAYFOLDER_USER_DATA_dfTypeDaily) == 0) { + GDateTime* _tmp6_; + gchar* _tmp7_ = NULL; + _tmp6_ = dateTime; + _tmp7_ = g_date_time_format (_tmp6_, "%Y-%m-%d"); + _g_free0 (directoryName); + directoryName = _tmp7_; + } else { + const gchar* _tmp8_; + _tmp8_ = self->priv->_dfType; + if (g_strcmp0 (_tmp8_, DAYFOLDER_USER_DATA_dfTypeWeekly) == 0) { + GDateTime* _tmp9_; + GDateTime* _tmp10_; + gint _tmp11_ = 0; + GDateTime* _tmp12_ = NULL; + GDateTime* _tmp13_; + gchar* _tmp14_ = NULL; + gchar* _tmp15_; + GDateTime* _tmp16_; + GDateTime* _tmp17_ = NULL; + GDateTime* _tmp18_; + gchar* _tmp19_ = NULL; + gchar* _tmp20_; + gchar* _tmp21_; + _tmp9_ = dateTime; + _tmp10_ = dateTime; + _tmp11_ = g_date_time_get_day_of_week (_tmp10_); + _tmp12_ = g_date_time_add_days (_tmp9_, 0 - _tmp11_); + _g_date_time_unref0 (dateTime); + dateTime = _tmp12_; + _tmp13_ = dateTime; + _tmp14_ = g_date_time_format (_tmp13_, "%Y-%m-%d to "); + _tmp15_ = _tmp14_; + _tmp16_ = dateTime; + _tmp17_ = g_date_time_add_days (_tmp16_, 6); + _tmp18_ = _tmp17_; + _tmp19_ = g_date_time_format (_tmp18_, "%Y-%m-%d"); + _tmp20_ = _tmp19_; + _tmp21_ = g_strconcat (_tmp15_, _tmp20_, NULL); + _g_free0 (directoryName); + directoryName = _tmp21_; + _g_free0 (_tmp20_); + _g_date_time_unref0 (_tmp18_); + _g_free0 (_tmp15_); + } else { + const gchar* _tmp22_; + _tmp22_ = self->priv->_dfType; + if (g_strcmp0 (_tmp22_, DAYFOLDER_USER_DATA_dfTypeMonthly) == 0) { + GDateTime* _tmp23_; + GDateTime* _tmp24_; + gint _tmp25_ = 0; + GDateTime* _tmp26_ = NULL; + GDateTime* _tmp27_; + gchar* _tmp28_ = NULL; + _tmp23_ = dateTime; + _tmp24_ = dateTime; + _tmp25_ = g_date_time_get_day_of_month (_tmp24_); + _tmp26_ = g_date_time_add_days (_tmp23_, 1 - _tmp25_); + _tmp27_ = _tmp26_; + _tmp28_ = g_date_time_format (_tmp27_, "%Y-%m"); + _g_free0 (directoryName); + directoryName = _tmp28_; + _g_date_time_unref0 (_tmp27_); + } + } + } + _tmp29_ = self->priv->_dfRootPath; + _tmp30_ = directoryName; + _tmp31_ = g_build_path (G_DIR_SEPARATOR_S, _tmp29_, _tmp30_, NULL); + _tmp32_ = _tmp31_; + dayfolder_monitored_directory_set_dayFolderDirPath (self, _tmp32_); + _g_free0 (_tmp32_); + _g_free0 (directoryName); + _g_date_time_unref0 (dateTime); +} + + +/** + * + */ +gboolean dayfolder_monitored_directory_isDailyDfType (dayfolderMonitoredDirectory* self) { + gboolean result = FALSE; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = self->priv->_dfType; + result = g_strcmp0 (_tmp0_, DAYFOLDER_USER_DATA_dfTypeDaily) == 0; + return result; +} + + +gboolean dayfolder_monitored_directory_isWeeklyDfType (dayfolderMonitoredDirectory* self) { + gboolean result = FALSE; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = self->priv->_dfType; + result = g_strcmp0 (_tmp0_, DAYFOLDER_USER_DATA_dfTypeWeekly) == 0; + return result; +} + + +gboolean dayfolder_monitored_directory_isMonthlyDfType (dayfolderMonitoredDirectory* self) { + gboolean result = FALSE; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = self->priv->_dfType; + result = g_strcmp0 (_tmp0_, DAYFOLDER_USER_DATA_dfTypeMonthly) == 0; + return result; +} + + +/** + * Debug method. + */ +void dayfolder_monitored_directory_printDebug (dayfolderMonitoredDirectory* self) { + const gchar* _tmp0_; + gchar* _tmp1_; + gchar* _tmp2_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->_dirPath; + _tmp1_ = g_strconcat ("Monitored Directory: ", _tmp0_, NULL); + _tmp2_ = _tmp1_; + zystem_zystem_debug (_tmp2_); + _g_free0 (_tmp2_); + zystem_zystem_debug ("FileRules: "); + { + GeeHashMap* _tmp3_; + GeeCollection* _tmp4_; + GeeCollection* _tmp5_; + GeeCollection* _tmp6_; + GeeIterator* _tmp7_ = NULL; + GeeIterator* _tmp8_; + GeeIterator* _rule_it; + _tmp3_ = self->priv->rulesMap; + _tmp4_ = gee_abstract_map_get_values ((GeeMap*) _tmp3_); + _tmp5_ = _tmp4_; + _tmp6_ = _tmp5_; + _tmp7_ = gee_iterable_iterator ((GeeIterable*) _tmp6_); + _tmp8_ = _tmp7_; + _g_object_unref0 (_tmp6_); + _rule_it = _tmp8_; + while (TRUE) { + GeeIterator* _tmp9_; + gboolean _tmp10_ = FALSE; + GeeIterator* _tmp11_; + gpointer _tmp12_ = NULL; + dayfolderDfRule* rule; + dayfolderDfRule* _tmp13_; + const gchar* _tmp14_; + const gchar* _tmp15_; + _tmp9_ = _rule_it; + _tmp10_ = gee_iterator_next (_tmp9_); + if (!_tmp10_) { + break; + } + _tmp11_ = _rule_it; + _tmp12_ = gee_iterator_get (_tmp11_); + rule = (dayfolderDfRule*) _tmp12_; + _tmp13_ = rule; + _tmp14_ = dayfolder_df_rule_get_criteriaString (_tmp13_); + _tmp15_ = _tmp14_; + zystem_zystem_debug (_tmp15_); + _g_object_unref0 (rule); + } + _g_object_unref0 (_rule_it); + } +} + + +/** + * Make sure that today's folder is created, then clean the desktop. + */ +void dayfolder_monitored_directory_runCleanup (dayfolderMonitoredDirectory* self) { + const gchar* _tmp0_; + gchar* _tmp1_; + gchar* _tmp2_; + GError * _inner_error_ = NULL; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->_dirPath; + _tmp1_ = g_strconcat ("In MonitoredDirectory.runCleanup() for ", _tmp0_, NULL); + _tmp2_ = _tmp1_; + zystem_zystem_debug (_tmp2_); + _g_free0 (_tmp2_); + dayfolder_monitored_directory_setDayFolderDirPath (self); + dayfolder_monitored_directory_createTodaysFolder (self); + { + const gchar* _tmp3_; + GFile* _tmp4_ = NULL; + GFile* desktop; + GFile* _tmp5_; + GFileEnumerator* _tmp6_ = NULL; + GFileEnumerator* enumerator; + GFileInfo* fileInfo = NULL; + _tmp3_ = self->priv->_dirPath; + _tmp4_ = g_file_new_for_path (_tmp3_); + desktop = _tmp4_; + _tmp5_ = desktop; + _tmp6_ = g_file_enumerate_children (_tmp5_, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, &_inner_error_); + enumerator = _tmp6_; + if (_inner_error_ != NULL) { + _g_object_unref0 (desktop); + goto __catch1_g_error; + } + while (TRUE) { + GFileEnumerator* _tmp7_; + GFileInfo* _tmp8_ = NULL; + GFileInfo* _tmp9_; + GFileInfo* _tmp10_; + GFileInfo* _tmp11_; + _tmp7_ = enumerator; + _tmp8_ = g_file_enumerator_next_file (_tmp7_, NULL, &_inner_error_); + _tmp9_ = _tmp8_; + if (_inner_error_ != NULL) { + _g_object_unref0 (fileInfo); + _g_object_unref0 (enumerator); + _g_object_unref0 (desktop); + goto __catch1_g_error; + } + _g_object_unref0 (fileInfo); + fileInfo = _tmp9_; + _tmp10_ = fileInfo; + if (!(_tmp10_ != NULL)) { + break; + } + _tmp11_ = fileInfo; + dayfolder_monitored_directory_processFile (self, _tmp11_); + } + _g_object_unref0 (fileInfo); + _g_object_unref0 (enumerator); + _g_object_unref0 (desktop); + } + goto __finally1; + __catch1_g_error: + { + GError* e = NULL; + FILE* _tmp12_; + GError* _tmp13_; + const gchar* _tmp14_; + e = _inner_error_; + _inner_error_ = NULL; + _tmp12_ = stderr; + _tmp13_ = e; + _tmp14_ = _tmp13_->message; + fprintf (_tmp12_, "Error in DayFolder.cleanDesktop(): %s\n", _tmp14_); + _g_error_free0 (e); + } + __finally1: + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return; + } + zystem_zystem_debug ("Finished cleaning directory"); +} + + +/** + * Create today's folder in the DayFolder directory. + */ +static void dayfolder_monitored_directory_createTodaysFolder (dayfolderMonitoredDirectory* self) { + const gchar* _tmp0_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->_dayFolderDirPath; + g_mkdir_with_parents (_tmp0_, 0775); +} + + +/** + * Process the passed file. + */ +static void dayfolder_monitored_directory_processFile (dayfolderMonitoredDirectory* self, GFileInfo* file) { + GFileInfo* _tmp0_; + gboolean fileProcessed; + GFileInfo* _tmp1_; + GFileType _tmp2_ = 0; + gboolean _tmp26_ = FALSE; + gboolean _tmp27_; + gboolean _tmp30_; + g_return_if_fail (self != NULL); + g_return_if_fail (file != NULL); + _tmp0_ = file; + zystem_zystem_debugFileInfo (_tmp0_); + fileProcessed = FALSE; + _tmp1_ = file; + _tmp2_ = g_file_info_get_file_type (_tmp1_); + if (_tmp2_ == G_FILE_TYPE_REGULAR) { + { + GeeHashMap* _tmp3_; + GeeCollection* _tmp4_; + GeeCollection* _tmp5_; + GeeCollection* _tmp6_; + GeeIterator* _tmp7_ = NULL; + GeeIterator* _tmp8_; + GeeIterator* _rule_it; + _tmp3_ = self->priv->rulesMap; + _tmp4_ = gee_abstract_map_get_values ((GeeMap*) _tmp3_); + _tmp5_ = _tmp4_; + _tmp6_ = _tmp5_; + _tmp7_ = gee_iterable_iterator ((GeeIterable*) _tmp6_); + _tmp8_ = _tmp7_; + _g_object_unref0 (_tmp6_); + _rule_it = _tmp8_; + while (TRUE) { + GeeIterator* _tmp9_; + gboolean _tmp10_ = FALSE; + GeeIterator* _tmp11_; + gpointer _tmp12_ = NULL; + dayfolderDfRule* rule; + dayfolderDfRule* _tmp13_; + GFileInfo* _tmp14_; + const gchar* _tmp15_; + gboolean _tmp16_ = FALSE; + gboolean _tmp17_; + _tmp9_ = _rule_it; + _tmp10_ = gee_iterator_next (_tmp9_); + if (!_tmp10_) { + break; + } + _tmp11_ = _rule_it; + _tmp12_ = gee_iterator_get (_tmp11_); + rule = (dayfolderDfRule*) _tmp12_; + _tmp13_ = rule; + _tmp14_ = file; + _tmp15_ = self->priv->_dirPath; + _tmp16_ = dayfolder_df_rule_processFile (_tmp13_, _tmp14_, _tmp15_); + fileProcessed = _tmp16_; + _tmp17_ = fileProcessed; + if (_tmp17_) { + GFileInfo* _tmp18_; + const gchar* _tmp19_ = NULL; + gchar* _tmp20_; + gchar* _tmp21_; + _tmp18_ = file; + _tmp19_ = g_file_info_get_name (_tmp18_); + _tmp20_ = g_strconcat (_tmp19_, " was processed.", NULL); + _tmp21_ = _tmp20_; + zystem_zystem_debug (_tmp21_); + _g_free0 (_tmp21_); + _g_object_unref0 (rule); + break; + } else { + GFileInfo* _tmp22_; + const gchar* _tmp23_ = NULL; + gchar* _tmp24_; + gchar* _tmp25_; + _tmp22_ = file; + _tmp23_ = g_file_info_get_name (_tmp22_); + _tmp24_ = g_strconcat (_tmp23_, " was NOT processed.", NULL); + _tmp25_ = _tmp24_; + zystem_zystem_debug (_tmp25_); + _g_free0 (_tmp25_); + } + _g_object_unref0 (rule); + } + _g_object_unref0 (_rule_it); + } + } + _tmp27_ = fileProcessed; + if (!_tmp27_) { + GFileInfo* _tmp28_; + gboolean _tmp29_ = FALSE; + _tmp28_ = file; + _tmp29_ = dayfolder_monitored_directory_fileShouldMoveToDayFolder (self, _tmp28_); + _tmp26_ = _tmp29_; + } else { + _tmp26_ = FALSE; + } + _tmp30_ = _tmp26_; + if (_tmp30_) { + GFileInfo* _tmp31_; + zystem_zystem_debug ("Moving regular file to DayFolder directory"); + _tmp31_ = file; + dayfolder_monitored_directory_moveFile (self, _tmp31_, ""); + } +} + + +/** + * + */ +static gboolean dayfolder_monitored_directory_fileShouldMoveToDayFolder (dayfolderMonitoredDirectory* self, GFileInfo* file) { + gboolean result = FALSE; + gboolean _result_; + gboolean _tmp0_ = FALSE; + GFileInfo* _tmp1_; + GFileType _tmp2_ = 0; + gboolean _tmp4_; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (file != NULL, FALSE); + _result_ = FALSE; + _tmp1_ = file; + _tmp2_ = g_file_info_get_file_type (_tmp1_); + if (_tmp2_ == G_FILE_TYPE_REGULAR) { + gboolean _tmp3_; + _tmp3_ = self->priv->_useDayFolder; + _tmp0_ = _tmp3_; + } else { + _tmp0_ = FALSE; + } + _tmp4_ = _tmp0_; + if (_tmp4_) { + _result_ = TRUE; + } else { + gboolean _tmp5_ = FALSE; + gboolean _tmp6_ = FALSE; + GFileInfo* _tmp7_; + GFileType _tmp8_ = 0; + gboolean _tmp10_; + gboolean _tmp12_; + _tmp7_ = file; + _tmp8_ = g_file_info_get_file_type (_tmp7_); + if (_tmp8_ == G_FILE_TYPE_DIRECTORY) { + gboolean _tmp9_; + _tmp9_ = self->priv->_useDayFolder; + _tmp6_ = _tmp9_; + } else { + _tmp6_ = FALSE; + } + _tmp10_ = _tmp6_; + if (_tmp10_) { + gboolean _tmp11_; + _tmp11_ = self->priv->_moveDirs; + _tmp5_ = _tmp11_; + } else { + _tmp5_ = FALSE; + } + _tmp12_ = _tmp5_; + if (_tmp12_) { + _result_ = TRUE; + } + } + result = _result_; + return result; +} + + +/** + * Actually move the file to where it's supposed to go. + */ +void dayfolder_monitored_directory_moveFile (dayfolderMonitoredDirectory* self, GFileInfo* file, const gchar* destDir) { + const gchar* _tmp0_; + gchar* _tmp1_; + gchar* _tmp2_; + gchar* _tmp3_; + gchar* fileDestPath; + const gchar* _tmp4_; + const gchar* _tmp17_; + GFile* _tmp18_ = NULL; + GFile* destFile; + GFile* _tmp19_; + gboolean _tmp20_ = FALSE; + GFile* _tmp26_; + gboolean _tmp27_ = FALSE; + g_return_if_fail (self != NULL); + g_return_if_fail (file != NULL); + g_return_if_fail (destDir != NULL); + _tmp0_ = self->priv->_dayFolderDirPath; + _tmp1_ = g_strconcat ("dayFolderDirPath is: ", _tmp0_, NULL); + _tmp2_ = _tmp1_; + zystem_zystem_debug (_tmp2_); + _g_free0 (_tmp2_); + _tmp3_ = g_strdup (""); + fileDestPath = _tmp3_; + _tmp4_ = destDir; + if (g_strcmp0 (_tmp4_, "") == 0) { + const gchar* _tmp5_; + gchar* _tmp6_; + gchar* _tmp7_; + GFileInfo* _tmp8_; + const gchar* _tmp9_ = NULL; + gchar* _tmp10_; + _tmp5_ = self->priv->_dayFolderDirPath; + _tmp6_ = g_strconcat (_tmp5_, "/", NULL); + _tmp7_ = _tmp6_; + _tmp8_ = file; + _tmp9_ = g_file_info_get_name (_tmp8_); + _tmp10_ = g_strconcat (_tmp7_, _tmp9_, NULL); + _g_free0 (fileDestPath); + fileDestPath = _tmp10_; + _g_free0 (_tmp7_); + } else { + const gchar* _tmp11_; + gchar* _tmp12_; + gchar* _tmp13_; + GFileInfo* _tmp14_; + const gchar* _tmp15_ = NULL; + gchar* _tmp16_; + _tmp11_ = destDir; + _tmp12_ = g_strconcat (_tmp11_, "/", NULL); + _tmp13_ = _tmp12_; + _tmp14_ = file; + _tmp15_ = g_file_info_get_name (_tmp14_); + _tmp16_ = g_strconcat (_tmp13_, _tmp15_, NULL); + _g_free0 (fileDestPath); + fileDestPath = _tmp16_; + _g_free0 (_tmp13_); + } + _tmp17_ = fileDestPath; + _tmp18_ = g_file_new_for_path (_tmp17_); + destFile = _tmp18_; + _tmp19_ = destFile; + _tmp20_ = g_file_query_exists (_tmp19_, NULL); + if (_tmp20_) { + const gchar* _tmp21_; + const gchar* _tmp22_; + gchar* _tmp23_ = NULL; + const gchar* _tmp24_; + GFile* _tmp25_ = NULL; + _tmp21_ = fileDestPath; + _tmp22_ = destDir; + _tmp23_ = dayfolder_monitored_directory_addTimestampToFilePath (self, _tmp21_, g_strcmp0 (_tmp22_, "") != 0); + _g_free0 (fileDestPath); + fileDestPath = _tmp23_; + _tmp24_ = fileDestPath; + _tmp25_ = g_file_new_for_path (_tmp24_); + _g_object_unref0 (destFile); + destFile = _tmp25_; + } + _tmp26_ = destFile; + _tmp27_ = g_file_query_exists (_tmp26_, NULL); + if (!_tmp27_) { + const gchar* _tmp28_; + gchar* _tmp29_; + gchar* _tmp30_; + GFileInfo* _tmp31_; + const gchar* _tmp32_ = NULL; + gchar* _tmp33_; + gchar* _tmp34_; + const gchar* _tmp35_; + _tmp28_ = self->priv->_dirPath; + _tmp29_ = g_strconcat (_tmp28_, "/", NULL); + _tmp30_ = _tmp29_; + _tmp31_ = file; + _tmp32_ = g_file_info_get_name (_tmp31_); + _tmp33_ = g_strconcat (_tmp30_, _tmp32_, NULL); + _tmp34_ = _tmp33_; + _tmp35_ = fileDestPath; + g_rename (_tmp34_, _tmp35_); + _g_free0 (_tmp34_); + _g_free0 (_tmp30_); + } + _g_object_unref0 (destFile); + _g_free0 (fileDestPath); +} + + +/** + * Get the file path with the unique timestamp inserted at end of + * filename before file extension. + */ +static glong string_strnlen (gchar* str, glong maxlen) { + glong result = 0L; + gchar* _tmp0_; + glong _tmp1_; + gchar* _tmp2_ = NULL; + gchar* end; + gchar* _tmp3_; + _tmp0_ = str; + _tmp1_ = maxlen; + _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_); + end = _tmp2_; + _tmp3_ = end; + if (_tmp3_ == NULL) { + glong _tmp4_; + _tmp4_ = maxlen; + result = _tmp4_; + return result; + } else { + gchar* _tmp5_; + gchar* _tmp6_; + _tmp5_ = end; + _tmp6_ = str; + result = (glong) (_tmp5_ - _tmp6_); + return result; + } +} + + +static gchar* string_substring (const gchar* self, glong offset, glong len) { + gchar* result = NULL; + glong string_length = 0L; + gboolean _tmp0_ = FALSE; + glong _tmp1_; + gboolean _tmp3_; + glong _tmp9_; + glong _tmp15_; + glong _tmp18_; + glong _tmp19_; + glong _tmp20_; + glong _tmp21_; + glong _tmp22_; + gchar* _tmp23_ = NULL; + g_return_val_if_fail (self != NULL, NULL); + _tmp1_ = offset; + if (_tmp1_ >= ((glong) 0)) { + glong _tmp2_; + _tmp2_ = len; + _tmp0_ = _tmp2_ >= ((glong) 0); + } else { + _tmp0_ = FALSE; + } + _tmp3_ = _tmp0_; + if (_tmp3_) { + glong _tmp4_; + glong _tmp5_; + glong _tmp6_ = 0L; + _tmp4_ = offset; + _tmp5_ = len; + _tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_); + string_length = _tmp6_; + } else { + gint _tmp7_; + gint _tmp8_; + _tmp7_ = strlen (self); + _tmp8_ = _tmp7_; + string_length = (glong) _tmp8_; + } + _tmp9_ = offset; + if (_tmp9_ < ((glong) 0)) { + glong _tmp10_; + glong _tmp11_; + glong _tmp12_; + _tmp10_ = string_length; + _tmp11_ = offset; + offset = _tmp10_ + _tmp11_; + _tmp12_ = offset; + g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL); + } else { + glong _tmp13_; + glong _tmp14_; + _tmp13_ = offset; + _tmp14_ = string_length; + g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL); + } + _tmp15_ = len; + if (_tmp15_ < ((glong) 0)) { + glong _tmp16_; + glong _tmp17_; + _tmp16_ = string_length; + _tmp17_ = offset; + len = _tmp16_ - _tmp17_; + } + _tmp18_ = offset; + _tmp19_ = len; + _tmp20_ = string_length; + g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL); + _tmp21_ = offset; + _tmp22_ = len; + _tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_); + result = _tmp23_; + return result; +} + + +static gint string_last_index_of (const gchar* self, const gchar* needle, gint start_index) { + gint result = 0; + gint _tmp0_; + const gchar* _tmp1_; + gchar* _tmp2_ = NULL; + gchar* _result_; + gchar* _tmp3_; + g_return_val_if_fail (self != NULL, 0); + g_return_val_if_fail (needle != NULL, 0); + _tmp0_ = start_index; + _tmp1_ = needle; + _tmp2_ = g_strrstr (((gchar*) self) + _tmp0_, (gchar*) _tmp1_); + _result_ = _tmp2_; + _tmp3_ = _result_; + if (_tmp3_ != NULL) { + gchar* _tmp4_; + _tmp4_ = _result_; + result = (gint) (_tmp4_ - ((gchar*) self)); + return result; + } else { + result = -1; + return result; + } +} + + +static gchar* dayfolder_monitored_directory_addTimestampToFilePath (dayfolderMonitoredDirectory* self, const gchar* filePath, gboolean isFileExtRule) { + gchar* result = NULL; + GDateTime* _tmp0_; + GDateTime* dateTime; + const gchar* _tmp1_; + const gchar* _tmp2_; + gint _tmp3_ = 0; + gchar* _tmp4_ = NULL; + gchar* pathPrefix; + const gchar* _tmp5_; + const gchar* _tmp6_; + gint _tmp7_ = 0; + gchar* _tmp8_ = NULL; + gchar* fileExt; + gchar* _tmp9_; + gchar* timestamp; + gboolean _tmp10_; + const gchar* _tmp22_; + const gchar* _tmp23_; + gchar* _tmp24_; + gchar* _tmp25_; + const gchar* _tmp26_; + gchar* _tmp27_; + gchar* _tmp28_; + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (filePath != NULL, NULL); + _tmp0_ = g_date_time_new_now_local (); + dateTime = _tmp0_; + _tmp1_ = filePath; + _tmp2_ = filePath; + _tmp3_ = string_last_index_of (_tmp2_, ".", 0); + _tmp4_ = string_substring (_tmp1_, (glong) 0, (glong) _tmp3_); + pathPrefix = _tmp4_; + _tmp5_ = filePath; + _tmp6_ = filePath; + _tmp7_ = string_last_index_of (_tmp6_, ".", 0); + _tmp8_ = string_substring (_tmp5_, (glong) _tmp7_, (glong) (-1)); + fileExt = _tmp8_; + _tmp9_ = g_strdup ("_"); + timestamp = _tmp9_; + _tmp10_ = isFileExtRule; + if (_tmp10_) { + GDateTime* _tmp11_; + gchar* _tmp12_ = NULL; + _tmp11_ = dateTime; + _tmp12_ = g_date_time_format (_tmp11_, "_%Y%m%d_%H%M%S"); + _g_free0 (timestamp); + timestamp = _tmp12_; + } else { + gboolean _tmp13_ = FALSE; + _tmp13_ = dayfolder_monitored_directory_isDailyDfType (self); + if (_tmp13_) { + GDateTime* _tmp14_; + gchar* _tmp15_ = NULL; + _tmp14_ = dateTime; + _tmp15_ = g_date_time_format (_tmp14_, "_%H%M%S"); + _g_free0 (timestamp); + timestamp = _tmp15_; + } else { + gboolean _tmp16_ = FALSE; + gboolean _tmp17_ = FALSE; + gboolean _tmp19_; + _tmp17_ = dayfolder_monitored_directory_isWeeklyDfType (self); + if (_tmp17_) { + _tmp16_ = TRUE; + } else { + gboolean _tmp18_ = FALSE; + _tmp18_ = dayfolder_monitored_directory_isMonthlyDfType (self); + _tmp16_ = _tmp18_; + } + _tmp19_ = _tmp16_; + if (_tmp19_) { + GDateTime* _tmp20_; + gchar* _tmp21_ = NULL; + _tmp20_ = dateTime; + _tmp21_ = g_date_time_format (_tmp20_, "_%d_%H%M%S"); + _g_free0 (timestamp); + timestamp = _tmp21_; + } + } + } + _tmp22_ = pathPrefix; + _tmp23_ = timestamp; + _tmp24_ = g_strconcat (_tmp22_, _tmp23_, NULL); + _tmp25_ = _tmp24_; + _tmp26_ = fileExt; + _tmp27_ = g_strconcat (_tmp25_, _tmp26_, NULL); + _tmp28_ = _tmp27_; + _g_free0 (_tmp25_); + result = _tmp28_; + _g_free0 (timestamp); + _g_free0 (fileExt); + _g_free0 (pathPrefix); + _g_date_time_unref0 (dateTime); + return result; +} + + +const gchar* dayfolder_monitored_directory_get_dirPath (dayfolderMonitoredDirectory* self) { + const gchar* result; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = self->priv->_dirPath; + result = _tmp0_; + return result; +} + + +static void dayfolder_monitored_directory_set_dirPath (dayfolderMonitoredDirectory* self, const gchar* value) { + const gchar* _tmp0_; + gchar* _tmp1_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + _tmp1_ = g_strdup (_tmp0_); + _g_free0 (self->priv->_dirPath); + self->priv->_dirPath = _tmp1_; + g_object_notify ((GObject *) self, "dirPath"); +} + + +const gchar* dayfolder_monitored_directory_get_fileExtRulesGroup (dayfolderMonitoredDirectory* self) { + const gchar* result; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = self->priv->_fileExtRulesGroup; + result = _tmp0_; + return result; +} + + +static void dayfolder_monitored_directory_set_fileExtRulesGroup (dayfolderMonitoredDirectory* self, const gchar* value) { + const gchar* _tmp0_; + gchar* _tmp1_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + _tmp1_ = g_strdup (_tmp0_); + _g_free0 (self->priv->_fileExtRulesGroup); + self->priv->_fileExtRulesGroup = _tmp1_; + g_object_notify ((GObject *) self, "fileExtRulesGroup"); +} + + +gboolean dayfolder_monitored_directory_get_useDayFolder (dayfolderMonitoredDirectory* self) { + gboolean result; + gboolean _tmp0_; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = self->priv->_useDayFolder; + result = _tmp0_; + return result; +} + + +void dayfolder_monitored_directory_set_useDayFolder (dayfolderMonitoredDirectory* self, gboolean value) { + gboolean _tmp0_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + self->priv->_useDayFolder = _tmp0_; + g_object_notify ((GObject *) self, "useDayFolder"); +} + + +const gchar* dayfolder_monitored_directory_get_dfRootPath (dayfolderMonitoredDirectory* self) { + const gchar* result; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = self->priv->_dfRootPath; + result = _tmp0_; + return result; +} + + +static void dayfolder_monitored_directory_set_dfRootPath (dayfolderMonitoredDirectory* self, const gchar* value) { + const gchar* _tmp0_; + gchar* _tmp1_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + _tmp1_ = g_strdup (_tmp0_); + _g_free0 (self->priv->_dfRootPath); + self->priv->_dfRootPath = _tmp1_; + g_object_notify ((GObject *) self, "dfRootPath"); +} + + +gboolean dayfolder_monitored_directory_get_moveDirs (dayfolderMonitoredDirectory* self) { + gboolean result; + gboolean _tmp0_; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = self->priv->_moveDirs; + result = _tmp0_; + return result; +} + + +void dayfolder_monitored_directory_set_moveDirs (dayfolderMonitoredDirectory* self, gboolean value) { + gboolean _tmp0_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + self->priv->_moveDirs = _tmp0_; + g_object_notify ((GObject *) self, "moveDirs"); +} + + +const gchar* dayfolder_monitored_directory_get_dfType (dayfolderMonitoredDirectory* self) { + const gchar* result; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = self->priv->_dfType; + result = _tmp0_; + return result; +} + + +static void dayfolder_monitored_directory_set_dfType (dayfolderMonitoredDirectory* self, const gchar* value) { + const gchar* _tmp0_; + gchar* _tmp1_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + _tmp1_ = g_strdup (_tmp0_); + _g_free0 (self->priv->_dfType); + self->priv->_dfType = _tmp1_; + g_object_notify ((GObject *) self, "dfType"); +} + + +const gchar* dayfolder_monitored_directory_get_dayFolderDirPath (dayfolderMonitoredDirectory* self) { + const gchar* result; + const gchar* _tmp0_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = self->priv->_dayFolderDirPath; + result = _tmp0_; + return result; +} + + +static void dayfolder_monitored_directory_set_dayFolderDirPath (dayfolderMonitoredDirectory* self, const gchar* value) { + const gchar* _tmp0_; + gchar* _tmp1_; + g_return_if_fail (self != NULL); + _tmp0_ = value; + _tmp1_ = g_strdup (_tmp0_); + _g_free0 (self->priv->_dayFolderDirPath); + self->priv->_dayFolderDirPath = _tmp1_; + g_object_notify ((GObject *) self, "dayFolderDirPath"); +} + + +static void dayfolder_monitored_directory_class_init (dayfolderMonitoredDirectoryClass * klass) { + dayfolder_monitored_directory_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (dayfolderMonitoredDirectoryPrivate)); + G_OBJECT_CLASS (klass)->get_property = _vala_dayfolder_monitored_directory_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_dayfolder_monitored_directory_set_property; + G_OBJECT_CLASS (klass)->finalize = dayfolder_monitored_directory_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_DIR_PATH, g_param_spec_string ("dirPath", "dirPath", "dirPath", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_FILE_EXT_RULES_GROUP, g_param_spec_string ("fileExtRulesGroup", "fileExtRulesGroup", "fileExtRulesGroup", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_USE_DAY_FOLDER, g_param_spec_boolean ("useDayFolder", "useDayFolder", "useDayFolder", TRUE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_DF_ROOT_PATH, g_param_spec_string ("dfRootPath", "dfRootPath", "dfRootPath", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_MOVE_DIRS, g_param_spec_boolean ("moveDirs", "moveDirs", "moveDirs", TRUE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_DF_TYPE, g_param_spec_string ("dfType", "dfType", "dfType", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_MONITORED_DIRECTORY_DAY_FOLDER_DIR_PATH, g_param_spec_string ("dayFolderDirPath", "dayFolderDirPath", "dayFolderDirPath", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); +} + + +static void dayfolder_monitored_directory_instance_init (dayfolderMonitoredDirectory * self) { + self->priv = DAYFOLDER_MONITORED_DIRECTORY_GET_PRIVATE (self); + self->priv->_useDayFolder = TRUE; + self->priv->_moveDirs = TRUE; +} + + +static void dayfolder_monitored_directory_finalize (GObject* obj) { + dayfolderMonitoredDirectory * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory); + _g_free0 (self->priv->_dirPath); + _g_free0 (self->priv->_fileExtRulesGroup); + _g_free0 (self->priv->_dfRootPath); + _g_free0 (self->priv->_dfType); + _g_free0 (self->priv->_dayFolderDirPath); + _g_object_unref0 (self->priv->rulesMap); + G_OBJECT_CLASS (dayfolder_monitored_directory_parent_class)->finalize (obj); +} + + +/** + * This class will manage all data in the settings file for a monitored directory. + */ +GType dayfolder_monitored_directory_get_type (void) { + static volatile gsize dayfolder_monitored_directory_type_id__volatile = 0; + if (g_once_init_enter (&dayfolder_monitored_directory_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (dayfolderMonitoredDirectoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dayfolder_monitored_directory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (dayfolderMonitoredDirectory), 0, (GInstanceInitFunc) dayfolder_monitored_directory_instance_init, NULL }; + GType dayfolder_monitored_directory_type_id; + dayfolder_monitored_directory_type_id = g_type_register_static (G_TYPE_OBJECT, "dayfolderMonitoredDirectory", &g_define_type_info, 0); + g_once_init_leave (&dayfolder_monitored_directory_type_id__volatile, dayfolder_monitored_directory_type_id); + } + return dayfolder_monitored_directory_type_id__volatile; +} + + +static void _vala_dayfolder_monitored_directory_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + dayfolderMonitoredDirectory * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory); + switch (property_id) { + case DAYFOLDER_MONITORED_DIRECTORY_DIR_PATH: + g_value_set_string (value, dayfolder_monitored_directory_get_dirPath (self)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_FILE_EXT_RULES_GROUP: + g_value_set_string (value, dayfolder_monitored_directory_get_fileExtRulesGroup (self)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_USE_DAY_FOLDER: + g_value_set_boolean (value, dayfolder_monitored_directory_get_useDayFolder (self)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_DF_ROOT_PATH: + g_value_set_string (value, dayfolder_monitored_directory_get_dfRootPath (self)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_MOVE_DIRS: + g_value_set_boolean (value, dayfolder_monitored_directory_get_moveDirs (self)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_DF_TYPE: + g_value_set_string (value, dayfolder_monitored_directory_get_dfType (self)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_DAY_FOLDER_DIR_PATH: + g_value_set_string (value, dayfolder_monitored_directory_get_dayFolderDirPath (self)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void _vala_dayfolder_monitored_directory_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + dayfolderMonitoredDirectory * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory); + switch (property_id) { + case DAYFOLDER_MONITORED_DIRECTORY_DIR_PATH: + dayfolder_monitored_directory_set_dirPath (self, g_value_get_string (value)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_FILE_EXT_RULES_GROUP: + dayfolder_monitored_directory_set_fileExtRulesGroup (self, g_value_get_string (value)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_USE_DAY_FOLDER: + dayfolder_monitored_directory_set_useDayFolder (self, g_value_get_boolean (value)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_DF_ROOT_PATH: + dayfolder_monitored_directory_set_dfRootPath (self, g_value_get_string (value)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_MOVE_DIRS: + dayfolder_monitored_directory_set_moveDirs (self, g_value_get_boolean (value)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_DF_TYPE: + dayfolder_monitored_directory_set_dfType (self, g_value_get_string (value)); + break; + case DAYFOLDER_MONITORED_DIRECTORY_DAY_FOLDER_DIR_PATH: + dayfolder_monitored_directory_set_dayFolderDirPath (self, g_value_get_string (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + + diff -Nru dayfolder-1.4.1/src/MonitoredDirectory.vala dayfolder-2.0.0/src/MonitoredDirectory.vala --- dayfolder-1.4.1/src/MonitoredDirectory.vala 1970-01-01 00:00:00.000000000 +0000 +++ dayfolder-2.0.0/src/MonitoredDirectory.vala 2013-05-11 22:20:02.000000000 +0000 @@ -0,0 +1,312 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + +using zystem; + +using Gee; + +namespace dayfolder { + +/** + * This class will manage all data in the settings file for a monitored directory. + */ +class MonitoredDirectory : Object { + + // Settings key names + public static const string useDayFolderKey = "useDayFolder"; + public static const string dfRootPathKey = "dfRootPath"; + public static const string sourcePathKey = "sourcePath"; + public static const string moveDirsKey = "moveDirs"; + public static const string dfTypeKey = "dfType"; + + // Settings variables + public string dirPath { get; private set; } + public string fileExtRulesGroup { get; private set; } + public bool useDayFolder { get; set; default = true; } + public string dfRootPath { get; private set; } + public bool moveDirs { get; set; default = true; } + public string dfType { get; private set; } + + // Other variables + public string dayFolderDirPath { get; private set; } + private HashMap rulesMap; + + /** + * Constructor. + */ + public MonitoredDirectory(string dirPath, bool useDayFolder, string dfRootPath, bool moveDirs, string dfType) { + this.dirPath = dirPath; + this.fileExtRulesGroup = dirPath + "FileExtRules"; + this.useDayFolder = useDayFolder; + this.dfRootPath = dfRootPath; + this.moveDirs = moveDirs; + this.dfType = dfType; + this.rulesMap = new HashMap(); + } + + /** + * Set the dfRootPath. + */ + public void setDfRootPath(string rootPath) { + this.dfRootPath = rootPath; + } + + /** + * Set the dfType. + */ + public void setDfType(string type) { + this.dfType = type; + } + + /** + * Add a FileRule for this monitored directory. + */ + public void addFileRule(string criteria, string destDir) { + var rule = new FileContainsRule(criteria, destDir); + this.rulesMap.set(rule.criteriaString, rule); + } + + /** + * Remove the FileRule. + */ + public void removeFileRule(string criteria) { + this.rulesMap.unset(criteria); + } + + /** + * Returns list of all file rules. + */ + public ArrayList getFileRules() { + Zystem.debug("In MonitoredDirectory.getFileRules()"); + ArrayList list = new ArrayList(); + + foreach (DfRule rule in rulesMap.values) { + list.add(rule); + } + + return list; + } + + /** + * Return the FileRule's destination. + */ + public string getFileRuleDest(string criteria) { + return rulesMap.get(criteria).destinationDir; + } + + /** + * Return if a rule exists for a file extension exists. + */ + public bool ruleExistsForCriteria(string criteria) { + return this.rulesMap.has_key(criteria); + } + + /** + * Sets dayFolderDirPath variable to today's dayFolder directory. This is based on the dfType, + * and determines the path to the daily, weekly, or monthly folder. + */ + private void setDayFolderDirPath() { + Zystem.debug("Generating DayFolderDirPath for " + dirPath); + + DateTime dateTime = new GLib.DateTime.now_local(); + string directoryName = ""; + + if (this.dfType == UserData.dfTypeDaily) { + // Get the dayfolder directory name from today's date + directoryName = dateTime.format("%Y-%m-%d"); + } else if (this.dfType == UserData.dfTypeWeekly) { + dateTime = dateTime.add_days(0 - dateTime.get_day_of_week()); + directoryName = dateTime.format("%Y-%m-%d to ") + dateTime.add_days(6).format("%Y-%m-%d"); + } else if (this.dfType == UserData.dfTypeMonthly) { + directoryName = dateTime.add_days(1 - dateTime.get_day_of_month()).format("%Y-%m"); + } + + dayFolderDirPath = GLib.Path.build_path(GLib.Path.DIR_SEPARATOR_S, this.dfRootPath, directoryName); + } + + /** + * + */ + public bool isDailyDfType() { + return dfType == UserData.dfTypeDaily; + } + + public bool isWeeklyDfType() { + return dfType == UserData.dfTypeWeekly; + } + + public bool isMonthlyDfType() { + return dfType == UserData.dfTypeMonthly; + } + + + /** + * Debug method. + */ + public void printDebug() { + Zystem.debug("Monitored Directory: " + dirPath); + + Zystem.debug("FileRules: "); + foreach (DfRule rule in rulesMap.values) { + Zystem.debug(rule.criteriaString); + } + } + + + + + + + + /********************************************* + * + ******************************************/ + + + + /** + * Make sure that today's folder is created, then clean the desktop. + */ + public void runCleanup() { + Zystem.debug("In MonitoredDirectory.runCleanup() for " + this.dirPath); + + this.setDayFolderDirPath(); + + createTodaysFolder(); + + try { + File desktop = File.new_for_path(this.dirPath); + FileEnumerator enumerator = desktop.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME, 0); + FileInfo fileInfo; + + // Go through the files + while((fileInfo = enumerator.next_file()) != null) { + processFile(fileInfo); + } + } catch(Error e) { + stderr.printf ("Error in DayFolder.cleanDesktop(): %s\n", e.message); + } + + Zystem.debug("Finished cleaning directory"); + } + + /** + * Create today's folder in the DayFolder directory. + */ + private void createTodaysFolder() { + // Create the directory. This method doesn't care if it exists already or not. + GLib.DirUtils.create_with_parents(dayFolderDirPath, 0775); + } + + /** + * Process the passed file. + */ + private void processFile(FileInfo file) { + Zystem.debugFileInfo(file); + + /* Here'e what we can do. + * Go through all rules, if it's a match, process the file, or else keep going. + * After all rules have been gone through, if none matched, just do default move. + */ + + bool fileProcessed = false; + + if (file.get_file_type() == FileType.REGULAR) { + foreach (DfRule rule in rulesMap.values) { + fileProcessed = rule.processFile(file, this.dirPath); + if (fileProcessed) { + Zystem.debug(file.get_name() + " was processed."); + break; + } else { + Zystem.debug(file.get_name() + " was NOT processed."); + } + } + } + + if (!fileProcessed && this.fileShouldMoveToDayFolder(file)) { + Zystem.debug("Moving regular file to DayFolder directory"); + moveFile(file); + } + } + + /** + * + */ + private bool fileShouldMoveToDayFolder(FileInfo file) { + bool result = false; + if (file.get_file_type() == FileType.REGULAR && this.useDayFolder) { + result = true; + } else if (file.get_file_type() == FileType.DIRECTORY && this.useDayFolder && this.moveDirs) { + result = true; + } + return result; + } + + /** + * Actually move the file to where it's supposed to go. + */ + public void moveFile(FileInfo file, string destDir = "") { + Zystem.debug("dayFolderDirPath is: " + dayFolderDirPath); + + string fileDestPath = ""; + + if (destDir == "") { + fileDestPath = dayFolderDirPath + "/" + file.get_name(); + } else { + fileDestPath = destDir + "/" + file.get_name(); + } + var destFile = File.new_for_path(fileDestPath); + + // If file already exists, add timestamp to file name + if (destFile.query_exists()) { + fileDestPath = addTimestampToFilePath(fileDestPath, (destDir != "")); + destFile = File.new_for_path(fileDestPath); + } + + // Only move the file if destination file does not exist. We don't want to write over any files. + if (!destFile.query_exists()) { + GLib.FileUtils.rename(dirPath + "/" + file.get_name(), fileDestPath); + } + } + + /** + * Get the file path with the unique timestamp inserted at end of + * filename before file extension. + */ + private string addTimestampToFilePath(string filePath, bool isFileExtRule) { + DateTime dateTime = new GLib.DateTime.now_local(); + + string pathPrefix = filePath.substring(0, filePath.last_index_of(".")); + string fileExt = filePath.substring(filePath.last_index_of(".")); + string timestamp = "_"; + + if (isFileExtRule) { + timestamp = dateTime.format("_%Y%m%d_%H%M%S"); + } else if (isDailyDfType()) { + timestamp = dateTime.format("_%H%M%S"); + } else if (isWeeklyDfType() || isMonthlyDfType()) { + timestamp = dateTime.format("_%d_%H%M%S"); + } + + return pathPrefix + timestamp + fileExt; + } + +} + +} diff -Nru dayfolder-1.4.1/src/Rules.c dayfolder-2.0.0/src/Rules.c --- dayfolder-1.4.1/src/Rules.c 2012-05-20 17:33:24.000000000 +0000 +++ dayfolder-2.0.0/src/Rules.c 2013-05-11 22:28:22.000000000 +0000 @@ -1,177 +1,566 @@ -/* Rules.c generated by valac 0.14.2, the Vala compiler +/* Rules.c generated by valac 0.18.1, the Vala compiler * generated from Rules.vala, do not modify */ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ #include #include +#include #include #include -#include +#include -#define DAYFOLDER_TYPE_FILE_EXT_RULE (dayfolder_file_ext_rule_get_type ()) -#define DAYFOLDER_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRule)) -#define DAYFOLDER_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) -#define DAYFOLDER_IS_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_IS_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_FILE_EXT_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) - -typedef struct _dayfolderFileExtRule dayfolderFileExtRule; -typedef struct _dayfolderFileExtRuleClass dayfolderFileExtRuleClass; -typedef struct _dayfolderFileExtRulePrivate dayfolderFileExtRulePrivate; +#define DAYFOLDER_TYPE_DF_RULE (dayfolder_df_rule_get_type ()) +#define DAYFOLDER_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRule)) +#define DAYFOLDER_IS_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DF_RULE)) +#define DAYFOLDER_DF_RULE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRuleIface)) + +typedef struct _dayfolderDfRule dayfolderDfRule; +typedef struct _dayfolderDfRuleIface dayfolderDfRuleIface; + +#define DAYFOLDER_TYPE_FILE_CONTAINS_RULE (dayfolder_file_contains_rule_get_type ()) +#define DAYFOLDER_FILE_CONTAINS_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRule)) +#define DAYFOLDER_FILE_CONTAINS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRuleClass)) +#define DAYFOLDER_IS_FILE_CONTAINS_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE)) +#define DAYFOLDER_IS_FILE_CONTAINS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_CONTAINS_RULE)) +#define DAYFOLDER_FILE_CONTAINS_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRuleClass)) + +typedef struct _dayfolderFileContainsRule dayfolderFileContainsRule; +typedef struct _dayfolderFileContainsRuleClass dayfolderFileContainsRuleClass; +typedef struct _dayfolderFileContainsRulePrivate dayfolderFileContainsRulePrivate; #define _g_free0(var) (var = (g_free (var), NULL)) +#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL))) -struct _dayfolderFileExtRule { +struct _dayfolderDfRuleIface { + GTypeInterface parent_iface; + gboolean (*processFile) (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); + const gchar* (*get_criteriaString) (dayfolderDfRule* self); + void (*set_criteriaString) (dayfolderDfRule* self, const gchar* value); + const gchar* (*get_destinationDir) (dayfolderDfRule* self); + void (*set_destinationDir) (dayfolderDfRule* self, const gchar* value); +}; + +struct _dayfolderFileContainsRule { GObject parent_instance; - dayfolderFileExtRulePrivate * priv; + dayfolderFileContainsRulePrivate * priv; }; -struct _dayfolderFileExtRuleClass { +struct _dayfolderFileContainsRuleClass { GObjectClass parent_class; }; -struct _dayfolderFileExtRulePrivate { - gchar* _fileExt; +struct _dayfolderFileContainsRulePrivate { + gchar* _criteriaString; gchar* _destinationDir; }; -static gpointer dayfolder_file_ext_rule_parent_class = NULL; +static gpointer dayfolder_file_contains_rule_parent_class = NULL; +static dayfolderDfRuleIface* dayfolder_file_contains_rule_dayfolder_df_rule_parent_iface = NULL; -GType dayfolder_file_ext_rule_get_type (void) G_GNUC_CONST; -#define DAYFOLDER_FILE_EXT_RULE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRulePrivate)) +GType dayfolder_df_rule_get_type (void) G_GNUC_CONST; +gboolean dayfolder_df_rule_processFile (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); +const gchar* dayfolder_df_rule_get_criteriaString (dayfolderDfRule* self); +void dayfolder_df_rule_set_criteriaString (dayfolderDfRule* self, const gchar* value); +const gchar* dayfolder_df_rule_get_destinationDir (dayfolderDfRule* self); +void dayfolder_df_rule_set_destinationDir (dayfolderDfRule* self, const gchar* value); +GType dayfolder_file_contains_rule_get_type (void) G_GNUC_CONST; +#define DAYFOLDER_FILE_CONTAINS_RULE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRulePrivate)) enum { - DAYFOLDER_FILE_EXT_RULE_DUMMY_PROPERTY, - DAYFOLDER_FILE_EXT_RULE_FILE_EXT, - DAYFOLDER_FILE_EXT_RULE_DESTINATION_DIR + DAYFOLDER_FILE_CONTAINS_RULE_DUMMY_PROPERTY, + DAYFOLDER_FILE_CONTAINS_RULE_CRITERIA_STRING, + DAYFOLDER_FILE_CONTAINS_RULE_DESTINATION_DIR }; -dayfolderFileExtRule* dayfolder_file_ext_rule_new (const gchar* fileExt, const gchar* destinationDir); -dayfolderFileExtRule* dayfolder_file_ext_rule_construct (GType object_type, const gchar* fileExt, const gchar* destinationDir); -static void dayfolder_file_ext_rule_set_fileExt (dayfolderFileExtRule* self, const gchar* value); -static void dayfolder_file_ext_rule_set_destinationDir (dayfolderFileExtRule* self, const gchar* value); -void dayfolder_file_ext_rule_moveFile (dayfolderFileExtRule* self, GFileInfo* file); -void dayfolder_file_utility_createFolder (const gchar* dirPath); -const gchar* dayfolder_file_ext_rule_get_destinationDir (dayfolderFileExtRule* self); -void dayfolder_file_utility_moveFile (GFileInfo* file, const gchar* destDir, gboolean isFileExtRule); -gboolean dayfolder_file_ext_rule_isRuleForExt (dayfolderFileExtRule* self, const gchar* ext); -const gchar* dayfolder_file_ext_rule_get_fileExt (dayfolderFileExtRule* self); -gchar* dayfolder_file_ext_rule_getFileExt (dayfolderFileExtRule* self); -gchar* dayfolder_file_ext_rule_getDestinationDir (dayfolderFileExtRule* self); -static void dayfolder_file_ext_rule_finalize (GObject* obj); -static void _vala_dayfolder_file_ext_rule_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); -static void _vala_dayfolder_file_ext_rule_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); +dayfolderFileContainsRule* dayfolder_file_contains_rule_new (const gchar* criteria, const gchar* destinationDir); +dayfolderFileContainsRule* dayfolder_file_contains_rule_construct (GType object_type, const gchar* criteria, const gchar* destinationDir); +static gboolean dayfolder_file_contains_rule_real_processFile (dayfolderDfRule* base, GFileInfo* file, const gchar* dirPath); +static void dayfolder_file_contains_rule_moveFile (dayfolderFileContainsRule* self, GFileInfo* file, const gchar* dirPath); +void zystem_zystem_debug (const gchar* s); +static gchar* dayfolder_file_contains_rule_addTimestampToFilePath (dayfolderFileContainsRule* self, const gchar* filePath); +gboolean dayfolder_file_contains_rule_isRuleForFile (dayfolderFileContainsRule* self, const gchar* fileName); +gchar* dayfolder_file_contains_rule_getDestinationDir (dayfolderFileContainsRule* self); +static void dayfolder_file_contains_rule_finalize (GObject* obj); +static void _vala_dayfolder_file_contains_rule_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void _vala_dayfolder_file_contains_rule_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); + + +gboolean dayfolder_df_rule_processFile (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath) { + g_return_val_if_fail (self != NULL, FALSE); + return DAYFOLDER_DF_RULE_GET_INTERFACE (self)->processFile (self, file, dirPath); +} + + +const gchar* dayfolder_df_rule_get_criteriaString (dayfolderDfRule* self) { + g_return_val_if_fail (self != NULL, NULL); + return DAYFOLDER_DF_RULE_GET_INTERFACE (self)->get_criteriaString (self); +} + + +void dayfolder_df_rule_set_criteriaString (dayfolderDfRule* self, const gchar* value) { + g_return_if_fail (self != NULL); + DAYFOLDER_DF_RULE_GET_INTERFACE (self)->set_criteriaString (self, value); +} + + +const gchar* dayfolder_df_rule_get_destinationDir (dayfolderDfRule* self) { + g_return_val_if_fail (self != NULL, NULL); + return DAYFOLDER_DF_RULE_GET_INTERFACE (self)->get_destinationDir (self); +} + + +void dayfolder_df_rule_set_destinationDir (dayfolderDfRule* self, const gchar* value) { + g_return_if_fail (self != NULL); + DAYFOLDER_DF_RULE_GET_INTERFACE (self)->set_destinationDir (self, value); +} + + +static void dayfolder_df_rule_base_init (dayfolderDfRuleIface * iface) { + static gboolean initialized = FALSE; + if (!initialized) { + initialized = TRUE; + g_object_interface_install_property (iface, g_param_spec_string ("criteriaString", "criteriaString", "criteriaString", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_interface_install_property (iface, g_param_spec_string ("destinationDir", "destinationDir", "destinationDir", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + } +} + + +GType dayfolder_df_rule_get_type (void) { + static volatile gsize dayfolder_df_rule_type_id__volatile = 0; + if (g_once_init_enter (&dayfolder_df_rule_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (dayfolderDfRuleIface), (GBaseInitFunc) dayfolder_df_rule_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; + GType dayfolder_df_rule_type_id; + dayfolder_df_rule_type_id = g_type_register_static (G_TYPE_INTERFACE, "dayfolderDfRule", &g_define_type_info, 0); + g_type_interface_add_prerequisite (dayfolder_df_rule_type_id, G_TYPE_OBJECT); + g_once_init_leave (&dayfolder_df_rule_type_id__volatile, dayfolder_df_rule_type_id); + } + return dayfolder_df_rule_type_id__volatile; +} /** * Constructor. */ -dayfolderFileExtRule* dayfolder_file_ext_rule_construct (GType object_type, const gchar* fileExt, const gchar* destinationDir) { - dayfolderFileExtRule * self = NULL; +dayfolderFileContainsRule* dayfolder_file_contains_rule_construct (GType object_type, const gchar* criteria, const gchar* destinationDir) { + dayfolderFileContainsRule * self = NULL; const gchar* _tmp0_; const gchar* _tmp1_; - g_return_val_if_fail (fileExt != NULL, NULL); + g_return_val_if_fail (criteria != NULL, NULL); g_return_val_if_fail (destinationDir != NULL, NULL); - self = (dayfolderFileExtRule*) g_object_new (object_type, NULL); - _tmp0_ = fileExt; - dayfolder_file_ext_rule_set_fileExt (self, _tmp0_); + self = (dayfolderFileContainsRule*) g_object_new (object_type, NULL); + _tmp0_ = criteria; + dayfolder_df_rule_set_criteriaString ((dayfolderDfRule*) self, _tmp0_); _tmp1_ = destinationDir; - dayfolder_file_ext_rule_set_destinationDir (self, _tmp1_); + dayfolder_df_rule_set_destinationDir ((dayfolderDfRule*) self, _tmp1_); return self; } -dayfolderFileExtRule* dayfolder_file_ext_rule_new (const gchar* fileExt, const gchar* destinationDir) { - return dayfolder_file_ext_rule_construct (DAYFOLDER_TYPE_FILE_EXT_RULE, fileExt, destinationDir); +dayfolderFileContainsRule* dayfolder_file_contains_rule_new (const gchar* criteria, const gchar* destinationDir) { + return dayfolder_file_contains_rule_construct (DAYFOLDER_TYPE_FILE_CONTAINS_RULE, criteria, destinationDir); } -void dayfolder_file_ext_rule_moveFile (dayfolderFileExtRule* self, GFileInfo* file) { +static gboolean string_contains (const gchar* self, const gchar* needle) { + gboolean result = FALSE; const gchar* _tmp0_; - GFileInfo* _tmp1_; + gchar* _tmp1_ = NULL; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (needle != NULL, FALSE); + _tmp0_ = needle; + _tmp1_ = strstr ((gchar*) self, (gchar*) _tmp0_); + result = _tmp1_ != NULL; + return result; +} + + +static gboolean dayfolder_file_contains_rule_real_processFile (dayfolderDfRule* base, GFileInfo* file, const gchar* dirPath) { + dayfolderFileContainsRule * self; + gboolean result = FALSE; + gboolean match; + GFileInfo* _tmp0_; + const gchar* _tmp1_ = NULL; + const gchar* _tmp2_; + const gchar* _tmp3_; + gboolean _tmp4_ = FALSE; + self = (dayfolderFileContainsRule*) base; + g_return_val_if_fail (file != NULL, FALSE); + g_return_val_if_fail (dirPath != NULL, FALSE); + match = FALSE; + _tmp0_ = file; + _tmp1_ = g_file_info_get_name (_tmp0_); + _tmp2_ = dayfolder_df_rule_get_criteriaString ((dayfolderDfRule*) self); + _tmp3_ = _tmp2_; + _tmp4_ = string_contains (_tmp1_, _tmp3_); + if (_tmp4_) { + GFileInfo* _tmp5_; + const gchar* _tmp6_; + match = TRUE; + _tmp5_ = file; + _tmp6_ = dirPath; + dayfolder_file_contains_rule_moveFile (self, _tmp5_, _tmp6_); + } + result = match; + return result; +} + + +/** + * Actually move the file to where it's supposed to go. + */ +static void dayfolder_file_contains_rule_moveFile (dayfolderFileContainsRule* self, GFileInfo* file, const gchar* dirPath) { + gchar* _tmp0_; + gchar* fileDestPath; + const gchar* _tmp1_; const gchar* _tmp2_; + gchar* _tmp3_; + gchar* _tmp4_; + GFileInfo* _tmp5_; + const gchar* _tmp6_ = NULL; + gchar* _tmp7_; + const gchar* _tmp8_; + GFile* _tmp9_ = NULL; + GFile* destFile; + GFile* _tmp10_; + gboolean _tmp11_ = FALSE; + GFile* _tmp16_; + gboolean _tmp17_ = FALSE; g_return_if_fail (self != NULL); g_return_if_fail (file != NULL); - _tmp0_ = self->priv->_destinationDir; - dayfolder_file_utility_createFolder (_tmp0_); - _tmp1_ = file; - _tmp2_ = self->priv->_destinationDir; - dayfolder_file_utility_moveFile (_tmp1_, _tmp2_, TRUE); + g_return_if_fail (dirPath != NULL); + zystem_zystem_debug ("Moving file based on Rule"); + _tmp0_ = g_strdup (""); + fileDestPath = _tmp0_; + _tmp1_ = dayfolder_df_rule_get_destinationDir ((dayfolderDfRule*) self); + _tmp2_ = _tmp1_; + _tmp3_ = g_strconcat (_tmp2_, "/", NULL); + _tmp4_ = _tmp3_; + _tmp5_ = file; + _tmp6_ = g_file_info_get_name (_tmp5_); + _tmp7_ = g_strconcat (_tmp4_, _tmp6_, NULL); + _g_free0 (fileDestPath); + fileDestPath = _tmp7_; + _g_free0 (_tmp4_); + _tmp8_ = fileDestPath; + _tmp9_ = g_file_new_for_path (_tmp8_); + destFile = _tmp9_; + _tmp10_ = destFile; + _tmp11_ = g_file_query_exists (_tmp10_, NULL); + if (_tmp11_) { + const gchar* _tmp12_; + gchar* _tmp13_ = NULL; + const gchar* _tmp14_; + GFile* _tmp15_ = NULL; + _tmp12_ = fileDestPath; + _tmp13_ = dayfolder_file_contains_rule_addTimestampToFilePath (self, _tmp12_); + _g_free0 (fileDestPath); + fileDestPath = _tmp13_; + _tmp14_ = fileDestPath; + _tmp15_ = g_file_new_for_path (_tmp14_); + _g_object_unref0 (destFile); + destFile = _tmp15_; + } + _tmp16_ = destFile; + _tmp17_ = g_file_query_exists (_tmp16_, NULL); + if (!_tmp17_) { + const gchar* _tmp18_; + gchar* _tmp19_; + gchar* _tmp20_; + GFileInfo* _tmp21_; + const gchar* _tmp22_ = NULL; + gchar* _tmp23_; + gchar* _tmp24_; + const gchar* _tmp25_; + _tmp18_ = dirPath; + _tmp19_ = g_strconcat (_tmp18_, "/", NULL); + _tmp20_ = _tmp19_; + _tmp21_ = file; + _tmp22_ = g_file_info_get_name (_tmp21_); + _tmp23_ = g_strconcat (_tmp20_, _tmp22_, NULL); + _tmp24_ = _tmp23_; + _tmp25_ = fileDestPath; + g_rename (_tmp24_, _tmp25_); + _g_free0 (_tmp24_); + _g_free0 (_tmp20_); + } + _g_object_unref0 (destFile); + _g_free0 (fileDestPath); } -gboolean dayfolder_file_ext_rule_isRuleForExt (dayfolderFileExtRule* self, const gchar* ext) { - gboolean result = FALSE; - const gchar* _tmp0_; - const gchar* _tmp1_; - g_return_val_if_fail (self != NULL, FALSE); - g_return_val_if_fail (ext != NULL, FALSE); - _tmp0_ = self->priv->_fileExt; - _tmp1_ = ext; - result = g_strcmp0 (_tmp0_, _tmp1_) == 0; +/** + * Get the file path with the unique timestamp inserted at end of + * filename before file extension. + */ +static glong string_strnlen (gchar* str, glong maxlen) { + glong result = 0L; + gchar* _tmp0_; + glong _tmp1_; + gchar* _tmp2_ = NULL; + gchar* end; + gchar* _tmp3_; + _tmp0_ = str; + _tmp1_ = maxlen; + _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_); + end = _tmp2_; + _tmp3_ = end; + if (_tmp3_ == NULL) { + glong _tmp4_; + _tmp4_ = maxlen; + result = _tmp4_; + return result; + } else { + gchar* _tmp5_; + gchar* _tmp6_; + _tmp5_ = end; + _tmp6_ = str; + result = (glong) (_tmp5_ - _tmp6_); + return result; + } +} + + +static gchar* string_substring (const gchar* self, glong offset, glong len) { + gchar* result = NULL; + glong string_length = 0L; + gboolean _tmp0_ = FALSE; + glong _tmp1_; + gboolean _tmp3_; + glong _tmp9_; + glong _tmp15_; + glong _tmp18_; + glong _tmp19_; + glong _tmp20_; + glong _tmp21_; + glong _tmp22_; + gchar* _tmp23_ = NULL; + g_return_val_if_fail (self != NULL, NULL); + _tmp1_ = offset; + if (_tmp1_ >= ((glong) 0)) { + glong _tmp2_; + _tmp2_ = len; + _tmp0_ = _tmp2_ >= ((glong) 0); + } else { + _tmp0_ = FALSE; + } + _tmp3_ = _tmp0_; + if (_tmp3_) { + glong _tmp4_; + glong _tmp5_; + glong _tmp6_ = 0L; + _tmp4_ = offset; + _tmp5_ = len; + _tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_); + string_length = _tmp6_; + } else { + gint _tmp7_; + gint _tmp8_; + _tmp7_ = strlen (self); + _tmp8_ = _tmp7_; + string_length = (glong) _tmp8_; + } + _tmp9_ = offset; + if (_tmp9_ < ((glong) 0)) { + glong _tmp10_; + glong _tmp11_; + glong _tmp12_; + _tmp10_ = string_length; + _tmp11_ = offset; + offset = _tmp10_ + _tmp11_; + _tmp12_ = offset; + g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL); + } else { + glong _tmp13_; + glong _tmp14_; + _tmp13_ = offset; + _tmp14_ = string_length; + g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL); + } + _tmp15_ = len; + if (_tmp15_ < ((glong) 0)) { + glong _tmp16_; + glong _tmp17_; + _tmp16_ = string_length; + _tmp17_ = offset; + len = _tmp16_ - _tmp17_; + } + _tmp18_ = offset; + _tmp19_ = len; + _tmp20_ = string_length; + g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL); + _tmp21_ = offset; + _tmp22_ = len; + _tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_); + result = _tmp23_; return result; } -gchar* dayfolder_file_ext_rule_getFileExt (dayfolderFileExtRule* self) { +static gint string_last_index_of (const gchar* self, const gchar* needle, gint start_index) { + gint result = 0; + gint _tmp0_; + const gchar* _tmp1_; + gchar* _tmp2_ = NULL; + gchar* _result_; + gchar* _tmp3_; + g_return_val_if_fail (self != NULL, 0); + g_return_val_if_fail (needle != NULL, 0); + _tmp0_ = start_index; + _tmp1_ = needle; + _tmp2_ = g_strrstr (((gchar*) self) + _tmp0_, (gchar*) _tmp1_); + _result_ = _tmp2_; + _tmp3_ = _result_; + if (_tmp3_ != NULL) { + gchar* _tmp4_; + _tmp4_ = _result_; + result = (gint) (_tmp4_ - ((gchar*) self)); + return result; + } else { + result = -1; + return result; + } +} + + +static gchar* dayfolder_file_contains_rule_addTimestampToFilePath (dayfolderFileContainsRule* self, const gchar* filePath) { gchar* result = NULL; - const gchar* _tmp0_; - gchar* _tmp1_; + GDateTime* _tmp0_; + GDateTime* dateTime; + const gchar* _tmp1_; + const gchar* _tmp2_; + gint _tmp3_ = 0; + gchar* _tmp4_ = NULL; + gchar* pathPrefix; + const gchar* _tmp5_; + const gchar* _tmp6_; + gint _tmp7_ = 0; + gchar* _tmp8_ = NULL; + gchar* fileExt; + gchar* _tmp9_ = NULL; + gchar* timestamp; + gchar* _tmp10_; + gchar* _tmp11_; + gchar* _tmp12_; + gchar* _tmp13_; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_fileExt; - _tmp1_ = g_strdup (_tmp0_); - result = _tmp1_; + g_return_val_if_fail (filePath != NULL, NULL); + _tmp0_ = g_date_time_new_now_local (); + dateTime = _tmp0_; + _tmp1_ = filePath; + _tmp2_ = filePath; + _tmp3_ = string_last_index_of (_tmp2_, ".", 0); + _tmp4_ = string_substring (_tmp1_, (glong) 0, (glong) _tmp3_); + pathPrefix = _tmp4_; + _tmp5_ = filePath; + _tmp6_ = filePath; + _tmp7_ = string_last_index_of (_tmp6_, ".", 0); + _tmp8_ = string_substring (_tmp5_, (glong) _tmp7_, (glong) (-1)); + fileExt = _tmp8_; + _tmp9_ = g_date_time_format (dateTime, "_%Y%m%d_%H%M%S"); + timestamp = _tmp9_; + _tmp10_ = g_strconcat (pathPrefix, timestamp, NULL); + _tmp11_ = _tmp10_; + _tmp12_ = g_strconcat (_tmp11_, fileExt, NULL); + _tmp13_ = _tmp12_; + _g_free0 (_tmp11_); + result = _tmp13_; + _g_free0 (timestamp); + _g_free0 (fileExt); + _g_free0 (pathPrefix); + _g_date_time_unref0 (dateTime); + return result; +} + + +gboolean dayfolder_file_contains_rule_isRuleForFile (dayfolderFileContainsRule* self, const gchar* fileName) { + gboolean result = FALSE; + const gchar* _tmp0_; + const gchar* _tmp1_; + const gchar* _tmp2_; + gboolean _tmp3_ = FALSE; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (fileName != NULL, FALSE); + _tmp0_ = dayfolder_df_rule_get_criteriaString ((dayfolderDfRule*) self); + _tmp1_ = _tmp0_; + _tmp2_ = fileName; + _tmp3_ = g_regex_match_simple (_tmp1_, _tmp2_, 0, 0); + result = _tmp3_; return result; } -gchar* dayfolder_file_ext_rule_getDestinationDir (dayfolderFileExtRule* self) { +gchar* dayfolder_file_contains_rule_getDestinationDir (dayfolderFileContainsRule* self) { gchar* result = NULL; const gchar* _tmp0_; - gchar* _tmp1_; + const gchar* _tmp1_; + gchar* _tmp2_; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_destinationDir; - _tmp1_ = g_strdup (_tmp0_); - result = _tmp1_; + _tmp0_ = dayfolder_df_rule_get_destinationDir ((dayfolderDfRule*) self); + _tmp1_ = _tmp0_; + _tmp2_ = g_strdup (_tmp1_); + result = _tmp2_; return result; } -const gchar* dayfolder_file_ext_rule_get_fileExt (dayfolderFileExtRule* self) { +static const gchar* dayfolder_file_contains_rule_real_get_criteriaString (dayfolderDfRule* base) { const gchar* result; + dayfolderFileContainsRule* self; const gchar* _tmp0_; - g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_fileExt; + self = (dayfolderFileContainsRule*) base; + _tmp0_ = self->priv->_criteriaString; result = _tmp0_; return result; } -static void dayfolder_file_ext_rule_set_fileExt (dayfolderFileExtRule* self, const gchar* value) { +static void dayfolder_file_contains_rule_real_set_criteriaString (dayfolderDfRule* base, const gchar* value) { + dayfolderFileContainsRule* self; const gchar* _tmp0_; gchar* _tmp1_; - g_return_if_fail (self != NULL); + self = (dayfolderFileContainsRule*) base; _tmp0_ = value; _tmp1_ = g_strdup (_tmp0_); - _g_free0 (self->priv->_fileExt); - self->priv->_fileExt = _tmp1_; - g_object_notify ((GObject *) self, "fileExt"); + _g_free0 (self->priv->_criteriaString); + self->priv->_criteriaString = _tmp1_; + g_object_notify ((GObject *) self, "criteriaString"); } -const gchar* dayfolder_file_ext_rule_get_destinationDir (dayfolderFileExtRule* self) { +static const gchar* dayfolder_file_contains_rule_real_get_destinationDir (dayfolderDfRule* base) { const gchar* result; + dayfolderFileContainsRule* self; const gchar* _tmp0_; - g_return_val_if_fail (self != NULL, NULL); + self = (dayfolderFileContainsRule*) base; _tmp0_ = self->priv->_destinationDir; result = _tmp0_; return result; } -static void dayfolder_file_ext_rule_set_destinationDir (dayfolderFileExtRule* self, const gchar* value) { +static void dayfolder_file_contains_rule_real_set_destinationDir (dayfolderDfRule* base, const gchar* value) { + dayfolderFileContainsRule* self; const gchar* _tmp0_; gchar* _tmp1_; - g_return_if_fail (self != NULL); + self = (dayfolderFileContainsRule*) base; _tmp0_ = value; _tmp1_ = g_strdup (_tmp0_); _g_free0 (self->priv->_destinationDir); @@ -180,52 +569,64 @@ } -static void dayfolder_file_ext_rule_class_init (dayfolderFileExtRuleClass * klass) { - dayfolder_file_ext_rule_parent_class = g_type_class_peek_parent (klass); - g_type_class_add_private (klass, sizeof (dayfolderFileExtRulePrivate)); - G_OBJECT_CLASS (klass)->get_property = _vala_dayfolder_file_ext_rule_get_property; - G_OBJECT_CLASS (klass)->set_property = _vala_dayfolder_file_ext_rule_set_property; - G_OBJECT_CLASS (klass)->finalize = dayfolder_file_ext_rule_finalize; - g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_FILE_EXT_RULE_FILE_EXT, g_param_spec_string ("fileExt", "fileExt", "fileExt", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_FILE_EXT_RULE_DESTINATION_DIR, g_param_spec_string ("destinationDir", "destinationDir", "destinationDir", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); +static void dayfolder_file_contains_rule_class_init (dayfolderFileContainsRuleClass * klass) { + dayfolder_file_contains_rule_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (dayfolderFileContainsRulePrivate)); + G_OBJECT_CLASS (klass)->get_property = _vala_dayfolder_file_contains_rule_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_dayfolder_file_contains_rule_set_property; + G_OBJECT_CLASS (klass)->finalize = dayfolder_file_contains_rule_finalize; + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_FILE_CONTAINS_RULE_CRITERIA_STRING, g_param_spec_string ("criteriaString", "criteriaString", "criteriaString", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_FILE_CONTAINS_RULE_DESTINATION_DIR, g_param_spec_string ("destinationDir", "destinationDir", "destinationDir", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); +} + + +static void dayfolder_file_contains_rule_dayfolder_df_rule_interface_init (dayfolderDfRuleIface * iface) { + dayfolder_file_contains_rule_dayfolder_df_rule_parent_iface = g_type_interface_peek_parent (iface); + iface->processFile = (gboolean (*)(dayfolderDfRule*, GFileInfo*, const gchar*)) dayfolder_file_contains_rule_real_processFile; + iface->get_criteriaString = dayfolder_file_contains_rule_real_get_criteriaString; + iface->set_criteriaString = dayfolder_file_contains_rule_real_set_criteriaString; + iface->get_destinationDir = dayfolder_file_contains_rule_real_get_destinationDir; + iface->set_destinationDir = dayfolder_file_contains_rule_real_set_destinationDir; } -static void dayfolder_file_ext_rule_instance_init (dayfolderFileExtRule * self) { - self->priv = DAYFOLDER_FILE_EXT_RULE_GET_PRIVATE (self); +static void dayfolder_file_contains_rule_instance_init (dayfolderFileContainsRule * self) { + self->priv = DAYFOLDER_FILE_CONTAINS_RULE_GET_PRIVATE (self); } -static void dayfolder_file_ext_rule_finalize (GObject* obj) { - dayfolderFileExtRule * self; - self = DAYFOLDER_FILE_EXT_RULE (obj); - _g_free0 (self->priv->_fileExt); +static void dayfolder_file_contains_rule_finalize (GObject* obj) { + dayfolderFileContainsRule * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRule); + _g_free0 (self->priv->_criteriaString); _g_free0 (self->priv->_destinationDir); - G_OBJECT_CLASS (dayfolder_file_ext_rule_parent_class)->finalize (obj); + G_OBJECT_CLASS (dayfolder_file_contains_rule_parent_class)->finalize (obj); } -GType dayfolder_file_ext_rule_get_type (void) { - static volatile gsize dayfolder_file_ext_rule_type_id__volatile = 0; - if (g_once_init_enter (&dayfolder_file_ext_rule_type_id__volatile)) { - static const GTypeInfo g_define_type_info = { sizeof (dayfolderFileExtRuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dayfolder_file_ext_rule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (dayfolderFileExtRule), 0, (GInstanceInitFunc) dayfolder_file_ext_rule_instance_init, NULL }; - GType dayfolder_file_ext_rule_type_id; - dayfolder_file_ext_rule_type_id = g_type_register_static (G_TYPE_OBJECT, "dayfolderFileExtRule", &g_define_type_info, 0); - g_once_init_leave (&dayfolder_file_ext_rule_type_id__volatile, dayfolder_file_ext_rule_type_id); +GType dayfolder_file_contains_rule_get_type (void) { + static volatile gsize dayfolder_file_contains_rule_type_id__volatile = 0; + if (g_once_init_enter (&dayfolder_file_contains_rule_type_id__volatile)) { + static const GTypeInfo g_define_type_info = { sizeof (dayfolderFileContainsRuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dayfolder_file_contains_rule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (dayfolderFileContainsRule), 0, (GInstanceInitFunc) dayfolder_file_contains_rule_instance_init, NULL }; + static const GInterfaceInfo dayfolder_df_rule_info = { (GInterfaceInitFunc) dayfolder_file_contains_rule_dayfolder_df_rule_interface_init, (GInterfaceFinalizeFunc) NULL, NULL}; + GType dayfolder_file_contains_rule_type_id; + dayfolder_file_contains_rule_type_id = g_type_register_static (G_TYPE_OBJECT, "dayfolderFileContainsRule", &g_define_type_info, 0); + g_type_add_interface_static (dayfolder_file_contains_rule_type_id, DAYFOLDER_TYPE_DF_RULE, &dayfolder_df_rule_info); + g_once_init_leave (&dayfolder_file_contains_rule_type_id__volatile, dayfolder_file_contains_rule_type_id); } - return dayfolder_file_ext_rule_type_id__volatile; + return dayfolder_file_contains_rule_type_id__volatile; } -static void _vala_dayfolder_file_ext_rule_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - dayfolderFileExtRule * self; - self = DAYFOLDER_FILE_EXT_RULE (object); +static void _vala_dayfolder_file_contains_rule_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + dayfolderFileContainsRule * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRule); switch (property_id) { - case DAYFOLDER_FILE_EXT_RULE_FILE_EXT: - g_value_set_string (value, dayfolder_file_ext_rule_get_fileExt (self)); + case DAYFOLDER_FILE_CONTAINS_RULE_CRITERIA_STRING: + g_value_set_string (value, dayfolder_df_rule_get_criteriaString ((dayfolderDfRule*) self)); break; - case DAYFOLDER_FILE_EXT_RULE_DESTINATION_DIR: - g_value_set_string (value, dayfolder_file_ext_rule_get_destinationDir (self)); + case DAYFOLDER_FILE_CONTAINS_RULE_DESTINATION_DIR: + g_value_set_string (value, dayfolder_df_rule_get_destinationDir ((dayfolderDfRule*) self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -234,15 +635,15 @@ } -static void _vala_dayfolder_file_ext_rule_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - dayfolderFileExtRule * self; - self = DAYFOLDER_FILE_EXT_RULE (object); +static void _vala_dayfolder_file_contains_rule_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + dayfolderFileContainsRule * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRule); switch (property_id) { - case DAYFOLDER_FILE_EXT_RULE_FILE_EXT: - dayfolder_file_ext_rule_set_fileExt (self, g_value_get_string (value)); + case DAYFOLDER_FILE_CONTAINS_RULE_CRITERIA_STRING: + dayfolder_df_rule_set_criteriaString ((dayfolderDfRule*) self, g_value_get_string (value)); break; - case DAYFOLDER_FILE_EXT_RULE_DESTINATION_DIR: - dayfolder_file_ext_rule_set_destinationDir (self, g_value_get_string (value)); + case DAYFOLDER_FILE_CONTAINS_RULE_DESTINATION_DIR: + dayfolder_df_rule_set_destinationDir ((dayfolderDfRule*) self, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); diff -Nru dayfolder-1.4.1/src/Rules.vala dayfolder-2.0.0/src/Rules.vala --- dayfolder-1.4.1/src/Rules.vala 2012-05-20 16:43:28.000000000 +0000 +++ dayfolder-2.0.0/src/Rules.vala 2013-05-11 22:17:46.000000000 +0000 @@ -1,40 +1,106 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + using Gee; using zystem; namespace dayfolder { -class FileExtRule : GLib.Object { +interface DfRule : GLib.Object { + + public abstract string criteriaString { get; protected set; } + public abstract string destinationDir { get; protected set; } + + public abstract bool processFile(FileInfo file, string dirPath); +} + +class FileContainsRule : Object, DfRule { // Instance variables - public string fileExt { get; private set; } + public string criteriaString { get; private set; } public string destinationDir { get; private set; } /** * Constructor. */ - public FileExtRule(string fileExt, string destinationDir) { - this.fileExt = fileExt; + public FileContainsRule(string criteria, string destinationDir) { + this.criteriaString = criteria; this.destinationDir = destinationDir; - // Make sure that the destination exists? + // Make sure that the destination exists? No. } - /* + public bool processFile(FileInfo file, string dirPath) { + bool match = false; + + if (this.criteriaString in file.get_name()) { + match = true; + // Process file - Move file to destinationDir + this.moveFile(file, dirPath); + } + + return match; + } + + /** * Actually move the file to where it's supposed to go. */ - public void moveFile(FileInfo file) { - FileUtility.createFolder(this.destinationDir); - FileUtility.moveFile(file, this.destinationDir, true); + private void moveFile(FileInfo file, string dirPath) { + Zystem.debug("Moving file based on Rule"); + + string fileDestPath = ""; + + fileDestPath = this.destinationDir + "/" + file.get_name(); + + var destFile = File.new_for_path(fileDestPath); + + // If file already exists, add timestamp to file name + if (destFile.query_exists()) { + fileDestPath = this.addTimestampToFilePath(fileDestPath); + destFile = File.new_for_path(fileDestPath); + } + + // Only move the file if destination file does not exist. We don't want to write over any files. + if (!destFile.query_exists()) { + GLib.FileUtils.rename(dirPath + "/" + file.get_name(), fileDestPath); + } } - public bool isRuleForExt(string ext){ - return (fileExt == ext); + /** + * Get the file path with the unique timestamp inserted at end of + * filename before file extension. + */ + private string addTimestampToFilePath(string filePath) { + DateTime dateTime = new GLib.DateTime.now_local(); + + string pathPrefix = filePath.substring(0, filePath.last_index_of(".")); + string fileExt = filePath.substring(filePath.last_index_of(".")); + string timestamp = dateTime.format("_%Y%m%d_%H%M%S"); + + return pathPrefix + timestamp + fileExt; } - public string getFileExt() { - return this.fileExt; + public bool isRuleForFile(string fileName){ + //return (criteriaString == ext); + return Regex.match_simple(criteriaString, fileName); } public string getDestinationDir() { @@ -42,5 +108,4 @@ } } - -} \ No newline at end of file +} diff -Nru dayfolder-1.4.1/src/TestFileMonitor.c dayfolder-2.0.0/src/TestFileMonitor.c --- dayfolder-1.4.1/src/TestFileMonitor.c 1970-01-01 00:00:00.000000000 +0000 +++ dayfolder-2.0.0/src/TestFileMonitor.c 2013-05-11 22:28:22.000000000 +0000 @@ -0,0 +1,31 @@ +/* TestFileMonitor.c generated by valac 0.18.1, the Vala compiler + * generated from TestFileMonitor.vala, do not modify */ + +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + +#include +#include + + + + + + + diff -Nru dayfolder-1.4.1/src/TestFileMonitor.vala dayfolder-2.0.0/src/TestFileMonitor.vala --- dayfolder-1.4.1/src/TestFileMonitor.vala 1970-01-01 00:00:00.000000000 +0000 +++ dayfolder-2.0.0/src/TestFileMonitor.vala 2013-05-11 22:27:49.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + +/**using zystem; + +using GLib; + +namespace dayfolder { + +public class TestFileMonitor : Object { + + public TestFileMonitor() { + // + File testFile = File.new_for_path("/home/zach/Desktop/test.txt"); + FileMonitor mon = testFile.monitor_file(GLib.FileMonitorFlags.NONE); + mon.changed.connect(onChange); + Zystem.debug("Set up the FileMonitor!"); + //GLib.MainLoop loop = new GLib.MainLoop(); + //loop.run(); + } + + private void onChange() { + // + Zystem.debug("THE TEST FILE HAS BEEN CHANGED! ALERT THE MEDIA!"); + } + + + + +} + +}*/ \ No newline at end of file diff -Nru dayfolder-1.4.1/src/UserData.c dayfolder-2.0.0/src/UserData.c --- dayfolder-1.4.1/src/UserData.c 2012-05-20 17:33:24.000000000 +0000 +++ dayfolder-2.0.0/src/UserData.c 2013-05-11 22:28:22.000000000 +0000 @@ -1,6 +1,24 @@ -/* UserData.c generated by valac 0.14.2, the Vala compiler +/* UserData.c generated by valac 0.18.1, the Vala compiler * generated from UserData.vala, do not modify */ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ #include #include @@ -31,18 +49,35 @@ typedef struct _dayfolderUserSettingsManager dayfolderUserSettingsManager; typedef struct _dayfolderUserSettingsManagerClass dayfolderUserSettingsManagerClass; -#define DAYFOLDER_TYPE_FILE_EXT_RULE (dayfolder_file_ext_rule_get_type ()) -#define DAYFOLDER_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRule)) -#define DAYFOLDER_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) -#define DAYFOLDER_IS_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_IS_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_FILE_EXT_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) +#define DAYFOLDER_TYPE_MONITORED_DIRECTORY (dayfolder_monitored_directory_get_type ()) +#define DAYFOLDER_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory)) +#define DAYFOLDER_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_MONITORED_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) -typedef struct _dayfolderFileExtRule dayfolderFileExtRule; -typedef struct _dayfolderFileExtRuleClass dayfolderFileExtRuleClass; +typedef struct _dayfolderMonitoredDirectory dayfolderMonitoredDirectory; +typedef struct _dayfolderMonitoredDirectoryClass dayfolderMonitoredDirectoryClass; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) + +#define DAYFOLDER_TYPE_FILE_CONTAINS_RULE (dayfolder_file_contains_rule_get_type ()) +#define DAYFOLDER_FILE_CONTAINS_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRule)) +#define DAYFOLDER_FILE_CONTAINS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRuleClass)) +#define DAYFOLDER_IS_FILE_CONTAINS_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE)) +#define DAYFOLDER_IS_FILE_CONTAINS_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_CONTAINS_RULE)) +#define DAYFOLDER_FILE_CONTAINS_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_CONTAINS_RULE, dayfolderFileContainsRuleClass)) + +typedef struct _dayfolderFileContainsRule dayfolderFileContainsRule; +typedef struct _dayfolderFileContainsRuleClass dayfolderFileContainsRuleClass; + +#define DAYFOLDER_TYPE_DF_RULE (dayfolder_df_rule_get_type ()) +#define DAYFOLDER_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRule)) +#define DAYFOLDER_IS_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DF_RULE)) +#define DAYFOLDER_DF_RULE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRuleIface)) + +typedef struct _dayfolderDfRule dayfolderDfRule; +typedef struct _dayfolderDfRuleIface dayfolderDfRuleIface; #define _g_free0(var) (var = (g_free (var), NULL)) -#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL))) struct _dayfolderUserData { GObject parent_instance; @@ -53,27 +88,32 @@ GObjectClass parent_class; }; +struct _dayfolderDfRuleIface { + GTypeInterface parent_iface; + gboolean (*processFile) (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); + const gchar* (*get_criteriaString) (dayfolderDfRule* self); + void (*set_criteriaString) (dayfolderDfRule* self, const gchar* value); + const gchar* (*get_destinationDir) (dayfolderDfRule* self); + void (*set_destinationDir) (dayfolderDfRule* self, const gchar* value); +}; + static gpointer dayfolder_user_data_parent_class = NULL; -static gchar* dayfolder_user_data__sourcePath; -static gchar* dayfolder_user_data__sourcePath = NULL; static gchar* dayfolder_user_data__desktopDirPath; static gchar* dayfolder_user_data__desktopDirPath = NULL; -static gchar* dayfolder_user_data__dayFolderDirPath; -static gchar* dayfolder_user_data__dayFolderDirPath = NULL; static gchar* dayfolder_user_data__homeDirPath; static gchar* dayfolder_user_data__homeDirPath = NULL; static dayfolderUserSettingsManager* dayfolder_user_data_settings; static dayfolderUserSettingsManager* dayfolder_user_data_settings = NULL; -static GeeHashMap* dayfolder_user_data_fileExtRulesMap; -static GeeHashMap* dayfolder_user_data_fileExtRulesMap = NULL; +static GeeHashMap* dayfolder_user_data_monitoredDirsMap; +static GeeHashMap* dayfolder_user_data_monitoredDirsMap = NULL; GType dayfolder_user_data_get_type (void) G_GNUC_CONST; enum { DAYFOLDER_USER_DATA_DUMMY_PROPERTY }; GType dayfolder_user_settings_manager_get_type (void) G_GNUC_CONST; -GType dayfolder_file_ext_rule_get_type (void) G_GNUC_CONST; +GType dayfolder_monitored_directory_get_type (void) G_GNUC_CONST; #define DAYFOLDER_USER_DATA_dfTypeDaily "D" #define DAYFOLDER_USER_DATA_dfTypeWeekly "W" #define DAYFOLDER_USER_DATA_dfTypeMonthly "M" @@ -84,47 +124,58 @@ static void dayfolder_user_data_set_desktopDirPath (const gchar* value); dayfolderUserSettingsManager* dayfolder_user_settings_manager_new (void); dayfolderUserSettingsManager* dayfolder_user_settings_manager_construct (GType object_type); -const gchar* dayfolder_user_data_get_sourcePath (void); -const gchar* dayfolder_user_settings_manager_get_sourcePath (dayfolderUserSettingsManager* self); -static void dayfolder_user_data_set_sourcePath (const gchar* value); -static void dayfolder_user_data_setDayFolderDirPath (void); -static void dayfolder_user_data_loadFileExtRules (void); -const gchar* dayfolder_user_settings_manager_get_dfType (dayfolderUserSettingsManager* self); -const gchar* dayfolder_user_data_get_dayFolderDirPath (void); -const gchar* dayfolder_user_settings_manager_get_dfRootPath (dayfolderUserSettingsManager* self); -static void dayfolder_user_data_set_dayFolderDirPath (const gchar* value); -GeeArrayList* dayfolder_user_settings_manager_getFileExtRules (dayfolderUserSettingsManager* self); -void dayfolder_user_data_addFileExtRule (const gchar* fileExt, const gchar* destDir); -const gchar* dayfolder_file_ext_rule_get_fileExt (dayfolderFileExtRule* self); -const gchar* dayfolder_file_ext_rule_get_destinationDir (dayfolderFileExtRule* self); -void dayfolder_user_data_setDfRootPath (const gchar* path); -void dayfolder_user_settings_manager_setDfRootPath (dayfolderUserSettingsManager* self, const gchar* dfRootPath); -void dayfolder_user_data_setSourcePath (const gchar* path); -void dayfolder_user_settings_manager_setSourcePath (dayfolderUserSettingsManager* self, const gchar* sourcePath); -gchar* dayfolder_user_data_getDfRootPath (void); -gchar* dayfolder_user_data_getSourcePath (void); -void dayfolder_user_data_resetDfRootPath (void); +static void dayfolder_user_data_loadMonitoredDirs (void); +void dayfolder_user_data_cleanupAllMonDirs (void); +void dayfolder_monitored_directory_runCleanup (dayfolderMonitoredDirectory* self); +void dayfolder_user_data_setDfRootPath (const gchar* monDirPath, const gchar* path); +void dayfolder_user_settings_manager_setDfRootPath (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* dfRootPath); +void dayfolder_monitored_directory_setDfRootPath (dayfolderMonitoredDirectory* self, const gchar* rootPath); +void dayfolder_user_data_addFileRule (const gchar* dirPath, const gchar* criteria, const gchar* destDir); +void dayfolder_monitored_directory_addFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria, const gchar* destDir); +dayfolderFileContainsRule* dayfolder_file_contains_rule_new (const gchar* criteria, const gchar* destinationDir); +dayfolderFileContainsRule* dayfolder_file_contains_rule_construct (GType object_type, const gchar* criteria, const gchar* destinationDir); +GType dayfolder_file_contains_rule_get_type (void) G_GNUC_CONST; +GType dayfolder_df_rule_get_type (void) G_GNUC_CONST; +void dayfolder_user_settings_manager_addFileRule (dayfolderUserSettingsManager* self, const gchar* monDirPath, dayfolderDfRule* rule); +GeeArrayList* dayfolder_user_settings_manager_getMonitoredDirs (dayfolderUserSettingsManager* self); +const gchar* dayfolder_monitored_directory_get_dirPath (dayfolderMonitoredDirectory* self); +void zystem_zystem_debug (const gchar* s); +void dayfolder_user_data_addMonitoredDirectory (const gchar* dirPath); gchar* dayfolder_user_data_getDefaultDfRootPath (void); -void dayfolder_user_data_resetSourcePath (void); +dayfolderMonitoredDirectory* dayfolder_monitored_directory_new (const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType); +dayfolderMonitoredDirectory* dayfolder_monitored_directory_construct (GType object_type, const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType); +void dayfolder_user_settings_manager_addMonitoredDirectory (dayfolderUserSettingsManager* self, dayfolderMonitoredDirectory* dir); +void dayfolder_user_data_removeMonitoredDir (const gchar* dirPath); +void dayfolder_user_settings_manager_removeMonitoredDirectory (dayfolderUserSettingsManager* self, const gchar* dirPath); gchar* dayfolder_user_data_getDefaultSourcePath (void); -GeeArrayList* dayfolder_user_data_getFileExtRules (void); -dayfolderFileExtRule* dayfolder_file_ext_rule_new (const gchar* fileExt, const gchar* destinationDir); -dayfolderFileExtRule* dayfolder_file_ext_rule_construct (GType object_type, const gchar* fileExt, const gchar* destinationDir); -gchar* dayfolder_file_ext_rule_getFileExt (dayfolderFileExtRule* self); -void dayfolder_user_settings_manager_addFileExtRule (dayfolderUserSettingsManager* self, dayfolderFileExtRule* rule); -void dayfolder_user_data_removeFileExtRule (const gchar* fileExt); -void dayfolder_user_settings_manager_removeFileExtRule (dayfolderUserSettingsManager* self, const gchar* fileExt); -void dayfolder_user_data_runFileExtRule (GFileInfo* file); -gchar* dayfolder_file_utility_getFileExtension (GFileInfo* file); -void dayfolder_file_ext_rule_moveFile (dayfolderFileExtRule* self, GFileInfo* file); -gboolean dayfolder_user_data_ruleExistsForFileExt (const gchar* ext); -gchar* dayfolder_user_data_getFileExtRuleDest (const gchar* fileExt); -void dayfolder_user_data_setDfType (const gchar* dfType); -void dayfolder_user_settings_manager_setDfType (dayfolderUserSettingsManager* self, const gchar* dfType); -gchar* dayfolder_user_data_getDfType (void); -gboolean dayfolder_user_data_isDailyDfType (void); -gboolean dayfolder_user_data_isWeeklyDfType (void); -gboolean dayfolder_user_data_isMonthlyDfType (void); +GeeArrayList* dayfolder_user_data_getFileRules (const gchar* monDirPath); +GeeArrayList* dayfolder_monitored_directory_getFileRules (dayfolderMonitoredDirectory* self); +GeeArrayList* dayfolder_user_data_getMonitoredDirs (void); +void dayfolder_user_data_removeFileRule (const gchar* monDirPath, const gchar* criteria); +void dayfolder_monitored_directory_removeFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria); +void dayfolder_user_settings_manager_removeFileRule (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* criteria); +gchar* dayfolder_user_data_getFileRuleDest (const gchar* monDirPath, const gchar* criteria); +gchar* dayfolder_monitored_directory_getFileRuleDest (dayfolderMonitoredDirectory* self, const gchar* criteria); +void dayfolder_user_data_setMoveDirs (const gchar* monDirPath, gboolean moveDirs); +void dayfolder_user_settings_manager_setMoveDirs (dayfolderUserSettingsManager* self, const gchar* monDirPath, gboolean moveDirs); +void dayfolder_monitored_directory_set_moveDirs (dayfolderMonitoredDirectory* self, gboolean value); +gboolean dayfolder_user_data_getMoveDirs (const gchar* monDirPath); +gboolean dayfolder_monitored_directory_get_moveDirs (dayfolderMonitoredDirectory* self); +void dayfolder_user_data_setUseDayFolder (const gchar* monDirPath, gboolean useDayFolder); +void dayfolder_user_settings_manager_setUseDayFolder (dayfolderUserSettingsManager* self, const gchar* monDirPath, gboolean useDayFolder); +void dayfolder_monitored_directory_set_useDayFolder (dayfolderMonitoredDirectory* self, gboolean value); +gboolean dayfolder_user_data_getUseDayFolder (const gchar* monDirPath); +gboolean dayfolder_monitored_directory_get_useDayFolder (dayfolderMonitoredDirectory* self); +void dayfolder_user_data_setDfType (const gchar* monDirPath, const gchar* dfType); +void dayfolder_user_settings_manager_setDfType (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* dfType); +void dayfolder_monitored_directory_setDfType (dayfolderMonitoredDirectory* self, const gchar* type); +gchar* dayfolder_user_data_getDfRootPath (const gchar* dirPath); +const gchar* dayfolder_monitored_directory_get_dfRootPath (dayfolderMonitoredDirectory* self); +gchar* dayfolder_user_data_getSourcePath (const gchar* dirPath); +gchar* dayfolder_user_data_getDfType (const gchar* dirPath); +const gchar* dayfolder_monitored_directory_get_dfType (dayfolderMonitoredDirectory* self); +void dayfolder_user_data_printDebug (void); +void dayfolder_monitored_directory_printDebug (dayfolderMonitoredDirectory* self); dayfolderUserData* dayfolder_user_data_new (void); dayfolderUserData* dayfolder_user_data_construct (GType object_type); static void dayfolder_user_data_finalize (GObject* obj); @@ -144,11 +195,6 @@ const gchar* _tmp5_ = NULL; dayfolderUserSettingsManager* _tmp6_; GeeHashMap* _tmp7_; - const gchar* _tmp8_; - const gchar* _tmp9_; - dayfolderUserSettingsManager* _tmp10_; - const gchar* _tmp11_; - const gchar* _tmp12_; _tmp0_ = dayfolder_user_data_get_homeDirPath (); _tmp1_ = _tmp0_; _tmp2_ = g_get_home_dir (); @@ -160,168 +206,153 @@ _tmp6_ = dayfolder_user_settings_manager_new (); _g_object_unref0 (dayfolder_user_data_settings); dayfolder_user_data_settings = _tmp6_; - _tmp7_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, DAYFOLDER_TYPE_FILE_EXT_RULE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL); - _g_object_unref0 (dayfolder_user_data_fileExtRulesMap); - dayfolder_user_data_fileExtRulesMap = _tmp7_; - _tmp8_ = dayfolder_user_data_get_sourcePath (); - _tmp9_ = _tmp8_; - _tmp10_ = dayfolder_user_data_settings; - _tmp11_ = dayfolder_user_settings_manager_get_sourcePath (_tmp10_); - _tmp12_ = _tmp11_; - dayfolder_user_data_set_sourcePath (_tmp12_); - dayfolder_user_data_setDayFolderDirPath (); - dayfolder_user_data_loadFileExtRules (); + _tmp7_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, DAYFOLDER_TYPE_MONITORED_DIRECTORY, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL); + _g_object_unref0 (dayfolder_user_data_monitoredDirsMap); + dayfolder_user_data_monitoredDirsMap = _tmp7_; + dayfolder_user_data_loadMonitoredDirs (); } /** - * Sets dayFolderDirPath variable to today's dayFolder directory. This is based on the dfType, - * and determines the path to the daily, weekly, or monthly folder. - */ -static void dayfolder_user_data_setDayFolderDirPath (void) { - GDateTime* _tmp0_; - GDateTime* dateTime; - gchar* _tmp1_; - gchar* directoryName; - dayfolderUserSettingsManager* _tmp2_; - const gchar* _tmp3_; - const gchar* _tmp4_; - const gchar* _tmp32_; - const gchar* _tmp33_; - dayfolderUserSettingsManager* _tmp34_; - const gchar* _tmp35_; - const gchar* _tmp36_; - const gchar* _tmp37_; - gchar* _tmp38_ = NULL; - gchar* _tmp39_; - _tmp0_ = g_date_time_new_now_local (); - dateTime = _tmp0_; - _tmp1_ = g_strdup (""); - directoryName = _tmp1_; - _tmp2_ = dayfolder_user_data_settings; - _tmp3_ = dayfolder_user_settings_manager_get_dfType (_tmp2_); - _tmp4_ = _tmp3_; - if (g_strcmp0 (_tmp4_, DAYFOLDER_USER_DATA_dfTypeDaily) == 0) { - GDateTime* _tmp5_; - gchar* _tmp6_ = NULL; - _tmp5_ = dateTime; - _tmp6_ = g_date_time_format (_tmp5_, "%Y-%m-%d"); - _g_free0 (directoryName); - directoryName = _tmp6_; - } else { - dayfolderUserSettingsManager* _tmp7_; - const gchar* _tmp8_; - const gchar* _tmp9_; - _tmp7_ = dayfolder_user_data_settings; - _tmp8_ = dayfolder_user_settings_manager_get_dfType (_tmp7_); - _tmp9_ = _tmp8_; - if (g_strcmp0 (_tmp9_, DAYFOLDER_USER_DATA_dfTypeWeekly) == 0) { - GDateTime* _tmp10_; - GDateTime* _tmp11_; - gint _tmp12_ = 0; - GDateTime* _tmp13_ = NULL; - GDateTime* _tmp14_; - gchar* _tmp15_ = NULL; - gchar* _tmp16_; - GDateTime* _tmp17_; - GDateTime* _tmp18_ = NULL; - GDateTime* _tmp19_; - gchar* _tmp20_ = NULL; - gchar* _tmp21_; - gchar* _tmp22_; - _tmp10_ = dateTime; - _tmp11_ = dateTime; - _tmp12_ = g_date_time_get_day_of_week (_tmp11_); - _tmp13_ = g_date_time_add_days (_tmp10_, 0 - _tmp12_); - _g_date_time_unref0 (dateTime); - dateTime = _tmp13_; - _tmp14_ = dateTime; - _tmp15_ = g_date_time_format (_tmp14_, "%Y-%m-%d to "); - _tmp16_ = _tmp15_; - _tmp17_ = dateTime; - _tmp18_ = g_date_time_add_days (_tmp17_, 6); - _tmp19_ = _tmp18_; - _tmp20_ = g_date_time_format (_tmp19_, "%Y-%m-%d"); - _tmp21_ = _tmp20_; - _tmp22_ = g_strconcat (_tmp16_, _tmp21_, NULL); - _g_free0 (directoryName); - directoryName = _tmp22_; - _g_free0 (_tmp21_); - _g_date_time_unref0 (_tmp19_); - _g_free0 (_tmp16_); - } else { - dayfolderUserSettingsManager* _tmp23_; - const gchar* _tmp24_; - const gchar* _tmp25_; - _tmp23_ = dayfolder_user_data_settings; - _tmp24_ = dayfolder_user_settings_manager_get_dfType (_tmp23_); - _tmp25_ = _tmp24_; - if (g_strcmp0 (_tmp25_, DAYFOLDER_USER_DATA_dfTypeMonthly) == 0) { - GDateTime* _tmp26_; - GDateTime* _tmp27_; - gint _tmp28_ = 0; - GDateTime* _tmp29_ = NULL; - GDateTime* _tmp30_; - gchar* _tmp31_ = NULL; - _tmp26_ = dateTime; - _tmp27_ = dateTime; - _tmp28_ = g_date_time_get_day_of_month (_tmp27_); - _tmp29_ = g_date_time_add_days (_tmp26_, 1 - _tmp28_); - _tmp30_ = _tmp29_; - _tmp31_ = g_date_time_format (_tmp30_, "%Y-%m"); - _g_free0 (directoryName); - directoryName = _tmp31_; - _g_date_time_unref0 (_tmp30_); + * Run cleanup on all monitored directories. + */ +void dayfolder_user_data_cleanupAllMonDirs (void) { + { + GeeHashMap* _tmp0_; + GeeCollection* _tmp1_; + GeeCollection* _tmp2_; + GeeCollection* _tmp3_; + GeeIterator* _tmp4_ = NULL; + GeeIterator* _tmp5_; + GeeIterator* _monDir_it; + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = gee_abstract_map_get_values ((GeeMap*) _tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = _tmp2_; + _tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_); + _tmp5_ = _tmp4_; + _g_object_unref0 (_tmp3_); + _monDir_it = _tmp5_; + while (TRUE) { + GeeIterator* _tmp6_; + gboolean _tmp7_ = FALSE; + GeeIterator* _tmp8_; + gpointer _tmp9_ = NULL; + dayfolderMonitoredDirectory* monDir; + dayfolderMonitoredDirectory* _tmp10_; + _tmp6_ = _monDir_it; + _tmp7_ = gee_iterator_next (_tmp6_); + if (!_tmp7_) { + break; } + _tmp8_ = _monDir_it; + _tmp9_ = gee_iterator_get (_tmp8_); + monDir = (dayfolderMonitoredDirectory*) _tmp9_; + _tmp10_ = monDir; + dayfolder_monitored_directory_runCleanup (_tmp10_); + _g_object_unref0 (monDir); } + _g_object_unref0 (_monDir_it); } - _tmp32_ = dayfolder_user_data_get_dayFolderDirPath (); - _tmp33_ = _tmp32_; - _tmp34_ = dayfolder_user_data_settings; - _tmp35_ = dayfolder_user_settings_manager_get_dfRootPath (_tmp34_); - _tmp36_ = _tmp35_; - _tmp37_ = directoryName; - _tmp38_ = g_build_path (G_DIR_SEPARATOR_S, _tmp36_, _tmp37_, NULL); - _tmp39_ = _tmp38_; - dayfolder_user_data_set_dayFolderDirPath (_tmp39_); - _g_free0 (_tmp39_); - _g_free0 (directoryName); - _g_date_time_unref0 (dateTime); } /** - * + * Set the DayFolder root path from the passed in string in the settings and in the + * monitored directory object. + */ +void dayfolder_user_data_setDfRootPath (const gchar* monDirPath, const gchar* path) { + dayfolderUserSettingsManager* _tmp0_; + const gchar* _tmp1_; + const gchar* _tmp2_; + GeeHashMap* _tmp3_; + const gchar* _tmp4_; + gpointer _tmp5_ = NULL; + dayfolderMonitoredDirectory* monDir; + const gchar* _tmp6_; + g_return_if_fail (monDirPath != NULL); + g_return_if_fail (path != NULL); + _tmp0_ = dayfolder_user_data_settings; + _tmp1_ = monDirPath; + _tmp2_ = path; + dayfolder_user_settings_manager_setDfRootPath (_tmp0_, _tmp1_, _tmp2_); + _tmp3_ = dayfolder_user_data_monitoredDirsMap; + _tmp4_ = monDirPath; + _tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_); + monDir = (dayfolderMonitoredDirectory*) _tmp5_; + _tmp6_ = path; + dayfolder_monitored_directory_setDfRootPath (monDir, _tmp6_); + _g_object_unref0 (monDir); +} + + +void dayfolder_user_data_addFileRule (const gchar* dirPath, const gchar* criteria, const gchar* destDir) { + GeeHashMap* _tmp0_; + const gchar* _tmp1_; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* dir; + const gchar* _tmp3_; + const gchar* _tmp4_; + const gchar* _tmp5_; + const gchar* _tmp6_; + dayfolderFileContainsRule* _tmp7_; + dayfolderFileContainsRule* rule; + dayfolderUserSettingsManager* _tmp8_; + const gchar* _tmp9_; + g_return_if_fail (dirPath != NULL); + g_return_if_fail (criteria != NULL); + g_return_if_fail (destDir != NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = dirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + dir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = criteria; + _tmp4_ = destDir; + dayfolder_monitored_directory_addFileRule (dir, _tmp3_, _tmp4_); + _tmp5_ = criteria; + _tmp6_ = destDir; + _tmp7_ = dayfolder_file_contains_rule_new (_tmp5_, _tmp6_); + rule = _tmp7_; + _tmp8_ = dayfolder_user_data_settings; + _tmp9_ = dirPath; + dayfolder_user_settings_manager_addFileRule (_tmp8_, _tmp9_, (dayfolderDfRule*) rule); + _g_object_unref0 (rule); + _g_object_unref0 (dir); +} + + +/** + * Load Monitored Directory Data from the settings. */ static gpointer _g_object_ref0 (gpointer self) { return self ? g_object_ref (self) : NULL; } -static void dayfolder_user_data_loadFileExtRules (void) { +static void dayfolder_user_data_loadMonitoredDirs (void) { dayfolderUserSettingsManager* _tmp0_; GeeArrayList* _tmp1_ = NULL; - GeeArrayList* fileExtRules; + GeeArrayList* monitoredDirs; _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_getFileExtRules (_tmp0_); - fileExtRules = _tmp1_; + _tmp1_ = dayfolder_user_settings_manager_getMonitoredDirs (_tmp0_); + monitoredDirs = _tmp1_; { GeeArrayList* _tmp2_; GeeArrayList* _tmp3_; - GeeArrayList* _rule_list; + GeeArrayList* _dir_list; GeeArrayList* _tmp4_; gint _tmp5_; gint _tmp6_; - gint _rule_size; - gint _rule_index; - _tmp2_ = fileExtRules; + gint _dir_size; + gint _dir_index; + _tmp2_ = monitoredDirs; _tmp3_ = _g_object_ref0 (_tmp2_); - _rule_list = _tmp3_; - _tmp4_ = _rule_list; + _dir_list = _tmp3_; + _tmp4_ = _dir_list; _tmp5_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp4_); _tmp6_ = _tmp5_; - _rule_size = _tmp6_; - _rule_index = -1; + _dir_size = _tmp6_; + _dir_index = -1; while (TRUE) { gint _tmp7_; gint _tmp8_; @@ -329,177 +360,96 @@ GeeArrayList* _tmp10_; gint _tmp11_; gpointer _tmp12_ = NULL; - dayfolderFileExtRule* rule; - dayfolderFileExtRule* _tmp13_; - const gchar* _tmp14_; + dayfolderMonitoredDirectory* dir; + GeeHashMap* _tmp13_; + dayfolderMonitoredDirectory* _tmp14_; const gchar* _tmp15_; - dayfolderFileExtRule* _tmp16_; - const gchar* _tmp17_; - const gchar* _tmp18_; - _tmp7_ = _rule_index; - _rule_index = _tmp7_ + 1; - _tmp8_ = _rule_index; - _tmp9_ = _rule_size; + const gchar* _tmp16_; + dayfolderMonitoredDirectory* _tmp17_; + dayfolderMonitoredDirectory* _tmp18_; + const gchar* _tmp19_; + const gchar* _tmp20_; + gchar* _tmp21_; + gchar* _tmp22_; + _tmp7_ = _dir_index; + _dir_index = _tmp7_ + 1; + _tmp8_ = _dir_index; + _tmp9_ = _dir_size; if (!(_tmp8_ < _tmp9_)) { break; } - _tmp10_ = _rule_list; - _tmp11_ = _rule_index; + _tmp10_ = _dir_list; + _tmp11_ = _dir_index; _tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp10_, _tmp11_); - rule = (dayfolderFileExtRule*) _tmp12_; - _tmp13_ = rule; - _tmp14_ = dayfolder_file_ext_rule_get_fileExt (_tmp13_); - _tmp15_ = _tmp14_; - _tmp16_ = rule; - _tmp17_ = dayfolder_file_ext_rule_get_destinationDir (_tmp16_); - _tmp18_ = _tmp17_; - dayfolder_user_data_addFileExtRule (_tmp15_, _tmp18_); - _g_object_unref0 (rule); + dir = (dayfolderMonitoredDirectory*) _tmp12_; + _tmp13_ = dayfolder_user_data_monitoredDirsMap; + _tmp14_ = dir; + _tmp15_ = dayfolder_monitored_directory_get_dirPath (_tmp14_); + _tmp16_ = _tmp15_; + _tmp17_ = dir; + gee_abstract_map_set ((GeeAbstractMap*) _tmp13_, _tmp16_, _tmp17_); + _tmp18_ = dir; + _tmp19_ = dayfolder_monitored_directory_get_dirPath (_tmp18_); + _tmp20_ = _tmp19_; + _tmp21_ = g_strconcat ("Loaded Monitored Dir: ", _tmp20_, NULL); + _tmp22_ = _tmp21_; + zystem_zystem_debug (_tmp22_); + _g_free0 (_tmp22_); + _g_object_unref0 (dir); } - _g_object_unref0 (_rule_list); + _g_object_unref0 (_dir_list); } - _g_object_unref0 (fileExtRules); -} - - -/** - * Set the DayFolder root path from the passed in string. - */ -void dayfolder_user_data_setDfRootPath (const gchar* path) { - dayfolderUserSettingsManager* _tmp0_; - const gchar* _tmp1_; - g_return_if_fail (path != NULL); - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = path; - dayfolder_user_settings_manager_setDfRootPath (_tmp0_, _tmp1_); - dayfolder_user_data_setDayFolderDirPath (); -} - - -/** - * Set the source location from the passed in string. - */ -void dayfolder_user_data_setSourcePath (const gchar* path) { - dayfolderUserSettingsManager* _tmp0_; - const gchar* _tmp1_; - const gchar* _tmp2_; - const gchar* _tmp3_; - const gchar* _tmp4_; - g_return_if_fail (path != NULL); - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = path; - dayfolder_user_settings_manager_setSourcePath (_tmp0_, _tmp1_); - _tmp2_ = dayfolder_user_data_get_sourcePath (); - _tmp3_ = _tmp2_; - _tmp4_ = path; - dayfolder_user_data_set_sourcePath (_tmp4_); + _g_object_unref0 (monitoredDirs); } /** - * Returns the DayFolder root directory path string. + * Add a monitored directory. */ -gchar* dayfolder_user_data_getDfRootPath (void) { - gchar* result = NULL; - dayfolderUserSettingsManager* _tmp0_; - const gchar* _tmp1_; - const gchar* _tmp2_; - gchar* _tmp3_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_dfRootPath (_tmp0_); - _tmp2_ = _tmp1_; - _tmp3_ = g_strdup (_tmp2_); - result = _tmp3_; - return result; -} - - -/** - * Returns the source location path. - */ -gchar* dayfolder_user_data_getSourcePath (void) { - gchar* result = NULL; - dayfolderUserSettingsManager* _tmp0_; - const gchar* _tmp1_; - const gchar* _tmp2_; - gchar* _tmp3_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_sourcePath (_tmp0_); - _tmp2_ = _tmp1_; - _tmp3_ = g_strdup (_tmp2_); - result = _tmp3_; - return result; -} - - -/** - * Resets the DayFolder root directory. Will not set it if it's already default. - */ -void dayfolder_user_data_resetDfRootPath (void) { - dayfolderUserSettingsManager* _tmp0_; - const gchar* _tmp1_; - const gchar* _tmp2_; - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - gboolean _tmp5_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_dfRootPath (_tmp0_); +void dayfolder_user_data_addMonitoredDirectory (const gchar* dirPath) { + const gchar* _tmp0_; + gchar* _tmp1_ = NULL; + gchar* _tmp2_; + dayfolderMonitoredDirectory* _tmp3_; + dayfolderMonitoredDirectory* _tmp4_; + dayfolderMonitoredDirectory* dir; + GeeHashMap* _tmp5_; + const gchar* _tmp6_; + const gchar* _tmp7_; + dayfolderUserSettingsManager* _tmp8_; + g_return_if_fail (dirPath != NULL); + _tmp0_ = dirPath; + _tmp1_ = dayfolder_user_data_getDefaultDfRootPath (); _tmp2_ = _tmp1_; - _tmp3_ = dayfolder_user_data_getDefaultDfRootPath (); + _tmp3_ = dayfolder_monitored_directory_new (_tmp0_, TRUE, _tmp2_, TRUE, DAYFOLDER_USER_DATA_dfTypeDaily); _tmp4_ = _tmp3_; - _tmp5_ = g_strcmp0 (_tmp2_, _tmp4_) != 0; - _g_free0 (_tmp4_); - if (_tmp5_) { - dayfolderUserSettingsManager* _tmp6_; - gchar* _tmp7_ = NULL; - gchar* _tmp8_; - _tmp6_ = dayfolder_user_data_settings; - _tmp7_ = dayfolder_user_data_getDefaultDfRootPath (); - _tmp8_ = _tmp7_; - dayfolder_user_settings_manager_setDfRootPath (_tmp6_, _tmp8_); - _g_free0 (_tmp8_); - dayfolder_user_data_setDayFolderDirPath (); - } + _g_free0 (_tmp2_); + dir = _tmp4_; + _tmp5_ = dayfolder_user_data_monitoredDirsMap; + _tmp6_ = dayfolder_monitored_directory_get_dirPath (dir); + _tmp7_ = _tmp6_; + gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, _tmp7_, dir); + _tmp8_ = dayfolder_user_data_settings; + dayfolder_user_settings_manager_addMonitoredDirectory (_tmp8_, dir); + _g_object_unref0 (dir); } /** - * Resets the Source Location directory. Will not set it if it's already default. + * Remove a monitored directory. */ -void dayfolder_user_data_resetSourcePath (void) { - dayfolderUserSettingsManager* _tmp0_; +void dayfolder_user_data_removeMonitoredDir (const gchar* dirPath) { + GeeHashMap* _tmp0_; const gchar* _tmp1_; - const gchar* _tmp2_; - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - gboolean _tmp5_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_sourcePath (_tmp0_); - _tmp2_ = _tmp1_; - _tmp3_ = dayfolder_user_data_getDefaultSourcePath (); - _tmp4_ = _tmp3_; - _tmp5_ = g_strcmp0 (_tmp2_, _tmp4_) != 0; - _g_free0 (_tmp4_); - if (_tmp5_) { - dayfolderUserSettingsManager* _tmp6_; - gchar* _tmp7_ = NULL; - gchar* _tmp8_; - const gchar* _tmp9_; - const gchar* _tmp10_; - gchar* _tmp11_ = NULL; - gchar* _tmp12_; - _tmp6_ = dayfolder_user_data_settings; - _tmp7_ = dayfolder_user_data_getDefaultSourcePath (); - _tmp8_ = _tmp7_; - dayfolder_user_settings_manager_setSourcePath (_tmp6_, _tmp8_); - _g_free0 (_tmp8_); - _tmp9_ = dayfolder_user_data_get_sourcePath (); - _tmp10_ = _tmp9_; - _tmp11_ = dayfolder_user_data_getDefaultSourcePath (); - _tmp12_ = _tmp11_; - dayfolder_user_data_set_sourcePath (_tmp12_); - _g_free0 (_tmp12_); - } + dayfolderUserSettingsManager* _tmp2_; + const gchar* _tmp3_; + g_return_if_fail (dirPath != NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = dirPath; + gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp1_, NULL); + _tmp2_ = dayfolder_user_data_settings; + _tmp3_ = dirPath; + dayfolder_user_settings_manager_removeMonitoredDirectory (_tmp2_, _tmp3_); } @@ -536,13 +486,36 @@ /** + * Returns list of all file rules for the given monitored directory. + */ +GeeArrayList* dayfolder_user_data_getFileRules (const gchar* monDirPath) { + GeeArrayList* result = NULL; + GeeHashMap* _tmp0_; + const gchar* _tmp1_; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* monDir; + GeeArrayList* _tmp3_ = NULL; + g_return_val_if_fail (monDirPath != NULL, NULL); + zystem_zystem_debug ("Calling MonitoredDirectory for fileRules..."); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = monDirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + monDir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = dayfolder_monitored_directory_getFileRules (monDir); + result = _tmp3_; + _g_object_unref0 (monDir); + return result; +} + + +/** * Returns list of all file ext rules in the rule manager. */ -GeeArrayList* dayfolder_user_data_getFileExtRules (void) { +GeeArrayList* dayfolder_user_data_getMonitoredDirs (void) { GeeArrayList* result = NULL; GeeArrayList* _tmp0_; GeeArrayList* list; - _tmp0_ = gee_array_list_new (DAYFOLDER_TYPE_FILE_EXT_RULE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + _tmp0_ = gee_array_list_new (DAYFOLDER_TYPE_MONITORED_DIRECTORY, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); list = _tmp0_; { GeeHashMap* _tmp1_; @@ -551,37 +524,37 @@ GeeCollection* _tmp4_; GeeIterator* _tmp5_ = NULL; GeeIterator* _tmp6_; - GeeIterator* _rule_it; - _tmp1_ = dayfolder_user_data_fileExtRulesMap; + GeeIterator* _data_it; + _tmp1_ = dayfolder_user_data_monitoredDirsMap; _tmp2_ = gee_abstract_map_get_values ((GeeMap*) _tmp1_); _tmp3_ = _tmp2_; _tmp4_ = _tmp3_; _tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_); _tmp6_ = _tmp5_; _g_object_unref0 (_tmp4_); - _rule_it = _tmp6_; + _data_it = _tmp6_; while (TRUE) { GeeIterator* _tmp7_; gboolean _tmp8_ = FALSE; GeeIterator* _tmp9_; gpointer _tmp10_ = NULL; - dayfolderFileExtRule* rule; + dayfolderMonitoredDirectory* data; GeeArrayList* _tmp11_; - dayfolderFileExtRule* _tmp12_; - _tmp7_ = _rule_it; + dayfolderMonitoredDirectory* _tmp12_; + _tmp7_ = _data_it; _tmp8_ = gee_iterator_next (_tmp7_); if (!_tmp8_) { break; } - _tmp9_ = _rule_it; + _tmp9_ = _data_it; _tmp10_ = gee_iterator_get (_tmp9_); - rule = (dayfolderFileExtRule*) _tmp10_; + data = (dayfolderMonitoredDirectory*) _tmp10_; _tmp11_ = list; - _tmp12_ = rule; + _tmp12_ = data; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, _tmp12_); - _g_object_unref0 (rule); + _g_object_unref0 (data); } - _g_object_unref0 (_rule_it); + _g_object_unref0 (_data_it); } result = list; return result; @@ -589,92 +562,102 @@ /** - * + * Remove the FileExtRule for the given monitored directory and remove from settings. */ -void dayfolder_user_data_addFileExtRule (const gchar* fileExt, const gchar* destDir) { - const gchar* _tmp0_; +void dayfolder_user_data_removeFileRule (const gchar* monDirPath, const gchar* criteria) { + GeeHashMap* _tmp0_; const gchar* _tmp1_; - dayfolderFileExtRule* _tmp2_; - dayfolderFileExtRule* rule; - GeeHashMap* _tmp3_; - gchar* _tmp4_ = NULL; - gchar* _tmp5_; - dayfolderUserSettingsManager* _tmp6_; - g_return_if_fail (fileExt != NULL); - g_return_if_fail (destDir != NULL); - _tmp0_ = fileExt; - _tmp1_ = destDir; - _tmp2_ = dayfolder_file_ext_rule_new (_tmp0_, _tmp1_); - rule = _tmp2_; - _tmp3_ = dayfolder_user_data_fileExtRulesMap; - _tmp4_ = dayfolder_file_ext_rule_getFileExt (rule); - _tmp5_ = _tmp4_; - gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, _tmp5_, rule); - _g_free0 (_tmp5_); - _tmp6_ = dayfolder_user_data_settings; - dayfolder_user_settings_manager_addFileExtRule (_tmp6_, rule); - _g_object_unref0 (rule); + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* monDir; + const gchar* _tmp3_; + dayfolderUserSettingsManager* _tmp4_; + const gchar* _tmp5_; + const gchar* _tmp6_; + g_return_if_fail (monDirPath != NULL); + g_return_if_fail (criteria != NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = monDirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + monDir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = criteria; + dayfolder_monitored_directory_removeFileRule (monDir, _tmp3_); + _tmp4_ = dayfolder_user_data_settings; + _tmp5_ = monDirPath; + _tmp6_ = criteria; + dayfolder_user_settings_manager_removeFileRule (_tmp4_, _tmp5_, _tmp6_); + _g_object_unref0 (monDir); } /** - * + * Return the FileRule's destination for the given monitored directory. */ -void dayfolder_user_data_removeFileExtRule (const gchar* fileExt) { +gchar* dayfolder_user_data_getFileRuleDest (const gchar* monDirPath, const gchar* criteria) { + gchar* result = NULL; GeeHashMap* _tmp0_; const gchar* _tmp1_; - dayfolderUserSettingsManager* _tmp2_; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* monDir; const gchar* _tmp3_; - g_return_if_fail (fileExt != NULL); - _tmp0_ = dayfolder_user_data_fileExtRulesMap; - _tmp1_ = fileExt; - gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp1_, NULL); - _tmp2_ = dayfolder_user_data_settings; - _tmp3_ = fileExt; - dayfolder_user_settings_manager_removeFileExtRule (_tmp2_, _tmp3_); + gchar* _tmp4_ = NULL; + g_return_val_if_fail (monDirPath != NULL, NULL); + g_return_val_if_fail (criteria != NULL, NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = monDirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + monDir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = criteria; + _tmp4_ = dayfolder_monitored_directory_getFileRuleDest (monDir, _tmp3_); + result = _tmp4_; + _g_object_unref0 (monDir); + return result; } /** - * + * Set whether or not to move subfolders in given monitored directory. */ -void dayfolder_user_data_runFileExtRule (GFileInfo* file) { - GeeHashMap* _tmp0_; - GFileInfo* _tmp1_; - gchar* _tmp2_ = NULL; - gchar* _tmp3_; - gpointer _tmp4_ = NULL; - dayfolderFileExtRule* _tmp5_; - dayfolderFileExtRule* rule; - GFileInfo* _tmp6_; - g_return_if_fail (file != NULL); - _tmp0_ = dayfolder_user_data_fileExtRulesMap; - _tmp1_ = file; - _tmp2_ = dayfolder_file_utility_getFileExtension (_tmp1_); - _tmp3_ = _tmp2_; - _tmp4_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp3_); - _tmp5_ = (dayfolderFileExtRule*) _tmp4_; - _g_free0 (_tmp3_); - rule = _tmp5_; - _tmp6_ = file; - dayfolder_file_ext_rule_moveFile (rule, _tmp6_); - _g_object_unref0 (rule); +void dayfolder_user_data_setMoveDirs (const gchar* monDirPath, gboolean moveDirs) { + dayfolderUserSettingsManager* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_; + GeeHashMap* _tmp3_; + const gchar* _tmp4_; + gpointer _tmp5_ = NULL; + dayfolderMonitoredDirectory* monDir; + gboolean _tmp6_; + g_return_if_fail (monDirPath != NULL); + _tmp0_ = dayfolder_user_data_settings; + _tmp1_ = monDirPath; + _tmp2_ = moveDirs; + dayfolder_user_settings_manager_setMoveDirs (_tmp0_, _tmp1_, _tmp2_); + _tmp3_ = dayfolder_user_data_monitoredDirsMap; + _tmp4_ = monDirPath; + _tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_); + monDir = (dayfolderMonitoredDirectory*) _tmp5_; + _tmp6_ = moveDirs; + dayfolder_monitored_directory_set_moveDirs (monDir, _tmp6_); + _g_object_unref0 (monDir); } -/** - * Return if a rule exists for a file extension exists. - */ -gboolean dayfolder_user_data_ruleExistsForFileExt (const gchar* ext) { +gboolean dayfolder_user_data_getMoveDirs (const gchar* monDirPath) { gboolean result = FALSE; GeeHashMap* _tmp0_; const gchar* _tmp1_; - gboolean _tmp2_ = FALSE; - g_return_val_if_fail (ext != NULL, FALSE); - _tmp0_ = dayfolder_user_data_fileExtRulesMap; - _tmp1_ = ext; - _tmp2_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp1_); - result = _tmp2_; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* monDir; + gboolean _tmp3_; + gboolean _tmp4_; + g_return_val_if_fail (monDirPath != NULL, FALSE); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = monDirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + monDir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = dayfolder_monitored_directory_get_moveDirs (monDir); + _tmp4_ = _tmp3_; + result = _tmp4_; + _g_object_unref0 (monDir); return result; } @@ -682,99 +665,198 @@ /** * */ -gchar* dayfolder_user_data_getFileExtRuleDest (const gchar* fileExt) { - gchar* result = NULL; +void dayfolder_user_data_setUseDayFolder (const gchar* monDirPath, gboolean useDayFolder) { + dayfolderUserSettingsManager* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_; + GeeHashMap* _tmp3_; + const gchar* _tmp4_; + gpointer _tmp5_ = NULL; + dayfolderMonitoredDirectory* monDir; + gboolean _tmp6_; + g_return_if_fail (monDirPath != NULL); + _tmp0_ = dayfolder_user_data_settings; + _tmp1_ = monDirPath; + _tmp2_ = useDayFolder; + dayfolder_user_settings_manager_setUseDayFolder (_tmp0_, _tmp1_, _tmp2_); + _tmp3_ = dayfolder_user_data_monitoredDirsMap; + _tmp4_ = monDirPath; + _tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_); + monDir = (dayfolderMonitoredDirectory*) _tmp5_; + _tmp6_ = useDayFolder; + dayfolder_monitored_directory_set_useDayFolder (monDir, _tmp6_); + _g_object_unref0 (monDir); +} + + +gboolean dayfolder_user_data_getUseDayFolder (const gchar* monDirPath) { + gboolean result = FALSE; GeeHashMap* _tmp0_; const gchar* _tmp1_; gpointer _tmp2_ = NULL; - dayfolderFileExtRule* _tmp3_; - const gchar* _tmp4_; - const gchar* _tmp5_; - gchar* _tmp6_; - gchar* _tmp7_; - g_return_val_if_fail (fileExt != NULL, NULL); - _tmp0_ = dayfolder_user_data_fileExtRulesMap; - _tmp1_ = fileExt; + dayfolderMonitoredDirectory* monDir; + gboolean _tmp3_; + gboolean _tmp4_; + g_return_val_if_fail (monDirPath != NULL, FALSE); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = monDirPath; _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); - _tmp3_ = (dayfolderFileExtRule*) _tmp2_; - _tmp4_ = dayfolder_file_ext_rule_get_destinationDir (_tmp3_); - _tmp5_ = _tmp4_; - _tmp6_ = g_strdup (_tmp5_); - _tmp7_ = _tmp6_; - _g_object_unref0 (_tmp3_); - result = _tmp7_; + monDir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = dayfolder_monitored_directory_get_useDayFolder (monDir); + _tmp4_ = _tmp3_; + result = _tmp4_; + _g_object_unref0 (monDir); return result; } /** - * + * Sets the dfType in the settings and the monitored directory. */ -void dayfolder_user_data_setDfType (const gchar* dfType) { +void dayfolder_user_data_setDfType (const gchar* monDirPath, const gchar* dfType) { dayfolderUserSettingsManager* _tmp0_; const gchar* _tmp1_; + const gchar* _tmp2_; + GeeHashMap* _tmp3_; + const gchar* _tmp4_; + gpointer _tmp5_ = NULL; + dayfolderMonitoredDirectory* monDir; + const gchar* _tmp6_; + g_return_if_fail (monDirPath != NULL); g_return_if_fail (dfType != NULL); _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dfType; - dayfolder_user_settings_manager_setDfType (_tmp0_, _tmp1_); - dayfolder_user_data_setDayFolderDirPath (); + _tmp1_ = monDirPath; + _tmp2_ = dfType; + dayfolder_user_settings_manager_setDfType (_tmp0_, _tmp1_, _tmp2_); + _tmp3_ = dayfolder_user_data_monitoredDirsMap; + _tmp4_ = monDirPath; + _tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_); + monDir = (dayfolderMonitoredDirectory*) _tmp5_; + _tmp6_ = dfType; + dayfolder_monitored_directory_setDfType (monDir, _tmp6_); + _g_object_unref0 (monDir); } /** - * + * Returns the DayFolder root directory path string. */ -gchar* dayfolder_user_data_getDfType (void) { +gchar* dayfolder_user_data_getDfRootPath (const gchar* dirPath) { gchar* result = NULL; - dayfolderUserSettingsManager* _tmp0_; + GeeHashMap* _tmp0_; const gchar* _tmp1_; - const gchar* _tmp2_; - gchar* _tmp3_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_dfType (_tmp0_); - _tmp2_ = _tmp1_; - _tmp3_ = g_strdup (_tmp2_); - result = _tmp3_; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* dir; + const gchar* _tmp3_; + const gchar* _tmp4_; + gchar* _tmp5_; + g_return_val_if_fail (dirPath != NULL, NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = dirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + dir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = dayfolder_monitored_directory_get_dfRootPath (dir); + _tmp4_ = _tmp3_; + _tmp5_ = g_strdup (_tmp4_); + result = _tmp5_; + _g_object_unref0 (dir); return result; } -gboolean dayfolder_user_data_isDailyDfType (void) { - gboolean result = FALSE; - dayfolderUserSettingsManager* _tmp0_; +/** + * Returns the source location path. + */ +gchar* dayfolder_user_data_getSourcePath (const gchar* dirPath) { + gchar* result = NULL; + GeeHashMap* _tmp0_; const gchar* _tmp1_; - const gchar* _tmp2_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_dfType (_tmp0_); - _tmp2_ = _tmp1_; - result = g_strcmp0 (_tmp2_, DAYFOLDER_USER_DATA_dfTypeDaily) == 0; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* dir; + const gchar* _tmp3_; + const gchar* _tmp4_; + gchar* _tmp5_; + g_return_val_if_fail (dirPath != NULL, NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = dirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + dir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = dayfolder_monitored_directory_get_dirPath (dir); + _tmp4_ = _tmp3_; + _tmp5_ = g_strdup (_tmp4_); + result = _tmp5_; + _g_object_unref0 (dir); return result; } -gboolean dayfolder_user_data_isWeeklyDfType (void) { - gboolean result = FALSE; - dayfolderUserSettingsManager* _tmp0_; +/** + * Return the dfType for the passed in monitored directory's path. + */ +gchar* dayfolder_user_data_getDfType (const gchar* dirPath) { + gchar* result = NULL; + GeeHashMap* _tmp0_; const gchar* _tmp1_; - const gchar* _tmp2_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_dfType (_tmp0_); - _tmp2_ = _tmp1_; - result = g_strcmp0 (_tmp2_, DAYFOLDER_USER_DATA_dfTypeWeekly) == 0; + gpointer _tmp2_ = NULL; + dayfolderMonitoredDirectory* dir; + const gchar* _tmp3_; + const gchar* _tmp4_; + gchar* _tmp5_; + g_return_val_if_fail (dirPath != NULL, NULL); + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = dirPath; + _tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _tmp1_); + dir = (dayfolderMonitoredDirectory*) _tmp2_; + _tmp3_ = dayfolder_monitored_directory_get_dfType (dir); + _tmp4_ = _tmp3_; + _tmp5_ = g_strdup (_tmp4_); + result = _tmp5_; + _g_object_unref0 (dir); return result; } -gboolean dayfolder_user_data_isMonthlyDfType (void) { - gboolean result = FALSE; - dayfolderUserSettingsManager* _tmp0_; - const gchar* _tmp1_; - const gchar* _tmp2_; - _tmp0_ = dayfolder_user_data_settings; - _tmp1_ = dayfolder_user_settings_manager_get_dfType (_tmp0_); - _tmp2_ = _tmp1_; - result = g_strcmp0 (_tmp2_, DAYFOLDER_USER_DATA_dfTypeMonthly) == 0; - return result; +/** + * Debug method. + */ +void dayfolder_user_data_printDebug (void) { + { + GeeHashMap* _tmp0_; + GeeCollection* _tmp1_; + GeeCollection* _tmp2_; + GeeCollection* _tmp3_; + GeeIterator* _tmp4_ = NULL; + GeeIterator* _tmp5_; + GeeIterator* _monDir_it; + _tmp0_ = dayfolder_user_data_monitoredDirsMap; + _tmp1_ = gee_abstract_map_get_values ((GeeMap*) _tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = _tmp2_; + _tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_); + _tmp5_ = _tmp4_; + _g_object_unref0 (_tmp3_); + _monDir_it = _tmp5_; + while (TRUE) { + GeeIterator* _tmp6_; + gboolean _tmp7_ = FALSE; + GeeIterator* _tmp8_; + gpointer _tmp9_ = NULL; + dayfolderMonitoredDirectory* monDir; + dayfolderMonitoredDirectory* _tmp10_; + _tmp6_ = _monDir_it; + _tmp7_ = gee_iterator_next (_tmp6_); + if (!_tmp7_) { + break; + } + _tmp8_ = _monDir_it; + _tmp9_ = gee_iterator_get (_tmp8_); + monDir = (dayfolderMonitoredDirectory*) _tmp9_; + _tmp10_ = monDir; + dayfolder_monitored_directory_printDebug (_tmp10_); + _g_object_unref0 (monDir); + } + _g_object_unref0 (_monDir_it); + } } @@ -790,25 +872,6 @@ } -const gchar* dayfolder_user_data_get_sourcePath (void) { - const gchar* result; - const gchar* _tmp0_; - _tmp0_ = dayfolder_user_data__sourcePath; - result = _tmp0_; - return result; -} - - -static void dayfolder_user_data_set_sourcePath (const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); - _g_free0 (dayfolder_user_data__sourcePath); - dayfolder_user_data__sourcePath = _tmp1_; -} - - const gchar* dayfolder_user_data_get_desktopDirPath (void) { const gchar* result; const gchar* _tmp0_; @@ -828,25 +891,6 @@ } -const gchar* dayfolder_user_data_get_dayFolderDirPath (void) { - const gchar* result; - const gchar* _tmp0_; - _tmp0_ = dayfolder_user_data__dayFolderDirPath; - result = _tmp0_; - return result; -} - - -static void dayfolder_user_data_set_dayFolderDirPath (const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); - _g_free0 (dayfolder_user_data__dayFolderDirPath); - dayfolder_user_data__dayFolderDirPath = _tmp1_; -} - - const gchar* dayfolder_user_data_get_homeDirPath (void) { const gchar* result; const gchar* _tmp0_; @@ -880,7 +924,7 @@ static void dayfolder_user_data_finalize (GObject* obj) { dayfolderUserData * self; - self = DAYFOLDER_USER_DATA (obj); + self = G_TYPE_CHECK_INSTANCE_CAST (obj, DAYFOLDER_TYPE_USER_DATA, dayfolderUserData); G_OBJECT_CLASS (dayfolder_user_data_parent_class)->finalize (obj); } @@ -904,7 +948,7 @@ static void _vala_dayfolder_user_data_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { dayfolderUserData * self; - self = DAYFOLDER_USER_DATA (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, DAYFOLDER_TYPE_USER_DATA, dayfolderUserData); switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -915,7 +959,7 @@ static void _vala_dayfolder_user_data_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { dayfolderUserData * self; - self = DAYFOLDER_USER_DATA (object); + self = G_TYPE_CHECK_INSTANCE_CAST (object, DAYFOLDER_TYPE_USER_DATA, dayfolderUserData); switch (property_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); diff -Nru dayfolder-1.4.1/src/UserData.vala dayfolder-2.0.0/src/UserData.vala --- dayfolder-1.4.1/src/UserData.vala 2012-05-20 17:23:50.000000000 +0000 +++ dayfolder-2.0.0/src/UserData.vala 2013-05-11 22:16:21.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + using Gee; using zystem; @@ -17,16 +36,12 @@ public static const string dfTypeMonthly = "M"; // Properties - public static string sourcePath { get; private set; } public static string desktopDirPath { get; private set; } - public static string dayFolderDirPath { get; private set; } public static string homeDirPath { get; private set; } private static UserSettingsManager settings; - private static HashMap fileExtRulesMap; - - //private static RuleManager ruleManager; + private static HashMap monitoredDirsMap; /** * Pretty much a static constructor. Initializes the variables so UserData is ready to use. @@ -37,97 +52,69 @@ settings = new UserSettingsManager(); - fileExtRulesMap = new HashMap(); + monitoredDirsMap = new HashMap(); - sourcePath = settings.sourcePath; - - setDayFolderDirPath(); - - loadFileExtRules(); + loadMonitoredDirs(); } /** - * Sets dayFolderDirPath variable to today's dayFolder directory. This is based on the dfType, - * and determines the path to the daily, weekly, or monthly folder. + * Run cleanup on all monitored directories. */ - private static void setDayFolderDirPath() { - - DateTime dateTime = new GLib.DateTime.now_local(); - string directoryName = ""; - - if (settings.dfType == dfTypeDaily) { - // Get the dayfolder directory name from today's date - directoryName = dateTime.format("%Y-%m-%d"); - } else if (settings.dfType == dfTypeWeekly) { - dateTime = dateTime.add_days(0 - dateTime.get_day_of_week()); - directoryName = dateTime.format("%Y-%m-%d to ") + dateTime.add_days(6).format("%Y-%m-%d"); - } else if (settings.dfType == dfTypeMonthly) { - directoryName = dateTime.add_days(1 - dateTime.get_day_of_month()).format("%Y-%m"); + public static void cleanupAllMonDirs() { + foreach (MonitoredDirectory monDir in monitoredDirsMap.values) { + monDir.runCleanup(); } - - dayFolderDirPath = GLib.Path.build_path(GLib.Path.DIR_SEPARATOR_S, settings.dfRootPath, directoryName); } /** - * + * Set the DayFolder root path from the passed in string in the settings and in the + * monitored directory object. */ - private static void loadFileExtRules() { - // - ArrayList fileExtRules = settings.getFileExtRules(); - - foreach (FileExtRule rule in fileExtRules) { - addFileExtRule(rule.fileExt, rule.destinationDir); - } + public static void setDfRootPath(string monDirPath, string path) { + settings.setDfRootPath(monDirPath, path); + MonitoredDirectory monDir = monitoredDirsMap.get(monDirPath); + monDir.setDfRootPath(path); } - /** - * Set the DayFolder root path from the passed in string. - */ - public static void setDfRootPath(string path) { - settings.setDfRootPath(path); - setDayFolderDirPath(); - } - - /** - * Set the source location from the passed in string. - */ - public static void setSourcePath(string path) { - settings.setSourcePath(path); - sourcePath = path; + public static void addFileRule(string dirPath, string criteria, string destDir) { + MonitoredDirectory dir = monitoredDirsMap.get(dirPath); + dir.addFileRule(criteria, destDir); + + var rule = new FileContainsRule(criteria, destDir); + settings.addFileRule(dirPath, rule); } /** - * Returns the DayFolder root directory path string. + * Load Monitored Directory Data from the settings. */ - public static string getDfRootPath() { - return settings.dfRootPath; - } + private static void loadMonitoredDirs() { + ArrayList monitoredDirs = settings.getMonitoredDirs(); - /** - * Returns the source location path. - */ - public static string getSourcePath() { - return settings.sourcePath; + foreach (MonitoredDirectory dir in monitoredDirs) { + monitoredDirsMap.set(dir.dirPath, dir); + Zystem.debug("Loaded Monitored Dir: " + dir.dirPath); + } } /** - * Resets the DayFolder root directory. Will not set it if it's already default. + * Add a monitored directory. */ - public static void resetDfRootPath() { - if (settings.dfRootPath != getDefaultDfRootPath()) { - settings.setDfRootPath(getDefaultDfRootPath()); - setDayFolderDirPath(); - } + public static void addMonitoredDirectory(string dirPath) { + var dir = new MonitoredDirectory(dirPath, // dirPath + true, // useDayFolder + getDefaultDfRootPath(),// dfRootPath + true, // moveDirs + dfTypeDaily); // dfType + monitoredDirsMap.set(dir.dirPath, dir); + settings.addMonitoredDirectory(dir); } /** - * Resets the Source Location directory. Will not set it if it's already default. + * Remove a monitored directory. */ - public static void resetSourcePath() { - if (settings.sourcePath != getDefaultSourcePath()) { - settings.setSourcePath(getDefaultSourcePath()); - sourcePath = getDefaultSourcePath(); - } + public static void removeMonitoredDir(string dirPath) { + monitoredDirsMap.unset(dirPath); + settings.removeMonitoredDirectory(dirPath); } /** @@ -145,89 +132,118 @@ } /** + * Returns list of all file rules for the given monitored directory. + */ + public static ArrayList getFileRules(string monDirPath) { + Zystem.debug("Calling MonitoredDirectory for fileRules..."); + var monDir = monitoredDirsMap.get(monDirPath); + return monDir.getFileRules(); + } + + /** * Returns list of all file ext rules in the rule manager. */ - public static ArrayList getFileExtRules() { - ArrayList list = new ArrayList(); + public static ArrayList getMonitoredDirs() { + ArrayList list = new ArrayList(); - foreach (FileExtRule rule in fileExtRulesMap.values) { - list.add(rule); + foreach (MonitoredDirectory data in monitoredDirsMap.values) { + list.add(data); } return list; } /** - * + * Remove the FileExtRule for the given monitored directory and remove from settings. */ - public static void addFileExtRule(string fileExt, string destDir) { - var rule = new FileExtRule(fileExt, destDir); - fileExtRulesMap.set(rule.getFileExt(), rule); - settings.addFileExtRule(rule); + public static void removeFileRule(string monDirPath, string criteria) { + var monDir = monitoredDirsMap.get(monDirPath); + monDir.removeFileRule(criteria); + + settings.removeFileRule(monDirPath, criteria); } /** - * + * Return the FileRule's destination for the given monitored directory. */ - public static void removeFileExtRule(string fileExt) { - fileExtRulesMap.unset(fileExt); - settings.removeFileExtRule(fileExt); + public static string getFileRuleDest(string monDirPath, string criteria) { + var monDir = monitoredDirsMap.get(monDirPath); + return monDir.getFileRuleDest(criteria); } /** - * + * Set whether or not to move subfolders in given monitored directory. */ - public static void runFileExtRule(FileInfo file) { + public static void setMoveDirs(string monDirPath, bool moveDirs) { + settings.setMoveDirs(monDirPath, moveDirs); - FileExtRule rule = fileExtRulesMap.get(FileUtility.getFileExtension(file)); - - rule.moveFile(file); + MonitoredDirectory monDir = monitoredDirsMap.get(monDirPath); + monDir.moveDirs = moveDirs; } - /** - * Return if a rule exists for a file extension exists. - */ - public static bool ruleExistsForFileExt(string ext){ - return fileExtRulesMap.has_key(ext); + public static bool getMoveDirs(string monDirPath) { + MonitoredDirectory monDir = monitoredDirsMap.get(monDirPath); + return monDir.moveDirs; } /** * */ - public static string getFileExtRuleDest(string fileExt) { - return fileExtRulesMap.get(fileExt).destinationDir; + public static void setUseDayFolder(string monDirPath, bool useDayFolder) { + settings.setUseDayFolder(monDirPath, useDayFolder); + + MonitoredDirectory monDir = monitoredDirsMap.get(monDirPath); + monDir.useDayFolder = useDayFolder; + } + + public static bool getUseDayFolder(string monDirPath) { + MonitoredDirectory monDir = monitoredDirsMap.get(monDirPath); + return monDir.useDayFolder; } /** - * + * Sets the dfType in the settings and the monitored directory. */ - public static void setDfType(string dfType) { - // Set dfType - settings.setDfType(dfType); - - // Also set dayFolderDirPath - setDayFolderDirPath(); + public static void setDfType(string monDirPath, string dfType) { + settings.setDfType(monDirPath, dfType); + + MonitoredDirectory monDir = monitoredDirsMap.get(monDirPath); + monDir.setDfType(dfType); } /** - * + * Returns the DayFolder root directory path string. */ - public static string getDfType() { - return settings.dfType; + public static string getDfRootPath(string dirPath) { + MonitoredDirectory dir = monitoredDirsMap.get(dirPath); + return dir.dfRootPath; } - public static bool isDailyDfType() { - return settings.dfType == dfTypeDaily; + /** + * Returns the source location path. + */ + public static string getSourcePath(string dirPath) { + MonitoredDirectory dir = monitoredDirsMap.get(dirPath); + return dir.dirPath; } - public static bool isWeeklyDfType() { - return settings.dfType == dfTypeWeekly; + /** + * Return the dfType for the passed in monitored directory's path. + */ + public static string getDfType(string dirPath) { + MonitoredDirectory dir = monitoredDirsMap.get(dirPath); + return dir.dfType; } - public static bool isMonthlyDfType() { - return settings.dfType == dfTypeMonthly; + /** + * Debug method. + */ + public static void printDebug() { + foreach (MonitoredDirectory monDir in monitoredDirsMap.values) { + monDir.printDebug(); + } } } -} \ No newline at end of file +} diff -Nru dayfolder-1.4.1/src/UserSettingsManager.c dayfolder-2.0.0/src/UserSettingsManager.c --- dayfolder-1.4.1/src/UserSettingsManager.c 2012-05-09 23:22:45.000000000 +0000 +++ dayfolder-2.0.0/src/UserSettingsManager.c 2013-05-11 22:28:22.000000000 +0000 @@ -1,6 +1,24 @@ -/* UserSettingsManager.c generated by valac 0.14.2, the Vala compiler +/* UserSettingsManager.c generated by valac 0.18.1, the Vala compiler * generated from UserSettingsManager.vala, do not modify */ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ #include #include @@ -27,15 +45,23 @@ #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) -#define DAYFOLDER_TYPE_FILE_EXT_RULE (dayfolder_file_ext_rule_get_type ()) -#define DAYFOLDER_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRule)) -#define DAYFOLDER_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) -#define DAYFOLDER_IS_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_IS_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_FILE_EXT_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) +#define DAYFOLDER_TYPE_MONITORED_DIRECTORY (dayfolder_monitored_directory_get_type ()) +#define DAYFOLDER_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory)) +#define DAYFOLDER_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_MONITORED_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) + +typedef struct _dayfolderMonitoredDirectory dayfolderMonitoredDirectory; +typedef struct _dayfolderMonitoredDirectoryClass dayfolderMonitoredDirectoryClass; + +#define DAYFOLDER_TYPE_DF_RULE (dayfolder_df_rule_get_type ()) +#define DAYFOLDER_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRule)) +#define DAYFOLDER_IS_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DF_RULE)) +#define DAYFOLDER_DF_RULE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRuleIface)) -typedef struct _dayfolderFileExtRule dayfolderFileExtRule; -typedef struct _dayfolderFileExtRuleClass dayfolderFileExtRuleClass; +typedef struct _dayfolderDfRule dayfolderDfRule; +typedef struct _dayfolderDfRuleIface dayfolderDfRuleIface; struct _dayfolderUserSettingsManager { GObject parent_instance; @@ -49,9 +75,15 @@ struct _dayfolderUserSettingsManagerPrivate { GKeyFile* keyFile; gchar* dfConfPath; - gchar* _sourcePath; - gchar* _dfRootPath; - gchar* _dfType; +}; + +struct _dayfolderDfRuleIface { + GTypeInterface parent_iface; + gboolean (*processFile) (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); + const gchar* (*get_criteriaString) (dayfolderDfRule* self); + void (*set_criteriaString) (dayfolderDfRule* self, const gchar* value); + const gchar* (*get_destinationDir) (dayfolderDfRule* self); + void (*set_destinationDir) (dayfolderDfRule* self, const gchar* value); }; @@ -60,46 +92,49 @@ GType dayfolder_user_settings_manager_get_type (void) G_GNUC_CONST; #define DAYFOLDER_USER_SETTINGS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DAYFOLDER_TYPE_USER_SETTINGS_MANAGER, dayfolderUserSettingsManagerPrivate)) enum { - DAYFOLDER_USER_SETTINGS_MANAGER_DUMMY_PROPERTY, - DAYFOLDER_USER_SETTINGS_MANAGER_SOURCE_PATH, - DAYFOLDER_USER_SETTINGS_MANAGER_DF_ROOT_PATH, - DAYFOLDER_USER_SETTINGS_MANAGER_DF_TYPE + DAYFOLDER_USER_SETTINGS_MANAGER_DUMMY_PROPERTY }; -#define DAYFOLDER_USER_SETTINGS_MANAGER_groupName "DayFolder" #define DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup "FileExtRules" +#define DAYFOLDER_USER_SETTINGS_MANAGER_monitoredDirsGroup "MonitoredDirectories" #define DAYFOLDER_USER_DATA_dfTypeDaily "D" #define DAYFOLDER_USER_SETTINGS_MANAGER_defaultDfType DAYFOLDER_USER_DATA_dfTypeDaily -#define DAYFOLDER_USER_SETTINGS_MANAGER_sourcePathName "sourcePath" -#define DAYFOLDER_USER_SETTINGS_MANAGER_dfRootPathName "dfRootPath" -#define DAYFOLDER_USER_SETTINGS_MANAGER_dfTypeName "dfType" dayfolderUserSettingsManager* dayfolder_user_settings_manager_new (void); dayfolderUserSettingsManager* dayfolder_user_settings_manager_construct (GType object_type); const gchar* dayfolder_user_data_get_homeDirPath (void); void dayfolder_file_utility_createFolder (const gchar* dirPath); static gboolean dayfolder_user_settings_manager_processKeyFile (dayfolderUserSettingsManager* self); static void dayfolder_user_settings_manager_writeKeyFile (dayfolderUserSettingsManager* self); -static void dayfolder_user_settings_manager_set_sourcePath (dayfolderUserSettingsManager* self, const gchar* value); -gchar* dayfolder_user_data_getDefaultSourcePath (void); -const gchar* dayfolder_user_settings_manager_get_sourcePath (dayfolderUserSettingsManager* self); -static void dayfolder_user_settings_manager_set_dfRootPath (dayfolderUserSettingsManager* self, const gchar* value); +void dayfolder_user_settings_manager_setDfRootPath (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* dfRootPath); +#define DAYFOLDER_MONITORED_DIRECTORY_dfRootPathKey "dfRootPath" +void dayfolder_user_settings_manager_setSourcePath (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* sourcePath); +#define DAYFOLDER_MONITORED_DIRECTORY_sourcePathKey "sourcePath" +void dayfolder_user_settings_manager_setDfType (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* dfType); +#define DAYFOLDER_MONITORED_DIRECTORY_dfTypeKey "dfType" +void dayfolder_user_settings_manager_setMoveDirs (dayfolderUserSettingsManager* self, const gchar* monDirPath, gboolean moveDirs); +#define DAYFOLDER_MONITORED_DIRECTORY_moveDirsKey "moveDirs" +void dayfolder_user_settings_manager_setUseDayFolder (dayfolderUserSettingsManager* self, const gchar* monDirPath, gboolean useDayFolder); +#define DAYFOLDER_MONITORED_DIRECTORY_useDayFolderKey "useDayFolder" +GType dayfolder_monitored_directory_get_type (void) G_GNUC_CONST; +GeeArrayList* dayfolder_user_settings_manager_getMonitoredDirs (dayfolderUserSettingsManager* self); +void zystem_zystem_debug (const gchar* s); +static gboolean dayfolder_user_settings_manager_getUseDayFolder (dayfolderUserSettingsManager* self, const gchar* dirPath); +static gchar* dayfolder_user_settings_manager_getDfRootPath (dayfolderUserSettingsManager* self, const gchar* dirPath); +static gboolean dayfolder_user_settings_manager_getMoveDirs (dayfolderUserSettingsManager* self, const gchar* dirPath); +static gchar* dayfolder_user_settings_manager_getDfType (dayfolderUserSettingsManager* self, const gchar* dirPath); +dayfolderMonitoredDirectory* dayfolder_monitored_directory_new (const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType); +dayfolderMonitoredDirectory* dayfolder_monitored_directory_construct (GType object_type, const gchar* dirPath, gboolean useDayFolder, const gchar* dfRootPath, gboolean moveDirs, const gchar* dfType); +const gchar* dayfolder_monitored_directory_get_fileExtRulesGroup (dayfolderMonitoredDirectory* self); +void dayfolder_monitored_directory_addFileRule (dayfolderMonitoredDirectory* self, const gchar* criteria, const gchar* destDir); +GType dayfolder_df_rule_get_type (void) G_GNUC_CONST; +void dayfolder_user_settings_manager_addFileRule (dayfolderUserSettingsManager* self, const gchar* monDirPath, dayfolderDfRule* rule); +const gchar* dayfolder_df_rule_get_criteriaString (dayfolderDfRule* self); +const gchar* dayfolder_df_rule_get_destinationDir (dayfolderDfRule* self); +void dayfolder_user_settings_manager_addMonitoredDirectory (dayfolderUserSettingsManager* self, dayfolderMonitoredDirectory* dir); +const gchar* dayfolder_monitored_directory_get_dirPath (dayfolderMonitoredDirectory* self); +void dayfolder_user_settings_manager_removeMonitoredDirectory (dayfolderUserSettingsManager* self, const gchar* dirPath); +void dayfolder_user_settings_manager_removeFileRule (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* criteria); gchar* dayfolder_user_data_getDefaultDfRootPath (void); -const gchar* dayfolder_user_settings_manager_get_dfRootPath (dayfolderUserSettingsManager* self); -static void dayfolder_user_settings_manager_set_dfType (dayfolderUserSettingsManager* self, const gchar* value); -const gchar* dayfolder_user_settings_manager_get_dfType (dayfolderUserSettingsManager* self); -void dayfolder_user_settings_manager_setDfRootPath (dayfolderUserSettingsManager* self, const gchar* dfRootPath); -void dayfolder_user_settings_manager_setSourcePath (dayfolderUserSettingsManager* self, const gchar* sourcePath); -void dayfolder_user_settings_manager_setDfType (dayfolderUserSettingsManager* self, const gchar* dfType); -GType dayfolder_file_ext_rule_get_type (void) G_GNUC_CONST; -GeeArrayList* dayfolder_user_settings_manager_getFileExtRules (dayfolderUserSettingsManager* self); -dayfolderFileExtRule* dayfolder_file_ext_rule_new (const gchar* fileExt, const gchar* destinationDir); -dayfolderFileExtRule* dayfolder_file_ext_rule_construct (GType object_type, const gchar* fileExt, const gchar* destinationDir); -void dayfolder_user_settings_manager_addFileExtRule (dayfolderUserSettingsManager* self, dayfolderFileExtRule* rule); -const gchar* dayfolder_file_ext_rule_get_fileExt (dayfolderFileExtRule* self); -const gchar* dayfolder_file_ext_rule_get_destinationDir (dayfolderFileExtRule* self); -void dayfolder_user_settings_manager_removeFileExtRule (dayfolderUserSettingsManager* self, const gchar* fileExt); static void dayfolder_user_settings_manager_finalize (GObject* obj); -static void _vala_dayfolder_user_settings_manager_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); -static void _vala_dayfolder_user_settings_manager_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); @@ -150,11 +185,11 @@ _tmp12_ = _tmp11_; _g_object_unref0 (_tmp12_); if (_inner_error_ != NULL) { - goto __catch3_g_error; + goto __catch2_g_error; } } - goto __finally3; - __catch3_g_error: + goto __finally2; + __catch2_g_error: { GError* e = NULL; FILE* _tmp13_; @@ -168,7 +203,7 @@ fprintf (_tmp13_, "Error creating settings file: %s\n", _tmp15_); _g_error_free0 (e); } - __finally3: + __finally2: if (_inner_error_ != NULL) { _g_object_unref0 (settingsFile); _g_free0 (settingsDirPath); @@ -187,11 +222,11 @@ _tmp18_ = self->priv->dfConfPath; g_key_file_load_from_file (_tmp17_, _tmp18_, 0, &_inner_error_); if (_inner_error_ != NULL) { - goto __catch4_g_error; + goto __catch3_g_error; } } - goto __finally4; - __catch4_g_error: + goto __finally3; + __catch3_g_error: { GError* e = NULL; FILE* _tmp19_; @@ -205,7 +240,7 @@ fprintf (_tmp19_, "Error in UserSettingsManager(): %s\n", _tmp21_); _g_error_free0 (e); } - __finally4: + __finally3: if (_inner_error_ != NULL) { _g_object_unref0 (settingsFile); _g_free0 (settingsDirPath); @@ -236,178 +271,20 @@ GKeyFile* _tmp0_; gchar* _tmp1_ = NULL; gchar* originalKeyFileData; - GKeyFile* _tmp33_; - gchar* _tmp34_ = NULL; - gchar* _tmp35_; - gboolean _tmp36_; - GError * _inner_error_ = NULL; + GKeyFile* _tmp2_; + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + gboolean _tmp5_; g_return_val_if_fail (self != NULL, FALSE); _tmp0_ = self->priv->keyFile; _tmp1_ = g_key_file_to_data (_tmp0_, NULL, NULL); originalKeyFileData = _tmp1_; - { - GKeyFile* _tmp2_; - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - gchar* _tmp5_; - _tmp2_ = self->priv->keyFile; - _tmp3_ = g_key_file_get_string (_tmp2_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_sourcePathName, &_inner_error_); - _tmp4_ = _tmp3_; - if (_inner_error_ != NULL) { - if (_inner_error_->domain == G_KEY_FILE_ERROR) { - goto __catch5_g_key_file_error; - } - _g_free0 (originalKeyFileData); - g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return FALSE; - } - _tmp5_ = _tmp4_; - dayfolder_user_settings_manager_set_sourcePath (self, _tmp5_); - _g_free0 (_tmp5_); - } - goto __finally5; - __catch5_g_key_file_error: - { - GError* e = NULL; - FILE* _tmp6_; - GError* _tmp7_; - const gchar* _tmp8_; - gchar* _tmp9_ = NULL; - gchar* _tmp10_; - GKeyFile* _tmp11_; - const gchar* _tmp12_; - e = _inner_error_; - _inner_error_ = NULL; - _tmp6_ = stderr; - _tmp7_ = e; - _tmp8_ = _tmp7_->message; - fprintf (_tmp6_, "Error getting string: %s\n", _tmp8_); - _tmp9_ = dayfolder_user_data_getDefaultSourcePath (); - _tmp10_ = _tmp9_; - dayfolder_user_settings_manager_set_sourcePath (self, _tmp10_); - _g_free0 (_tmp10_); - _tmp11_ = self->priv->keyFile; - _tmp12_ = self->priv->_sourcePath; - g_key_file_set_string (_tmp11_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_sourcePathName, _tmp12_); - _g_error_free0 (e); - } - __finally5: - if (_inner_error_ != NULL) { - _g_free0 (originalKeyFileData); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return FALSE; - } - { - GKeyFile* _tmp13_; - gchar* _tmp14_ = NULL; - gchar* _tmp15_; - gchar* _tmp16_; - _tmp13_ = self->priv->keyFile; - _tmp14_ = g_key_file_get_string (_tmp13_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_dfRootPathName, &_inner_error_); - _tmp15_ = _tmp14_; - if (_inner_error_ != NULL) { - if (_inner_error_->domain == G_KEY_FILE_ERROR) { - goto __catch6_g_key_file_error; - } - _g_free0 (originalKeyFileData); - g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return FALSE; - } - _tmp16_ = _tmp15_; - dayfolder_user_settings_manager_set_dfRootPath (self, _tmp16_); - _g_free0 (_tmp16_); - } - goto __finally6; - __catch6_g_key_file_error: - { - GError* e = NULL; - FILE* _tmp17_; - GError* _tmp18_; - const gchar* _tmp19_; - gchar* _tmp20_ = NULL; - gchar* _tmp21_; - GKeyFile* _tmp22_; - const gchar* _tmp23_; - e = _inner_error_; - _inner_error_ = NULL; - _tmp17_ = stderr; - _tmp18_ = e; - _tmp19_ = _tmp18_->message; - fprintf (_tmp17_, "Error getting string: %s\n", _tmp19_); - _tmp20_ = dayfolder_user_data_getDefaultDfRootPath (); - _tmp21_ = _tmp20_; - dayfolder_user_settings_manager_set_dfRootPath (self, _tmp21_); - _g_free0 (_tmp21_); - _tmp22_ = self->priv->keyFile; - _tmp23_ = self->priv->_dfRootPath; - g_key_file_set_string (_tmp22_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_dfRootPathName, _tmp23_); - _g_error_free0 (e); - } - __finally6: - if (_inner_error_ != NULL) { - _g_free0 (originalKeyFileData); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return FALSE; - } - { - GKeyFile* _tmp24_; - gchar* _tmp25_ = NULL; - gchar* _tmp26_; - gchar* _tmp27_; - _tmp24_ = self->priv->keyFile; - _tmp25_ = g_key_file_get_string (_tmp24_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_dfTypeName, &_inner_error_); - _tmp26_ = _tmp25_; - if (_inner_error_ != NULL) { - if (_inner_error_->domain == G_KEY_FILE_ERROR) { - goto __catch7_g_key_file_error; - } - _g_free0 (originalKeyFileData); - g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return FALSE; - } - _tmp27_ = _tmp26_; - dayfolder_user_settings_manager_set_dfType (self, _tmp27_); - _g_free0 (_tmp27_); - } - goto __finally7; - __catch7_g_key_file_error: - { - GError* e = NULL; - FILE* _tmp28_; - GError* _tmp29_; - const gchar* _tmp30_; - GKeyFile* _tmp31_; - const gchar* _tmp32_; - e = _inner_error_; - _inner_error_ = NULL; - _tmp28_ = stderr; - _tmp29_ = e; - _tmp30_ = _tmp29_->message; - fprintf (_tmp28_, "Error getting string: %s\n", _tmp30_); - dayfolder_user_settings_manager_set_dfType (self, DAYFOLDER_USER_SETTINGS_MANAGER_defaultDfType); - _tmp31_ = self->priv->keyFile; - _tmp32_ = self->priv->_dfType; - g_key_file_set_string (_tmp31_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_dfTypeName, _tmp32_); - _g_error_free0 (e); - } - __finally7: - if (_inner_error_ != NULL) { - _g_free0 (originalKeyFileData); - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return FALSE; - } - _tmp33_ = self->priv->keyFile; - _tmp34_ = g_key_file_to_data (_tmp33_, NULL, NULL); - _tmp35_ = _tmp34_; - _tmp36_ = g_strcmp0 (originalKeyFileData, _tmp35_) != 0; - _g_free0 (_tmp35_); - result = _tmp36_; + _tmp2_ = self->priv->keyFile; + _tmp3_ = g_key_file_to_data (_tmp2_, NULL, NULL); + _tmp4_ = _tmp3_; + _tmp5_ = g_strcmp0 (originalKeyFileData, _tmp4_) != 0; + _g_free0 (_tmp4_); + result = _tmp5_; _g_free0 (originalKeyFileData); return result; } @@ -431,11 +308,11 @@ g_file_set_contents (_tmp0_, _tmp3_, (gssize) (-1), &_inner_error_); _g_free0 (_tmp3_); if (_inner_error_ != NULL) { - goto __catch8_g_error; + goto __catch4_g_error; } } - goto __finally8; - __catch8_g_error: + goto __finally4; + __catch4_g_error: { GError* e = NULL; FILE* _tmp4_; @@ -449,7 +326,7 @@ fprintf (_tmp4_, "Error writing keyFile: %s\n", _tmp6_); _g_error_free0 (e); } - __finally8: + __finally4: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -459,157 +336,307 @@ /** - * Set dfRootPath + * Set dfRootPath for the given monitored directory. */ -void dayfolder_user_settings_manager_setDfRootPath (dayfolderUserSettingsManager* self, const gchar* dfRootPath) { +void dayfolder_user_settings_manager_setDfRootPath (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* dfRootPath) { GKeyFile* _tmp0_; const gchar* _tmp1_; const gchar* _tmp2_; g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); g_return_if_fail (dfRootPath != NULL); _tmp0_ = self->priv->keyFile; - _tmp1_ = dfRootPath; - g_key_file_set_string (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_dfRootPathName, _tmp1_); + _tmp1_ = monDirPath; _tmp2_ = dfRootPath; - dayfolder_user_settings_manager_set_dfRootPath (self, _tmp2_); + g_key_file_set_string (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_dfRootPathKey, _tmp2_); dayfolder_user_settings_manager_writeKeyFile (self); } /** - * Set source location path + * Set source location path for the given monitored directory. */ -void dayfolder_user_settings_manager_setSourcePath (dayfolderUserSettingsManager* self, const gchar* sourcePath) { +void dayfolder_user_settings_manager_setSourcePath (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* sourcePath) { GKeyFile* _tmp0_; const gchar* _tmp1_; const gchar* _tmp2_; g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); g_return_if_fail (sourcePath != NULL); _tmp0_ = self->priv->keyFile; - _tmp1_ = sourcePath; - g_key_file_set_string (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_sourcePathName, _tmp1_); + _tmp1_ = monDirPath; _tmp2_ = sourcePath; - dayfolder_user_settings_manager_set_sourcePath (self, _tmp2_); + g_key_file_set_string (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_sourcePathKey, _tmp2_); dayfolder_user_settings_manager_writeKeyFile (self); } /** - * Set dfType + * Set dfType for the given monitored directory. */ -void dayfolder_user_settings_manager_setDfType (dayfolderUserSettingsManager* self, const gchar* dfType) { +void dayfolder_user_settings_manager_setDfType (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* dfType) { GKeyFile* _tmp0_; const gchar* _tmp1_; const gchar* _tmp2_; g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); g_return_if_fail (dfType != NULL); _tmp0_ = self->priv->keyFile; - _tmp1_ = dfType; - g_key_file_set_string (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_groupName, DAYFOLDER_USER_SETTINGS_MANAGER_dfTypeName, _tmp1_); + _tmp1_ = monDirPath; _tmp2_ = dfType; - dayfolder_user_settings_manager_set_dfType (self, _tmp2_); + g_key_file_set_string (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_dfTypeKey, _tmp2_); dayfolder_user_settings_manager_writeKeyFile (self); } /** - * + * Set moveDirs for the given monitored directory. */ -GeeArrayList* dayfolder_user_settings_manager_getFileExtRules (dayfolderUserSettingsManager* self) { +void dayfolder_user_settings_manager_setMoveDirs (dayfolderUserSettingsManager* self, const gchar* monDirPath, gboolean moveDirs) { + GKeyFile* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_; + g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); + _tmp0_ = self->priv->keyFile; + _tmp1_ = monDirPath; + _tmp2_ = moveDirs; + g_key_file_set_boolean (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_moveDirsKey, _tmp2_); + dayfolder_user_settings_manager_writeKeyFile (self); +} + + +/** + * Set useDayFolder for the given monitored directory. + */ +void dayfolder_user_settings_manager_setUseDayFolder (dayfolderUserSettingsManager* self, const gchar* monDirPath, gboolean useDayFolder) { + GKeyFile* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_; + g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); + _tmp0_ = self->priv->keyFile; + _tmp1_ = monDirPath; + _tmp2_ = useDayFolder; + g_key_file_set_boolean (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_useDayFolderKey, _tmp2_); +} + + +/** + * Get the monitored directories. + */ +GeeArrayList* dayfolder_user_settings_manager_getMonitoredDirs (dayfolderUserSettingsManager* self) { GeeArrayList* result = NULL; GeeArrayList* _tmp0_; - GeeArrayList* rules; + GeeArrayList* monitoredDirs; GError * _inner_error_ = NULL; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = gee_array_list_new (DAYFOLDER_TYPE_FILE_EXT_RULE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); - rules = _tmp0_; + _tmp0_ = gee_array_list_new (DAYFOLDER_TYPE_MONITORED_DIRECTORY, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + monitoredDirs = _tmp0_; { GKeyFile* _tmp1_; gsize _tmp2_; gchar** _tmp3_ = NULL; - gchar** fileExts; - gint fileExts_length1; - gint _fileExts_size_; + gchar** monitoredDirPaths; + gint monitoredDirPaths_length1; + gint _monitoredDirPaths_size_; gchar** _tmp4_; gint _tmp4__length1; _tmp1_ = self->priv->keyFile; - _tmp3_ = g_key_file_get_keys (_tmp1_, DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup, &_tmp2_, &_inner_error_); - fileExts = _tmp3_; - fileExts_length1 = _tmp2_; - _fileExts_size_ = fileExts_length1; + _tmp3_ = g_key_file_get_keys (_tmp1_, DAYFOLDER_USER_SETTINGS_MANAGER_monitoredDirsGroup, &_tmp2_, &_inner_error_); + monitoredDirPaths = _tmp3_; + monitoredDirPaths_length1 = _tmp2_; + _monitoredDirPaths_size_ = monitoredDirPaths_length1; if (_inner_error_ != NULL) { - goto __catch9_g_error; + goto __catch5_g_error; } - _tmp4_ = fileExts; - _tmp4__length1 = fileExts_length1; + _tmp4_ = monitoredDirPaths; + _tmp4__length1 = monitoredDirPaths_length1; { - gchar** ext_collection = NULL; - gint ext_collection_length1 = 0; - gint _ext_collection_size_ = 0; - gint ext_it = 0; - ext_collection = _tmp4_; - ext_collection_length1 = _tmp4__length1; - for (ext_it = 0; ext_it < _tmp4__length1; ext_it = ext_it + 1) { + gchar** dirPath_collection = NULL; + gint dirPath_collection_length1 = 0; + gint _dirPath_collection_size_ = 0; + gint dirPath_it = 0; + dirPath_collection = _tmp4_; + dirPath_collection_length1 = _tmp4__length1; + for (dirPath_it = 0; dirPath_it < _tmp4__length1; dirPath_it = dirPath_it + 1) { gchar* _tmp5_; - gchar* ext = NULL; - _tmp5_ = g_strdup (ext_collection[ext_it]); - ext = _tmp5_; + gchar* dirPath = NULL; + _tmp5_ = g_strdup (dirPath_collection[dirPath_it]); + dirPath = _tmp5_; { - GKeyFile* _tmp6_; + const gchar* _tmp6_; const gchar* _tmp7_; - gchar* _tmp8_ = NULL; - gchar* _tmp9_; - GeeArrayList* _tmp10_; + gboolean _tmp8_ = FALSE; + gboolean useDayFolder; + const gchar* _tmp9_; + gchar* _tmp10_ = NULL; + gchar* dfRootPath; const gchar* _tmp11_; - gchar* _tmp12_; - dayfolderFileExtRule* _tmp13_; - dayfolderFileExtRule* _tmp14_; - _tmp6_ = self->priv->keyFile; - _tmp7_ = ext; - _tmp8_ = g_key_file_get_string (_tmp6_, DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup, _tmp7_, &_inner_error_); - _tmp9_ = _tmp8_; - if (_inner_error_ != NULL) { - _g_free0 (ext); + gboolean _tmp12_ = FALSE; + gboolean moveDirs; + const gchar* _tmp13_; + gchar* _tmp14_ = NULL; + gchar* dfType; + const gchar* _tmp15_; + gboolean _tmp16_; + const gchar* _tmp17_; + gboolean _tmp18_; + const gchar* _tmp19_; + dayfolderMonitoredDirectory* _tmp20_; + dayfolderMonitoredDirectory* monDir; + GKeyFile* _tmp21_; + dayfolderMonitoredDirectory* _tmp22_; + const gchar* _tmp23_; + const gchar* _tmp24_; + gboolean _tmp25_ = FALSE; + GeeArrayList* _tmp44_; + dayfolderMonitoredDirectory* _tmp45_; + _tmp6_ = dirPath; + zystem_zystem_debug (_tmp6_); + _tmp7_ = dirPath; + _tmp8_ = dayfolder_user_settings_manager_getUseDayFolder (self, _tmp7_); + useDayFolder = _tmp8_; + _tmp9_ = dirPath; + _tmp10_ = dayfolder_user_settings_manager_getDfRootPath (self, _tmp9_); + dfRootPath = _tmp10_; + _tmp11_ = dirPath; + _tmp12_ = dayfolder_user_settings_manager_getMoveDirs (self, _tmp11_); + moveDirs = _tmp12_; + _tmp13_ = dirPath; + _tmp14_ = dayfolder_user_settings_manager_getDfType (self, _tmp13_); + dfType = _tmp14_; + _tmp15_ = dirPath; + _tmp16_ = useDayFolder; + _tmp17_ = dfRootPath; + _tmp18_ = moveDirs; + _tmp19_ = dfType; + _tmp20_ = dayfolder_monitored_directory_new (_tmp15_, _tmp16_, _tmp17_, _tmp18_, _tmp19_); + monDir = _tmp20_; + _tmp21_ = self->priv->keyFile; + _tmp22_ = monDir; + _tmp23_ = dayfolder_monitored_directory_get_fileExtRulesGroup (_tmp22_); + _tmp24_ = _tmp23_; + _tmp25_ = g_key_file_has_group (_tmp21_, _tmp24_); + if (_tmp25_) { + GKeyFile* _tmp26_; + dayfolderMonitoredDirectory* _tmp27_; + const gchar* _tmp28_; + const gchar* _tmp29_; + gsize _tmp30_; + gchar** _tmp31_ = NULL; + gchar** fileExts; + gint fileExts_length1; + gint _fileExts_size_; + gchar** _tmp32_; + gint _tmp32__length1; + _tmp26_ = self->priv->keyFile; + _tmp27_ = monDir; + _tmp28_ = dayfolder_monitored_directory_get_fileExtRulesGroup (_tmp27_); + _tmp29_ = _tmp28_; + _tmp31_ = g_key_file_get_keys (_tmp26_, _tmp29_, &_tmp30_, &_inner_error_); + fileExts = _tmp31_; + fileExts_length1 = _tmp30_; + _fileExts_size_ = fileExts_length1; + if (_inner_error_ != NULL) { + _g_object_unref0 (monDir); + _g_free0 (dfType); + _g_free0 (dfRootPath); + _g_free0 (dirPath); + monitoredDirPaths = (_vala_array_free (monitoredDirPaths, monitoredDirPaths_length1, (GDestroyNotify) g_free), NULL); + goto __catch5_g_error; + } + _tmp32_ = fileExts; + _tmp32__length1 = fileExts_length1; + { + gchar** ext_collection = NULL; + gint ext_collection_length1 = 0; + gint _ext_collection_size_ = 0; + gint ext_it = 0; + ext_collection = _tmp32_; + ext_collection_length1 = _tmp32__length1; + for (ext_it = 0; ext_it < _tmp32__length1; ext_it = ext_it + 1) { + gchar* _tmp33_; + gchar* ext = NULL; + _tmp33_ = g_strdup (ext_collection[ext_it]); + ext = _tmp33_; + { + GKeyFile* _tmp34_; + dayfolderMonitoredDirectory* _tmp35_; + const gchar* _tmp36_; + const gchar* _tmp37_; + const gchar* _tmp38_; + gchar* _tmp39_ = NULL; + gchar* _tmp40_; + dayfolderMonitoredDirectory* _tmp41_; + const gchar* _tmp42_; + gchar* _tmp43_; + zystem_zystem_debug ("Adding file rule"); + _tmp34_ = self->priv->keyFile; + _tmp35_ = monDir; + _tmp36_ = dayfolder_monitored_directory_get_fileExtRulesGroup (_tmp35_); + _tmp37_ = _tmp36_; + _tmp38_ = ext; + _tmp39_ = g_key_file_get_string (_tmp34_, _tmp37_, _tmp38_, &_inner_error_); + _tmp40_ = _tmp39_; + if (_inner_error_ != NULL) { + _g_free0 (ext); + fileExts = (_vala_array_free (fileExts, fileExts_length1, (GDestroyNotify) g_free), NULL); + _g_object_unref0 (monDir); + _g_free0 (dfType); + _g_free0 (dfRootPath); + _g_free0 (dirPath); + monitoredDirPaths = (_vala_array_free (monitoredDirPaths, monitoredDirPaths_length1, (GDestroyNotify) g_free), NULL); + goto __catch5_g_error; + } + _tmp41_ = monDir; + _tmp42_ = ext; + _tmp43_ = _tmp40_; + dayfolder_monitored_directory_addFileRule (_tmp41_, _tmp42_, _tmp43_); + _g_free0 (_tmp43_); + _g_free0 (ext); + } + } + } fileExts = (_vala_array_free (fileExts, fileExts_length1, (GDestroyNotify) g_free), NULL); - goto __catch9_g_error; } - _tmp10_ = rules; - _tmp11_ = ext; - _tmp12_ = _tmp9_; - _tmp13_ = dayfolder_file_ext_rule_new (_tmp11_, _tmp12_); - _tmp14_ = _tmp13_; - gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp14_); - _g_object_unref0 (_tmp14_); - _g_free0 (_tmp12_); - _g_free0 (ext); + _tmp44_ = monitoredDirs; + _tmp45_ = monDir; + gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, _tmp45_); + _g_object_unref0 (monDir); + _g_free0 (dfType); + _g_free0 (dfRootPath); + _g_free0 (dirPath); } } } - fileExts = (_vala_array_free (fileExts, fileExts_length1, (GDestroyNotify) g_free), NULL); + monitoredDirPaths = (_vala_array_free (monitoredDirPaths, monitoredDirPaths_length1, (GDestroyNotify) g_free), NULL); } - goto __finally9; - __catch9_g_error: + goto __finally5; + __catch5_g_error: { GError* e = NULL; - FILE* _tmp15_; - GError* _tmp16_; - const gchar* _tmp17_; + FILE* _tmp46_; + GError* _tmp47_; + const gchar* _tmp48_; e = _inner_error_; _inner_error_ = NULL; - _tmp15_ = stderr; - _tmp16_ = e; - _tmp17_ = _tmp16_->message; - fprintf (_tmp15_, "Error in UserSettingsManager.getFileExtRules(): %s\n", _tmp17_); + _tmp46_ = stderr; + _tmp47_ = e; + _tmp48_ = _tmp47_->message; + fprintf (_tmp46_, "Error in UserSettingsManager.getMonitoredDirs(): %s\n", _tmp48_); + zystem_zystem_debug ("Settings file didn't have MonitoredDir info in it. That's totally fine" \ +"."); _g_error_free0 (e); } - __finally9: + __finally5: if (_inner_error_ != NULL) { - _g_object_unref0 (rules); + _g_object_unref0 (monitoredDirs); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } - result = rules; + result = monitoredDirs; return result; } @@ -617,40 +644,76 @@ /** * */ -void dayfolder_user_settings_manager_addFileExtRule (dayfolderUserSettingsManager* self, dayfolderFileExtRule* rule) { +void dayfolder_user_settings_manager_addFileRule (dayfolderUserSettingsManager* self, const gchar* monDirPath, dayfolderDfRule* rule) { GKeyFile* _tmp0_; - dayfolderFileExtRule* _tmp1_; - const gchar* _tmp2_; - const gchar* _tmp3_; - dayfolderFileExtRule* _tmp4_; + const gchar* _tmp1_; + gchar* _tmp2_; + gchar* _tmp3_; + dayfolderDfRule* _tmp4_; const gchar* _tmp5_; const gchar* _tmp6_; + dayfolderDfRule* _tmp7_; + const gchar* _tmp8_; + const gchar* _tmp9_; g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); g_return_if_fail (rule != NULL); _tmp0_ = self->priv->keyFile; - _tmp1_ = rule; - _tmp2_ = dayfolder_file_ext_rule_get_fileExt (_tmp1_); + _tmp1_ = monDirPath; + _tmp2_ = g_strconcat (_tmp1_, DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup, NULL); _tmp3_ = _tmp2_; _tmp4_ = rule; - _tmp5_ = dayfolder_file_ext_rule_get_destinationDir (_tmp4_); + _tmp5_ = dayfolder_df_rule_get_criteriaString (_tmp4_); _tmp6_ = _tmp5_; - g_key_file_set_string (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup, _tmp3_, _tmp6_); + _tmp7_ = rule; + _tmp8_ = dayfolder_df_rule_get_destinationDir (_tmp7_); + _tmp9_ = _tmp8_; + g_key_file_set_string (_tmp0_, _tmp3_, _tmp6_, _tmp9_); + _g_free0 (_tmp3_); dayfolder_user_settings_manager_writeKeyFile (self); } /** - * + * Add monitored directory. */ -void dayfolder_user_settings_manager_removeFileExtRule (dayfolderUserSettingsManager* self, const gchar* fileExt) { +void dayfolder_user_settings_manager_addMonitoredDirectory (dayfolderUserSettingsManager* self, dayfolderMonitoredDirectory* dir) { + GKeyFile* _tmp0_; + dayfolderMonitoredDirectory* _tmp1_; + const gchar* _tmp2_; + const gchar* _tmp3_; + GKeyFile* _tmp4_; + dayfolderMonitoredDirectory* _tmp5_; + const gchar* _tmp6_; + const gchar* _tmp7_; + g_return_if_fail (self != NULL); + g_return_if_fail (dir != NULL); + _tmp0_ = self->priv->keyFile; + _tmp1_ = dir; + _tmp2_ = dayfolder_monitored_directory_get_dirPath (_tmp1_); + _tmp3_ = _tmp2_; + g_key_file_set_boolean (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_monitoredDirsGroup, _tmp3_, TRUE); + _tmp4_ = self->priv->keyFile; + _tmp5_ = dir; + _tmp6_ = dayfolder_monitored_directory_get_dirPath (_tmp5_); + _tmp7_ = _tmp6_; + g_key_file_set_boolean (_tmp4_, _tmp7_, DAYFOLDER_MONITORED_DIRECTORY_useDayFolderKey, TRUE); + dayfolder_user_settings_manager_writeKeyFile (self); +} + + +/** + * Remove monitored directory. + */ +void dayfolder_user_settings_manager_removeMonitoredDirectory (dayfolderUserSettingsManager* self, const gchar* dirPath) { GKeyFile* _tmp0_; const gchar* _tmp1_; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); - g_return_if_fail (fileExt != NULL); + g_return_if_fail (dirPath != NULL); _tmp0_ = self->priv->keyFile; - _tmp1_ = fileExt; - g_key_file_remove_key (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup, _tmp1_, &_inner_error_); + _tmp1_ = dirPath; + g_key_file_remove_key (_tmp0_, DAYFOLDER_USER_SETTINGS_MANAGER_monitoredDirsGroup, _tmp1_, &_inner_error_); if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); @@ -660,81 +723,231 @@ } -const gchar* dayfolder_user_settings_manager_get_sourcePath (dayfolderUserSettingsManager* self) { - const gchar* result; - const gchar* _tmp0_; - g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_sourcePath; - result = _tmp0_; - return result; +/** + * Remove the FileExtRule for the given monitored directory. + */ +void dayfolder_user_settings_manager_removeFileRule (dayfolderUserSettingsManager* self, const gchar* monDirPath, const gchar* criteria) { + GKeyFile* _tmp0_; + const gchar* _tmp1_; + gchar* _tmp2_; + gchar* _tmp3_; + const gchar* _tmp4_; + GError * _inner_error_ = NULL; + g_return_if_fail (self != NULL); + g_return_if_fail (monDirPath != NULL); + g_return_if_fail (criteria != NULL); + _tmp0_ = self->priv->keyFile; + _tmp1_ = monDirPath; + _tmp2_ = g_strconcat (_tmp1_, DAYFOLDER_USER_SETTINGS_MANAGER_fileExtRulesGroup, NULL); + _tmp3_ = _tmp2_; + _tmp4_ = criteria; + g_key_file_remove_key (_tmp0_, _tmp3_, _tmp4_, &_inner_error_); + _g_free0 (_tmp3_); + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return; + } + dayfolder_user_settings_manager_writeKeyFile (self); } -static void dayfolder_user_settings_manager_set_sourcePath (dayfolderUserSettingsManager* self, const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; - g_return_if_fail (self != NULL); - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); - _g_free0 (self->priv->_sourcePath); - self->priv->_sourcePath = _tmp1_; - g_object_notify ((GObject *) self, "sourcePath"); +/** + * Get the UseDayFolder setting for the monitored dirpath. + */ +static gboolean dayfolder_user_settings_manager_getUseDayFolder (dayfolderUserSettingsManager* self, const gchar* dirPath) { + gboolean result = FALSE; + gboolean useDf; + GError * _inner_error_ = NULL; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (dirPath != NULL, FALSE); + useDf = TRUE; + { + GKeyFile* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_ = FALSE; + gboolean _tmp3_; + _tmp0_ = self->priv->keyFile; + _tmp1_ = dirPath; + _tmp2_ = g_key_file_get_boolean (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_useDayFolderKey, &_inner_error_); + _tmp3_ = _tmp2_; + if (_inner_error_ != NULL) { + goto __catch6_g_error; + } + useDf = _tmp3_; + } + goto __finally6; + __catch6_g_error: + { + GError* e = NULL; + e = _inner_error_; + _inner_error_ = NULL; + zystem_zystem_debug ("Could not retrieve UseDayFolder setting. Using default value."); + _g_error_free0 (e); + } + __finally6: + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return FALSE; + } + result = useDf; + return result; } -const gchar* dayfolder_user_settings_manager_get_dfRootPath (dayfolderUserSettingsManager* self) { - const gchar* result; - const gchar* _tmp0_; +/** + * Get the dfRootPath setting for the monitored dirpath. + */ +static gchar* dayfolder_user_settings_manager_getDfRootPath (dayfolderUserSettingsManager* self, const gchar* dirPath) { + gchar* result = NULL; + gchar* _tmp0_ = NULL; + gchar* rootPath; + const gchar* _tmp5_; + gchar* _tmp6_; + gchar* _tmp7_; + GError * _inner_error_ = NULL; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_dfRootPath; - result = _tmp0_; + g_return_val_if_fail (dirPath != NULL, NULL); + _tmp0_ = dayfolder_user_data_getDefaultDfRootPath (); + rootPath = _tmp0_; + { + GKeyFile* _tmp1_; + const gchar* _tmp2_; + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + _tmp1_ = self->priv->keyFile; + _tmp2_ = dirPath; + _tmp3_ = g_key_file_get_string (_tmp1_, _tmp2_, DAYFOLDER_MONITORED_DIRECTORY_dfRootPathKey, &_inner_error_); + _tmp4_ = _tmp3_; + if (_inner_error_ != NULL) { + goto __catch7_g_error; + } + _g_free0 (rootPath); + rootPath = _tmp4_; + } + goto __finally7; + __catch7_g_error: + { + GError* e = NULL; + e = _inner_error_; + _inner_error_ = NULL; + zystem_zystem_debug ("Could not retrieve DayFolder root path setting. Using default value."); + _g_error_free0 (e); + } + __finally7: + if (_inner_error_ != NULL) { + _g_free0 (rootPath); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return NULL; + } + _tmp5_ = rootPath; + _tmp6_ = g_strconcat ("DayFolder Root Path is: ", _tmp5_, NULL); + _tmp7_ = _tmp6_; + zystem_zystem_debug (_tmp7_); + _g_free0 (_tmp7_); + result = rootPath; return result; } -static void dayfolder_user_settings_manager_set_dfRootPath (dayfolderUserSettingsManager* self, const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; - g_return_if_fail (self != NULL); - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); - _g_free0 (self->priv->_dfRootPath); - self->priv->_dfRootPath = _tmp1_; - g_object_notify ((GObject *) self, "dfRootPath"); +/** + * Get the moveDirs setting for the monitored dirpath. + */ +static gboolean dayfolder_user_settings_manager_getMoveDirs (dayfolderUserSettingsManager* self, const gchar* dirPath) { + gboolean result = FALSE; + gboolean moveDirs; + GError * _inner_error_ = NULL; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (dirPath != NULL, FALSE); + moveDirs = TRUE; + { + GKeyFile* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_ = FALSE; + gboolean _tmp3_; + _tmp0_ = self->priv->keyFile; + _tmp1_ = dirPath; + _tmp2_ = g_key_file_get_boolean (_tmp0_, _tmp1_, DAYFOLDER_MONITORED_DIRECTORY_moveDirsKey, &_inner_error_); + _tmp3_ = _tmp2_; + if (_inner_error_ != NULL) { + goto __catch8_g_error; + } + moveDirs = _tmp3_; + } + goto __finally8; + __catch8_g_error: + { + GError* e = NULL; + e = _inner_error_; + _inner_error_ = NULL; + zystem_zystem_debug ("Could not retrieve Move Subfolders setting. Using default value."); + _g_error_free0 (e); + } + __finally8: + if (_inner_error_ != NULL) { + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return FALSE; + } + result = moveDirs; + return result; } -const gchar* dayfolder_user_settings_manager_get_dfType (dayfolderUserSettingsManager* self) { - const gchar* result; - const gchar* _tmp0_; +/** + * Get the dfType setting for the monitored dirpath. + */ +static gchar* dayfolder_user_settings_manager_getDfType (dayfolderUserSettingsManager* self, const gchar* dirPath) { + gchar* result = NULL; + gchar* _tmp0_; + gchar* dfType; + GError * _inner_error_ = NULL; g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = self->priv->_dfType; - result = _tmp0_; + g_return_val_if_fail (dirPath != NULL, NULL); + _tmp0_ = g_strdup (DAYFOLDER_USER_DATA_dfTypeDaily); + dfType = _tmp0_; + { + GKeyFile* _tmp1_; + const gchar* _tmp2_; + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + _tmp1_ = self->priv->keyFile; + _tmp2_ = dirPath; + _tmp3_ = g_key_file_get_string (_tmp1_, _tmp2_, DAYFOLDER_MONITORED_DIRECTORY_dfTypeKey, &_inner_error_); + _tmp4_ = _tmp3_; + if (_inner_error_ != NULL) { + goto __catch9_g_error; + } + _g_free0 (dfType); + dfType = _tmp4_; + } + goto __finally9; + __catch9_g_error: + { + GError* e = NULL; + e = _inner_error_; + _inner_error_ = NULL; + zystem_zystem_debug ("Could not retrieve DayFolder type setting. Using default value."); + _g_error_free0 (e); + } + __finally9: + if (_inner_error_ != NULL) { + _g_free0 (dfType); + g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); + g_clear_error (&_inner_error_); + return NULL; + } + result = dfType; return result; } -static void dayfolder_user_settings_manager_set_dfType (dayfolderUserSettingsManager* self, const gchar* value) { - const gchar* _tmp0_; - gchar* _tmp1_; - g_return_if_fail (self != NULL); - _tmp0_ = value; - _tmp1_ = g_strdup (_tmp0_); - _g_free0 (self->priv->_dfType); - self->priv->_dfType = _tmp1_; - g_object_notify ((GObject *) self, "dfType"); -} - - static void dayfolder_user_settings_manager_class_init (dayfolderUserSettingsManagerClass * klass) { dayfolder_user_settings_manager_parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (dayfolderUserSettingsManagerPrivate)); - G_OBJECT_CLASS (klass)->get_property = _vala_dayfolder_user_settings_manager_get_property; - G_OBJECT_CLASS (klass)->set_property = _vala_dayfolder_user_settings_manager_set_property; G_OBJECT_CLASS (klass)->finalize = dayfolder_user_settings_manager_finalize; - g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_USER_SETTINGS_MANAGER_SOURCE_PATH, g_param_spec_string ("sourcePath", "sourcePath", "sourcePath", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_USER_SETTINGS_MANAGER_DF_ROOT_PATH, g_param_spec_string ("dfRootPath", "dfRootPath", "dfRootPath", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), DAYFOLDER_USER_SETTINGS_MANAGER_DF_TYPE, g_param_spec_string ("dfType", "dfType", "dfType", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); } @@ -745,12 +958,9 @@ static void dayfolder_user_settings_manager_finalize (GObject* obj) { dayfolderUserSettingsManager * self; - self = DAYFOLDER_USER_SETTINGS_MANAGER (obj); + self = G_TYPE_CHECK_INSTANCE_CAST (obj, DAYFOLDER_TYPE_USER_SETTINGS_MANAGER, dayfolderUserSettingsManager); _g_key_file_free0 (self->priv->keyFile); _g_free0 (self->priv->dfConfPath); - _g_free0 (self->priv->_sourcePath); - _g_free0 (self->priv->_dfRootPath); - _g_free0 (self->priv->_dfType); G_OBJECT_CLASS (dayfolder_user_settings_manager_parent_class)->finalize (obj); } @@ -771,46 +981,6 @@ } -static void _vala_dayfolder_user_settings_manager_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - dayfolderUserSettingsManager * self; - self = DAYFOLDER_USER_SETTINGS_MANAGER (object); - switch (property_id) { - case DAYFOLDER_USER_SETTINGS_MANAGER_SOURCE_PATH: - g_value_set_string (value, dayfolder_user_settings_manager_get_sourcePath (self)); - break; - case DAYFOLDER_USER_SETTINGS_MANAGER_DF_ROOT_PATH: - g_value_set_string (value, dayfolder_user_settings_manager_get_dfRootPath (self)); - break; - case DAYFOLDER_USER_SETTINGS_MANAGER_DF_TYPE: - g_value_set_string (value, dayfolder_user_settings_manager_get_dfType (self)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - - -static void _vala_dayfolder_user_settings_manager_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - dayfolderUserSettingsManager * self; - self = DAYFOLDER_USER_SETTINGS_MANAGER (object); - switch (property_id) { - case DAYFOLDER_USER_SETTINGS_MANAGER_SOURCE_PATH: - dayfolder_user_settings_manager_set_sourcePath (self, g_value_get_string (value)); - break; - case DAYFOLDER_USER_SETTINGS_MANAGER_DF_ROOT_PATH: - dayfolder_user_settings_manager_set_dfRootPath (self, g_value_get_string (value)); - break; - case DAYFOLDER_USER_SETTINGS_MANAGER_DF_TYPE: - dayfolder_user_settings_manager_set_dfType (self, g_value_get_string (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - - static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) { if ((array != NULL) && (destroy_func != NULL)) { int i; diff -Nru dayfolder-1.4.1/src/UserSettingsManager.vala dayfolder-2.0.0/src/UserSettingsManager.vala --- dayfolder-1.4.1/src/UserSettingsManager.vala 2012-05-09 23:15:18.000000000 +0000 +++ dayfolder-2.0.0/src/UserSettingsManager.vala 2013-05-11 22:14:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ + using Gee; using zystem; @@ -15,19 +34,11 @@ string dfConfPath; - const string groupName = "DayFolder"; const string fileExtRulesGroup = "FileExtRules"; - const string defaultDfType = UserData.dfTypeDaily; - - // Settings variables - const string sourcePathName = "sourcePath"; - const string dfRootPathName = "dfRootPath"; - const string dfTypeName = "dfType"; - public string sourcePath { get; private set; } - public string dfRootPath { get; private set; } - public string dfType { get; private set; } + const string monitoredDirsGroup = "MonitoredDirectories"; + const string defaultDfType = UserData.dfTypeDaily; /** * Constructor. @@ -72,36 +83,6 @@ */ private bool processKeyFile() { string originalKeyFileData = keyFile.to_data(); - - // If sourcePath key does not exist, set default value - try { - sourcePath = keyFile.get_string(groupName, sourcePathName); - } catch (KeyFileError e) { - stderr.printf("Error getting string: %s\n", e.message); - // Set to default value - sourcePath = UserData.getDefaultSourcePath(); - keyFile.set_string(groupName, sourcePathName, sourcePath); - } - - // If dfRootPath key does not exist, set default value - try { - dfRootPath = keyFile.get_string(groupName, dfRootPathName); - } catch (KeyFileError e) { - stderr.printf("Error getting string: %s\n", e.message); - // Set to default value - dfRootPath = UserData.getDefaultDfRootPath(); - keyFile.set_string(groupName, dfRootPathName, dfRootPath); - } - - // If dfType key does not exist, set default value - try { - dfType = keyFile.get_string(groupName, dfTypeName); - } catch (KeyFileError e) { - stderr.printf("Error getting string: %s\n", e.message); - // Set to default value - dfType = defaultDfType; - keyFile.set_string(groupName, dfTypeName, dfType); - } // Return true if the keyFile data has been updated (if it's no longer the same as it was) return originalKeyFileData != keyFile.to_data(); @@ -119,66 +100,181 @@ } /** - * Set dfRootPath + * Set dfRootPath for the given monitored directory. */ - public void setDfRootPath(string dfRootPath) { - keyFile.set_string(groupName, dfRootPathName, dfRootPath); - this.dfRootPath = dfRootPath; + public void setDfRootPath(string monDirPath, string dfRootPath) { + keyFile.set_string(monDirPath, MonitoredDirectory.dfRootPathKey, dfRootPath); writeKeyFile(); } /** - * Set source location path + * Set source location path for the given monitored directory. */ - public void setSourcePath(string sourcePath) { - keyFile.set_string(groupName, sourcePathName, sourcePath); - this.sourcePath = sourcePath; + public void setSourcePath(string monDirPath, string sourcePath) { + keyFile.set_string(monDirPath, MonitoredDirectory.sourcePathKey, sourcePath); writeKeyFile(); } /** - * Set dfType + * Set dfType for the given monitored directory. */ - public void setDfType(string dfType) { - keyFile.set_string(groupName, dfTypeName, dfType); - this.dfType = dfType; + public void setDfType(string monDirPath, string dfType) { + keyFile.set_string(monDirPath, MonitoredDirectory.dfTypeKey, dfType); writeKeyFile(); } /** - * + * Set moveDirs for the given monitored directory. */ - public ArrayList getFileExtRules() { - ArrayList rules = new ArrayList(); - try { - string[] fileExts = keyFile.get_keys(fileExtRulesGroup); + public void setMoveDirs(string monDirPath, bool moveDirs) { + keyFile.set_boolean(monDirPath, MonitoredDirectory.moveDirsKey, moveDirs); + writeKeyFile(); + } + + /** + * Set useDayFolder for the given monitored directory. + */ + public void setUseDayFolder(string monDirPath, bool useDayFolder) { + keyFile.set_boolean(monDirPath, MonitoredDirectory.useDayFolderKey, useDayFolder); + } + + /** + * Get the monitored directories. + */ + public ArrayList getMonitoredDirs() { + ArrayList monitoredDirs = new ArrayList(); + + try{ + string[] monitoredDirPaths = keyFile.get_keys(monitoredDirsGroup); - foreach (string ext in fileExts) { - rules.add(new FileExtRule(ext, keyFile.get_string(fileExtRulesGroup, ext))); + foreach (string dirPath in monitoredDirPaths) { + Zystem.debug(dirPath); + + bool useDayFolder = getUseDayFolder(dirPath); + string dfRootPath = getDfRootPath(dirPath); + bool moveDirs = getMoveDirs(dirPath); + string dfType = getDfType(dirPath); + + var monDir = new MonitoredDirectory(dirPath, useDayFolder, dfRootPath, moveDirs, dfType); + + // FileExtRules + if (keyFile.has_group(monDir.fileExtRulesGroup)) { + string[] fileExts = keyFile.get_keys(monDir.fileExtRulesGroup); + + foreach (string ext in fileExts) { + Zystem.debug("Adding file rule"); + monDir.addFileRule(ext, keyFile.get_string(monDir.fileExtRulesGroup, ext)); + } + } + + monitoredDirs.add(monDir); } } catch (Error e) { - stderr.printf ("Error in UserSettingsManager.getFileExtRules(): %s\n", e.message); + stderr.printf ("Error in UserSettingsManager.getMonitoredDirs(): %s\n", e.message); + Zystem.debug("Settings file didn't have MonitoredDir info in it. That's totally fine."); } - return rules; + + return monitoredDirs; } /** * */ - public void addFileExtRule(FileExtRule rule) { - // - keyFile.set_string(fileExtRulesGroup, rule.fileExt, rule.destinationDir); + public void addFileRule(string monDirPath, DfRule rule) { + keyFile.set_string(monDirPath + fileExtRulesGroup, rule.criteriaString, rule.destinationDir); writeKeyFile(); } /** - * + * Add monitored directory. */ - public void removeFileExtRule(string fileExt) { - keyFile.remove_key(fileExtRulesGroup, fileExt); + public void addMonitoredDirectory(MonitoredDirectory dir) { + // Create the new monitored directory entry and related settings group + keyFile.set_boolean(monitoredDirsGroup, dir.dirPath, true); + keyFile.set_boolean(dir.dirPath, MonitoredDirectory.useDayFolderKey, true); writeKeyFile(); } + + /** + * Remove monitored directory. + */ + public void removeMonitoredDirectory(string dirPath) { + keyFile.remove_key(monitoredDirsGroup, dirPath); + writeKeyFile(); + } + + /** + * Remove the FileExtRule for the given monitored directory. + */ + public void removeFileRule(string monDirPath, string criteria) { + keyFile.remove_key(monDirPath + fileExtRulesGroup, criteria); + writeKeyFile(); + } + + + + /** + * Get the UseDayFolder setting for the monitored dirpath. + */ + private bool getUseDayFolder(string dirPath) { + bool useDf = true; // Default value + + try { + useDf = keyFile.get_boolean(dirPath, MonitoredDirectory.useDayFolderKey); + } catch (Error e) { + Zystem.debug("Could not retrieve UseDayFolder setting. Using default value."); + } + + return useDf; + } + + /** + * Get the dfRootPath setting for the monitored dirpath. + */ + private string getDfRootPath(string dirPath) { + string rootPath = UserData.getDefaultDfRootPath(); // Default value + + try { + rootPath = keyFile.get_string(dirPath, MonitoredDirectory.dfRootPathKey); + } catch (Error e) { + Zystem.debug("Could not retrieve DayFolder root path setting. Using default value."); + } + + Zystem.debug("DayFolder Root Path is: " + rootPath); + + return rootPath; + } + + /** + * Get the moveDirs setting for the monitored dirpath. + */ + private bool getMoveDirs(string dirPath) { + bool moveDirs = true; // Default value + + try { + moveDirs = keyFile.get_boolean(dirPath, MonitoredDirectory.moveDirsKey); + } catch (Error e) { + Zystem.debug("Could not retrieve Move Subfolders setting. Using default value."); + } + + return moveDirs; + } + + /** + * Get the dfType setting for the monitored dirpath. + */ + private string getDfType(string dirPath) { + string dfType = UserData.dfTypeDaily; // Default value + + try { + dfType = keyFile.get_string(dirPath, MonitoredDirectory.dfTypeKey); + } catch (Error e) { + Zystem.debug("Could not retrieve DayFolder type setting. Using default value."); + } + + return dfType; + } } -} \ No newline at end of file +} diff -Nru dayfolder-1.4.1/src/Zystem.c dayfolder-2.0.0/src/Zystem.c --- dayfolder-1.4.1/src/Zystem.c 2012-05-14 02:26:46.000000000 +0000 +++ dayfolder-2.0.0/src/Zystem.c 2013-05-11 22:28:22.000000000 +0000 @@ -1,13 +1,31 @@ -/* Zystem.c generated by valac 0.14.2, the Vala compiler +/* Zystem.c generated by valac 0.18.1, the Vala compiler * generated from Zystem.vala, do not modify */ -/*using GLib;*/ +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ #include #include #include #include #include +#include #define ZYSTEM_TYPE_ZYSTEM (zystem_zystem_get_type ()) @@ -33,14 +51,24 @@ static gpointer zystem_zystem_parent_class = NULL; +static gboolean zystem_zystem__debugOn; +static gboolean zystem_zystem__debugOn = FALSE; GType zystem_zystem_get_type (void) G_GNUC_CONST; enum { ZYSTEM_ZYSTEM_DUMMY_PROPERTY }; void zystem_zystem_println (const gchar* s); +void zystem_zystem_debug (const gchar* s); +gboolean zystem_zystem_get_debugOn (void); +void zystem_zystem_debugFileInfo (GFileInfo* file); +const gchar* g_file_type_to_string (GFileType self); zystemZystem* zystem_zystem_new (void); zystemZystem* zystem_zystem_construct (GType object_type); +void zystem_zystem_set_debugOn (gboolean value); +static void zystem_zystem_finalize (GObject* obj); +static void _vala_zystem_zystem_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void _vala_zystem_zystem_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); /** @@ -61,6 +89,50 @@ } +/** + * Debug method. Only prints if debug is set on. + */ +void zystem_zystem_debug (const gchar* s) { + gboolean _tmp0_; + gboolean _tmp1_; + g_return_if_fail (s != NULL); + _tmp0_ = zystem_zystem_get_debugOn (); + _tmp1_ = _tmp0_; + if (_tmp1_) { + FILE* _tmp2_; + const gchar* _tmp3_; + gchar* _tmp4_; + gchar* _tmp5_; + _tmp2_ = stdout; + _tmp3_ = s; + _tmp4_ = g_strconcat (_tmp3_, "\n", NULL); + _tmp5_ = _tmp4_; + fprintf (_tmp2_, "%s", _tmp5_); + _g_free0 (_tmp5_); + } +} + + +/** + * + */ +void zystem_zystem_debugFileInfo (GFileInfo* file) { + GFileInfo* _tmp0_; + GFileType _tmp1_ = 0; + GEnumValue* _tmp2_; + gchar* _tmp3_; + gchar* _tmp4_; + g_return_if_fail (file != NULL); + _tmp0_ = file; + _tmp1_ = g_file_info_get_file_type (_tmp0_); + _tmp2_ = g_enum_get_value (g_type_class_ref (g_file_type_get_type ()), _tmp1_); + _tmp3_ = g_strconcat ("File type: ", (_tmp2_ != NULL) ? _tmp2_->value_name : NULL, NULL); + _tmp4_ = _tmp3_; + zystem_zystem_debug (_tmp4_); + _g_free0 (_tmp4_); +} + + zystemZystem* zystem_zystem_construct (GType object_type) { zystemZystem * self = NULL; self = (zystemZystem*) g_object_new (object_type, NULL); @@ -73,8 +145,27 @@ } +gboolean zystem_zystem_get_debugOn (void) { + gboolean result; + gboolean _tmp0_; + _tmp0_ = zystem_zystem__debugOn; + result = _tmp0_; + return result; +} + + +void zystem_zystem_set_debugOn (gboolean value) { + gboolean _tmp0_; + _tmp0_ = value; + zystem_zystem__debugOn = _tmp0_; +} + + static void zystem_zystem_class_init (zystemZystemClass * klass) { zystem_zystem_parent_class = g_type_class_peek_parent (klass); + G_OBJECT_CLASS (klass)->get_property = _vala_zystem_zystem_get_property; + G_OBJECT_CLASS (klass)->set_property = _vala_zystem_zystem_set_property; + G_OBJECT_CLASS (klass)->finalize = zystem_zystem_finalize; } @@ -82,6 +173,13 @@ } +static void zystem_zystem_finalize (GObject* obj) { + zystemZystem * self; + self = G_TYPE_CHECK_INSTANCE_CAST (obj, ZYSTEM_TYPE_ZYSTEM, zystemZystem); + G_OBJECT_CLASS (zystem_zystem_parent_class)->finalize (obj); +} + + /** * This class is for random helpful methods. */ @@ -97,4 +195,26 @@ } +static void _vala_zystem_zystem_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + zystemZystem * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, ZYSTEM_TYPE_ZYSTEM, zystemZystem); + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +static void _vala_zystem_zystem_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { + zystemZystem * self; + self = G_TYPE_CHECK_INSTANCE_CAST (object, ZYSTEM_TYPE_ZYSTEM, zystemZystem); + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + diff -Nru dayfolder-1.4.1/src/Zystem.vala dayfolder-2.0.0/src/Zystem.vala --- dayfolder-1.4.1/src/Zystem.vala 2012-05-14 02:26:28.000000000 +0000 +++ dayfolder-2.0.0/src/Zystem.vala 2013-05-11 22:13:33.000000000 +0000 @@ -1,4 +1,21 @@ -//using GLib; +/* + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or + * (at your option) any later version. + * + * DayFolder 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, see . + */ namespace zystem { @@ -7,6 +24,8 @@ */ class Zystem : GLib.Object { + public static bool debugOn { get; set; default = false; } + /** * My own println method. Hey, I'm a Java programmer! */ @@ -14,7 +33,23 @@ stdout.printf(s + "\n"); } + /** + * Debug method. Only prints if debug is set on. + */ + public static void debug(string s) { + if (debugOn) { + stdout.printf(s + "\n"); + } + } + + /** + * + */ + public static void debugFileInfo(FileInfo file) { + debug("File type: " + file.get_file_type().to_string()); + } + } -} \ No newline at end of file +} diff -Nru dayfolder-1.4.1/src/dayfolder.c dayfolder-2.0.0/src/dayfolder.c --- dayfolder-1.4.1/src/dayfolder.c 2012-06-09 14:36:47.000000000 +0000 +++ dayfolder-2.0.0/src/dayfolder.c 2013-05-11 22:28:22.000000000 +0000 @@ -1,12 +1,13 @@ -/* dayfolder.c generated by valac 0.14.2, the Vala compiler +/* dayfolder.c generated by valac 0.18.1, the Vala compiler * generated from dayfolder.vala, do not modify */ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * main.c - * Copyright (C) Zach Burnham 2012 - * -DayFolder is free software: you can redistribute it and/or modify it + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or * (at your option) any later version. @@ -26,11 +27,14 @@ #include #include #include -#include +#include "config.h" #include #include #include +#include +#include #include +#include #define TYPE_MAIN (main_get_type ()) @@ -43,30 +47,29 @@ typedef struct _Main Main; typedef struct _MainClass MainClass; typedef struct _MainPrivate MainPrivate; - -#define DAYFOLDER_TYPE_DAY_FOLDER (dayfolder_day_folder_get_type ()) -#define DAYFOLDER_DAY_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DAY_FOLDER, dayfolderDayFolder)) -#define DAYFOLDER_DAY_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_DAY_FOLDER, dayfolderDayFolderClass)) -#define DAYFOLDER_IS_DAY_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DAY_FOLDER)) -#define DAYFOLDER_IS_DAY_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_DAY_FOLDER)) -#define DAYFOLDER_DAY_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_DAY_FOLDER, dayfolderDayFolderClass)) - -typedef struct _dayfolderDayFolder dayfolderDayFolder; -typedef struct _dayfolderDayFolderClass dayfolderDayFolderClass; #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL))) #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) +typedef struct _Block1Data Block1Data; -#define DAYFOLDER_TYPE_FILE_EXT_RULE (dayfolder_file_ext_rule_get_type ()) -#define DAYFOLDER_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRule)) -#define DAYFOLDER_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) -#define DAYFOLDER_IS_FILE_EXT_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_IS_FILE_EXT_RULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_FILE_EXT_RULE)) -#define DAYFOLDER_FILE_EXT_RULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_FILE_EXT_RULE, dayfolderFileExtRuleClass)) +#define DAYFOLDER_TYPE_DF_RULE (dayfolder_df_rule_get_type ()) +#define DAYFOLDER_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRule)) +#define DAYFOLDER_IS_DF_RULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_DF_RULE)) +#define DAYFOLDER_DF_RULE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DAYFOLDER_TYPE_DF_RULE, dayfolderDfRuleIface)) + +typedef struct _dayfolderDfRule dayfolderDfRule; +typedef struct _dayfolderDfRuleIface dayfolderDfRuleIface; + +#define DAYFOLDER_TYPE_MONITORED_DIRECTORY (dayfolder_monitored_directory_get_type ()) +#define DAYFOLDER_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectory)) +#define DAYFOLDER_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_IS_MONITORED_DIRECTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DAYFOLDER_TYPE_MONITORED_DIRECTORY)) +#define DAYFOLDER_MONITORED_DIRECTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DAYFOLDER_TYPE_MONITORED_DIRECTORY, dayfolderMonitoredDirectoryClass)) -typedef struct _dayfolderFileExtRule dayfolderFileExtRule; -typedef struct _dayfolderFileExtRuleClass dayfolderFileExtRuleClass; +typedef struct _dayfolderMonitoredDirectory dayfolderMonitoredDirectory; +typedef struct _dayfolderMonitoredDirectoryClass dayfolderMonitoredDirectoryClass; #define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL))) struct _Main { @@ -79,16 +82,47 @@ }; struct _MainPrivate { - dayfolderDayFolder* dayFolder; - GtkBuilder* dfSettingsBuilder; + GtkWindow* window; GList* fileExtList; + GList* monitoredDirsList; + gchar* currentMonitoredDir; + GtkTreeView* tvFileRules; + GtkTreeView* tvMonitoredDirs; + GtkRadioButton* rdoDaily; + GtkRadioButton* rdoWeekly; + GtkRadioButton* rdoMonthly; + GtkEntry* txtFileNameContains; + GtkEntry* txtFileRuleDest; + GtkLabel* lblDfLocationDisplay; + GtkSwitch* swUseDayFolder; + GtkSwitch* swMoveSubfolders; + GtkButton* btnChangeDfLocation; + GtkButton* btnChangeFileRuleDest; + GtkLabel* lblSrcFolderLocationDisplay; + GtkLabel* lblSubfoldersOption; + GtkLabel* lblDfTypeHeading; +}; + +struct _Block1Data { + int _ref_count_; + Main * self; + GtkButton* btnAddMonitoredDir; + GtkButton* btnRemoveMonitoredDir; +}; + +struct _dayfolderDfRuleIface { + GTypeInterface parent_iface; + gboolean (*processFile) (dayfolderDfRule* self, GFileInfo* file, const gchar* dirPath); + const gchar* (*get_criteriaString) (dayfolderDfRule* self); + void (*set_criteriaString) (dayfolderDfRule* self, const gchar* value); + const gchar* (*get_destinationDir) (dayfolderDfRule* self); + void (*set_destinationDir) (dayfolderDfRule* self, const gchar* value); }; static gpointer main_parent_class = NULL; GType main_get_type (void) G_GNUC_CONST; -GType dayfolder_day_folder_get_type (void) G_GNUC_CONST; #define MAIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN, MainPrivate)) enum { MAIN_DUMMY_PROPERTY @@ -96,62 +130,107 @@ static void _g_free0_ (gpointer var); static void _g_list_free__g_free0_ (GList* self); #define MAIN_DF_INDICATOR_ICON "dayfolder-panel" -#define MAIN_UI_DF_SETTINGS PACKAGE_DATA_DIR "/dayfolder/ui/dfSettings.ui" +#define MAIN_isInstalled TRUE Main* main_new (void); Main* main_construct (GType object_type); -dayfolderDayFolder* dayfolder_day_folder_new (void); -dayfolderDayFolder* dayfolder_day_folder_construct (GType object_type); -static void __lambda0_ (Main* self); -static void main_runDayFolder (Main* self); -static void ___lambda0__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); -static void __lambda1_ (Main* self); -static void main_settingsClicked (Main* self); -static void ___lambda1__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); +gboolean zystem_zystem_get_debugOn (void); +void zystem_zystem_set_debugOn (gboolean value); +void zystem_zystem_debug (const gchar* s); +void dayfolder_user_data_initializeUserData (void); +static void __lambda2_ (Main* self); +void dayfolder_user_data_cleanupAllMonDirs (void); +static void ___lambda2__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); static void __lambda3_ (Main* self); -static void main_openTodaysFolderClicked (Main* self); +static void main_settingsClicked (Main* self); static void ___lambda3__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); -static void __lambda4_ (Main* self); +static void __lambda13_ (Main* self); +static void main_openTodaysFolderClicked (Main* self); +static void ___lambda13__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); +static void __lambda14_ (Main* self); static void main_exitDayFolder (Main* self); -static void ___lambda4__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); -void dayfolder_day_folder_run (dayfolderDayFolder* self); -gchar* dayfolder_user_data_getDfRootPath (void); -static void main_loadDfTypeOption (Main* self); -gchar* dayfolder_user_data_getSourcePath (void); -static void main_loadFileExtRulesTreeView (Main* self); -static void ___lambda2_ (Main* self); +static void ___lambda14__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self); +gchar* dayfolder_user_data_getDefaultDfRootPath (void); +static Block1Data* block1_data_ref (Block1Data* _data1_); +static void block1_data_unref (void * _userdata_); +static void __lambda4_ (Main* self); +void main_on_destroy (Main* self, GtkWidget* window); +static void ___lambda4__gtk_widget_destroy (GtkWidget* _sender, gpointer self); +static void main_setupMonitoredDirsListView (Main* self); +static void __lambda6_ (Block1Data* _data1_); +void main_btnAddMonitoredDirClicked (Main* self, GtkButton* button); +static void ___lambda6__gtk_button_clicked (GtkButton* _sender, gpointer self); +static void __lambda7_ (Block1Data* _data1_); +void main_btnRemoveMonitoredDirClicked (Main* self, GtkButton* button); +static void ___lambda7__gtk_button_clicked (GtkButton* _sender, gpointer self); +static GtkLabel* main_createLabelLeftAlign (Main* self, const gchar* text); +static void main_swUseDayFolderClicked (Main* self); +static void _main_swUseDayFolderClicked_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void __lambda8_ (Main* self); +void main_btnDfRootPathClicked (Main* self, GtkButton* chooser); +static void ___lambda8__gtk_button_clicked (GtkButton* _sender, gpointer self); +static void main_swMoveSubfoldersClicked (Main* self); +static void _main_swMoveSubfoldersClicked_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self); +static void __lambda9_ (Main* self); +void main_rdoDayClicked (Main* self, GtkRadioButton* button); +static void ___lambda9__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self); +static void __lambda10_ (Main* self); +void main_rdoWeekClicked (Main* self, GtkRadioButton* button); +static void ___lambda10__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self); +static void __lambda11_ (Main* self); +void main_rdoMonthClicked (Main* self, GtkRadioButton* button); +static void ___lambda11__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self); +static void main_setupFileRulesListView (Main* self); +void main_btnChangeFileRuleDestClicked (Main* self); +static void _main_btnChangeFileRuleDestClicked_gtk_button_clicked (GtkButton* _sender, gpointer self); +void main_btnRemoveFileRuleClicked (Main* self); +static void _main_btnRemoveFileRuleClicked_gtk_button_clicked (GtkButton* _sender, gpointer self); +void main_btnSaveFileRuleClicked (Main* self); +static void _main_btnSaveFileRuleClicked_gtk_button_clicked (GtkButton* _sender, gpointer self); +static void main_disableControls (Main* self); +static void __lambda5_ (Main* self); +static void main_monitoredDirSelected (Main* self); +static void ___lambda5__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self); +static void main_loadMonitoredDirsView (Main* self); +static void __lambda12_ (Main* self); static void main_fileExtRuleSelected (Main* self); -static void ____lambda2__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self); -GType dayfolder_file_ext_rule_get_type (void) G_GNUC_CONST; -GeeArrayList* dayfolder_user_data_getFileExtRules (void); -const gchar* dayfolder_file_ext_rule_get_fileExt (dayfolderFileExtRule* self); -const gchar* dayfolder_file_ext_rule_get_destinationDir (dayfolderFileExtRule* self); -gchar* dayfolder_user_data_getDfType (void); +static void ___lambda12__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self); +static void main_loadFileExtRulesTreeView (Main* self); +GType dayfolder_df_rule_get_type (void) G_GNUC_CONST; +GeeArrayList* dayfolder_user_data_getFileRules (const gchar* monDirPath); +const gchar* dayfolder_df_rule_get_criteriaString (dayfolderDfRule* self); +GType dayfolder_monitored_directory_get_type (void) G_GNUC_CONST; +GeeArrayList* dayfolder_user_data_getMonitoredDirs (void); +const gchar* dayfolder_monitored_directory_get_dirPath (dayfolderMonitoredDirectory* self); +static void main_loadDfTypeOption (Main* self); +gchar* dayfolder_user_data_getDfType (const gchar* dirPath); #define DAYFOLDER_USER_DATA_dfTypeDaily "D" #define DAYFOLDER_USER_DATA_dfTypeWeekly "W" #define DAYFOLDER_USER_DATA_dfTypeMonthly "M" -void main_btnResetDfRootClicked (GtkButton* button, Main* self); -void dayfolder_user_data_resetDfRootPath (void); -static void main_setLabelText (Main* self, const gchar* labelName, const gchar* path); -gchar* dayfolder_user_data_getDefaultDfRootPath (void); -void main_btnResetSourceClicked (GtkButton* button, Main* self); -void dayfolder_user_data_resetSourcePath (void); -gchar* dayfolder_user_data_getDefaultSourcePath (void); -void main_btnSaveFileExtRuleClicked (GtkButton* button, Main* self); -void dayfolder_user_data_addFileExtRule (const gchar* fileExt, const gchar* destDir); -void main_btnFileExtDestDirClicked (GtkButton* button, Main* self); -void main_on_destroy (GtkWidget* window, Main* self); -void main_btnDfRootPathClicked (GtkButton* chooser, Main* self); -void dayfolder_user_data_setDfRootPath (const gchar* path); -void main_btnSourcePathClicked (GtkButton* chooser, Main* self); -void dayfolder_user_data_setSourcePath (const gchar* path); -void main_btnRemoveFileExtRuleClicked (GtkButton* button, Main* self); +void dayfolder_user_data_addFileRule (const gchar* dirPath, const gchar* criteria, const gchar* destDir); +void dayfolder_user_data_setDfRootPath (const gchar* monDirPath, const gchar* path); static gchar* main_getSelectedFileExt (Main* self); -void dayfolder_user_data_removeFileExtRule (const gchar* fileExt); -void main_rdoDayClicked (GtkRadioButton* button, Main* self); -void dayfolder_user_data_setDfType (const gchar* dfType); -void main_rdoWeekClicked (GtkRadioButton* button, Main* self); -void main_rdoMonthClicked (GtkRadioButton* button, Main* self); -gchar* dayfolder_user_data_getFileExtRuleDest (const gchar* fileExt); +void dayfolder_user_data_removeFileRule (const gchar* monDirPath, const gchar* criteria); +static gchar* main_getSelectedMonitoredDir (Main* self); +void dayfolder_user_data_removeMonitoredDir (const gchar* dirPath); +void dayfolder_user_data_setDfType (const gchar* monDirPath, const gchar* dfType); +static void main_addMonitoredDir (Main* self, const gchar* path); +void dayfolder_user_data_addMonitoredDirectory (const gchar* dirPath); +gchar* dayfolder_user_data_getFileRuleDest (const gchar* monDirPath, const gchar* criteria); +static gint main_getSelectedFromView (Main* self, GtkTreeView* view); +static void main_enableControls (Main* self); +static void main_loadCurrentMonitoredDir (Main* self); +static void main_setSwMoveSubfolders (Main* self); +static void main_setSwUseDayFolder (Main* self); +gchar* dayfolder_user_data_getSourcePath (const gchar* dirPath); +gchar* dayfolder_user_data_getDfRootPath (const gchar* dirPath); +gboolean dayfolder_user_data_getUseDayFolder (const gchar* monDirPath); +static void main_enableUseDayFolderControls (Main* self, gboolean enabled); +gboolean dayfolder_user_data_getMoveDirs (const gchar* monDirPath); +void dayfolder_user_data_setUseDayFolder (const gchar* monDirPath, gboolean useDayFolder); +void dayfolder_user_data_setMoveDirs (const gchar* monDirPath, gboolean moveDirs); +static void main_setControlsEnabled (Main* self, gboolean enabled); +static GeeArrayList* main_getSettingsWidgets (Main* self); +static GeeArrayList* main_getUseDayFolderWidgets (Main* self); static gint main_main (gchar** args, int args_length1); static void main_finalize (GObject* obj); @@ -170,55 +249,55 @@ /** * Constructor for Main. */ -static void __lambda0_ (Main* self) { - main_runDayFolder (self); +static void __lambda2_ (Main* self) { + dayfolder_user_data_cleanupAllMonDirs (); } -static void ___lambda0__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { - __lambda0_ (self); +static void ___lambda2__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { + __lambda2_ (self); } -static void __lambda1_ (Main* self) { +static void __lambda3_ (Main* self) { main_settingsClicked (self); } -static void ___lambda1__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { - __lambda1_ (self); +static void ___lambda3__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { + __lambda3_ (self); } -static void __lambda3_ (Main* self) { +static void __lambda13_ (Main* self) { main_openTodaysFolderClicked (self); } -static void ___lambda3__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { - __lambda3_ (self); +static void ___lambda13__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { + __lambda13_ (self); } -static void __lambda4_ (Main* self) { +static void __lambda14_ (Main* self) { main_exitDayFolder (self); } -static void ___lambda4__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { - __lambda4_ (self); +static void ___lambda14__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) { + __lambda14_ (self); } Main* main_construct (GType object_type) { Main * self = NULL; - dayfolderDayFolder* _tmp0_; - AppIndicator* _tmp1_; + gboolean _tmp0_; + gboolean _tmp1_; + gchar* _tmp2_; + AppIndicator* _tmp3_; AppIndicator* indicator; - GtkMenu* _tmp2_; - GtkMenu* _tmp3_; + GtkMenu* _tmp4_; GtkMenu* menu; - GtkMenuItem* _tmp4_; GtkMenuItem* _tmp5_; GtkMenuItem* item; GtkMenuItem* _tmp6_; @@ -229,61 +308,66 @@ GtkMenuItem* _tmp11_; GtkMenuItem* _tmp12_; GtkMenuItem* _tmp13_; - GtkMenuItem* _tmp14_; - GtkMenuItem* _tmp15_; - GtkSeparatorMenuItem* _tmp16_; - GtkSeparatorMenuItem* _tmp17_; + GtkSeparatorMenuItem* _tmp14_; + GtkSeparatorMenuItem* _tmp15_; + GtkMenuItem* _tmp16_; + GtkMenuItem* _tmp17_; GtkMenuItem* _tmp18_; - GtkMenuItem* _tmp19_; - GtkMenuItem* _tmp20_; - GtkMenuItem* _tmp21_; self = (Main*) g_object_new (object_type, NULL); - _tmp0_ = dayfolder_day_folder_new (); - _g_object_unref0 (self->priv->dayFolder); - self->priv->dayFolder = _tmp0_; + _tmp0_ = zystem_zystem_get_debugOn (); + _tmp1_ = _tmp0_; + zystem_zystem_set_debugOn (!MAIN_isInstalled); + zystem_zystem_debug ("Package data dir: " PACKAGE_DATA_DIR); + dayfolder_user_data_initializeUserData (); __g_list_free__g_free0_0 (self->priv->fileExtList); self->priv->fileExtList = NULL; - _tmp1_ = app_indicator_new ("DayFolder", MAIN_DF_INDICATOR_ICON, APP_INDICATOR_CATEGORY_APPLICATION_STATUS); - indicator = _tmp1_; + __g_list_free__g_free0_0 (self->priv->monitoredDirsList); + self->priv->monitoredDirsList = NULL; + _tmp2_ = g_strdup (""); + _g_free0 (self->priv->currentMonitoredDir); + self->priv->currentMonitoredDir = _tmp2_; + _tmp3_ = app_indicator_new ("DayFolder", MAIN_DF_INDICATOR_ICON, APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + indicator = _tmp3_; app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); - _tmp2_ = (GtkMenu*) gtk_menu_new (); - _tmp3_ = g_object_ref_sink (_tmp2_); - menu = _tmp3_; - _tmp4_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Clean Source Folder"); - _tmp5_ = g_object_ref_sink (_tmp4_); + _tmp4_ = (GtkMenu*) gtk_menu_new (); + g_object_ref_sink (_tmp4_); + menu = _tmp4_; + _tmp5_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Clean Up Folders"); + g_object_ref_sink (_tmp5_); item = _tmp5_; _tmp6_ = item; - g_signal_connect_object (_tmp6_, "activate", (GCallback) ___lambda0__gtk_menu_item_activate, self, 0); + g_signal_connect_object (_tmp6_, "activate", (GCallback) ___lambda2__gtk_menu_item_activate, self, 0); _tmp7_ = item; gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp7_); _tmp8_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Settings..."); - _tmp9_ = g_object_ref_sink (_tmp8_); + g_object_ref_sink (_tmp8_); _g_object_unref0 (item); - item = _tmp9_; + item = _tmp8_; + _tmp9_ = item; + g_signal_connect_object (_tmp9_, "activate", (GCallback) ___lambda3__gtk_menu_item_activate, self, 0); _tmp10_ = item; - g_signal_connect_object (_tmp10_, "activate", (GCallback) ___lambda1__gtk_menu_item_activate, self, 0); - _tmp11_ = item; - gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp11_); - _tmp12_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("View DayFolder"); - _tmp13_ = g_object_ref_sink (_tmp12_); + gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp10_); + _tmp11_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("View DayFolder"); + g_object_ref_sink (_tmp11_); _g_object_unref0 (item); - item = _tmp13_; - _tmp14_ = item; - g_signal_connect_object (_tmp14_, "activate", (GCallback) ___lambda3__gtk_menu_item_activate, self, 0); - _tmp15_ = item; - gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp15_); - _tmp16_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new (); - _tmp17_ = g_object_ref_sink (_tmp16_); - gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) ((GtkMenuItem*) _tmp17_)); - _g_object_unref0 (_tmp17_); - _tmp18_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Quit"); - _tmp19_ = g_object_ref_sink (_tmp18_); + item = _tmp11_; + _tmp12_ = item; + g_signal_connect_object (_tmp12_, "activate", (GCallback) ___lambda13__gtk_menu_item_activate, self, 0); + _tmp13_ = item; + gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp13_); + _tmp14_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new (); + g_object_ref_sink (_tmp14_); + _tmp15_ = _tmp14_; + gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) ((GtkMenuItem*) _tmp15_)); + _g_object_unref0 (_tmp15_); + _tmp16_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Quit"); + g_object_ref_sink (_tmp16_); _g_object_unref0 (item); - item = _tmp19_; - _tmp20_ = item; - g_signal_connect_object (_tmp20_, "activate", (GCallback) ___lambda4__gtk_menu_item_activate, self, 0); - _tmp21_ = item; - gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp21_); + item = _tmp16_; + _tmp17_ = item; + g_signal_connect_object (_tmp17_, "activate", (GCallback) ___lambda14__gtk_menu_item_activate, self, 0); + _tmp18_ = item; + gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) _tmp18_); gtk_widget_show_all ((GtkWidget*) menu); app_indicator_set_menu (indicator, menu); gtk_main (); @@ -300,17 +384,6 @@ /** - * Run the DayFolder. - */ -static void main_runDayFolder (Main* self) { - dayfolderDayFolder* _tmp0_; - g_return_if_fail (self != NULL); - _tmp0_ = self->priv->dayFolder; - dayfolder_day_folder_run (_tmp0_); -} - - -/** * Opens the DayFolder root directory for user. */ static void main_openTodaysFolderClicked (Main* self) { @@ -321,7 +394,7 @@ gchar* _tmp1_; gchar* _tmp2_; gchar* _tmp3_; - _tmp0_ = dayfolder_user_data_getDfRootPath (); + _tmp0_ = dayfolder_user_data_getDefaultDfRootPath (); _tmp1_ = _tmp0_; _tmp2_ = g_strconcat ("file://", _tmp1_, NULL); _tmp3_ = _tmp2_; @@ -357,148 +430,591 @@ /** - * When the Settings menu item is clicked. + * Create and show the settings window. + */ +static Block1Data* block1_data_ref (Block1Data* _data1_) { + g_atomic_int_inc (&_data1_->_ref_count_); + return _data1_; +} + + +static void block1_data_unref (void * _userdata_) { + Block1Data* _data1_; + _data1_ = (Block1Data*) _userdata_; + if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) { + Main * self; + self = _data1_->self; + _g_object_unref0 (_data1_->btnRemoveMonitoredDir); + _g_object_unref0 (_data1_->btnAddMonitoredDir); + _g_object_unref0 (self); + g_slice_free (Block1Data, _data1_); + } +} + + +static void __lambda4_ (Main* self) { + GtkWindow* _tmp0_; + _tmp0_ = self->priv->window; + main_on_destroy (self, (GtkWidget*) _tmp0_); +} + + +static void ___lambda4__gtk_widget_destroy (GtkWidget* _sender, gpointer self) { + __lambda4_ (self); +} + + +static void __lambda6_ (Block1Data* _data1_) { + Main * self; + self = _data1_->self; + main_btnAddMonitoredDirClicked (self, _data1_->btnAddMonitoredDir); +} + + +static void ___lambda6__gtk_button_clicked (GtkButton* _sender, gpointer self) { + __lambda6_ (self); +} + + +static void __lambda7_ (Block1Data* _data1_) { + Main * self; + self = _data1_->self; + main_btnRemoveMonitoredDirClicked (self, _data1_->btnRemoveMonitoredDir); +} + + +static void ___lambda7__gtk_button_clicked (GtkButton* _sender, gpointer self) { + __lambda7_ (self); +} + + +static void _main_swUseDayFolderClicked_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + main_swUseDayFolderClicked (self); +} + + +static void __lambda8_ (Main* self) { + GtkButton* _tmp0_; + _tmp0_ = self->priv->btnChangeDfLocation; + main_btnDfRootPathClicked (self, _tmp0_); +} + + +static void ___lambda8__gtk_button_clicked (GtkButton* _sender, gpointer self) { + __lambda8_ (self); +} + + +static void _main_swMoveSubfoldersClicked_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) { + main_swMoveSubfoldersClicked (self); +} + + +static void __lambda9_ (Main* self) { + GtkRadioButton* _tmp0_; + _tmp0_ = self->priv->rdoDaily; + main_rdoDayClicked (self, _tmp0_); +} + + +static void ___lambda9__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) { + __lambda9_ (self); +} + + +static void __lambda10_ (Main* self) { + GtkRadioButton* _tmp0_; + _tmp0_ = self->priv->rdoWeekly; + main_rdoWeekClicked (self, _tmp0_); +} + + +static void ___lambda10__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) { + __lambda10_ (self); +} + + +static void __lambda11_ (Main* self) { + GtkRadioButton* _tmp0_; + _tmp0_ = self->priv->rdoMonthly; + main_rdoMonthClicked (self, _tmp0_); +} + + +static void ___lambda11__gtk_toggle_button_toggled (GtkToggleButton* _sender, gpointer self) { + __lambda11_ (self); +} + + +static void _main_btnChangeFileRuleDestClicked_gtk_button_clicked (GtkButton* _sender, gpointer self) { + main_btnChangeFileRuleDestClicked (self); +} + + +static void _main_btnRemoveFileRuleClicked_gtk_button_clicked (GtkButton* _sender, gpointer self) { + main_btnRemoveFileRuleClicked (self); +} + + +static void _main_btnSaveFileRuleClicked_gtk_button_clicked (GtkButton* _sender, gpointer self) { + main_btnSaveFileRuleClicked (self); +} + + +static void main_settingsClicked (Main* self) { + Block1Data* _data1_; + GtkWindow* _tmp0_; + GtkWindow* _tmp1_; + GtkWindow* _tmp2_; + GtkWindow* _tmp3_; + GtkWindow* _tmp4_; + GtkBox* _tmp5_; + GtkBox* leftSideBox; + GtkTreeView* _tmp6_; + GtkTreeView* _tmp7_; + GtkCellRendererText* _tmp8_; + GtkCellRendererText* _tmp9_; + GtkTreeView* _tmp10_; + GtkButton* _tmp11_; + GtkButton* _tmp12_; + GtkBox* _tmp13_; + GtkBox* leftSideButtonBox; + GtkBox* _tmp14_; + GtkBox* mainBox; + GtkLabel* _tmp15_ = NULL; + GtkLabel* lblSrcFolderLocationHeading; + GtkLabel* _tmp16_ = NULL; + GtkLabel* _tmp17_; + GtkLabel* _tmp18_; + GtkBox* _tmp19_; + GtkBox* dfLocationHeadingBox; + GtkLabel* _tmp20_ = NULL; + GtkLabel* lblDfLocationHeading; + GtkSwitch* _tmp21_; + GtkSwitch* _tmp22_; + GtkSwitch* _tmp23_; + GtkBox* _tmp24_; + GtkBox* dfLocationDisplayBox; + GtkLabel* _tmp25_ = NULL; + GtkLabel* _tmp26_; + GtkLabel* _tmp27_; + GtkButton* _tmp28_; + GtkButton* _tmp29_; + GtkButton* _tmp30_; + GtkBox* _tmp31_; + GtkBox* subfoldersOptionBox; + GtkLabel* _tmp32_ = NULL; + GtkLabel* _tmp33_; + GtkLabel* _tmp34_; + GtkSwitch* _tmp35_; + GtkSwitch* _tmp36_; + GtkSwitch* _tmp37_; + GtkLabel* _tmp38_ = NULL; + GtkLabel* _tmp39_; + GtkLabel* _tmp40_; + GtkBox* _tmp41_; + GtkBox* dfTypeBox; + GtkRadioButton* _tmp42_; + GtkRadioButton* _tmp43_; + GtkRadioButton* _tmp44_; + GtkRadioButton* _tmp45_; + GtkRadioButton* _tmp46_; + GtkRadioButton* _tmp47_; + GtkRadioButton* _tmp48_; + GtkRadioButton* _tmp49_; + GtkRadioButton* _tmp50_; + GtkRadioButton* _tmp51_; + GtkRadioButton* _tmp52_; + GtkRadioButton* _tmp53_; + GtkRadioButton* _tmp54_; + GtkLabel* _tmp55_; + GtkLabel* lblSpacer; + GtkBox* _tmp56_; + GtkBox* fileRulesBox; + GtkTreeView* _tmp57_; + GtkTreeView* _tmp58_; + GtkCellRendererText* _tmp59_; + GtkCellRendererText* _tmp60_; + GtkTreeView* _tmp61_; + GtkBox* _tmp62_; + GtkBox* fileRuleEditBox; + GtkLabel* _tmp63_ = NULL; + GtkLabel* lblFileNameContains; + GtkEntry* _tmp64_; + GtkEntry* _tmp65_; + GtkLabel* _tmp66_ = NULL; + GtkLabel* lblMoveFileTo; + GtkBox* _tmp67_; + GtkBox* fileRuleDestBox; + GtkEntry* _tmp68_; + GtkEntry* _tmp69_; + GtkButton* _tmp70_; + GtkButton* _tmp71_; + GtkButton* _tmp72_; + GtkBox* _tmp73_; + GtkBox* fileRuleButtonsBox; + GtkButton* _tmp74_; + GtkButton* btnRemoveFileRule; + GtkButton* _tmp75_; + GtkButton* btnSaveFileRule; + GtkBox* _tmp76_; + GtkBox* containerBox; + GtkWindow* _tmp77_; + GtkWindow* _tmp78_; + g_return_if_fail (self != NULL); + _data1_ = g_slice_new0 (Block1Data); + _data1_->_ref_count_ = 1; + _data1_->self = g_object_ref (self); + _tmp0_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_object_ref_sink (_tmp0_); + _g_object_unref0 (self->priv->window); + self->priv->window = _tmp0_; + _tmp1_ = self->priv->window; + gtk_widget_set_size_request ((GtkWidget*) _tmp1_, 600, 500); + _tmp2_ = self->priv->window; + gtk_window_set_resizable (_tmp2_, FALSE); + _tmp3_ = self->priv->window; + gtk_window_set_title (_tmp3_, "DayFolder Settings"); + _tmp4_ = self->priv->window; + g_signal_connect_object ((GtkWidget*) _tmp4_, "destroy", (GCallback) ___lambda4__gtk_widget_destroy, self, 0); + _tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + g_object_ref_sink (_tmp5_); + leftSideBox = _tmp5_; + _tmp6_ = (GtkTreeView*) gtk_tree_view_new (); + g_object_ref_sink (_tmp6_); + _g_object_unref0 (self->priv->tvMonitoredDirs); + self->priv->tvMonitoredDirs = _tmp6_; + main_setupMonitoredDirsListView (self); + _tmp7_ = self->priv->tvMonitoredDirs; + _tmp8_ = (GtkCellRendererText*) gtk_cell_renderer_text_new (); + g_object_ref_sink (_tmp8_); + _tmp9_ = _tmp8_; + gtk_tree_view_insert_column_with_attributes (_tmp7_, -1, "Monitored Folders", (GtkCellRenderer*) _tmp9_, "text", 0, NULL); + _g_object_unref0 (_tmp9_); + _tmp10_ = self->priv->tvMonitoredDirs; + gtk_box_pack_start (leftSideBox, (GtkWidget*) _tmp10_, FALSE, TRUE, (guint) 0); + _tmp11_ = (GtkButton*) gtk_button_new_with_label ("Add"); + g_object_ref_sink (_tmp11_); + _data1_->btnAddMonitoredDir = _tmp11_; + g_signal_connect_data (_data1_->btnAddMonitoredDir, "clicked", (GCallback) ___lambda6__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); + _tmp12_ = (GtkButton*) gtk_button_new_with_label ("Remove"); + g_object_ref_sink (_tmp12_); + _data1_->btnRemoveMonitoredDir = _tmp12_; + g_signal_connect_data (_data1_->btnRemoveMonitoredDir, "clicked", (GCallback) ___lambda7__gtk_button_clicked, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); + _tmp13_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp13_); + leftSideButtonBox = _tmp13_; + gtk_box_pack_start (leftSideButtonBox, (GtkWidget*) _data1_->btnAddMonitoredDir, FALSE, TRUE, (guint) 0); + gtk_box_pack_start (leftSideButtonBox, (GtkWidget*) _data1_->btnRemoveMonitoredDir, FALSE, TRUE, (guint) 0); + gtk_box_pack_start (leftSideBox, (GtkWidget*) leftSideButtonBox, FALSE, TRUE, (guint) 0); + g_object_set ((GtkWidget*) leftSideBox, "width-request", 160, NULL); + _tmp14_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + g_object_ref_sink (_tmp14_); + mainBox = _tmp14_; + _tmp15_ = main_createLabelLeftAlign (self, "Source Folder Location"); + lblSrcFolderLocationHeading = _tmp15_; + gtk_label_set_use_markup (lblSrcFolderLocationHeading, TRUE); + gtk_box_pack_start (mainBox, (GtkWidget*) lblSrcFolderLocationHeading, FALSE, FALSE, (guint) 4); + _tmp16_ = main_createLabelLeftAlign (self, NULL); + _g_object_unref0 (self->priv->lblSrcFolderLocationDisplay); + self->priv->lblSrcFolderLocationDisplay = _tmp16_; + _tmp17_ = self->priv->lblSrcFolderLocationDisplay; + gtk_label_set_label (_tmp17_, ""); + _tmp18_ = self->priv->lblSrcFolderLocationDisplay; + gtk_box_pack_start (mainBox, (GtkWidget*) _tmp18_, FALSE, TRUE, (guint) 4); + _tmp19_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp19_); + dfLocationHeadingBox = _tmp19_; + _tmp20_ = main_createLabelLeftAlign (self, "DayFolder Location"); + lblDfLocationHeading = _tmp20_; + gtk_label_set_use_markup (lblDfLocationHeading, TRUE); + gtk_box_pack_start (dfLocationHeadingBox, (GtkWidget*) lblDfLocationHeading, TRUE, TRUE, (guint) 4); + _tmp21_ = (GtkSwitch*) gtk_switch_new (); + g_object_ref_sink (_tmp21_); + _g_object_unref0 (self->priv->swUseDayFolder); + self->priv->swUseDayFolder = _tmp21_; + _tmp22_ = self->priv->swUseDayFolder; + g_signal_connect_object ((GObject*) _tmp22_, "notify::active", (GCallback) _main_swUseDayFolderClicked_g_object_notify, self, 0); + _tmp23_ = self->priv->swUseDayFolder; + gtk_box_pack_start (dfLocationHeadingBox, (GtkWidget*) _tmp23_, FALSE, TRUE, (guint) 4); + gtk_box_pack_start (mainBox, (GtkWidget*) dfLocationHeadingBox, FALSE, TRUE, (guint) 0); + _tmp24_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp24_); + dfLocationDisplayBox = _tmp24_; + _tmp25_ = main_createLabelLeftAlign (self, NULL); + _g_object_unref0 (self->priv->lblDfLocationDisplay); + self->priv->lblDfLocationDisplay = _tmp25_; + _tmp26_ = self->priv->lblDfLocationDisplay; + gtk_label_set_label (_tmp26_, ""); + _tmp27_ = self->priv->lblDfLocationDisplay; + gtk_box_pack_start (dfLocationDisplayBox, (GtkWidget*) _tmp27_, TRUE, TRUE, (guint) 4); + _tmp28_ = (GtkButton*) gtk_button_new_from_stock (GTK_STOCK_OPEN); + g_object_ref_sink (_tmp28_); + _g_object_unref0 (self->priv->btnChangeDfLocation); + self->priv->btnChangeDfLocation = _tmp28_; + _tmp29_ = self->priv->btnChangeDfLocation; + g_signal_connect_object (_tmp29_, "clicked", (GCallback) ___lambda8__gtk_button_clicked, self, 0); + _tmp30_ = self->priv->btnChangeDfLocation; + gtk_box_pack_start (dfLocationDisplayBox, (GtkWidget*) _tmp30_, FALSE, TRUE, (guint) 4); + gtk_box_pack_start (mainBox, (GtkWidget*) dfLocationDisplayBox, FALSE, TRUE, (guint) 4); + _tmp31_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp31_); + subfoldersOptionBox = _tmp31_; + _tmp32_ = main_createLabelLeftAlign (self, "Also move subfolders to DayFolder"); + _g_object_unref0 (self->priv->lblSubfoldersOption); + self->priv->lblSubfoldersOption = _tmp32_; + _tmp33_ = self->priv->lblSubfoldersOption; + g_object_set ((GtkMisc*) _tmp33_, "xalign", (gfloat) 0, NULL); + _tmp34_ = self->priv->lblSubfoldersOption; + gtk_box_pack_start (subfoldersOptionBox, (GtkWidget*) _tmp34_, TRUE, TRUE, (guint) 4); + _tmp35_ = (GtkSwitch*) gtk_switch_new (); + g_object_ref_sink (_tmp35_); + _g_object_unref0 (self->priv->swMoveSubfolders); + self->priv->swMoveSubfolders = _tmp35_; + _tmp36_ = self->priv->swMoveSubfolders; + g_signal_connect_object ((GObject*) _tmp36_, "notify::active", (GCallback) _main_swMoveSubfoldersClicked_g_object_notify, self, 0); + _tmp37_ = self->priv->swMoveSubfolders; + gtk_box_pack_start (subfoldersOptionBox, (GtkWidget*) _tmp37_, FALSE, FALSE, (guint) 4); + gtk_box_pack_start (mainBox, (GtkWidget*) subfoldersOptionBox, FALSE, TRUE, (guint) 4); + _tmp38_ = main_createLabelLeftAlign (self, "DayFolder Type"); + _g_object_unref0 (self->priv->lblDfTypeHeading); + self->priv->lblDfTypeHeading = _tmp38_; + _tmp39_ = self->priv->lblDfTypeHeading; + gtk_label_set_use_markup (_tmp39_, TRUE); + _tmp40_ = self->priv->lblDfTypeHeading; + gtk_box_pack_start (mainBox, (GtkWidget*) _tmp40_, FALSE, TRUE, (guint) 4); + _tmp41_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp41_); + dfTypeBox = _tmp41_; + _tmp42_ = (GtkRadioButton*) gtk_radio_button_new (NULL); + g_object_ref_sink (_tmp42_); + _tmp43_ = _tmp42_; + _tmp44_ = (GtkRadioButton*) gtk_radio_button_new_with_label_from_widget (_tmp43_, "Daily"); + g_object_ref_sink (_tmp44_); + _g_object_unref0 (self->priv->rdoDaily); + self->priv->rdoDaily = _tmp44_; + _g_object_unref0 (_tmp43_); + _tmp45_ = self->priv->rdoDaily; + _tmp46_ = (GtkRadioButton*) gtk_radio_button_new_with_label_from_widget (_tmp45_, "Weekly"); + g_object_ref_sink (_tmp46_); + _g_object_unref0 (self->priv->rdoWeekly); + self->priv->rdoWeekly = _tmp46_; + _tmp47_ = self->priv->rdoWeekly; + _tmp48_ = (GtkRadioButton*) gtk_radio_button_new_with_label_from_widget (_tmp47_, "Monthly"); + g_object_ref_sink (_tmp48_); + _g_object_unref0 (self->priv->rdoMonthly); + self->priv->rdoMonthly = _tmp48_; + _tmp49_ = self->priv->rdoDaily; + g_signal_connect_object ((GtkToggleButton*) _tmp49_, "toggled", (GCallback) ___lambda9__gtk_toggle_button_toggled, self, 0); + _tmp50_ = self->priv->rdoWeekly; + g_signal_connect_object ((GtkToggleButton*) _tmp50_, "toggled", (GCallback) ___lambda10__gtk_toggle_button_toggled, self, 0); + _tmp51_ = self->priv->rdoMonthly; + g_signal_connect_object ((GtkToggleButton*) _tmp51_, "toggled", (GCallback) ___lambda11__gtk_toggle_button_toggled, self, 0); + _tmp52_ = self->priv->rdoDaily; + gtk_box_pack_start (dfTypeBox, (GtkWidget*) _tmp52_, FALSE, TRUE, (guint) 2); + _tmp53_ = self->priv->rdoWeekly; + gtk_box_pack_start (dfTypeBox, (GtkWidget*) _tmp53_, FALSE, TRUE, (guint) 2); + _tmp54_ = self->priv->rdoMonthly; + gtk_box_pack_start (dfTypeBox, (GtkWidget*) _tmp54_, FALSE, TRUE, (guint) 2); + gtk_box_pack_start (mainBox, (GtkWidget*) dfTypeBox, FALSE, TRUE, (guint) 2); + _tmp55_ = (GtkLabel*) gtk_label_new (""); + g_object_ref_sink (_tmp55_); + lblSpacer = _tmp55_; + g_object_set ((GtkWidget*) lblSpacer, "width-request", 20, NULL); + g_object_set ((GtkWidget*) lblSpacer, "height-request", 30, NULL); + gtk_box_pack_start (mainBox, (GtkWidget*) lblSpacer, FALSE, TRUE, (guint) 2); + _tmp56_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); + g_object_ref_sink (_tmp56_); + fileRulesBox = _tmp56_; + _tmp57_ = (GtkTreeView*) gtk_tree_view_new (); + g_object_ref_sink (_tmp57_); + _g_object_unref0 (self->priv->tvFileRules); + self->priv->tvFileRules = _tmp57_; + main_setupFileRulesListView (self); + _tmp58_ = self->priv->tvFileRules; + _tmp59_ = (GtkCellRendererText*) gtk_cell_renderer_text_new (); + g_object_ref_sink (_tmp59_); + _tmp60_ = _tmp59_; + gtk_tree_view_insert_column_with_attributes (_tmp58_, -1, "File Rules", (GtkCellRenderer*) _tmp60_, "text", 0, NULL); + _g_object_unref0 (_tmp60_); + _tmp61_ = self->priv->tvFileRules; + gtk_box_pack_start (fileRulesBox, (GtkWidget*) _tmp61_, TRUE, TRUE, (guint) 2); + _tmp62_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); + g_object_ref_sink (_tmp62_); + fileRuleEditBox = _tmp62_; + _tmp63_ = main_createLabelLeftAlign (self, "File name contains (such as a key word or file extention)"); + lblFileNameContains = _tmp63_; + gtk_box_pack_start (fileRuleEditBox, (GtkWidget*) lblFileNameContains, FALSE, TRUE, (guint) 2); + _tmp64_ = (GtkEntry*) gtk_entry_new (); + g_object_ref_sink (_tmp64_); + _g_object_unref0 (self->priv->txtFileNameContains); + self->priv->txtFileNameContains = _tmp64_; + _tmp65_ = self->priv->txtFileNameContains; + gtk_box_pack_start (fileRuleEditBox, (GtkWidget*) _tmp65_, FALSE, TRUE, (guint) 2); + _tmp66_ = main_createLabelLeftAlign (self, "Move file to..."); + lblMoveFileTo = _tmp66_; + gtk_box_pack_start (fileRuleEditBox, (GtkWidget*) lblMoveFileTo, FALSE, TRUE, (guint) 2); + _tmp67_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp67_); + fileRuleDestBox = _tmp67_; + _tmp68_ = (GtkEntry*) gtk_entry_new (); + g_object_ref_sink (_tmp68_); + _g_object_unref0 (self->priv->txtFileRuleDest); + self->priv->txtFileRuleDest = _tmp68_; + _tmp69_ = self->priv->txtFileRuleDest; + gtk_box_pack_start (fileRuleDestBox, (GtkWidget*) _tmp69_, TRUE, TRUE, (guint) 0); + _tmp70_ = (GtkButton*) gtk_button_new_from_stock (GTK_STOCK_OPEN); + g_object_ref_sink (_tmp70_); + _g_object_unref0 (self->priv->btnChangeFileRuleDest); + self->priv->btnChangeFileRuleDest = _tmp70_; + _tmp71_ = self->priv->btnChangeFileRuleDest; + g_signal_connect_object (_tmp71_, "clicked", (GCallback) _main_btnChangeFileRuleDestClicked_gtk_button_clicked, self, 0); + _tmp72_ = self->priv->btnChangeFileRuleDest; + gtk_box_pack_start (fileRuleDestBox, (GtkWidget*) _tmp72_, FALSE, TRUE, (guint) 2); + gtk_box_pack_start (fileRuleEditBox, (GtkWidget*) fileRuleDestBox, FALSE, TRUE, (guint) 0); + _tmp73_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp73_); + fileRuleButtonsBox = _tmp73_; + _tmp74_ = (GtkButton*) gtk_button_new_with_label ("Remove"); + g_object_ref_sink (_tmp74_); + btnRemoveFileRule = _tmp74_; + g_signal_connect_object (btnRemoveFileRule, "clicked", (GCallback) _main_btnRemoveFileRuleClicked_gtk_button_clicked, self, 0); + _tmp75_ = (GtkButton*) gtk_button_new_with_label ("Save"); + g_object_ref_sink (_tmp75_); + btnSaveFileRule = _tmp75_; + g_signal_connect_object (btnSaveFileRule, "clicked", (GCallback) _main_btnSaveFileRuleClicked_gtk_button_clicked, self, 0); + gtk_box_pack_start (fileRuleButtonsBox, (GtkWidget*) btnRemoveFileRule, FALSE, TRUE, (guint) 0); + gtk_box_pack_start (fileRuleButtonsBox, (GtkWidget*) btnSaveFileRule, FALSE, TRUE, (guint) 0); + gtk_box_pack_start (fileRuleEditBox, (GtkWidget*) fileRuleButtonsBox, TRUE, TRUE, (guint) 0); + gtk_box_pack_start (fileRulesBox, (GtkWidget*) fileRuleEditBox, FALSE, TRUE, (guint) 2); + gtk_box_pack_start (mainBox, (GtkWidget*) fileRulesBox, FALSE, TRUE, (guint) 2); + _tmp76_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_object_ref_sink (_tmp76_); + containerBox = _tmp76_; + gtk_box_pack_start (containerBox, (GtkWidget*) leftSideBox, FALSE, TRUE, (guint) 4); + gtk_box_pack_start (containerBox, (GtkWidget*) mainBox, TRUE, TRUE, (guint) 4); + _tmp77_ = self->priv->window; + gtk_container_add ((GtkContainer*) _tmp77_, (GtkWidget*) containerBox); + main_disableControls (self); + _tmp78_ = self->priv->window; + gtk_widget_show_all ((GtkWidget*) _tmp78_); + _g_object_unref0 (containerBox); + _g_object_unref0 (btnSaveFileRule); + _g_object_unref0 (btnRemoveFileRule); + _g_object_unref0 (fileRuleButtonsBox); + _g_object_unref0 (fileRuleDestBox); + _g_object_unref0 (lblMoveFileTo); + _g_object_unref0 (lblFileNameContains); + _g_object_unref0 (fileRuleEditBox); + _g_object_unref0 (fileRulesBox); + _g_object_unref0 (lblSpacer); + _g_object_unref0 (dfTypeBox); + _g_object_unref0 (subfoldersOptionBox); + _g_object_unref0 (dfLocationDisplayBox); + _g_object_unref0 (lblDfLocationHeading); + _g_object_unref0 (dfLocationHeadingBox); + _g_object_unref0 (lblSrcFolderLocationHeading); + _g_object_unref0 (mainBox); + _g_object_unref0 (leftSideButtonBox); + _g_object_unref0 (leftSideBox); + block1_data_unref (_data1_); + _data1_ = NULL; +} + + +/** + * Setup the monitored directories listview with ListStore and signals. */ static gpointer _g_object_ref0 (gpointer self) { return self ? g_object_ref (self) : NULL; } -static void ___lambda2_ (Main* self) { +static void __lambda5_ (Main* self) { + main_monitoredDirSelected (self); +} + + +static void ___lambda5__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) { + __lambda5_ (self); +} + + +static void main_setupMonitoredDirsListView (Main* self) { + GtkListStore* _tmp0_; + GtkListStore* listmodel; + GtkTreeView* _tmp1_; + GtkTreeView* _tmp2_; + GtkTreeSelection* _tmp3_ = NULL; + GtkTreeSelection* _tmp4_; + GtkTreeSelection* treeSelection; + g_return_if_fail (self != NULL); + _tmp0_ = gtk_list_store_new (1, G_TYPE_STRING); + listmodel = _tmp0_; + _tmp1_ = self->priv->tvMonitoredDirs; + gtk_tree_view_set_model (_tmp1_, (GtkTreeModel*) listmodel); + _tmp2_ = self->priv->tvMonitoredDirs; + _tmp3_ = gtk_tree_view_get_selection (_tmp2_); + _tmp4_ = _g_object_ref0 (_tmp3_); + treeSelection = _tmp4_; + gtk_tree_selection_set_mode (treeSelection, GTK_SELECTION_SINGLE); + g_signal_connect_object (treeSelection, "changed", (GCallback) ___lambda5__gtk_tree_selection_changed, self, 0); + main_loadMonitoredDirsView (self); + _g_object_unref0 (treeSelection); + _g_object_unref0 (listmodel); +} + + +/** + * + */ +static void __lambda12_ (Main* self) { main_fileExtRuleSelected (self); } -static void ____lambda2__gtk_tree_view_cursor_changed (GtkTreeView* _sender, gpointer self) { - ___lambda2_ (self); +static void ___lambda12__gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) { + __lambda12_ (self); } -static void main_settingsClicked (Main* self) { - GError * _inner_error_ = NULL; +static void main_setupFileRulesListView (Main* self) { + GtkListStore* _tmp0_; + GtkListStore* listmodel; + GtkTreeView* _tmp1_; + GtkTreeView* _tmp2_; + GtkTreeSelection* _tmp3_ = NULL; + GtkTreeSelection* _tmp4_; + GtkTreeSelection* treeSelection; g_return_if_fail (self != NULL); - { - GtkBuilder* _tmp0_; - GtkBuilder* _tmp1_; - GtkBuilder* _tmp2_; - GtkBuilder* _tmp3_; - GObject* _tmp4_ = NULL; - GtkLabel* _tmp5_; - GtkLabel* lblSourcePath; - GtkLabel* _tmp6_; - gchar* _tmp7_ = NULL; - gchar* _tmp8_; - GtkBuilder* _tmp9_; - GObject* _tmp10_ = NULL; - GtkLabel* _tmp11_; - GtkLabel* lblDfRootPath; - GtkLabel* _tmp12_; - gchar* _tmp13_ = NULL; - gchar* _tmp14_; - GtkBuilder* _tmp15_; - GObject* _tmp16_ = NULL; - GtkTreeView* _tmp17_; - GtkTreeView* view; - GtkListStore* _tmp18_; - GtkListStore* listmodel; - GtkTreeView* _tmp19_; - GtkListStore* _tmp20_; - GtkTreeView* _tmp21_; - GtkCellRendererText* _tmp22_; - GtkCellRendererText* _tmp23_; - GtkTreeView* _tmp24_; - GtkCellRendererText* _tmp25_; - GtkCellRendererText* _tmp26_; - GtkTreeView* _tmp27_; - GtkBuilder* _tmp28_; - GObject* _tmp29_ = NULL; - GtkWindow* _tmp30_; - GtkWindow* window; - GtkWindow* _tmp31_; - _tmp0_ = gtk_builder_new (); - _g_object_unref0 (self->priv->dfSettingsBuilder); - self->priv->dfSettingsBuilder = _tmp0_; - _tmp1_ = self->priv->dfSettingsBuilder; - gtk_builder_add_from_file (_tmp1_, MAIN_UI_DF_SETTINGS, &_inner_error_); - if (_inner_error_ != NULL) { - goto __catch1_g_error; - } - _tmp2_ = self->priv->dfSettingsBuilder; - gtk_builder_connect_signals (_tmp2_, self); - main_loadDfTypeOption (self); - _tmp3_ = self->priv->dfSettingsBuilder; - _tmp4_ = gtk_builder_get_object (_tmp3_, "lblSourcePath"); - _tmp5_ = _g_object_ref0 (GTK_IS_LABEL (_tmp4_) ? ((GtkLabel*) _tmp4_) : NULL); - lblSourcePath = _tmp5_; - _tmp6_ = lblSourcePath; - _tmp7_ = dayfolder_user_data_getSourcePath (); - _tmp8_ = _tmp7_; - gtk_label_set_label (_tmp6_, _tmp8_); - _g_free0 (_tmp8_); - _tmp9_ = self->priv->dfSettingsBuilder; - _tmp10_ = gtk_builder_get_object (_tmp9_, "lblDfRootPath"); - _tmp11_ = _g_object_ref0 (GTK_IS_LABEL (_tmp10_) ? ((GtkLabel*) _tmp10_) : NULL); - lblDfRootPath = _tmp11_; - _tmp12_ = lblDfRootPath; - _tmp13_ = dayfolder_user_data_getDfRootPath (); - _tmp14_ = _tmp13_; - gtk_label_set_label (_tmp12_, _tmp14_); - _g_free0 (_tmp14_); - _tmp15_ = self->priv->dfSettingsBuilder; - _tmp16_ = gtk_builder_get_object (_tmp15_, "tvFileExtRules"); - _tmp17_ = _g_object_ref0 (GTK_IS_TREE_VIEW (_tmp16_) ? ((GtkTreeView*) _tmp16_) : NULL); - view = _tmp17_; - _tmp18_ = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - listmodel = _tmp18_; - _tmp19_ = view; - _tmp20_ = listmodel; - gtk_tree_view_set_model (_tmp19_, (GtkTreeModel*) _tmp20_); - _tmp21_ = view; - _tmp22_ = (GtkCellRendererText*) gtk_cell_renderer_text_new (); - _tmp23_ = g_object_ref_sink (_tmp22_); - gtk_tree_view_insert_column_with_attributes (_tmp21_, -1, "File Extension", (GtkCellRenderer*) _tmp23_, "text", 0, NULL); - _g_object_unref0 (_tmp23_); - _tmp24_ = view; - _tmp25_ = (GtkCellRendererText*) gtk_cell_renderer_text_new (); - _tmp26_ = g_object_ref_sink (_tmp25_); - gtk_tree_view_insert_column_with_attributes (_tmp24_, -1, "Destination", (GtkCellRenderer*) _tmp26_, "text", 1, NULL); - _g_object_unref0 (_tmp26_); - main_loadFileExtRulesTreeView (self); - _tmp27_ = view; - g_signal_connect_object (_tmp27_, "cursor-changed", (GCallback) ____lambda2__gtk_tree_view_cursor_changed, self, 0); - _tmp28_ = self->priv->dfSettingsBuilder; - _tmp29_ = gtk_builder_get_object (_tmp28_, "window"); - _tmp30_ = _g_object_ref0 (GTK_IS_WINDOW (_tmp29_) ? ((GtkWindow*) _tmp29_) : NULL); - window = _tmp30_; - _tmp31_ = window; - gtk_widget_show_all ((GtkWidget*) _tmp31_); - _g_object_unref0 (window); - _g_object_unref0 (listmodel); - _g_object_unref0 (view); - _g_object_unref0 (lblDfRootPath); - _g_object_unref0 (lblSourcePath); - } - goto __finally1; - __catch1_g_error: - { - GError* e = NULL; - FILE* _tmp32_; - GError* _tmp33_; - const gchar* _tmp34_; - e = _inner_error_; - _inner_error_ = NULL; - _tmp32_ = stderr; - _tmp33_ = e; - _tmp34_ = _tmp33_->message; - fprintf (_tmp32_, "Could not load dfSettingsWindow UI: %s\n", _tmp34_); - _g_error_free0 (e); - } - __finally1: - if (_inner_error_ != NULL) { - g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); - g_clear_error (&_inner_error_); - return; - } + _tmp0_ = gtk_list_store_new (1, G_TYPE_STRING); + listmodel = _tmp0_; + _tmp1_ = self->priv->tvFileRules; + gtk_tree_view_set_model (_tmp1_, (GtkTreeModel*) listmodel); + _tmp2_ = self->priv->tvFileRules; + _tmp3_ = gtk_tree_view_get_selection (_tmp2_); + _tmp4_ = _g_object_ref0 (_tmp3_); + treeSelection = _tmp4_; + gtk_tree_selection_set_mode (treeSelection, GTK_SELECTION_SINGLE); + g_signal_connect_object (treeSelection, "changed", (GCallback) ___lambda12__gtk_tree_selection_changed, self, 0); + _g_object_unref0 (treeSelection); + _g_object_unref0 (listmodel); +} + + +static GtkLabel* main_createLabelLeftAlign (Main* self, const gchar* text) { + GtkLabel* result = NULL; + const gchar* _tmp0_; + GtkLabel* _tmp1_; + GtkLabel* label; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = text; + _tmp1_ = (GtkLabel*) gtk_label_new (_tmp0_); + g_object_ref_sink (_tmp1_); + label = _tmp1_; + g_object_set ((GtkMisc*) label, "xalign", (gfloat) 0, NULL); + result = label; + return result; } @@ -506,109 +1022,193 @@ * Load the user's File Extension Rules. */ static void main_loadFileExtRulesTreeView (Main* self) { - GtkBuilder* _tmp0_; - GObject* _tmp1_ = NULL; - GtkTreeView* _tmp2_; - GtkTreeView* view; - GtkTreeView* _tmp3_; - GtkTreeModel* _tmp4_; - GtkTreeModel* _tmp5_; - GtkListStore* _tmp6_; + GtkTreeView* _tmp0_; + GtkTreeModel* _tmp1_; + GtkTreeModel* _tmp2_; + GtkListStore* _tmp3_; GtkListStore* listmodel; - GtkListStore* _tmp7_; + GtkListStore* _tmp4_; GtkTreeIter iter = {0}; - GeeArrayList* _tmp8_ = NULL; - GeeArrayList* fileExtRules; + const gchar* _tmp5_; + GeeArrayList* _tmp6_ = NULL; + GeeArrayList* rules; g_return_if_fail (self != NULL); - _tmp0_ = self->priv->dfSettingsBuilder; - _tmp1_ = gtk_builder_get_object (_tmp0_, "tvFileExtRules"); - _tmp2_ = _g_object_ref0 (GTK_IS_TREE_VIEW (_tmp1_) ? ((GtkTreeView*) _tmp1_) : NULL); - view = _tmp2_; - _tmp3_ = view; - _tmp4_ = gtk_tree_view_get_model (_tmp3_); - _tmp5_ = _tmp4_; - _tmp6_ = _g_object_ref0 (GTK_IS_LIST_STORE (_tmp5_) ? ((GtkListStore*) _tmp5_) : NULL); - listmodel = _tmp6_; - _tmp7_ = listmodel; - gtk_list_store_clear (_tmp7_); + zystem_zystem_debug ("Loading FileExtRule TreeView..."); + _tmp0_ = self->priv->tvFileRules; + _tmp1_ = gtk_tree_view_get_model (_tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GTK_TYPE_LIST_STORE) ? ((GtkListStore*) _tmp2_) : NULL); + listmodel = _tmp3_; + _tmp4_ = listmodel; + gtk_list_store_clear (_tmp4_); __g_list_free__g_free0_0 (self->priv->fileExtList); self->priv->fileExtList = NULL; - _tmp8_ = dayfolder_user_data_getFileExtRules (); - fileExtRules = _tmp8_; + _tmp5_ = self->priv->currentMonitoredDir; + _tmp6_ = dayfolder_user_data_getFileRules (_tmp5_); + rules = _tmp6_; { - GeeArrayList* _tmp9_; - GeeArrayList* _tmp10_; + GeeArrayList* _tmp7_; + GeeArrayList* _tmp8_; GeeArrayList* _rule_list; - GeeArrayList* _tmp11_; - gint _tmp12_; - gint _tmp13_; + GeeArrayList* _tmp9_; + gint _tmp10_; + gint _tmp11_; gint _rule_size; gint _rule_index; - _tmp9_ = fileExtRules; - _tmp10_ = _g_object_ref0 (_tmp9_); - _rule_list = _tmp10_; - _tmp11_ = _rule_list; - _tmp12_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp11_); - _tmp13_ = _tmp12_; - _rule_size = _tmp13_; + _tmp7_ = rules; + _tmp8_ = _g_object_ref0 (_tmp7_); + _rule_list = _tmp8_; + _tmp9_ = _rule_list; + _tmp10_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp9_); + _tmp11_ = _tmp10_; + _rule_size = _tmp11_; _rule_index = -1; while (TRUE) { + gint _tmp12_; + gint _tmp13_; gint _tmp14_; - gint _tmp15_; + GeeArrayList* _tmp15_; gint _tmp16_; - GeeArrayList* _tmp17_; - gint _tmp18_; - gpointer _tmp19_ = NULL; - dayfolderFileExtRule* rule; + gpointer _tmp17_ = NULL; + dayfolderDfRule* rule; + GtkListStore* _tmp18_; + GtkTreeIter _tmp19_ = {0}; GtkListStore* _tmp20_; - GtkTreeIter _tmp21_ = {0}; - GtkListStore* _tmp22_; - GtkTreeIter _tmp23_; - dayfolderFileExtRule* _tmp24_; - const gchar* _tmp25_; + GtkTreeIter _tmp21_; + dayfolderDfRule* _tmp22_; + const gchar* _tmp23_; + const gchar* _tmp24_; + dayfolderDfRule* _tmp25_; const gchar* _tmp26_; - dayfolderFileExtRule* _tmp27_; - const gchar* _tmp28_; - const gchar* _tmp29_; - dayfolderFileExtRule* _tmp30_; - const gchar* _tmp31_; - const gchar* _tmp32_; - gchar* _tmp33_; - _tmp14_ = _rule_index; - _rule_index = _tmp14_ + 1; - _tmp15_ = _rule_index; - _tmp16_ = _rule_size; - if (!(_tmp15_ < _tmp16_)) { + const gchar* _tmp27_; + gchar* _tmp28_; + _tmp12_ = _rule_index; + _rule_index = _tmp12_ + 1; + _tmp13_ = _rule_index; + _tmp14_ = _rule_size; + if (!(_tmp13_ < _tmp14_)) { break; } - _tmp17_ = _rule_list; - _tmp18_ = _rule_index; - _tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _tmp17_, _tmp18_); - rule = (dayfolderFileExtRule*) _tmp19_; + _tmp15_ = _rule_list; + _tmp16_ = _rule_index; + _tmp17_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, _tmp16_); + rule = (dayfolderDfRule*) _tmp17_; + _tmp18_ = listmodel; + gtk_list_store_append (_tmp18_, &_tmp19_); + iter = _tmp19_; _tmp20_ = listmodel; - gtk_list_store_append (_tmp20_, &_tmp21_); - iter = _tmp21_; - _tmp22_ = listmodel; - _tmp23_ = iter; - _tmp24_ = rule; - _tmp25_ = dayfolder_file_ext_rule_get_fileExt (_tmp24_); - _tmp26_ = _tmp25_; - _tmp27_ = rule; - _tmp28_ = dayfolder_file_ext_rule_get_destinationDir (_tmp27_); - _tmp29_ = _tmp28_; - gtk_list_store_set (_tmp22_, &_tmp23_, 0, _tmp26_, 1, _tmp29_, -1); - _tmp30_ = rule; - _tmp31_ = dayfolder_file_ext_rule_get_fileExt (_tmp30_); - _tmp32_ = _tmp31_; - _tmp33_ = g_strdup (_tmp32_); - self->priv->fileExtList = g_list_append (self->priv->fileExtList, _tmp33_); + _tmp21_ = iter; + _tmp22_ = rule; + _tmp23_ = dayfolder_df_rule_get_criteriaString (_tmp22_); + _tmp24_ = _tmp23_; + gtk_list_store_set (_tmp20_, &_tmp21_, 0, _tmp24_, -1); + _tmp25_ = rule; + _tmp26_ = dayfolder_df_rule_get_criteriaString (_tmp25_); + _tmp27_ = _tmp26_; + _tmp28_ = g_strdup (_tmp27_); + self->priv->fileExtList = g_list_append (self->priv->fileExtList, _tmp28_); _g_object_unref0 (rule); } _g_object_unref0 (_rule_list); } - _g_object_unref0 (fileExtRules); + _g_object_unref0 (rules); + _g_object_unref0 (listmodel); +} + + +/** + * Load the Monitored Directories TreeView. + */ +static void main_loadMonitoredDirsView (Main* self) { + GtkTreeView* _tmp0_; + GtkTreeModel* _tmp1_; + GtkTreeModel* _tmp2_; + GtkListStore* _tmp3_; + GtkListStore* listmodel; + GtkListStore* _tmp4_; + GtkTreeIter iter = {0}; + GeeArrayList* _tmp5_ = NULL; + GeeArrayList* monitoredDirs; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->tvMonitoredDirs; + _tmp1_ = gtk_tree_view_get_model (_tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GTK_TYPE_LIST_STORE) ? ((GtkListStore*) _tmp2_) : NULL); + listmodel = _tmp3_; + _tmp4_ = listmodel; + gtk_list_store_clear (_tmp4_); + __g_list_free__g_free0_0 (self->priv->monitoredDirsList); + self->priv->monitoredDirsList = NULL; + _tmp5_ = dayfolder_user_data_getMonitoredDirs (); + monitoredDirs = _tmp5_; + { + GeeArrayList* _tmp6_; + GeeArrayList* _tmp7_; + GeeArrayList* _dir_list; + GeeArrayList* _tmp8_; + gint _tmp9_; + gint _tmp10_; + gint _dir_size; + gint _dir_index; + _tmp6_ = monitoredDirs; + _tmp7_ = _g_object_ref0 (_tmp6_); + _dir_list = _tmp7_; + _tmp8_ = _dir_list; + _tmp9_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp8_); + _tmp10_ = _tmp9_; + _dir_size = _tmp10_; + _dir_index = -1; + while (TRUE) { + gint _tmp11_; + gint _tmp12_; + gint _tmp13_; + GeeArrayList* _tmp14_; + gint _tmp15_; + gpointer _tmp16_ = NULL; + dayfolderMonitoredDirectory* dir; + GtkListStore* _tmp17_; + GtkTreeIter _tmp18_ = {0}; + GtkListStore* _tmp19_; + GtkTreeIter _tmp20_; + dayfolderMonitoredDirectory* _tmp21_; + const gchar* _tmp22_; + const gchar* _tmp23_; + dayfolderMonitoredDirectory* _tmp24_; + const gchar* _tmp25_; + const gchar* _tmp26_; + gchar* _tmp27_; + _tmp11_ = _dir_index; + _dir_index = _tmp11_ + 1; + _tmp12_ = _dir_index; + _tmp13_ = _dir_size; + if (!(_tmp12_ < _tmp13_)) { + break; + } + _tmp14_ = _dir_list; + _tmp15_ = _dir_index; + _tmp16_ = gee_abstract_list_get ((GeeAbstractList*) _tmp14_, _tmp15_); + dir = (dayfolderMonitoredDirectory*) _tmp16_; + _tmp17_ = listmodel; + gtk_list_store_append (_tmp17_, &_tmp18_); + iter = _tmp18_; + _tmp19_ = listmodel; + _tmp20_ = iter; + _tmp21_ = dir; + _tmp22_ = dayfolder_monitored_directory_get_dirPath (_tmp21_); + _tmp23_ = _tmp22_; + gtk_list_store_set (_tmp19_, &_tmp20_, 0, _tmp23_, -1); + _tmp24_ = dir; + _tmp25_ = dayfolder_monitored_directory_get_dirPath (_tmp24_); + _tmp26_ = _tmp25_; + _tmp27_ = g_strdup (_tmp26_); + self->priv->monitoredDirsList = g_list_append (self->priv->monitoredDirsList, _tmp27_); + _g_object_unref0 (dir); + } + _g_object_unref0 (_dir_list); + } + main_disableControls (self); + _g_object_unref0 (monitoredDirs); _g_object_unref0 (listmodel); - _g_object_unref0 (view); } @@ -616,58 +1216,33 @@ * */ static void main_loadDfTypeOption (Main* self) { - gchar* _tmp0_ = NULL; + const gchar* _tmp0_; + gchar* _tmp1_ = NULL; gchar* dfType; - const gchar* _tmp1_; + const gchar* _tmp2_; g_return_if_fail (self != NULL); - _tmp0_ = dayfolder_user_data_getDfType (); - dfType = _tmp0_; - _tmp1_ = dfType; - if (g_strcmp0 (_tmp1_, DAYFOLDER_USER_DATA_dfTypeDaily) == 0) { - GtkBuilder* _tmp2_; - GObject* _tmp3_ = NULL; - GtkRadioButton* _tmp4_; - GtkRadioButton* rdoDay; - GtkRadioButton* _tmp5_; - _tmp2_ = self->priv->dfSettingsBuilder; - _tmp3_ = gtk_builder_get_object (_tmp2_, "rdoDay"); - _tmp4_ = _g_object_ref0 (GTK_IS_RADIO_BUTTON (_tmp3_) ? ((GtkRadioButton*) _tmp3_) : NULL); - rdoDay = _tmp4_; - _tmp5_ = rdoDay; - g_signal_emit_by_name ((GtkButton*) _tmp5_, "activate"); - _g_object_unref0 (rdoDay); + _tmp0_ = self->priv->currentMonitoredDir; + _tmp1_ = dayfolder_user_data_getDfType (_tmp0_); + dfType = _tmp1_; + _tmp2_ = dfType; + if (g_strcmp0 (_tmp2_, DAYFOLDER_USER_DATA_dfTypeDaily) == 0) { + GtkRadioButton* _tmp3_; + _tmp3_ = self->priv->rdoDaily; + g_signal_emit_by_name ((GtkButton*) _tmp3_, "activate"); } else { - const gchar* _tmp6_; - _tmp6_ = dfType; - if (g_strcmp0 (_tmp6_, DAYFOLDER_USER_DATA_dfTypeWeekly) == 0) { - GtkBuilder* _tmp7_; - GObject* _tmp8_ = NULL; - GtkRadioButton* _tmp9_; - GtkRadioButton* rdoWeek; - GtkRadioButton* _tmp10_; - _tmp7_ = self->priv->dfSettingsBuilder; - _tmp8_ = gtk_builder_get_object (_tmp7_, "rdoWeek"); - _tmp9_ = _g_object_ref0 (GTK_IS_RADIO_BUTTON (_tmp8_) ? ((GtkRadioButton*) _tmp8_) : NULL); - rdoWeek = _tmp9_; - _tmp10_ = rdoWeek; - g_signal_emit_by_name ((GtkButton*) _tmp10_, "activate"); - _g_object_unref0 (rdoWeek); + const gchar* _tmp4_; + _tmp4_ = dfType; + if (g_strcmp0 (_tmp4_, DAYFOLDER_USER_DATA_dfTypeWeekly) == 0) { + GtkRadioButton* _tmp5_; + _tmp5_ = self->priv->rdoWeekly; + g_signal_emit_by_name ((GtkButton*) _tmp5_, "activate"); } else { - const gchar* _tmp11_; - _tmp11_ = dfType; - if (g_strcmp0 (_tmp11_, DAYFOLDER_USER_DATA_dfTypeMonthly) == 0) { - GtkBuilder* _tmp12_; - GObject* _tmp13_ = NULL; - GtkRadioButton* _tmp14_; - GtkRadioButton* rdoMonth; - GtkRadioButton* _tmp15_; - _tmp12_ = self->priv->dfSettingsBuilder; - _tmp13_ = gtk_builder_get_object (_tmp12_, "rdoMonth"); - _tmp14_ = _g_object_ref0 (GTK_IS_RADIO_BUTTON (_tmp13_) ? ((GtkRadioButton*) _tmp13_) : NULL); - rdoMonth = _tmp14_; - _tmp15_ = rdoMonth; - g_signal_emit_by_name ((GtkButton*) _tmp15_, "activate"); - _g_object_unref0 (rdoMonth); + const gchar* _tmp6_; + _tmp6_ = dfType; + if (g_strcmp0 (_tmp6_, DAYFOLDER_USER_DATA_dfTypeMonthly) == 0) { + GtkRadioButton* _tmp7_; + _tmp7_ = self->priv->rdoMonthly; + g_signal_emit_by_name ((GtkButton*) _tmp7_, "activate"); } } } @@ -685,231 +1260,136 @@ /** - * Reset the DayFolder root directory to the default value. - */ -void main_btnResetDfRootClicked (GtkButton* button, Main* self) { - gchar* _tmp0_ = NULL; - gchar* _tmp1_; - g_return_if_fail (self != NULL); - g_return_if_fail (button != NULL); - dayfolder_user_data_resetDfRootPath (); - _tmp0_ = dayfolder_user_data_getDefaultDfRootPath (); - _tmp1_ = _tmp0_; - main_setLabelText (self, "lblDfRootPath", _tmp1_); - _g_free0 (_tmp1_); -} - - -/** - * Reset the Source Location to the default value. - */ -void main_btnResetSourceClicked (GtkButton* button, Main* self) { - gchar* _tmp0_ = NULL; - gchar* _tmp1_; - g_return_if_fail (self != NULL); - g_return_if_fail (button != NULL); - dayfolder_user_data_resetSourcePath (); - _tmp0_ = dayfolder_user_data_getDefaultSourcePath (); - _tmp1_ = _tmp0_; - main_setLabelText (self, "lblSourcePath", _tmp1_); - _g_free0 (_tmp1_); -} - - -/** * */ -void main_btnSaveFileExtRuleClicked (GtkButton* button, Main* self) { - GtkBuilder* _tmp0_; - GObject* _tmp1_ = NULL; - GtkEntry* _tmp2_; - GtkEntry* txtFileExt; - GtkBuilder* _tmp3_; - GObject* _tmp4_ = NULL; - GtkEntry* _tmp5_; - GtkEntry* txtDestDir; +void main_btnSaveFileRuleClicked (Main* self) { + const gchar* _tmp0_; + GtkEntry* _tmp1_; + const gchar* _tmp2_; + const gchar* _tmp3_; + GtkEntry* _tmp4_; + const gchar* _tmp5_; const gchar* _tmp6_; - const gchar* _tmp7_; - const gchar* _tmp8_; - const gchar* _tmp9_; + GtkEntry* _tmp7_; + GtkEntry* _tmp8_; g_return_if_fail (self != NULL); - g_return_if_fail (button != NULL); - _tmp0_ = self->priv->dfSettingsBuilder; - _tmp1_ = gtk_builder_get_object (_tmp0_, "txtFileExt"); - _tmp2_ = _g_object_ref0 (GTK_IS_ENTRY (_tmp1_) ? ((GtkEntry*) _tmp1_) : NULL); - txtFileExt = _tmp2_; - _tmp3_ = self->priv->dfSettingsBuilder; - _tmp4_ = gtk_builder_get_object (_tmp3_, "txtDestDir"); - _tmp5_ = _g_object_ref0 (GTK_IS_ENTRY (_tmp4_) ? ((GtkEntry*) _tmp4_) : NULL); - txtDestDir = _tmp5_; - _tmp6_ = gtk_entry_get_text (txtFileExt); - _tmp7_ = _tmp6_; - _tmp8_ = gtk_entry_get_text (txtDestDir); - _tmp9_ = _tmp8_; - dayfolder_user_data_addFileExtRule (_tmp7_, _tmp9_); - gtk_entry_set_text (txtFileExt, ""); - gtk_entry_set_text (txtDestDir, ""); + _tmp0_ = self->priv->currentMonitoredDir; + _tmp1_ = self->priv->txtFileNameContains; + _tmp2_ = gtk_entry_get_text (_tmp1_); + _tmp3_ = _tmp2_; + _tmp4_ = self->priv->txtFileRuleDest; + _tmp5_ = gtk_entry_get_text (_tmp4_); + _tmp6_ = _tmp5_; + dayfolder_user_data_addFileRule (_tmp0_, _tmp3_, _tmp6_); + _tmp7_ = self->priv->txtFileNameContains; + gtk_entry_set_text (_tmp7_, ""); + _tmp8_ = self->priv->txtFileRuleDest; + gtk_entry_set_text (_tmp8_, ""); main_loadFileExtRulesTreeView (self); - _g_object_unref0 (txtDestDir); - _g_object_unref0 (txtFileExt); } /** * */ -void main_btnFileExtDestDirClicked (GtkButton* button, Main* self) { - GtkBuilder* _tmp0_; - GObject* _tmp1_ = NULL; - GtkWindow* _tmp2_; +void main_btnChangeFileRuleDestClicked (Main* self) { + GtkWindow* _tmp0_; + GtkWindow* _tmp1_; GtkWindow* window; - GtkBuilder* _tmp3_; - GObject* _tmp4_ = NULL; - GtkEntry* _tmp5_; + GtkEntry* _tmp2_; + GtkEntry* _tmp3_; GtkEntry* txtDestDir; - GtkWindow* _tmp6_; - GtkFileChooserDialog* _tmp7_; - GtkFileChooserDialog* _tmp8_; - GtkFileChooserDialog* fileChooser; - GtkFileChooserDialog* _tmp9_; - gint _tmp10_ = 0; - GtkFileChooserDialog* _tmp15_; - g_return_if_fail (self != NULL); - g_return_if_fail (button != NULL); - _tmp0_ = self->priv->dfSettingsBuilder; - _tmp1_ = gtk_builder_get_object (_tmp0_, "window"); - _tmp2_ = _g_object_ref0 (GTK_IS_WINDOW (_tmp1_) ? ((GtkWindow*) _tmp1_) : NULL); - window = _tmp2_; - _tmp3_ = self->priv->dfSettingsBuilder; - _tmp4_ = gtk_builder_get_object (_tmp3_, "txtDestDir"); - _tmp5_ = _g_object_ref0 (GTK_IS_ENTRY (_tmp4_) ? ((GtkEntry*) _tmp4_) : NULL); - txtDestDir = _tmp5_; - _tmp6_ = window; - _tmp7_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", _tmp6_, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - _tmp8_ = g_object_ref_sink (_tmp7_); - fileChooser = _tmp8_; - _tmp9_ = fileChooser; - _tmp10_ = gtk_dialog_run ((GtkDialog*) _tmp9_); - if (_tmp10_ == ((gint) GTK_RESPONSE_ACCEPT)) { - GtkFileChooserDialog* _tmp11_; - gchar* _tmp12_ = NULL; - gchar* dirPath; - GtkEntry* _tmp13_; - const gchar* _tmp14_; - _tmp11_ = fileChooser; - _tmp12_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp11_); - dirPath = _tmp12_; - _tmp13_ = txtDestDir; - _tmp14_ = dirPath; - gtk_entry_set_text (_tmp13_, _tmp14_); - _g_free0 (dirPath); - } - _tmp15_ = fileChooser; - gtk_widget_destroy ((GtkWidget*) _tmp15_); - _g_object_unref0 (fileChooser); - _g_object_unref0 (txtDestDir); - _g_object_unref0 (window); -} - - -/** - * Closing a dialog. - */ -void main_on_destroy (GtkWidget* window, Main* self) { - g_return_if_fail (self != NULL); - g_return_if_fail (window != NULL); -} - - -/** - * - */ -void main_btnDfRootPathClicked (GtkButton* chooser, Main* self) { - GtkBuilder* _tmp0_; - GObject* _tmp1_ = NULL; - GtkWindow* _tmp2_; - GtkWindow* window; - GtkWindow* _tmp3_; - GtkFileChooserDialog* _tmp4_; + GtkWindow* _tmp4_; GtkFileChooserDialog* _tmp5_; GtkFileChooserDialog* fileChooser; GtkFileChooserDialog* _tmp6_; gint _tmp7_ = 0; GtkFileChooserDialog* _tmp12_; g_return_if_fail (self != NULL); - g_return_if_fail (chooser != NULL); - _tmp0_ = self->priv->dfSettingsBuilder; - _tmp1_ = gtk_builder_get_object (_tmp0_, "window"); - _tmp2_ = _g_object_ref0 (GTK_IS_WINDOW (_tmp1_) ? ((GtkWindow*) _tmp1_) : NULL); - window = _tmp2_; - _tmp3_ = window; - _tmp4_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", _tmp3_, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - _tmp5_ = g_object_ref_sink (_tmp4_); + _tmp0_ = self->priv->window; + _tmp1_ = _g_object_ref0 (_tmp0_); + window = _tmp1_; + _tmp2_ = self->priv->txtFileRuleDest; + _tmp3_ = _g_object_ref0 (_tmp2_); + txtDestDir = _tmp3_; + _tmp4_ = window; + _tmp5_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Choose File Rule Destination", _tmp4_, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + g_object_ref_sink (_tmp5_); fileChooser = _tmp5_; _tmp6_ = fileChooser; _tmp7_ = gtk_dialog_run ((GtkDialog*) _tmp6_); if (_tmp7_ == ((gint) GTK_RESPONSE_ACCEPT)) { GtkFileChooserDialog* _tmp8_; gchar* _tmp9_ = NULL; - gchar* path; - const gchar* _tmp10_; + gchar* dirPath; + GtkEntry* _tmp10_; const gchar* _tmp11_; _tmp8_ = fileChooser; _tmp9_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp8_); - path = _tmp9_; - _tmp10_ = path; - dayfolder_user_data_setDfRootPath (_tmp10_); - _tmp11_ = path; - main_setLabelText (self, "lblDfRootPath", _tmp11_); - _g_free0 (path); + dirPath = _tmp9_; + _tmp10_ = txtDestDir; + _tmp11_ = dirPath; + gtk_entry_set_text (_tmp10_, _tmp11_); + _g_free0 (dirPath); } _tmp12_ = fileChooser; gtk_widget_destroy ((GtkWidget*) _tmp12_); _g_object_unref0 (fileChooser); + _g_object_unref0 (txtDestDir); _g_object_unref0 (window); } /** + * Closing a dialog. + */ +void main_on_destroy (Main* self, GtkWidget* window) { + g_return_if_fail (self != NULL); + g_return_if_fail (window != NULL); +} + + +/** * */ -void main_btnSourcePathClicked (GtkButton* chooser, Main* self) { - GtkBuilder* _tmp0_; - GObject* _tmp1_ = NULL; - GtkWindow* _tmp2_; +void main_btnDfRootPathClicked (Main* self, GtkButton* chooser) { + GtkWindow* _tmp0_; + GtkWindow* _tmp1_; GtkWindow* window; - GtkWindow* _tmp3_; - GtkFileChooserDialog* _tmp4_; - GtkFileChooserDialog* _tmp5_; + GtkWindow* _tmp2_; + GtkFileChooserDialog* _tmp3_; GtkFileChooserDialog* fileChooser; - GtkFileChooserDialog* _tmp6_; - gint _tmp7_ = 0; + GtkFileChooserDialog* _tmp4_; + gint _tmp5_ = 0; GtkFileChooserDialog* _tmp12_; g_return_if_fail (self != NULL); g_return_if_fail (chooser != NULL); - _tmp0_ = self->priv->dfSettingsBuilder; - _tmp1_ = gtk_builder_get_object (_tmp0_, "window"); - _tmp2_ = _g_object_ref0 (GTK_IS_WINDOW (_tmp1_) ? ((GtkWindow*) _tmp1_) : NULL); - window = _tmp2_; - _tmp3_ = window; - _tmp4_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", _tmp3_, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - _tmp5_ = g_object_ref_sink (_tmp4_); - fileChooser = _tmp5_; - _tmp6_ = fileChooser; - _tmp7_ = gtk_dialog_run ((GtkDialog*) _tmp6_); - if (_tmp7_ == ((gint) GTK_RESPONSE_ACCEPT)) { - GtkFileChooserDialog* _tmp8_; - gchar* _tmp9_ = NULL; + _tmp0_ = self->priv->window; + _tmp1_ = _g_object_ref0 (_tmp0_); + window = _tmp1_; + _tmp2_ = window; + _tmp3_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Open File", _tmp2_, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + g_object_ref_sink (_tmp3_); + fileChooser = _tmp3_; + _tmp4_ = fileChooser; + _tmp5_ = gtk_dialog_run ((GtkDialog*) _tmp4_); + if (_tmp5_ == ((gint) GTK_RESPONSE_ACCEPT)) { + GtkFileChooserDialog* _tmp6_; + gchar* _tmp7_ = NULL; gchar* path; - const gchar* _tmp10_; + const gchar* _tmp8_; + const gchar* _tmp9_; + GtkLabel* _tmp10_; const gchar* _tmp11_; - _tmp8_ = fileChooser; - _tmp9_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp8_); - path = _tmp9_; - _tmp10_ = path; - dayfolder_user_data_setSourcePath (_tmp10_); + _tmp6_ = fileChooser; + _tmp7_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp6_); + path = _tmp7_; + _tmp8_ = self->priv->currentMonitoredDir; + _tmp9_ = path; + dayfolder_user_data_setDfRootPath (_tmp8_, _tmp9_); + _tmp10_ = self->priv->lblDfLocationDisplay; _tmp11_ = path; - main_setLabelText (self, "lblSourcePath", _tmp11_); + gtk_label_set_label (_tmp10_, _tmp11_); _g_free0 (path); } _tmp12_ = fileChooser; @@ -920,70 +1400,75 @@ /** - * Set label text. + * */ -static void main_setLabelText (Main* self, const gchar* labelName, const gchar* path) { - GtkBuilder* _tmp0_; +void main_btnRemoveFileRuleClicked (Main* self) { + gchar* _tmp0_ = NULL; + gchar* fileCriteriaString; const gchar* _tmp1_; - GObject* _tmp2_ = NULL; - GtkLabel* _tmp3_; - GtkLabel* lbl; - const gchar* _tmp4_; + GtkEntry* _tmp2_; + GtkEntry* _tmp3_; g_return_if_fail (self != NULL); - g_return_if_fail (labelName != NULL); - g_return_if_fail (path != NULL); - _tmp0_ = self->priv->dfSettingsBuilder; - _tmp1_ = labelName; - _tmp2_ = gtk_builder_get_object (_tmp0_, _tmp1_); - _tmp3_ = _g_object_ref0 (GTK_IS_LABEL (_tmp2_) ? ((GtkLabel*) _tmp2_) : NULL); - lbl = _tmp3_; - _tmp4_ = path; - gtk_label_set_label (lbl, _tmp4_); - _g_object_unref0 (lbl); + _tmp0_ = main_getSelectedFileExt (self); + fileCriteriaString = _tmp0_; + _tmp1_ = self->priv->currentMonitoredDir; + dayfolder_user_data_removeFileRule (_tmp1_, fileCriteriaString); + _tmp2_ = self->priv->txtFileNameContains; + gtk_entry_set_text (_tmp2_, ""); + _tmp3_ = self->priv->txtFileRuleDest; + gtk_entry_set_text (_tmp3_, ""); + main_loadFileExtRulesTreeView (self); + _g_free0 (fileCriteriaString); } /** - * + * Remove the selected monitored directory. */ -void main_btnRemoveFileExtRuleClicked (GtkButton* button, Main* self) { +void main_btnRemoveMonitoredDirClicked (Main* self, GtkButton* button) { gchar* _tmp0_ = NULL; - gchar* fileExt; + gchar* dirPath; g_return_if_fail (self != NULL); g_return_if_fail (button != NULL); - _tmp0_ = main_getSelectedFileExt (self); - fileExt = _tmp0_; - dayfolder_user_data_removeFileExtRule (fileExt); - main_loadFileExtRulesTreeView (self); - _g_free0 (fileExt); + zystem_zystem_debug ("Removing Monitored Dir..."); + _tmp0_ = main_getSelectedMonitoredDir (self); + dirPath = _tmp0_; + dayfolder_user_data_removeMonitoredDir (dirPath); + main_loadMonitoredDirsView (self); + _g_free0 (dirPath); } /** * When choosing Daily DayFolder. */ -void main_rdoDayClicked (GtkRadioButton* button, Main* self) { +void main_rdoDayClicked (Main* self, GtkRadioButton* button) { gboolean _tmp0_ = FALSE; GtkRadioButton* _tmp1_; gboolean _tmp2_ = FALSE; - gboolean _tmp5_; + gboolean _tmp6_; g_return_if_fail (self != NULL); g_return_if_fail (button != NULL); + zystem_zystem_debug ("Day toggled"); _tmp1_ = button; _tmp2_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp1_); if (_tmp2_) { - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - _tmp3_ = dayfolder_user_data_getDfType (); - _tmp4_ = _tmp3_; - _tmp0_ = g_strcmp0 (_tmp4_, DAYFOLDER_USER_DATA_dfTypeDaily) != 0; - _g_free0 (_tmp4_); + const gchar* _tmp3_; + gchar* _tmp4_ = NULL; + gchar* _tmp5_; + _tmp3_ = self->priv->currentMonitoredDir; + _tmp4_ = dayfolder_user_data_getDfType (_tmp3_); + _tmp5_ = _tmp4_; + _tmp0_ = g_strcmp0 (_tmp5_, DAYFOLDER_USER_DATA_dfTypeDaily) != 0; + _g_free0 (_tmp5_); } else { _tmp0_ = FALSE; } - _tmp5_ = _tmp0_; - if (_tmp5_) { - dayfolder_user_data_setDfType (DAYFOLDER_USER_DATA_dfTypeDaily); + _tmp6_ = _tmp0_; + if (_tmp6_) { + const gchar* _tmp7_; + _tmp7_ = self->priv->currentMonitoredDir; + dayfolder_user_data_setDfType (_tmp7_, DAYFOLDER_USER_DATA_dfTypeDaily); } } @@ -991,28 +1476,33 @@ /** * When choosing Weekly DayFolder. */ -void main_rdoWeekClicked (GtkRadioButton* button, Main* self) { +void main_rdoWeekClicked (Main* self, GtkRadioButton* button) { gboolean _tmp0_ = FALSE; GtkRadioButton* _tmp1_; gboolean _tmp2_ = FALSE; - gboolean _tmp5_; + gboolean _tmp6_; g_return_if_fail (self != NULL); g_return_if_fail (button != NULL); + zystem_zystem_debug ("Week toggled"); _tmp1_ = button; _tmp2_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp1_); if (_tmp2_) { - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - _tmp3_ = dayfolder_user_data_getDfType (); - _tmp4_ = _tmp3_; - _tmp0_ = g_strcmp0 (_tmp4_, DAYFOLDER_USER_DATA_dfTypeWeekly) != 0; - _g_free0 (_tmp4_); + const gchar* _tmp3_; + gchar* _tmp4_ = NULL; + gchar* _tmp5_; + _tmp3_ = self->priv->currentMonitoredDir; + _tmp4_ = dayfolder_user_data_getDfType (_tmp3_); + _tmp5_ = _tmp4_; + _tmp0_ = g_strcmp0 (_tmp5_, DAYFOLDER_USER_DATA_dfTypeWeekly) != 0; + _g_free0 (_tmp5_); } else { _tmp0_ = FALSE; } - _tmp5_ = _tmp0_; - if (_tmp5_) { - dayfolder_user_data_setDfType (DAYFOLDER_USER_DATA_dfTypeWeekly); + _tmp6_ = _tmp0_; + if (_tmp6_) { + const gchar* _tmp7_; + _tmp7_ = self->priv->currentMonitoredDir; + dayfolder_user_data_setDfType (_tmp7_, DAYFOLDER_USER_DATA_dfTypeWeekly); } } @@ -1020,68 +1510,130 @@ /** * When choosing Monthly DayFolder. */ -void main_rdoMonthClicked (GtkRadioButton* button, Main* self) { +void main_rdoMonthClicked (Main* self, GtkRadioButton* button) { gboolean _tmp0_ = FALSE; GtkRadioButton* _tmp1_; gboolean _tmp2_ = FALSE; - gboolean _tmp5_; + gboolean _tmp6_; g_return_if_fail (self != NULL); g_return_if_fail (button != NULL); + zystem_zystem_debug ("Month toggled"); _tmp1_ = button; _tmp2_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp1_); if (_tmp2_) { - gchar* _tmp3_ = NULL; - gchar* _tmp4_; - _tmp3_ = dayfolder_user_data_getDfType (); - _tmp4_ = _tmp3_; - _tmp0_ = g_strcmp0 (_tmp4_, DAYFOLDER_USER_DATA_dfTypeMonthly) != 0; - _g_free0 (_tmp4_); + const gchar* _tmp3_; + gchar* _tmp4_ = NULL; + gchar* _tmp5_; + _tmp3_ = self->priv->currentMonitoredDir; + _tmp4_ = dayfolder_user_data_getDfType (_tmp3_); + _tmp5_ = _tmp4_; + _tmp0_ = g_strcmp0 (_tmp5_, DAYFOLDER_USER_DATA_dfTypeMonthly) != 0; + _g_free0 (_tmp5_); } else { _tmp0_ = FALSE; } - _tmp5_ = _tmp0_; - if (_tmp5_) { - dayfolder_user_data_setDfType (DAYFOLDER_USER_DATA_dfTypeMonthly); + _tmp6_ = _tmp0_; + if (_tmp6_) { + const gchar* _tmp7_; + _tmp7_ = self->priv->currentMonitoredDir; + dayfolder_user_data_setDfType (_tmp7_, DAYFOLDER_USER_DATA_dfTypeMonthly); } } /** - * + * Start a new monitored dir to add to settings. This adds a blank entry + * to the tree view. + */ +void main_btnAddMonitoredDirClicked (Main* self, GtkButton* button) { + GtkWindow* _tmp0_; + GtkFileChooserDialog* _tmp1_; + GtkFileChooserDialog* fileChooser; + GtkFileChooserDialog* _tmp2_; + gint _tmp3_ = 0; + GtkFileChooserDialog* _tmp7_; + g_return_if_fail (self != NULL); + g_return_if_fail (button != NULL); + _tmp0_ = self->priv->window; + _tmp1_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Add Monitored Folder", _tmp0_, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + g_object_ref_sink (_tmp1_); + fileChooser = _tmp1_; + _tmp2_ = fileChooser; + _tmp3_ = gtk_dialog_run ((GtkDialog*) _tmp2_); + if (_tmp3_ == ((gint) GTK_RESPONSE_ACCEPT)) { + GtkFileChooserDialog* _tmp4_; + gchar* _tmp5_ = NULL; + gchar* path; + const gchar* _tmp6_; + _tmp4_ = fileChooser; + _tmp5_ = gtk_file_chooser_get_filename ((GtkFileChooser*) _tmp4_); + path = _tmp5_; + _tmp6_ = path; + main_addMonitoredDir (self, _tmp6_); + _g_free0 (path); + } + _tmp7_ = fileChooser; + gtk_widget_destroy ((GtkWidget*) _tmp7_); + _g_object_unref0 (fileChooser); +} + + +/** + * This is the process of adding a new monitored directory. + */ +static void main_addMonitoredDir (Main* self, const gchar* path) { + GtkTreeView* _tmp0_; + GtkTreeModel* _tmp1_; + GtkTreeModel* _tmp2_; + GtkListStore* _tmp3_; + GtkListStore* listmodel; + GtkTreeIter iter = {0}; + GtkTreeIter _tmp4_ = {0}; + GtkTreeIter _tmp5_; + const gchar* _tmp6_; + const gchar* _tmp7_; + g_return_if_fail (self != NULL); + g_return_if_fail (path != NULL); + _tmp0_ = self->priv->tvMonitoredDirs; + _tmp1_ = gtk_tree_view_get_model (_tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GTK_TYPE_LIST_STORE) ? ((GtkListStore*) _tmp2_) : NULL); + listmodel = _tmp3_; + gtk_list_store_append (listmodel, &_tmp4_); + iter = _tmp4_; + _tmp5_ = iter; + _tmp6_ = path; + gtk_list_store_set (listmodel, &_tmp5_, 0, _tmp6_, -1); + _tmp7_ = path; + dayfolder_user_data_addMonitoredDirectory (_tmp7_); + main_loadMonitoredDirsView (self); + _g_object_unref0 (listmodel); +} + + +/** * This method is connected to the signal in the code when the settings window * was created. */ static void main_fileExtRuleSelected (Main* self) { gchar* _tmp0_ = NULL; gchar* fileExt; - GtkBuilder* _tmp1_; - GObject* _tmp2_ = NULL; - GtkEntry* _tmp3_; - GtkEntry* txtFileExt; - GtkBuilder* _tmp4_; - GObject* _tmp5_ = NULL; - GtkEntry* _tmp6_; - GtkEntry* txtDestDir; - gchar* _tmp7_ = NULL; - gchar* _tmp8_; + GtkEntry* _tmp1_; + GtkEntry* _tmp2_; + const gchar* _tmp3_; + gchar* _tmp4_ = NULL; + gchar* _tmp5_; g_return_if_fail (self != NULL); _tmp0_ = main_getSelectedFileExt (self); fileExt = _tmp0_; - _tmp1_ = self->priv->dfSettingsBuilder; - _tmp2_ = gtk_builder_get_object (_tmp1_, "txtFileExt"); - _tmp3_ = _g_object_ref0 (GTK_IS_ENTRY (_tmp2_) ? ((GtkEntry*) _tmp2_) : NULL); - txtFileExt = _tmp3_; - _tmp4_ = self->priv->dfSettingsBuilder; - _tmp5_ = gtk_builder_get_object (_tmp4_, "txtDestDir"); - _tmp6_ = _g_object_ref0 (GTK_IS_ENTRY (_tmp5_) ? ((GtkEntry*) _tmp5_) : NULL); - txtDestDir = _tmp6_; - gtk_entry_set_text (txtFileExt, fileExt); - _tmp7_ = dayfolder_user_data_getFileExtRuleDest (fileExt); - _tmp8_ = _tmp7_; - gtk_entry_set_text (txtDestDir, _tmp8_); - _g_free0 (_tmp8_); - _g_object_unref0 (txtDestDir); - _g_object_unref0 (txtFileExt); + _tmp1_ = self->priv->txtFileNameContains; + gtk_entry_set_text (_tmp1_, fileExt); + _tmp2_ = self->priv->txtFileRuleDest; + _tmp3_ = self->priv->currentMonitoredDir; + _tmp4_ = dayfolder_user_data_getFileRuleDest (_tmp3_, fileExt); + _tmp5_ = _tmp4_; + gtk_entry_set_text (_tmp2_, _tmp5_); + _g_free0 (_tmp5_); _g_free0 (fileExt); } @@ -1093,80 +1645,531 @@ gchar* result = NULL; gchar* _tmp0_; gchar* fileExt; - GtkBuilder* _tmp1_; - GObject* _tmp2_ = NULL; + GtkTreeView* _tmp1_; + GtkTreeView* _tmp2_; + GtkTreeView* view; GtkTreeView* _tmp3_; + gint _tmp4_ = 0; + gint index; + gint _tmp5_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = g_strdup (""); + fileExt = _tmp0_; + _tmp1_ = self->priv->tvFileRules; + _tmp2_ = _g_object_ref0 (_tmp1_); + view = _tmp2_; + _tmp3_ = view; + _tmp4_ = main_getSelectedFromView (self, _tmp3_); + index = _tmp4_; + _tmp5_ = index; + if (_tmp5_ >= 0) { + GList* _tmp6_; + gint _tmp7_; + gconstpointer _tmp8_ = NULL; + gchar* _tmp9_; + _tmp6_ = self->priv->fileExtList; + _tmp7_ = index; + _tmp8_ = g_list_nth_data (_tmp6_, (guint) _tmp7_); + _tmp9_ = g_strdup ((const gchar*) _tmp8_); + _g_free0 (fileExt); + fileExt = _tmp9_; + } + result = fileExt; + _g_object_unref0 (view); + return result; +} + + +/** + * Called when a monitored directory is selected. + */ +static void main_monitoredDirSelected (Main* self) { + gchar* _tmp0_ = NULL; + gchar* monDirPath; + const gchar* _tmp1_; + g_return_if_fail (self != NULL); + main_enableControls (self); + _tmp0_ = main_getSelectedMonitoredDir (self); + monDirPath = _tmp0_; + _tmp1_ = monDirPath; + if (g_strcmp0 (_tmp1_, "") != 0) { + const gchar* _tmp2_; + gchar* _tmp3_; + _tmp2_ = monDirPath; + _tmp3_ = g_strdup (_tmp2_); + _g_free0 (self->priv->currentMonitoredDir); + self->priv->currentMonitoredDir = _tmp3_; + main_loadCurrentMonitoredDir (self); + } + _g_free0 (monDirPath); +} + + +/** + * Return currently selected monitored directory path as string. + */ +static gchar* main_getSelectedMonitoredDir (Main* self) { + gchar* result = NULL; + gchar* _tmp0_; + gchar* dirPath; + GtkTreeView* _tmp1_; + GtkTreeView* _tmp2_; GtkTreeView* view; - gint index = 0; - GtkTreeView* _tmp4_; - GtkTreeSelection* _tmp5_ = NULL; - GtkTreeSelection* _tmp6_; + GtkTreeView* _tmp3_; + gint _tmp4_ = 0; + gint index; + gint _tmp5_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = g_strdup (""); + dirPath = _tmp0_; + _tmp1_ = self->priv->tvMonitoredDirs; + _tmp2_ = _g_object_ref0 (_tmp1_); + view = _tmp2_; + _tmp3_ = view; + _tmp4_ = main_getSelectedFromView (self, _tmp3_); + index = _tmp4_; + _tmp5_ = index; + if (_tmp5_ >= 0) { + GList* _tmp6_; + gint _tmp7_; + gconstpointer _tmp8_ = NULL; + gchar* _tmp9_; + _tmp6_ = self->priv->monitoredDirsList; + _tmp7_ = index; + _tmp8_ = g_list_nth_data (_tmp6_, (guint) _tmp7_); + _tmp9_ = g_strdup ((const gchar*) _tmp8_); + _g_free0 (dirPath); + dirPath = _tmp9_; + } + result = dirPath; + _g_object_unref0 (view); + return result; +} + + +/** + * + */ +static void main_loadCurrentMonitoredDir (Main* self) { + const gchar* _tmp0_; + gchar* _tmp1_; + gchar* _tmp2_; + GtkLabel* _tmp3_; + const gchar* _tmp4_; + gchar* _tmp5_ = NULL; + gchar* _tmp6_; + GtkLabel* _tmp7_; + const gchar* _tmp8_; + gchar* _tmp9_ = NULL; + gchar* _tmp10_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->currentMonitoredDir; + _tmp1_ = g_strconcat ("Loading Monitored Directory: ", _tmp0_, NULL); + _tmp2_ = _tmp1_; + zystem_zystem_debug (_tmp2_); + _g_free0 (_tmp2_); + main_loadDfTypeOption (self); + main_setSwMoveSubfolders (self); + main_setSwUseDayFolder (self); + _tmp3_ = self->priv->lblSrcFolderLocationDisplay; + _tmp4_ = self->priv->currentMonitoredDir; + _tmp5_ = dayfolder_user_data_getSourcePath (_tmp4_); + _tmp6_ = _tmp5_; + gtk_label_set_label (_tmp3_, _tmp6_); + _g_free0 (_tmp6_); + _tmp7_ = self->priv->lblDfLocationDisplay; + _tmp8_ = self->priv->currentMonitoredDir; + _tmp9_ = dayfolder_user_data_getDfRootPath (_tmp8_); + _tmp10_ = _tmp9_; + gtk_label_set_label (_tmp7_, _tmp10_); + _g_free0 (_tmp10_); + main_loadFileExtRulesTreeView (self); +} + + +static void main_setSwUseDayFolder (Main* self) { + const gchar* _tmp0_; + gboolean _tmp1_ = FALSE; + gboolean useDayFolder; + GtkSwitch* _tmp2_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->currentMonitoredDir; + _tmp1_ = dayfolder_user_data_getUseDayFolder (_tmp0_); + useDayFolder = _tmp1_; + _tmp2_ = self->priv->swUseDayFolder; + gtk_switch_set_active (_tmp2_, useDayFolder); + main_enableUseDayFolderControls (self, useDayFolder); +} + + +static void main_setSwMoveSubfolders (Main* self) { + GtkSwitch* _tmp0_; + const gchar* _tmp1_; + gboolean _tmp2_ = FALSE; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->swMoveSubfolders; + _tmp1_ = self->priv->currentMonitoredDir; + _tmp2_ = dayfolder_user_data_getMoveDirs (_tmp1_); + gtk_switch_set_active (_tmp0_, _tmp2_); +} + + +/** + * Set the Use DayFolder option for the currentMonitoredDir and set appropriate widgets disabled. + */ +static gchar* bool_to_string (gboolean self) { + gchar* result = NULL; + if (self) { + gchar* _tmp0_; + _tmp0_ = g_strdup ("true"); + result = _tmp0_; + return result; + } else { + gchar* _tmp1_; + _tmp1_ = g_strdup ("false"); + result = _tmp1_; + return result; + } +} + + +static void main_swUseDayFolderClicked (Main* self) { + GtkSwitch* _tmp0_; + gboolean _tmp1_; + gboolean _tmp2_; + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + gchar* _tmp5_; + gchar* _tmp6_; + const gchar* _tmp7_; + GtkSwitch* _tmp8_; + gboolean _tmp9_; + gboolean _tmp10_; + GtkSwitch* _tmp11_; + gboolean _tmp12_; + gboolean _tmp13_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->swUseDayFolder; + _tmp1_ = gtk_switch_get_active (_tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = bool_to_string (_tmp2_); + _tmp4_ = _tmp3_; + _tmp5_ = g_strconcat ("swUseDayFolder: ", _tmp4_, NULL); + _tmp6_ = _tmp5_; + zystem_zystem_debug (_tmp6_); + _g_free0 (_tmp6_); + _g_free0 (_tmp4_); + _tmp7_ = self->priv->currentMonitoredDir; + _tmp8_ = self->priv->swUseDayFolder; + _tmp9_ = gtk_switch_get_active (_tmp8_); + _tmp10_ = _tmp9_; + dayfolder_user_data_setUseDayFolder (_tmp7_, _tmp10_); + _tmp11_ = self->priv->swUseDayFolder; + _tmp12_ = gtk_switch_get_active (_tmp11_); + _tmp13_ = _tmp12_; + main_enableUseDayFolderControls (self, _tmp13_); +} + + +/** + * Set the MoveDirs option to the + */ +static void main_swMoveSubfoldersClicked (Main* self) { + GtkSwitch* _tmp0_; + gboolean _tmp1_; + gboolean _tmp2_; + gchar* _tmp3_ = NULL; + gchar* _tmp4_; + gchar* _tmp5_; + gchar* _tmp6_; + const gchar* _tmp7_; + GtkSwitch* _tmp8_; + gboolean _tmp9_; + gboolean _tmp10_; + g_return_if_fail (self != NULL); + _tmp0_ = self->priv->swMoveSubfolders; + _tmp1_ = gtk_switch_get_active (_tmp0_); + _tmp2_ = _tmp1_; + _tmp3_ = bool_to_string (_tmp2_); + _tmp4_ = _tmp3_; + _tmp5_ = g_strconcat ("swMoveSubfolders: ", _tmp4_, NULL); + _tmp6_ = _tmp5_; + zystem_zystem_debug (_tmp6_); + _g_free0 (_tmp6_); + _g_free0 (_tmp4_); + _tmp7_ = self->priv->currentMonitoredDir; + _tmp8_ = self->priv->swMoveSubfolders; + _tmp9_ = gtk_switch_get_active (_tmp8_); + _tmp10_ = _tmp9_; + dayfolder_user_data_setMoveDirs (_tmp7_, _tmp10_); +} + + +/** + * Return index value of currently selected item in passed in TreeView. + */ +static gint main_getSelectedFromView (Main* self, GtkTreeView* view) { + gint result = 0; + gint index; + GtkTreeView* _tmp0_; + GtkTreeSelection* _tmp1_ = NULL; + GtkTreeSelection* _tmp2_; GtkTreeSelection* selection; - GtkTreeSelection* _tmp7_; + GtkTreeSelection* _tmp3_; GtkTreeModel* model = NULL; GtkTreeIter iter = {0}; - GtkTreeSelection* _tmp8_; - GtkTreeModel* _tmp9_ = NULL; - GtkTreeIter _tmp10_ = {0}; - gboolean _tmp11_ = FALSE; - GtkTreeModel* _tmp12_; - gint _tmp19_; - g_return_val_if_fail (self != NULL, NULL); - _tmp0_ = g_strdup (""); - fileExt = _tmp0_; - _tmp1_ = self->priv->dfSettingsBuilder; - _tmp2_ = gtk_builder_get_object (_tmp1_, "tvFileExtRules"); - _tmp3_ = _g_object_ref0 (GTK_IS_TREE_VIEW (_tmp2_) ? ((GtkTreeView*) _tmp2_) : NULL); - view = _tmp3_; - _tmp4_ = view; - _tmp5_ = gtk_tree_view_get_selection (_tmp4_); - _tmp6_ = _g_object_ref0 (GTK_IS_TREE_SELECTION (_tmp5_) ? ((GtkTreeSelection*) _tmp5_) : NULL); - selection = _tmp6_; - _tmp7_ = selection; - gtk_tree_selection_set_mode (_tmp7_, GTK_SELECTION_SINGLE); - _tmp8_ = selection; - _tmp11_ = gtk_tree_selection_get_selected (_tmp8_, &_tmp9_, &_tmp10_); + GtkTreeSelection* _tmp4_; + GtkTreeModel* _tmp5_ = NULL; + GtkTreeIter _tmp6_ = {0}; + gboolean _tmp7_ = FALSE; + GtkTreeModel* _tmp8_; + g_return_val_if_fail (self != NULL, 0); + g_return_val_if_fail (view != NULL, 0); + index = -1; + _tmp0_ = view; + _tmp1_ = gtk_tree_view_get_selection (_tmp0_); + _tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GTK_TYPE_TREE_SELECTION) ? ((GtkTreeSelection*) _tmp1_) : NULL); + selection = _tmp2_; + _tmp3_ = selection; + gtk_tree_selection_set_mode (_tmp3_, GTK_SELECTION_SINGLE); + _tmp4_ = selection; + _tmp7_ = gtk_tree_selection_get_selected (_tmp4_, &_tmp5_, &_tmp6_); _g_object_unref0 (model); - _tmp12_ = _g_object_ref0 (_tmp9_); - model = _tmp12_; - iter = _tmp10_; - if (!_tmp11_) { + _tmp8_ = _g_object_ref0 (_tmp5_); + model = _tmp8_; + iter = _tmp6_; + if (!_tmp7_) { index = -1; } else { - GtkTreeModel* _tmp13_; - GtkTreeIter _tmp14_; - GtkTreePath* _tmp15_ = NULL; + GtkTreeModel* _tmp9_; + GtkTreeIter _tmp10_; + GtkTreePath* _tmp11_ = NULL; GtkTreePath* path; - GtkTreePath* _tmp16_; - const gchar* _tmp17_ = NULL; - gint _tmp18_ = 0; - _tmp13_ = model; - _tmp14_ = iter; - _tmp15_ = gtk_tree_model_get_path (_tmp13_, &_tmp14_); - path = _tmp15_; - _tmp16_ = path; - _tmp17_ = gtk_tree_path_to_string (_tmp16_); - _tmp18_ = atoi (_tmp17_); - index = _tmp18_; + GtkTreePath* _tmp12_; + const gchar* _tmp13_ = NULL; + gint _tmp14_ = 0; + _tmp9_ = model; + _tmp10_ = iter; + _tmp11_ = gtk_tree_model_get_path (_tmp9_, &_tmp10_); + path = _tmp11_; + _tmp12_ = path; + _tmp13_ = gtk_tree_path_to_string (_tmp12_); + _tmp14_ = atoi (_tmp13_); + index = _tmp14_; _gtk_tree_path_free0 (path); } - _tmp19_ = index; - if (_tmp19_ >= 0) { - GList* _tmp20_; - gint _tmp21_; - gconstpointer _tmp22_ = NULL; - gchar* _tmp23_; - _tmp20_ = self->priv->fileExtList; - _tmp21_ = index; - _tmp22_ = g_list_nth_data (_tmp20_, (guint) _tmp21_); - _tmp23_ = g_strdup ((const gchar*) _tmp22_); - _g_free0 (fileExt); - fileExt = _tmp23_; - } - result = fileExt; + result = index; _g_object_unref0 (model); _g_object_unref0 (selection); - _g_object_unref0 (view); + return result; +} + + +/** + * Disable GUI controls. + */ +static void main_disableControls (Main* self) { + g_return_if_fail (self != NULL); + main_setControlsEnabled (self, FALSE); +} + + +/** + * Enable GUI controls. + */ +static void main_enableControls (Main* self) { + g_return_if_fail (self != NULL); + main_setControlsEnabled (self, TRUE); +} + + +/** + * Sets GUI widgets enabled value. + */ +static void main_setControlsEnabled (Main* self, gboolean enabled) { + GeeArrayList* _tmp0_ = NULL; + GeeArrayList* widgetList; + g_return_if_fail (self != NULL); + _tmp0_ = main_getSettingsWidgets (self); + widgetList = _tmp0_; + { + GeeArrayList* _tmp1_; + GeeArrayList* _tmp2_; + GeeArrayList* _w_list; + GeeArrayList* _tmp3_; + gint _tmp4_; + gint _tmp5_; + gint _w_size; + gint _w_index; + _tmp1_ = widgetList; + _tmp2_ = _g_object_ref0 (_tmp1_); + _w_list = _tmp2_; + _tmp3_ = _w_list; + _tmp4_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp3_); + _tmp5_ = _tmp4_; + _w_size = _tmp5_; + _w_index = -1; + while (TRUE) { + gint _tmp6_; + gint _tmp7_; + gint _tmp8_; + GeeArrayList* _tmp9_; + gint _tmp10_; + gpointer _tmp11_ = NULL; + GtkWidget* w; + GtkWidget* _tmp12_; + gboolean _tmp13_; + _tmp6_ = _w_index; + _w_index = _tmp6_ + 1; + _tmp7_ = _w_index; + _tmp8_ = _w_size; + if (!(_tmp7_ < _tmp8_)) { + break; + } + _tmp9_ = _w_list; + _tmp10_ = _w_index; + _tmp11_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _tmp10_); + w = (GtkWidget*) _tmp11_; + _tmp12_ = w; + _tmp13_ = enabled; + gtk_widget_set_sensitive (_tmp12_, _tmp13_); + _g_object_unref0 (w); + } + _g_object_unref0 (_w_list); + } + _g_object_unref0 (widgetList); +} + + +static void main_enableUseDayFolderControls (Main* self, gboolean enabled) { + GeeArrayList* _tmp0_ = NULL; + GeeArrayList* widgetList; + g_return_if_fail (self != NULL); + _tmp0_ = main_getUseDayFolderWidgets (self); + widgetList = _tmp0_; + { + GeeArrayList* _tmp1_; + GeeArrayList* _tmp2_; + GeeArrayList* _w_list; + GeeArrayList* _tmp3_; + gint _tmp4_; + gint _tmp5_; + gint _w_size; + gint _w_index; + _tmp1_ = widgetList; + _tmp2_ = _g_object_ref0 (_tmp1_); + _w_list = _tmp2_; + _tmp3_ = _w_list; + _tmp4_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp3_); + _tmp5_ = _tmp4_; + _w_size = _tmp5_; + _w_index = -1; + while (TRUE) { + gint _tmp6_; + gint _tmp7_; + gint _tmp8_; + GeeArrayList* _tmp9_; + gint _tmp10_; + gpointer _tmp11_ = NULL; + GtkWidget* w; + GtkWidget* _tmp12_; + gboolean _tmp13_; + _tmp6_ = _w_index; + _w_index = _tmp6_ + 1; + _tmp7_ = _w_index; + _tmp8_ = _w_size; + if (!(_tmp7_ < _tmp8_)) { + break; + } + _tmp9_ = _w_list; + _tmp10_ = _w_index; + _tmp11_ = gee_abstract_list_get ((GeeAbstractList*) _tmp9_, _tmp10_); + w = (GtkWidget*) _tmp11_; + _tmp12_ = w; + _tmp13_ = enabled; + gtk_widget_set_sensitive (_tmp12_, _tmp13_); + _g_object_unref0 (w); + } + _g_object_unref0 (_w_list); + } + _g_object_unref0 (widgetList); +} + + +static GeeArrayList* main_getUseDayFolderWidgets (Main* self) { + GeeArrayList* result = NULL; + GeeArrayList* _tmp0_; + GeeArrayList* widgetList; + GtkButton* _tmp1_; + GtkSwitch* _tmp2_; + GtkRadioButton* _tmp3_; + GtkRadioButton* _tmp4_; + GtkRadioButton* _tmp5_; + GtkLabel* _tmp6_; + GtkLabel* _tmp7_; + GtkLabel* _tmp8_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = gee_array_list_new (GTK_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + widgetList = _tmp0_; + _tmp1_ = self->priv->btnChangeDfLocation; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp1_); + _tmp2_ = self->priv->swMoveSubfolders; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp2_); + _tmp3_ = self->priv->rdoDaily; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp3_); + _tmp4_ = self->priv->rdoWeekly; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp4_); + _tmp5_ = self->priv->rdoMonthly; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp5_); + _tmp6_ = self->priv->lblDfLocationDisplay; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp6_); + _tmp7_ = self->priv->lblSubfoldersOption; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp7_); + _tmp8_ = self->priv->lblDfTypeHeading; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp8_); + result = widgetList; + return result; +} + + +/** + * Return list of widgets to disable or enable. + */ +static GeeArrayList* main_getSettingsWidgets (Main* self) { + GeeArrayList* result = NULL; + GeeArrayList* _tmp0_; + GeeArrayList* widgetList; + GtkSwitch* _tmp1_; + GtkButton* _tmp2_; + GtkSwitch* _tmp3_; + GtkRadioButton* _tmp4_; + GtkRadioButton* _tmp5_; + GtkRadioButton* _tmp6_; + GtkButton* _tmp7_; + GtkEntry* _tmp8_; + GtkEntry* _tmp9_; + g_return_val_if_fail (self != NULL, NULL); + _tmp0_ = gee_array_list_new (GTK_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); + widgetList = _tmp0_; + _tmp1_ = self->priv->swUseDayFolder; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp1_); + _tmp2_ = self->priv->btnChangeDfLocation; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp2_); + _tmp3_ = self->priv->swMoveSubfolders; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp3_); + _tmp4_ = self->priv->rdoDaily; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp4_); + _tmp5_ = self->priv->rdoWeekly; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp5_); + _tmp6_ = self->priv->rdoMonthly; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp6_); + _tmp7_ = self->priv->btnChangeFileRuleDest; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp7_); + _tmp8_ = self->priv->txtFileNameContains; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp8_); + _tmp9_ = self->priv->txtFileRuleDest; + gee_abstract_collection_add ((GeeAbstractCollection*) widgetList, (GtkWidget*) _tmp9_); + result = widgetList; return result; } @@ -1207,10 +2210,26 @@ static void main_finalize (GObject* obj) { Main * self; - self = MAIN (obj); - _g_object_unref0 (self->priv->dayFolder); - _g_object_unref0 (self->priv->dfSettingsBuilder); + self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_MAIN, Main); + _g_object_unref0 (self->priv->window); __g_list_free__g_free0_0 (self->priv->fileExtList); + __g_list_free__g_free0_0 (self->priv->monitoredDirsList); + _g_free0 (self->priv->currentMonitoredDir); + _g_object_unref0 (self->priv->tvFileRules); + _g_object_unref0 (self->priv->tvMonitoredDirs); + _g_object_unref0 (self->priv->rdoDaily); + _g_object_unref0 (self->priv->rdoWeekly); + _g_object_unref0 (self->priv->rdoMonthly); + _g_object_unref0 (self->priv->txtFileNameContains); + _g_object_unref0 (self->priv->txtFileRuleDest); + _g_object_unref0 (self->priv->lblDfLocationDisplay); + _g_object_unref0 (self->priv->swUseDayFolder); + _g_object_unref0 (self->priv->swMoveSubfolders); + _g_object_unref0 (self->priv->btnChangeDfLocation); + _g_object_unref0 (self->priv->btnChangeFileRuleDest); + _g_object_unref0 (self->priv->lblSrcFolderLocationDisplay); + _g_object_unref0 (self->priv->lblSubfoldersOption); + _g_object_unref0 (self->priv->lblDfTypeHeading); G_OBJECT_CLASS (main_parent_class)->finalize (obj); } diff -Nru dayfolder-1.4.1/src/dayfolder.ui dayfolder-2.0.0/src/dayfolder.ui --- dayfolder-1.4.1/src/dayfolder.ui 2012-03-10 21:14:14.000000000 +0000 +++ dayfolder-2.0.0/src/dayfolder.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - - - - - True - False - window - 500 - 400 - - - - - - diff -Nru dayfolder-1.4.1/src/dayfolder.vala dayfolder-2.0.0/src/dayfolder.vala --- dayfolder-1.4.1/src/dayfolder.vala 2012-06-09 14:36:45.000000000 +0000 +++ dayfolder-2.0.0/src/dayfolder.vala 2013-05-11 22:13:04.000000000 +0000 @@ -1,9 +1,10 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * main.c - * Copyright (C) Zach Burnham 2012 - * -DayFolder is free software: you can redistribute it and/or modify it + * DayFolder + * + * Copyright (C) 2013 Zach Burnham + * + * DayFolder 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 3 of the License, or * (at your option) any later version. @@ -28,31 +29,47 @@ public class Main : Object { - /* - * Toggle comments of these lines when you are done testing and building a tarball - * or installing. - */ /* Icons */ - //const string DF_INDICATOR_ICON = "/home/zach/Programming/DayFolder/dayfolder_svn/icons/dayfolder-panel.png"; // Development - const string DF_INDICATOR_ICON = "dayfolder-panel"; // Installed - /* Settings UI file */ - //const string UI_DF_SETTINGS = "src/dfSettings.ui"; // Development - const string UI_DF_SETTINGS = Config.PACKAGE_DATA_DIR + "/dayfolder/ui/dfSettings.ui"; // Installed + const string DF_INDICATOR_ICON = "dayfolder-panel"; // Installed - private DayFolder dayFolder; - private Builder dfSettingsBuilder; + // SET THIS TO TRUE BEFORE BUILDING TARBALL + private const bool isInstalled = true; + private Gtk.Window window; private GLib.List fileExtList; + private GLib.List monitoredDirsList; + private string currentMonitoredDir; + private Gtk.TreeView tvFileRules; + private Gtk.TreeView tvMonitoredDirs; + private Gtk.RadioButton rdoDaily; + private Gtk.RadioButton rdoWeekly; + private Gtk.RadioButton rdoMonthly; + private Gtk.Entry txtFileNameContains; + private Gtk.Entry txtFileRuleDest; + private Gtk.Label lblDfLocationDisplay; + private Gtk.Switch swUseDayFolder; + private Gtk.Switch swMoveSubfolders; + private Gtk.Button btnChangeDfLocation; + private Gtk.Button btnChangeFileRuleDest; + private Gtk.Label lblSrcFolderLocationDisplay; + private Gtk.Label lblSubfoldersOption; + private Gtk.Label lblDfTypeHeading; /** * Constructor for Main. */ public Main() { - // Initialize DayFolder - dayFolder = new DayFolder(); + Zystem.debugOn = !isInstalled; + + Zystem.debug("Package data dir: " + Config.PACKAGE_DATA_DIR); + + // Create the UserData + UserData.initializeUserData(); fileExtList = new GLib.List(); + monitoredDirsList = new GLib.List(); + currentMonitoredDir = ""; // Create AppIndicator var indicator = new Indicator("DayFolder", DF_INDICATOR_ICON, @@ -60,26 +77,26 @@ indicator.set_status(IndicatorStatus.ACTIVE); // Create the Menu object - Menu menu = new Menu(); + Gtk.Menu menu = new Gtk.Menu(); // Create the Clean Desktop menu item and add it - MenuItem item = new MenuItem.with_label("Clean Source Folder"); - item.activate.connect(() => { runDayFolder(); }); + Gtk.MenuItem item = new Gtk.MenuItem.with_label("Clean Up Folders"); + item.activate.connect(() => { UserData.cleanupAllMonDirs(); }); menu.append(item); // Create the settings menu item - item = new MenuItem.with_label("Settings..."); + item = new Gtk.MenuItem.with_label("Settings..."); item.activate.connect(() => { settingsClicked(); }); menu.append(item); // Create the Go To DayFolder menu item - item = new MenuItem.with_label("View DayFolder"); + item = new Gtk.MenuItem.with_label("View DayFolder"); item.activate.connect(() => { openTodaysFolderClicked(); }); menu.append(item); // Create the Quit menu item menu.append(new Gtk.SeparatorMenuItem()); - item = new MenuItem.with_label("Quit"); + item = new Gtk.MenuItem.with_label("Quit"); item.activate.connect(() => { exitDayFolder(); }); menu.append(item); @@ -87,78 +104,238 @@ indicator.set_menu(menu); - // Create Builder object - //dfSettingsBuilder = new Builder(); - Gtk.main(); } /** - * Run the DayFolder. - */ - private void runDayFolder() { - dayFolder.run(); - } - - /** * Opens the DayFolder root directory for user. */ private void openTodaysFolderClicked() { try { - Gtk.show_uri(null, "file://" + UserData.getDfRootPath(), Gdk.CURRENT_TIME); + Gtk.show_uri(null, "file://" + UserData.getDefaultDfRootPath(), Gdk.CURRENT_TIME); } catch(Error e) { stderr.printf ("Error opening folder: %s\n", e.message); } } /** - * When the Settings menu item is clicked. + * Create and show the settings window. */ private void settingsClicked() { - try { - dfSettingsBuilder = new Builder(); - dfSettingsBuilder.add_from_file(UI_DF_SETTINGS); - dfSettingsBuilder.connect_signals(this); - - // Set dfType radio button - loadDfTypeOption(); - - // Set Source Location label text - var lblSourcePath = dfSettingsBuilder.get_object("lblSourcePath") as Label; - lblSourcePath.label = UserData.getSourcePath(); - - // Set DayFolder root path label text - var lblDfRootPath = dfSettingsBuilder.get_object("lblDfRootPath") as Label; - lblDfRootPath.label = UserData.getDfRootPath(); - - // Set listStore - var view = dfSettingsBuilder.get_object("tvFileExtRules") as TreeView; - var listmodel = new ListStore(2, typeof (string), typeof (string)); - view.set_model(listmodel); - view.insert_column_with_attributes (-1, "File Extension", new CellRendererText(), "text", 0); - view.insert_column_with_attributes (-1, "Destination", new CellRendererText(), "text", 1); - loadFileExtRulesTreeView(); - - // Connect signal for when user selects a row in the treeview - view.cursor_changed.connect(() => { - fileExtRuleSelected(); - }); - - // Show window - var window = dfSettingsBuilder.get_object("window") as Gtk.Window; - window.show_all(); - } catch (Error e) { - stderr.printf ("Could not load dfSettingsWindow UI: %s\n", e.message); - } + this.window = new Gtk.Window(Gtk.WindowType.TOPLEVEL); + window.set_size_request(600, 500); + window.resizable = false; + window.title = "DayFolder Settings"; + window.destroy.connect(() => { on_destroy(window); }); + + // Let's create the left side + Gtk.Box leftSideBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); + + this.tvMonitoredDirs = new Gtk.TreeView(); + // Setup treeview + this.setupMonitoredDirsListView(); + this.tvMonitoredDirs.insert_column_with_attributes(-1, "Monitored Folders", new CellRendererText(), "text", 0); + + leftSideBox.pack_start(tvMonitoredDirs, false, true, 0); + + Gtk.Button btnAddMonitoredDir = new Gtk.Button.with_label("Add"); + btnAddMonitoredDir.clicked.connect(() => { btnAddMonitoredDirClicked(btnAddMonitoredDir); }); + + Gtk.Button btnRemoveMonitoredDir = new Gtk.Button.with_label("Remove"); + btnRemoveMonitoredDir.clicked.connect(() => { btnRemoveMonitoredDirClicked(btnRemoveMonitoredDir); }); + + Gtk.Box leftSideButtonBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + leftSideButtonBox.pack_start(btnAddMonitoredDir, false, true, 0); + leftSideButtonBox.pack_start(btnRemoveMonitoredDir, false, true, 0); + + leftSideBox.pack_start(leftSideButtonBox, false, true, 0); + leftSideBox.width_request = 160; + + + // Main box + Gtk.Box mainBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); + + Gtk.Label lblSrcFolderLocationHeading = this.createLabelLeftAlign("Source Folder Location"); + lblSrcFolderLocationHeading.use_markup = true; + mainBox.pack_start(lblSrcFolderLocationHeading, false, false, 4); + + this.lblSrcFolderLocationDisplay = this.createLabelLeftAlign(null); + lblSrcFolderLocationDisplay.label = ""; + mainBox.pack_start(lblSrcFolderLocationDisplay, false, true, 4); + + Gtk.Box dfLocationHeadingBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + Gtk.Label lblDfLocationHeading = this.createLabelLeftAlign("DayFolder Location"); + lblDfLocationHeading.use_markup = true; + dfLocationHeadingBox.pack_start(lblDfLocationHeading, true, true, 4); + + this.swUseDayFolder = new Gtk.Switch(); + this.swUseDayFolder.notify["active"].connect(this.swUseDayFolderClicked); + dfLocationHeadingBox.pack_start(swUseDayFolder, false, true, 4); + + mainBox.pack_start(dfLocationHeadingBox, false, true, 0); + + Gtk.Box dfLocationDisplayBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + this.lblDfLocationDisplay = this.createLabelLeftAlign(null); + lblDfLocationDisplay.label = ""; + dfLocationDisplayBox.pack_start(lblDfLocationDisplay, true, true, 4); + + this.btnChangeDfLocation = new Gtk.Button.from_stock(Gtk.Stock.OPEN); + btnChangeDfLocation.clicked.connect(() => { this.btnDfRootPathClicked(this.btnChangeDfLocation); }); + dfLocationDisplayBox.pack_start(btnChangeDfLocation, false, true, 4); + + mainBox.pack_start(dfLocationDisplayBox, false, true, 4); + + Gtk.Box subfoldersOptionBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + this.lblSubfoldersOption = this.createLabelLeftAlign("Also move subfolders to DayFolder"); + lblSubfoldersOption.xalign = 0; + subfoldersOptionBox.pack_start(lblSubfoldersOption, true, true, 4); + + this.swMoveSubfolders = new Gtk.Switch(); + // connect switch + this.swMoveSubfolders.notify["active"].connect(this.swMoveSubfoldersClicked); + subfoldersOptionBox.pack_start(swMoveSubfolders, false, false, 4); + + mainBox.pack_start(subfoldersOptionBox, false, true, 4); + + this.lblDfTypeHeading = this.createLabelLeftAlign("DayFolder Type"); + lblDfTypeHeading.use_markup = true; + mainBox.pack_start(lblDfTypeHeading, false, true, 4); + + // Box for DayFolder type options + Gtk.Box dfTypeBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + this.rdoDaily = new Gtk.RadioButton.with_label_from_widget(new RadioButton(null), "Daily"); + this.rdoWeekly = new Gtk.RadioButton.with_label_from_widget(rdoDaily, "Weekly"); + this.rdoMonthly = new Gtk.RadioButton.with_label_from_widget(rdoWeekly, "Monthly"); + + this.rdoDaily.toggled.connect(() => { this.rdoDayClicked(this.rdoDaily); }); + this.rdoWeekly.toggled.connect(() => { this.rdoWeekClicked(this.rdoWeekly); }); + this.rdoMonthly.toggled.connect(() => { this.rdoMonthClicked(this.rdoMonthly); }); + + dfTypeBox.pack_start(rdoDaily, false, true, 2); + dfTypeBox.pack_start(rdoWeekly, false, true, 2); + dfTypeBox.pack_start(rdoMonthly, false, true, 2); + + mainBox.pack_start(dfTypeBox, false, true, 2); + + // Spacer + Gtk.Label lblSpacer = new Gtk.Label(""); + lblSpacer.width_request = 20; + lblSpacer.height_request = 30; + + mainBox.pack_start(lblSpacer, false, true, 2); + + // Box for File Rules + Gtk.Box fileRulesBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 2); + + this.tvFileRules = new Gtk.TreeView(); + // Setup treeview + this.setupFileRulesListView(); + tvFileRules.insert_column_with_attributes(-1, "File Rules", new CellRendererText(), "text", 0); + + fileRulesBox.pack_start(tvFileRules, true, true, 2); + + // Box for file rule editing stuff + Gtk.Box fileRuleEditBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 2); + + Gtk.Label lblFileNameContains = this.createLabelLeftAlign("File name contains (such as a key word or file extention)"); + fileRuleEditBox.pack_start(lblFileNameContains, false, true, 2); + + this.txtFileNameContains = new Gtk.Entry(); + fileRuleEditBox.pack_start(txtFileNameContains, false, true, 2); + + Gtk.Label lblMoveFileTo = this.createLabelLeftAlign("Move file to..."); + fileRuleEditBox.pack_start(lblMoveFileTo, false, true, 2); + + // File Rule Destination box + Gtk.Box fileRuleDestBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + this.txtFileRuleDest = new Gtk.Entry(); + fileRuleDestBox.pack_start(txtFileRuleDest, true, true, 0); + + this.btnChangeFileRuleDest = new Gtk.Button.from_stock(Gtk.Stock.OPEN); + btnChangeFileRuleDest.clicked.connect(this.btnChangeFileRuleDestClicked); + fileRuleDestBox.pack_start(btnChangeFileRuleDest, false, true, 2); + + fileRuleEditBox.pack_start(fileRuleDestBox, false, true, 0); + + // Add and Remove File Rule buttons + Gtk.Box fileRuleButtonsBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + Gtk.Button btnRemoveFileRule = new Button.with_label("Remove"); + btnRemoveFileRule.clicked.connect(this.btnRemoveFileRuleClicked); + Gtk.Button btnSaveFileRule = new Button.with_label("Save"); + btnSaveFileRule.clicked.connect(this.btnSaveFileRuleClicked); + + fileRuleButtonsBox.pack_start(btnRemoveFileRule, false, true, 0); + fileRuleButtonsBox.pack_start(btnSaveFileRule, false, true, 0); + + fileRuleEditBox.pack_start(fileRuleButtonsBox, true, true, 0); + + + fileRulesBox.pack_start(fileRuleEditBox, false, true, 2); + + mainBox.pack_start(fileRulesBox, false, true, 2); + + // Pack containerBox and put that in the window + Gtk.Box containerBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); + + containerBox.pack_start(leftSideBox, false, true, 4); + containerBox.pack_start(mainBox, true, true, 4); + + window.add(containerBox); + + this.disableControls(); + + window.show_all(); + } + + /** + * Setup the monitored directories listview with ListStore and signals. + */ + private void setupMonitoredDirsListView() { + var listmodel = new ListStore(1, typeof (string)); + this.tvMonitoredDirs.model = listmodel; + + var treeSelection = this.tvMonitoredDirs.get_selection(); + treeSelection.set_mode(SelectionMode.SINGLE); + treeSelection.changed.connect(() => { + this.monitoredDirSelected(); + }); + + this.loadMonitoredDirsView(); + } + + /** + * + */ + private void setupFileRulesListView() { + var listmodel = new ListStore(1, typeof(string)); + this.tvFileRules.model = listmodel; + + var treeSelection = this.tvFileRules.get_selection(); + treeSelection.set_mode(SelectionMode.SINGLE); + treeSelection.changed.connect(() => { + this.fileExtRuleSelected(); + }); + } + + private Label createLabelLeftAlign(string? text) { + var label = new Gtk.Label(text); + label.xalign = 0; + return label; } /** * Load the user's File Extension Rules. */ private void loadFileExtRulesTreeView() { - var view = dfSettingsBuilder.get_object("tvFileExtRules") as TreeView; - - var listmodel = view.model as ListStore; + Zystem.debug("Loading FileExtRule TreeView..."); + + var listmodel = this.tvFileRules.model as ListStore; listmodel.clear(); fileExtList = new GLib.List(); @@ -166,31 +343,51 @@ TreeIter iter; // Get file extension rules settings and add them - ArrayList fileExtRules = UserData.getFileExtRules(); + ArrayList rules = UserData.getFileRules(currentMonitoredDir); - foreach (FileExtRule rule in fileExtRules) { + foreach (DfRule rule in rules) { listmodel.append(out iter); - listmodel.set(iter, 0, rule.fileExt, 1, rule.destinationDir); - fileExtList.append(rule.fileExt); + listmodel.set(iter, 0, rule.criteriaString); + fileExtList.append(rule.criteriaString); } } /** + * Load the Monitored Directories TreeView. + */ + private void loadMonitoredDirsView() { + var listmodel = this.tvMonitoredDirs.model as ListStore; + + listmodel.clear(); + monitoredDirsList = new GLib.List(); + + TreeIter iter; + + // Get directories and add them + ArrayList monitoredDirs = UserData.getMonitoredDirs(); + + foreach (MonitoredDirectory dir in monitoredDirs) { + listmodel.append(out iter); + listmodel.set(iter, 0, dir.dirPath); + monitoredDirsList.append(dir.dirPath); + } + + this.disableControls(); + } + + /** * */ private void loadDfTypeOption() { // Get dfType option - string dfType = UserData.getDfType(); + string dfType = UserData.getDfType(currentMonitoredDir); if (dfType == UserData.dfTypeDaily) { - var rdoDay = dfSettingsBuilder.get_object("rdoDay") as RadioButton; - rdoDay.activate(); + this.rdoDaily.activate(); } else if (dfType == UserData.dfTypeWeekly) { - var rdoWeek = dfSettingsBuilder.get_object("rdoWeek") as RadioButton; - rdoWeek.activate(); + this.rdoWeekly.activate(); } else if (dfType == UserData.dfTypeMonthly) { - var rdoMonth = dfSettingsBuilder.get_object("rdoMonth") as RadioButton; - rdoMonth.activate(); + this.rdoMonthly.activate(); } } @@ -202,46 +399,23 @@ } /** - * Reset the DayFolder root directory to the default value. - */ - [CCode (instance_pos = -1)] - public void btnResetDfRootClicked(Button button) { - UserData.resetDfRootPath(); - setLabelText("lblDfRootPath", UserData.getDefaultDfRootPath()); - } - - /** - * Reset the Source Location to the default value. - */ - [CCode (instance_pos = -1)] - public void btnResetSourceClicked(Button button) { - UserData.resetSourcePath(); - setLabelText("lblSourcePath", UserData.getDefaultSourcePath()); - } - - /** * */ - [CCode (instance_pos = -1)] - public void btnSaveFileExtRuleClicked(Button button) { - var txtFileExt = dfSettingsBuilder.get_object("txtFileExt") as Entry; - var txtDestDir = dfSettingsBuilder.get_object("txtDestDir") as Entry; - UserData.addFileExtRule(txtFileExt.text, txtDestDir.text); - txtFileExt.text = ""; - txtDestDir.text = ""; + public void btnSaveFileRuleClicked() { + UserData.addFileRule(currentMonitoredDir, this.txtFileNameContains.text, this.txtFileRuleDest.text); + this.txtFileNameContains.text = ""; + this.txtFileRuleDest.text = ""; loadFileExtRulesTreeView(); } /** * */ - [CCode (instance_pos = -1)] - public void btnFileExtDestDirClicked(Button button) { - - var window = dfSettingsBuilder.get_object("window") as Gtk.Window; - var txtDestDir = dfSettingsBuilder.get_object("txtDestDir") as Entry; + public void btnChangeFileRuleDestClicked() { + var window = this.window; + var txtDestDir = this.txtFileRuleDest; - var fileChooser = new FileChooserDialog("Open File", window, + var fileChooser = new FileChooserDialog("Choose File Rule Destination", window, FileChooserAction.SELECT_FOLDER, Stock.CANCEL, ResponseType.CANCEL, Stock.OPEN, ResponseType.ACCEPT); @@ -255,7 +429,6 @@ /** * Closing a dialog. */ - [CCode (instance_pos = -1)] public void on_destroy (Widget window){ // Nothing to do } @@ -263,10 +436,9 @@ /** * */ - [CCode (instance_pos = -1)] public void btnDfRootPathClicked(Button chooser) { - var window = dfSettingsBuilder.get_object("window") as Gtk.Window; + var window = this.window; var fileChooser = new FileChooserDialog("Open File", window, FileChooserAction.SELECT_FOLDER, @@ -274,8 +446,8 @@ Stock.OPEN, ResponseType.ACCEPT); if (fileChooser.run() == ResponseType.ACCEPT) { string path = fileChooser.get_filename(); - UserData.setDfRootPath(path); - setLabelText("lblDfRootPath", path); + UserData.setDfRootPath(currentMonitoredDir, path); + this.lblDfLocationDisplay.label = path; } fileChooser.destroy(); } @@ -283,87 +455,105 @@ /** * */ - [CCode (instance_pos = -1)] - public void btnSourcePathClicked(Button chooser) { - - var window = dfSettingsBuilder.get_object("window") as Gtk.Window; - - var fileChooser = new FileChooserDialog("Open File", window, - FileChooserAction.SELECT_FOLDER, - Stock.CANCEL, ResponseType.CANCEL, - Stock.OPEN, ResponseType.ACCEPT); - if (fileChooser.run() == ResponseType.ACCEPT) { - string path = fileChooser.get_filename(); - UserData.setSourcePath(path); - setLabelText("lblSourcePath", path); - } - fileChooser.destroy(); - } + public void btnRemoveFileRuleClicked() { + string fileCriteriaString = getSelectedFileExt(); - /** - * Set label text. - */ - private void setLabelText(string labelName, string path) { - var lbl = dfSettingsBuilder.get_object(labelName) as Label; - lbl.label = path; + UserData.removeFileRule(currentMonitoredDir, fileCriteriaString); + + this.txtFileNameContains.text = ""; + this.txtFileRuleDest.text = ""; + + // Reload the treeview + loadFileExtRulesTreeView(); } /** - * + * Remove the selected monitored directory. */ - [CCode (instance_pos = -1)] - public void btnRemoveFileExtRuleClicked(Button button) { - string fileExt = getSelectedFileExt(); + public void btnRemoveMonitoredDirClicked(Button button) { + Zystem.debug("Removing Monitored Dir..."); + string dirPath = getSelectedMonitoredDir(); - UserData.removeFileExtRule(fileExt); + UserData.removeMonitoredDir(dirPath); // Reload the treeview - loadFileExtRulesTreeView(); + loadMonitoredDirsView(); } /** * When choosing Daily DayFolder. */ - [CCode (instance_pos = -1)] public void rdoDayClicked(RadioButton button) { - if (button.get_active() && UserData.getDfType() != UserData.dfTypeDaily) { - UserData.setDfType(UserData.dfTypeDaily); + Zystem.debug("Day toggled"); + if (button.get_active() && UserData.getDfType(currentMonitoredDir) != UserData.dfTypeDaily) { + UserData.setDfType(currentMonitoredDir, UserData.dfTypeDaily); } } /** * When choosing Weekly DayFolder. */ - [CCode (instance_pos = -1)] public void rdoWeekClicked(RadioButton button) { - if (button.get_active() && UserData.getDfType() != UserData.dfTypeWeekly) { - UserData.setDfType(UserData.dfTypeWeekly); + Zystem.debug("Week toggled"); + if (button.get_active() && UserData.getDfType(this.currentMonitoredDir) != UserData.dfTypeWeekly) { + UserData.setDfType(currentMonitoredDir, UserData.dfTypeWeekly); } } /** * When choosing Monthly DayFolder. */ - [CCode (instance_pos = -1)] public void rdoMonthClicked(RadioButton button) { - if (button.get_active() && UserData.getDfType() != UserData.dfTypeMonthly) { - UserData.setDfType(UserData.dfTypeMonthly); + Zystem.debug("Month toggled"); + if (button.get_active() && UserData.getDfType(this.currentMonitoredDir) != UserData.dfTypeMonthly) { + UserData.setDfType(currentMonitoredDir, UserData.dfTypeMonthly); } } /** - * + * Start a new monitored dir to add to settings. This adds a blank entry + * to the tree view. + */ + public void btnAddMonitoredDirClicked(Button button) { + var fileChooser = new FileChooserDialog("Add Monitored Folder", this.window, + FileChooserAction.SELECT_FOLDER, + Stock.CANCEL, ResponseType.CANCEL, + Stock.OPEN, ResponseType.ACCEPT); + if (fileChooser.run() == ResponseType.ACCEPT) { + string path = fileChooser.get_filename(); + this.addMonitoredDir(path); + } + fileChooser.destroy(); + } + + /** + * This is the process of adding a new monitored directory. + */ + private void addMonitoredDir(string path) { + // Add to TreeView + var listmodel = this.tvMonitoredDirs.model as ListStore; + + TreeIter iter; + + listmodel.append(out iter); + listmodel.set(iter, 0, path); + + // Add to UserData + UserData.addMonitoredDirectory(path); + + // Reload the monitored directories TreeView + loadMonitoredDirsView(); + } + + /** * This method is connected to the signal in the code when the settings window * was created. */ private void fileExtRuleSelected() { string fileExt = getSelectedFileExt(); - var txtFileExt = dfSettingsBuilder.get_object("txtFileExt") as Entry; - var txtDestDir = dfSettingsBuilder.get_object("txtDestDir") as Entry; - - txtFileExt.text = fileExt; - txtDestDir.text = UserData.getFileExtRuleDest(fileExt); + this.txtFileNameContains.text = fileExt; + this.txtFileRuleDest.text = UserData.getFileRuleDest(currentMonitoredDir, fileExt); } /** @@ -372,9 +562,109 @@ private string getSelectedFileExt() { string fileExt = ""; - var view = dfSettingsBuilder.get_object("tvFileExtRules") as TreeView; + var view = this.tvFileRules; + + int index = getSelectedFromView(view); + + if (index >= 0) { + fileExt = fileExtList.nth_data(index); + } + + return fileExt; + } + + /** + * Called when a monitored directory is selected. + */ + private void monitoredDirSelected() { + // Enable controls + enableControls(); + + string monDirPath = getSelectedMonitoredDir(); + + if (monDirPath != "") { + currentMonitoredDir = monDirPath; + loadCurrentMonitoredDir(); + } + } + + /** + * Return currently selected monitored directory path as string. + */ + private string getSelectedMonitoredDir() { + string dirPath = ""; + + var view = this.tvMonitoredDirs; - int index; + int index = getSelectedFromView(view); + + if (index >= 0) { + dirPath = monitoredDirsList.nth_data(index); + } + + return dirPath; + } + + /** + * + */ + private void loadCurrentMonitoredDir() { + Zystem.debug("Loading Monitored Directory: " + currentMonitoredDir); + + // Set dfType radio button + loadDfTypeOption(); + + // Set switches + this.setSwMoveSubfolders(); + this.setSwUseDayFolder(); + + // Set Source Location label text + this.lblSrcFolderLocationDisplay.label = UserData.getSourcePath(currentMonitoredDir); + + // Set DayFolder root path label text + this.lblDfLocationDisplay.label = UserData.getDfRootPath(currentMonitoredDir); + + // Load the FileExtRules + loadFileExtRulesTreeView(); + } + + private void setSwUseDayFolder() { + bool useDayFolder = UserData.getUseDayFolder(currentMonitoredDir); + + this.swUseDayFolder.active = useDayFolder; + + this.enableUseDayFolderControls(useDayFolder); + } + + private void setSwMoveSubfolders() { + this.swMoveSubfolders.active = UserData.getMoveDirs(currentMonitoredDir); + } + + /** + * Set the Use DayFolder option for the currentMonitoredDir and set appropriate widgets disabled. + */ + private void swUseDayFolderClicked() { + Zystem.debug("swUseDayFolder: " + this.swUseDayFolder.active.to_string()); + + UserData.setUseDayFolder(currentMonitoredDir, this.swUseDayFolder.active); + + this.enableUseDayFolderControls(this.swUseDayFolder.active); + } + + /** + * Set the MoveDirs option to the + */ + private void swMoveSubfoldersClicked() { + Zystem.debug("swMoveSubfolders: " + this.swMoveSubfolders.active.to_string()); + + UserData.setMoveDirs(currentMonitoredDir, this.swMoveSubfolders.active); + } + + /** + * Return index value of currently selected item in passed in TreeView. + */ + private int getSelectedFromView(TreeView view) { + int index = -1; var selection = view.get_selection() as TreeSelection; selection.set_mode(SelectionMode.SINGLE); TreeModel model; @@ -386,11 +676,74 @@ index = int.parse(path.to_string()); } - if (index >= 0) { - fileExt = fileExtList.nth_data(index); + return index; + } + + /** + * Disable GUI controls. + */ + private void disableControls() { + this.setControlsEnabled(false); + } + + /** + * Enable GUI controls. + */ + private void enableControls() { + this.setControlsEnabled(true); + } + + /** + * Sets GUI widgets enabled value. + */ + private void setControlsEnabled(bool enabled) { + var widgetList = getSettingsWidgets(); + + foreach (Widget w in widgetList) { + w.set_sensitive(enabled); } + } - return fileExt; + private void enableUseDayFolderControls(bool enabled) { + var widgetList = getUseDayFolderWidgets(); + + foreach (Widget w in widgetList) { + w.set_sensitive(enabled); + } + } + + private ArrayList getUseDayFolderWidgets() { + var widgetList = new ArrayList(); + + widgetList.add(this.btnChangeDfLocation); + widgetList.add(this.swMoveSubfolders); + widgetList.add(this.rdoDaily); + widgetList.add(this.rdoWeekly); + widgetList.add(this.rdoMonthly); + widgetList.add(this.lblDfLocationDisplay); + widgetList.add(this.lblSubfoldersOption); + widgetList.add(this.lblDfTypeHeading); + + return widgetList; + } + + /** + * Return list of widgets to disable or enable. + */ + private ArrayList getSettingsWidgets() { + var widgetList = new ArrayList(); + + widgetList.add(this.swUseDayFolder); + widgetList.add(this.btnChangeDfLocation); + widgetList.add(this.swMoveSubfolders); + widgetList.add(this.rdoDaily); + widgetList.add(this.rdoWeekly); + widgetList.add(this.rdoMonthly); + widgetList.add(this.btnChangeFileRuleDest); + widgetList.add(this.txtFileNameContains); + widgetList.add(this.txtFileRuleDest); + + return widgetList; } /** ************************************************* */ @@ -405,4 +758,4 @@ return 0; } -} \ No newline at end of file +} diff -Nru dayfolder-1.4.1/src/dfSettings.ui dayfolder-2.0.0/src/dfSettings.ui --- dayfolder-1.4.1/src/dfSettings.ui 2012-06-09 14:36:21.000000000 +0000 +++ dayfolder-2.0.0/src/dfSettings.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,661 +0,0 @@ - - - - - - True - False - DayFolder Settings - False - - - - True - False - 6 - 6 - 6 - 6 - vertical - - - True - False - vertical - - - True - False - 0 - Source Location - - - - - - False - True - 2 - 0 - - - - - True - False - - - True - False - 0 - - - True - True - 1 - - - - - False - True - True - True - False - - - - True - False - - - True - False - gtk-directory - - - False - True - 0 - - - - - True - False - Change - - - False - True - 1 - - - - - - - False - True - 2 - - - - - False - True - True - True - False - right - - - - True - False - - - True - False - gtk-clear - - - False - True - 0 - - - - - True - False - Reset - - - False - True - 1 - - - - - - - False - True - 3 - - - - - False - True - 2 - 1 - - - - - True - False - 0 - DayFolder Location - - - - - - False - True - 2 - 2 - - - - - True - False - - - True - False - 0 - - - True - True - 1 - - - - - False - True - True - True - False - - - - True - False - - - True - False - gtk-directory - - - False - True - 0 - - - - - True - False - Change - - - False - True - 1 - - - - - - - False - True - 2 - - - - - False - True - True - True - False - right - - - - True - False - - - True - False - gtk-clear - - - False - True - 0 - - - - - True - False - Reset - - - False - True - 1 - - - - - - - False - True - 3 - - - - - False - True - 2 - 3 - - - - - False - True - 0 - - - - - True - False - vertical - - - True - False - - - False - True - 12 - 0 - - - - - True - False - vertical - - - True - False - 0 - File Type Rules - - - - - - False - True - 2 - 0 - - - - - True - True - liststore1 - - - - - - False - True - 2 - 1 - - - - - True - True - 1 - - - - - True - False - vertical - - - True - False - 8 - - - True - False - 0 - FIle Extension - 18 - - - 0 - 0 - 1 - 1 - - - - - True - False - 0 - Destination - - - 1 - 0 - 1 - 1 - - - - - True - True - - 10 - True - - - 0 - 1 - 1 - 1 - - - - - True - False - - - True - True - - 38 - True - - - False - True - 0 - - - - - False - True - True - True - False - - - - True - False - gtk-directory - - - - - False - True - 1 - - - - - 1 - 1 - 1 - 1 - - - - - False - True - 2 - 0 - - - - - True - False - - - gtk-remove - False - True - True - True - False - True - - - - False - True - 0 - - - - - Save - False - True - True - True - False - - - - False - True - 1 - - - - - False - True - 1 - - - - - False - True - 3 - - - - - False - False - 1 - - - - - True - False - vertical - - - True - False - - - False - True - 12 - 0 - - - - - True - False - 0 - DayFolder Type - - - - - - False - True - 2 - 1 - - - - - True - False - - - Daily - False - True - True - False - False - 0 - True - - - - False - True - 2 - 0 - - - - - Weekly - False - True - True - False - False - 0 - True - rdoDay - - - - False - True - 2 - 1 - - - - - Monthly - False - True - True - False - False - 0 - True - rdoDay - - - - False - True - 2 - 2 - - - - - False - True - 2 - 2 - - - - - Support DayFolder! -Check out DayFolderPro - False - True - True - True - True - False - none - http://zburnham.co.cc/2012/06/dayfolderpro-is-coming/ - - - False - True - 3 - 3 - - - - - False - True - 2 - - - - - -