From d90d80c49709335e9101657d1a82cdd964e14c40 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Tue, 21 Jan 2014 08:25:13 +0000 Subject: [PATCH] allow to change the directory containing the notes. --- NEWS | 1 + NEWS.html | 7 ++++++- config.status | 6 +++--- po/Makefile | 2 +- po/Makefile.in | 2 +- src/note.c | 4 ++-- src/settings.c | 10 ++++++++++ src/settings.h | 4 +++- src/ui.c | 7 +++++++ 9 files changed, 34 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 014f504..91f1354 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ v0.0.5 * added creation date, due, id, uuid, urgency, and start date in the list of tasks. * popup menu to filter columns of the table of tasks. + * allow to change the directory containing the notes. v0.0.4 ------ diff --git a/NEWS.html b/NEWS.html index 37ac5a7..f13f412 100644 --- a/NEWS.html +++ b/NEWS.html @@ -367,6 +367,11 @@ added creation date, due, id, uuid, urgency, and start date in the popup menu to filter columns of the table of tasks.

+
  • +

    +allow to change the directory containing the notes. +

    +
  • @@ -512,7 +517,7 @@ Initial release.

    diff --git a/config.status b/config.status index 7ac0c65..675ff48 100755 --- a/config.status +++ b/config.status @@ -428,7 +428,7 @@ $config_commands Report bugs to . ptask home page: ." -ac_cs_config="" +ac_cs_config="'--prefix=/tmp'" 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' $ac_configure_extra_args --no-create --no-recursion + set X /bin/bash './configure' '--prefix=/tmp' $ac_configure_extra_args --no-create --no-recursion shift $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 CONFIG_SHELL='/bin/bash' @@ -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"]="/usr/local" +S["prefix"]="/tmp" S["exec_prefix"]="${prefix}" S["PACKAGE_URL"]="http://wpitchoune.net/ptask" S["PACKAGE_BUGREPORT"]="jeanfi@gmail.com" diff --git a/po/Makefile b/po/Makefile index 430bf0b..ea8150b 100644 --- a/po/Makefile +++ b/po/Makefile @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr/local +prefix = /tmp exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/po/Makefile.in b/po/Makefile.in index 9db3564..ca508b4 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr/local +prefix = /tmp exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/note.c b/src/note.c index be9d87a..247d8d9 100644 --- a/src/note.c +++ b/src/note.c @@ -53,11 +53,11 @@ static char *get_path(const char *uuid) const char *sdir; char *path, *dir; - sdir = settings_get_str(SETTINGS_KEY_NOTES_DIR); + sdir = settings_get_notes_dir(); if (sdir == NULL || *sdir == '\0') { dir = get_default_path(); - settings_set_str(SETTINGS_KEY_NOTES_DIR, dir); + settings_set_notes_dir(dir); } else { dir = strdup(sdir); } diff --git a/src/settings.c b/src/settings.c index be6e87c..8dd8d04 100644 --- a/src/settings.c +++ b/src/settings.c @@ -77,3 +77,13 @@ void settings_set_str(const gchar *key, const gchar *value) { g_settings_set_string(settings, key, value); } + +const char *settings_get_notes_dir() +{ + return settings_get_str(SETTINGS_KEY_NOTES_DIR); +} + +void settings_set_notes_dir(const char *dir) +{ + settings_set_str(SETTINGS_KEY_NOTES_DIR, dir); +} diff --git a/src/settings.h b/src/settings.h index 8453c10..8fa2ed3 100644 --- a/src/settings.h +++ b/src/settings.h @@ -30,7 +30,6 @@ 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(); @@ -42,4 +41,7 @@ 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); +const char *settings_get_notes_dir(); +void settings_set_notes_dir(const char *dir); + #endif diff --git a/src/ui.c b/src/ui.c index d28d87b..2cc8107 100644 --- a/src/ui.c +++ b/src/ui.c @@ -172,6 +172,7 @@ void preferences_activate_cbk(GtkWidget *menu_item, gpointer data) GtkBuilder *builder; GtkFileChooser *w_dir; char *dir; + const char *sdir; builder = gtk_builder_new(); gtk_builder_add_from_file @@ -184,6 +185,10 @@ void preferences_activate_cbk(GtkWidget *menu_item, gpointer data) w_dir = GTK_FILE_CHOOSER(gtk_builder_get_object(builder, "dir_chooser")); + sdir = settings_get_notes_dir(); + if (sdir && *sdir) + gtk_file_chooser_set_filename(w_dir, sdir); + result = gtk_dialog_run(diag); if (result) { @@ -192,9 +197,11 @@ void preferences_activate_cbk(GtkWidget *menu_item, gpointer data) if (dir) { log_debug("preferences_activate_cbk(): path=%s", dir); + settings_set_notes_dir(dir); free(dir); } + refresh(); } else { log_debug("preferences_activate_cbk(): cancel"); } -- 2.7.4