[gnome-commander] --config-dir command line option for customized location of config files



commit 0b2e85efb209ec7b6b4e766da248f81e67a37fc7
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Tue Nov 2 17:37:06 2010 +0100

    --config-dir command line option for customized location of config files

 NEWS                      |    1 +
 doc/C/gnome-commander.xml |    9 +++++++++
 doc/gnome-commander.1     |    3 +++
 src/gnome-cmd-data.cc     |   16 ++++++++--------
 src/gnome-cmd-data.h      |    4 ++++
 src/main.cc               |    3 +++
 6 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index f621e4f..3a322a3 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ New features:
  * One instance mode
  * User defined LS_COLORS colours
  * Enhanced file name matching in quick search
+ * --config-dir command line option for customized location of config files
  * New or updated docs: de, en, es, fr, sl
  * New or updated translations: da, es, eu, fr, hu, ko, nb, pl, ro, ru, sl, uk, zh_CN
  * New key bindings:
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index e3fc8a6..d921585 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -460,6 +460,12 @@
               </listitem>
               <listitem>
                 <para>
+                  <guilabel>--config-dir=STRING</guilabel>
+                </para>
+                <para>Specify the directory for configuration files.</para>
+              </listitem>
+              <listitem>
+                <para>
                   <guilabel>-d, --debug=STRING</guilabel>
                 </para>
                 <para>Specify debug flags to use. Debug output will be written to stdout.</para>
@@ -7429,6 +7435,9 @@
                             <para>Enhanced file name matching in quick search</para>
                         </listitem>
                         <listitem>
+                            <para>--config-dir command line option for customized location of config files</para>
+                        </listitem>
+                        <listitem>
                             <para>New or updated docs: de, en, es, fr, sl</para>
                         </listitem>
                         <listitem>
diff --git a/doc/gnome-commander.1 b/doc/gnome-commander.1
index 811bf39..ed03c64 100644
--- a/doc/gnome-commander.1
+++ b/doc/gnome-commander.1
@@ -39,6 +39,9 @@ Specify the start directory for the left pane
 .B \-r, \-\-start-right-dir=STRING
 Specify the start directory for the right pane
 .TP
+.B \    \-\-config-dir=STRING
+Specify the directory for configuration files
+.TP
 .B \-d, \-\-debug=STRING
 Specify debug flags to use.
 Debug output will be written to STDOUT.
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 14925cc..7737247 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -140,7 +140,7 @@ inline void write(XML::xstream &xml, GnomeCmdCon *con, const gchar *name)
 
 inline void save_connections (const gchar *fname)
 {
-    gchar *path = g_build_filename (g_get_home_dir (), "." PACKAGE, fname, NULL);
+    gchar *path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, fname, NULL);
     FILE  *fd = fopen (path, "w");
 
     if (fd)
@@ -173,7 +173,7 @@ inline void save_connections (const gchar *fname)
 
 inline void save_devices (const gchar *fname)
 {
-    gchar *path = g_build_filename (g_get_home_dir (), "." PACKAGE, fname, NULL);
+    gchar *path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, fname, NULL);
     FILE *fd = fopen (path, "w");
 
     if (fd)
@@ -218,7 +218,7 @@ inline void save_devices (const gchar *fname)
 
 inline void save_fav_apps (const gchar *fname)
 {
-    gchar *path = g_build_filename (g_get_home_dir (), "." PACKAGE, fname, NULL);
+    gchar *path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, fname, NULL);
     FILE *fd = fopen (path, "w");
 
     if (fd)
@@ -262,7 +262,7 @@ inline gboolean load_connections (const gchar *fname)
 {
     guint prev_ftp_cons_no = g_list_length (gnome_cmd_con_list_get_all_ftp (gnome_cmd_data.priv->con_list));
 
-    gchar *path = g_build_filename (g_get_home_dir (), "." PACKAGE, fname, NULL);
+    gchar *path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, fname, NULL);
     FILE  *fd = fopen (path, "r");
 
     if (fd)
@@ -604,7 +604,7 @@ inline void load_vfs_auto_devices ()
 
 inline void load_devices (const gchar *fname)
 {
-    gchar *path = g_build_filename (g_get_home_dir (), "." PACKAGE, fname, NULL);
+    gchar *path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, fname, NULL);
     FILE *fd = fopen (path, "r");
 
     if (fd)
@@ -654,7 +654,7 @@ inline void load_devices (const gchar *fname)
 inline void load_fav_apps (const gchar *fname)
 {
     gnome_cmd_data.priv->fav_apps = NULL;
-    gchar *path = g_build_filename (g_get_home_dir (), "." PACKAGE, fname, NULL);
+    gchar *path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, fname, NULL);
 
     ifstream f(path);
     string line;
@@ -1000,7 +1000,7 @@ void GnomeCmdData::free()
 
 void GnomeCmdData::load()
 {
-    gchar *xml_cfg_path = g_build_filename (g_get_home_dir (), "." PACKAGE, PACKAGE ".xml", NULL);
+    gchar *xml_cfg_path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, PACKAGE ".xml", NULL);
 
     gchar *document_icon_dir = g_strdup_printf ("%s/share/pixmaps/document-icons/", GNOME_PREFIX);
     gchar *theme_icon_dir    = g_strdup_printf ("%s/mime-icons", PIXMAPS_DIR);
@@ -1657,7 +1657,7 @@ void GnomeCmdData::save()
     save_intviewer_defaults();
 
     {
-        gchar *xml_cfg_path = g_build_filename (g_get_home_dir (), "." PACKAGE, PACKAGE ".xml", NULL);
+        gchar *xml_cfg_path = g_build_filename (g_get_home_dir (), config_dir ? config_dir : "." PACKAGE, PACKAGE ".xml", NULL);
 
         ofstream f(xml_cfg_path);
         XML::xstream xml(f);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 9cafbd1..96030fd 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -345,6 +345,10 @@ void gnome_cmd_data_set_symlink_prefix (const gchar *value);
 
 extern GnomeCmdData gnome_cmd_data;
 
+extern gchar *start_dir_left;
+extern gchar *start_dir_right;
+extern gchar *config_dir;
+
 extern DICT<guint> gdk_key_names;
 extern DICT<guint> gdk_modifiers_names;
 
diff --git a/src/main.cc b/src/main.cc
index 82adeb4..5206b8c 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -49,6 +49,7 @@ GnomeCmdMainWin *main_win;
 GtkWidget *main_win_widget;
 gchar *start_dir_left;
 gchar *start_dir_right;
+gchar *config_dir;
 gchar *debug_flags;
 
 #ifdef HAVE_LOCALE_H
@@ -68,6 +69,7 @@ struct poptOption popt_options[] = {
     {"debug", 'd', POPT_ARG_STRING, &debug_flags, 0, N_("Specify debug flags to use"), NULL},
     {"start-left-dir", 'l', POPT_ARG_STRING, &start_dir_left, 0, N_("Specify the start directory for the left pane"), NULL},
     {"start-right-dir", 'r', POPT_ARG_STRING, &start_dir_right, 0, N_("Specify the start directory for the right pane"), NULL},
+    {"config-dir", 0, POPT_ARG_STRING, &config_dir, 0, N_("Specify the directory for configuration files"), NULL},
     {NULL, 0, 0, NULL, 0, NULL, NULL}
 };
 
@@ -77,6 +79,7 @@ static const GOptionEntry options [] =
     {"debug", 'd', 0, G_OPTION_ARG_STRING, &debug_flags, N_("Specify debug flags to use"), NULL},
     {"start-left-dir", 'l', 0, G_OPTION_ARG_STRING, &start_dir_left, N_("Specify the start directory for the left pane"), NULL},
     {"start-right-dir", 'r', 0, G_OPTION_ARG_STRING, &start_dir_right, N_("Specify the start directory for the right pane"), NULL},
+    {"config-dir", 0, 0, G_OPTION_ARG_STRING, &config_dir, N_("Specify the directory for configuration files"), NULL},
     {NULL}
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]