aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-20 06:15:41 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-10-20 06:15:41 +0000
commit40168aab1e33815859958ba3541cf953a20e46b6 (patch)
treedd7e7ccd5941505479e172637bdf6ee0d336bfbb /src
parent4b921d38b48195db59f0224e994f8372adb5873f (diff)
added '--configdir' option which specifies config directory.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@667 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/export.c2
-rw-r--r--src/filesel.c2
-rw-r--r--src/main.c32
-rw-r--r--src/main.h1
-rw-r--r--src/manual.c17
5 files changed, 38 insertions, 16 deletions
diff --git a/src/export.c b/src/export.c
index f1de66a9..d81a014c 100644
--- a/src/export.c
+++ b/src/export.c
@@ -75,7 +75,7 @@ gint export_mbox(FolderItem *default_src)
else
gtk_widget_show(window);
- change_dir(startup_dir);
+ change_dir(get_startup_dir());
if (default_src && default_src->path)
src_id = folder_item_get_identifier(default_src);
diff --git a/src/filesel.c b/src/filesel.c
index 7d87a928..c9087b8e 100644
--- a/src/filesel.c
+++ b/src/filesel.c
@@ -85,7 +85,7 @@ static GSList *filesel_select_file_full(const gchar *title, const gchar *file,
if ((cwd = g_hash_table_lookup(path_table, title)) != NULL)
change_dir(cwd);
else
- change_dir(startup_dir);
+ change_dir(get_startup_dir());
dialog = filesel_create(title, action);
diff --git a/src/main.c b/src/main.c
index 79da0a7e..b54c75e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -94,7 +94,6 @@
#include "version.h"
gchar *prog_version;
-gchar *startup_dir;
static gint lock_socket = -1;
static gint lock_socket_tag = 0;
@@ -105,11 +104,12 @@ static struct RemoteCmd {
gboolean compose;
const gchar *compose_mailto;
GPtrArray *attach_files;
+ gboolean send;
gboolean status;
gboolean status_full;
GPtrArray *status_folders;
GPtrArray *status_full_folders;
- gboolean send;
+ gboolean configdir;
} cmd;
static void parse_cmd_opt (int argc,
@@ -295,7 +295,7 @@ static void parse_cmd_opt(int argc, char *argv[])
if (!cmd.attach_files)
cmd.attach_files = g_ptr_array_new();
if (*p != G_DIR_SEPARATOR)
- file = g_strconcat(startup_dir,
+ file = g_strconcat(get_startup_dir(),
G_DIR_SEPARATOR_S,
p, NULL);
else
@@ -334,6 +334,15 @@ static void parse_cmd_opt(int argc, char *argv[])
i++;
p = argv[i + 1];
}
+ } else if (!strncmp(argv[i], "--configdir", 11)) {
+ const gchar *p = argv[i + 1];
+
+ if (p && *p != '\0' && *p != '-') {
+ /* this must only be done at startup */
+ cmd.configdir = TRUE;
+ set_rc_dir(p);
+ i++;
+ }
} else if (!strncmp(argv[i], "--help", 6)) {
g_print(_("Usage: %s [OPTION]...\n"),
g_basename(argv[0]));
@@ -348,6 +357,7 @@ static void parse_cmd_opt(int argc, char *argv[])
g_print("%s\n", _(" --status [folder]... show the total number of messages"));
g_print("%s\n", _(" --status-full [folder]...\n"
" show the status of each folder"));
+ g_print("%s\n", _(" --configdir dirname specify directory which stores configuration files"));
g_print("%s\n", _(" --debug debug mode"));
g_print("%s\n", _(" --help display this help and exit"));
g_print("%s\n", _(" --version output version information and exit"));
@@ -382,11 +392,11 @@ static void app_init(void)
setlocale(LC_ALL, "");
prog_version = PROG_VERSION;
- startup_dir = g_get_current_dir();
+ set_startup_dir();
#ifdef G_OS_WIN32
/* include startup directory into %PATH% for GSpawn */
- newpath = g_strconcat(startup_dir, ";", g_getenv("PATH"), NULL);
+ newpath = g_strconcat(get_startup_dir(), ";", g_getenv("PATH"), NULL);
g_setenv("PATH", newpath, TRUE);
g_free(newpath);
#endif
@@ -396,7 +406,7 @@ static void app_init(void)
else {
gchar *locale_dir;
- locale_dir = g_strconcat(startup_dir, G_DIR_SEPARATOR_S,
+ locale_dir = g_strconcat(get_startup_dir(), G_DIR_SEPARATOR_S,
LOCALEDIR, NULL);
#ifdef G_OS_WIN32
{
@@ -452,17 +462,17 @@ static void parse_gtkrc_files(void)
static void setup_rc_dir(void)
{
+#ifndef G_OS_WIN32
CHDIR_EXIT_IF_FAIL(get_home_dir(), 1);
-#ifndef G_OS_WIN32
/* backup if old rc file exists */
- if (is_file_exist(RC_DIR)) {
+ if (!cmd.configdir && is_file_exist(RC_DIR)) {
if (rename_force(RC_DIR, RC_DIR ".bak") < 0)
FILE_OP_ERROR(RC_DIR, "rename");
}
/* migration from ~/.sylpheed to ~/.sylpheed-2.0 */
- if (!is_dir_exist(RC_DIR)) {
+ if (!cmd.configdir && !is_dir_exist(RC_DIR)) {
const gchar *envstr;
AlertValue val;
@@ -492,14 +502,14 @@ static void setup_rc_dir(void)
if (is_dir_exist(OLD_RC_DIR))
migrate_old_config();
}
-#else
+#endif /* !G_OS_WIN32 */
+
if (!is_dir_exist(get_rc_dir())) {
if (make_dir_hier(get_rc_dir()) < 0)
exit(1);
}
MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir());
-#endif /* G_OS_WIN32 */
CHDIR_EXIT_IF_FAIL(get_rc_dir(), 1);
diff --git a/src/main.h b/src/main.h
index 79c6abcd..bfb674dd 100644
--- a/src/main.h
+++ b/src/main.h
@@ -24,7 +24,6 @@
#include <gtk/gtkwidget.h>
extern gchar *prog_version;
-extern gchar *startup_dir;
void app_will_exit (GtkWidget *widget, gpointer data);
diff --git a/src/manual.c b/src/manual.c
index 8afc4bdb..44bc54e0 100644
--- a/src/manual.c
+++ b/src/manual.c
@@ -60,7 +60,14 @@ void manual_open(ManualLang lang)
lang_str = get_lang_str(lang);
if (!lang_str) return;
- file_uri = g_strconcat("file://", MANUALDIR,
+ file_uri = g_strconcat("file://",
+#ifdef G_OS_WIN32
+ get_startup_dir(),
+ G_DIR_SEPARATOR_S "doc" G_DIR_SEPARATOR_S
+ "manual",
+#else
+ MANUALDIR,
+#endif
G_DIR_SEPARATOR_S, lang_str, G_DIR_SEPARATOR_S,
MANUAL_HTML_INDEX, NULL);
debug_print("Opening manual: %s\n", file_uri);
@@ -76,7 +83,13 @@ void faq_open(ManualLang lang)
lang_str = get_lang_str(lang);
if (!lang_str) return;
- file_uri = g_strconcat("file://", FAQDIR,
+ file_uri = g_strconcat("file://",
+#ifdef G_OS_WIN32
+ get_startup_dir(),
+ G_DIR_SEPARATOR_S "doc" G_DIR_SEPARATOR_S "faq",
+#else
+ FAQDIR,
+#endif
G_DIR_SEPARATOR_S, lang_str, G_DIR_SEPARATOR_S,
FAQ_HTML_INDEX, NULL);
debug_print("Opening FAQ: %s\n", file_uri);