worked on notes directory setting
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 21 Jan 2014 07:55:44 +0000 (07:55 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 21 Jan 2014 07:55:44 +0000 (07:55 +0000)
config.status
po/Makefile
po/Makefile.in
src/Makefile.am
src/Makefile.in
src/glade/ptask.glade
src/note.c
src/settings.c
src/settings.h
src/ui.c

index 675ff48..7ac0c65 100755 (executable)
@@ -428,7 +428,7 @@ $config_commands
 Report bugs to <jeanfi@gmail.com>.
 ptask home page: <http://wpitchoune.net/ptask>."
 
-ac_cs_config="'--prefix=/tmp'"
+ac_cs_config=""
 ac_cs_version="\
 ptask config.status 0.0.x
 configured by ./configure, generated by GNU Autoconf 2.69,
@@ -520,7 +520,7 @@ if $ac_cs_silent; then
 fi
 
 if $ac_cs_recheck; then
-  set X /bin/bash './configure'  '--prefix=/tmp' $ac_configure_extra_args --no-create --no-recursion
+  set X /bin/bash './configure'  $ac_configure_extra_args --no-create --no-recursion
   shift
   $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
   CONFIG_SHELL='/bin/bash'
@@ -797,7 +797,7 @@ S["libexecdir"]="${exec_prefix}/libexec"
 S["sbindir"]="${exec_prefix}/sbin"
 S["bindir"]="${exec_prefix}/bin"
 S["program_transform_name"]="s,x,x,"
-S["prefix"]="/tmp"
+S["prefix"]="/usr/local"
 S["exec_prefix"]="${prefix}"
 S["PACKAGE_URL"]="http://wpitchoune.net/ptask"
 S["PACKAGE_BUGREPORT"]="jeanfi@gmail.com"
index ea8150b..430bf0b 100644 (file)
@@ -21,7 +21,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /tmp
+prefix = /usr/local
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index ca508b4..9db3564 100644 (file)
@@ -21,7 +21,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /tmp
+prefix = /usr/local
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index 3caecde..bb1cbfc 100644 (file)
@@ -15,6 +15,7 @@ ptask_SOURCES = list.c list.h \
        log.c log.h \
        main.c \
        note.c note.h \
+       pio.c pio.h \
        pstr.c pstr.h \
        ptime.c ptime.h \
        settings.c settings.h \
index 18239a3..b93cf56 100644 (file)
@@ -93,7 +93,7 @@ CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 PROGRAMS = $(bin_PROGRAMS)
 am_ptask_OBJECTS = list.$(OBJEXT) log.$(OBJEXT) main.$(OBJEXT) \
-       note.$(OBJEXT) pstr.$(OBJEXT) ptime.$(OBJEXT) \
+       note.$(OBJEXT) pio.$(OBJEXT) pstr.$(OBJEXT) ptime.$(OBJEXT) \
        settings.$(OBJEXT) tw.$(OBJEXT) ui.$(OBJEXT) \
        ui_newtask_diag.$(OBJEXT) ui_projecttree.$(OBJEXT) \
        ui_taskpanel.$(OBJEXT) ui_tasktree.$(OBJEXT)
@@ -364,6 +364,7 @@ ptask_SOURCES = list.c list.h \
        log.c log.h \
        main.c \
        note.c note.h \
+       pio.c pio.h \
        pstr.c pstr.h \
        ptime.c ptime.h \
        settings.c settings.h \
@@ -468,6 +469,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/note.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pstr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptime.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settings.Po@am__quote@
index 49d947d..a4fc97b 100644 (file)
@@ -95,7 +95,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkFileChooserButton" id="filechooserbutton1">
+              <object class="GtkFileChooserButton" id="dir_chooser">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">button3</action-widget>
+      <action-widget response="1">button3</action-widget>
       <action-widget response="0">button4</action-widget>
     </action-widgets>
   </object>
index 77f98cf..be9d87a 100644 (file)
 
 #include <log.h>
 #include <note.h>
+#include <pio.h>
+#include <settings.h>
 
-static char *get_default_path(const char *uuid)
+static const char *NOTE_SUF = ".note";
+
+static char *get_default_path()
 {
-       char *home, *dir, *path;
+       char *home, *dir;
 
        home = getenv("HOME");
 
@@ -41,17 +45,31 @@ static char *get_default_path(const char *uuid)
        sprintf(dir, "%s/%s", home, ".task");
        mkdir(dir, 0777);
 
-       path = malloc(strlen(dir) + 1 + strlen(uuid) + strlen(".note") + 1);
-       sprintf(path, "%s/%s.note", dir, uuid);
-
-       free(dir);
-
-       return path;
+       return dir;
 }
 
 static char *get_path(const char *uuid)
 {
-       return get_default_path(uuid);
+       const char *sdir;
+       char *path, *dir;
+
+       sdir = settings_get_str(SETTINGS_KEY_NOTES_DIR);
+
+       if (sdir == NULL || *sdir == '\0') {
+               dir = get_default_path();
+               settings_set_str(SETTINGS_KEY_NOTES_DIR, dir);
+       } else {
+               dir = strdup(sdir);
+       }
+
+       mkdirs(dir, 0777);
+
+       path = malloc(strlen(dir) + 1 + strlen(uuid) + strlen(NOTE_SUF) + 1);
+       sprintf(path, "%s/%s%s", dir, uuid, NOTE_SUF);
+
+       free(dir);
+
+       return path;
 }
 
 void note_put(const char *uuid, const char *note)
index 2f617c6..be6e87c 100644 (file)
@@ -27,6 +27,7 @@ const char *SETTINGS_KEY_SPLITER_VERTICAL_POS = "spliter-vertical-pos";
 const char *SETTINGS_KEY_SPLITER_HORIZONTAL_POS = "spliter-horizontal-pos";
 const char *SETTINGS_KEY_TASKS_SORT_COL = "tasks-sort-col";
 const char *SETTINGS_KEY_TASKS_SORT_ORDER = "tasks-sort-order";
+const char *SETTINGS_KEY_NOTES_DIR = "notes-dir";
 
 const char * const SETTINGS_VISIBLE_COL_KEYS[] = {
        "tasktree-id-visible",
@@ -66,3 +67,13 @@ void settings_set_boolean(const gchar *key, gboolean value)
 {
        g_settings_set_boolean(settings, key, value);
 }
+
+gchar *settings_get_str(const gchar *key)
+{
+       return g_settings_get_string(settings, key);
+}
+
+void settings_set_str(const gchar *key, const gchar *value)
+{
+       g_settings_set_string(settings, key, value);
+}
index d15fd4d..8453c10 100644 (file)
@@ -30,6 +30,7 @@ extern const char *SETTINGS_KEY_SPLITER_VERTICAL_POS;
 extern const char *SETTINGS_KEY_SPLITER_HORIZONTAL_POS;
 extern const char *SETTINGS_KEY_TASKS_SORT_COL;
 extern const char *SETTINGS_KEY_TASKS_SORT_ORDER;
+extern const char *SETTINGS_KEY_NOTES_DIR;
 extern const char * const SETTINGS_VISIBLE_COL_KEYS[];
 
 void settings_init();
@@ -38,5 +39,7 @@ gint settings_get_int(const gchar *key);
 void settings_set_int(const gchar *key, gint value);
 gboolean settings_get_boolean(const gchar *key);
 void settings_set_boolean(const gchar *key, gboolean value);
+gchar *settings_get_str(const gchar *key);
+void settings_set_str(const gchar *key, const gchar *value);
 
 #endif
index 57e5ade..d28d87b 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -18,6 +18,8 @@
  */
 #include <config.h>
 
+#include <stdlib.h>
+
 #include <glib/gi18n.h>
 
 #include <log.h>
@@ -163,13 +165,13 @@ void quit_activate_cbk(GtkWidget *menu_item, gpointer data)
        log_fct_exit();
 }
 
-
-
 void preferences_activate_cbk(GtkWidget *menu_item, gpointer data)
 {
        gint result;
        static GtkDialog *diag;
        GtkBuilder *builder;
+       GtkFileChooser *w_dir;
+       char *dir;
 
        builder = gtk_builder_new();
        gtk_builder_add_from_file
@@ -179,12 +181,23 @@ void preferences_activate_cbk(GtkWidget *menu_item, gpointer data)
        diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_preferences"));
        gtk_builder_connect_signals(builder, NULL);
 
+       w_dir = GTK_FILE_CHOOSER(gtk_builder_get_object(builder,
+                                                       "dir_chooser"));
+
        result = gtk_dialog_run(diag);
 
-       if (result == GTK_RESPONSE_ACCEPT)
+       if (result) {
                log_debug("preferences_activate_cbk(): accept");
-       else
+               dir = gtk_file_chooser_get_filename(w_dir);
+
+               if (dir) {
+                       log_debug("preferences_activate_cbk(): path=%s", dir);
+                       free(dir);
+               }
+
+       } else {
                log_debug("preferences_activate_cbk(): cancel");
+       }
 
        g_object_unref(G_OBJECT(builder));