Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv14334/src/gui

Modified Files:
        wxOptionsDlg.cpp 
Log Message:
added support for using file config by default under Windows

Index: wxOptionsDlg.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxOptionsDlg.cpp,v
retrieving revision 1.386
retrieving revision 1.387
diff -b -u -2 -r1.386 -r1.387
--- wxOptionsDlg.cpp    26 Sep 2003 09:33:44 -0000      1.386
+++ wxOptionsDlg.cpp    27 Sep 2003 23:14:26 -0000      1.387
@@ -47,4 +47,5 @@
 #include "Mpers.h"
 #include "Moptions.h"            // we need all MP_XXX for our arrays
+#include "ConfigSource.h"
 
 // we have to include these 3 headers just for wxOptionsPageNewMail... move it
@@ -559,5 +560,8 @@
    ConfigField_SyncStore,
    ConfigField_SyncRetrieve,
-   ConfigField_SyncLast = ConfigField_SyncRetrieve,
+   ConfigField_SyncSeparator,
+   ConfigField_SyncConfigFileHelp,
+   ConfigField_SyncConfigFile,
+   ConfigField_SyncLast = ConfigField_SyncConfigFile,
 
    // the end
@@ -1668,4 +1672,18 @@
    { gettext_noop("&Store settings..."), Field_SubDlg | Field_Global, 
ConfigField_RSynchronise },
    { gettext_noop("&Retrieve settings..."), Field_SubDlg | Field_Global, 
ConfigField_RSynchronise },
+#ifdef OS_WIN
+   { "\n\n",      Field_Message, -1 },
+   { gettext_noop("If a non empty filename is specified here, Mahogany uses\n"
+                  "this file instead of the registry for storing all of its\n"
+                  "options. This may be useful if you want to share the same\n"
+                  "file among several Windows machines (warning: don't try\n"
+                  "to share it with Unix machines, this wouldn't work well)."),
+                  Field_Message, -1 },
+   { gettext_noop("&Config file"),           Field_File |
+                                             Field_FileSave |
+                                             Field_Global |
+                                             Field_AppWide |
+                                             Field_Restart, -1 },
+#endif // OS_WIN
 };
 
@@ -2091,4 +2109,9 @@
    CONFIG_NONE(),
    CONFIG_NONE(),
+#ifdef OS_WIN
+   CONFIG_NONE(), // separator
+   CONFIG_NONE(), // help for config file setting
+   CONFIG_ENTRY(MP_USE_CONFIG_FILE),
+#endif // OS_WIN
 };
 
@@ -3765,5 +3788,8 @@
                                          MH_OPAGE_SYNC)
 {
-   m_SyncRemote = -1;
+#ifdef OS_WIN
+   m_usingConfigFile =
+#endif // OS_WIN
+   m_activateSync = -1;
 }
 
@@ -3773,5 +3799,10 @@
    if ( rc )
    {
-      m_SyncRemote = READ_CONFIG(m_Profile, MP_SYNC_REMOTE);
+      m_activateSync = READ_CONFIG(m_Profile, MP_SYNC_REMOTE);
+
+#ifdef OS_WIN
+      m_usingConfigFile =
+         !READ_CONFIG_TEXT(m_Profile, MP_USE_CONFIG_FILE).empty();
+#endif // OS_WIN
    }
 
@@ -3785,5 +3816,5 @@
    {
       bool syncRemote = READ_CONFIG_BOOL(m_Profile, MP_SYNC_REMOTE);
-      if ( syncRemote && !m_SyncRemote )
+      if ( syncRemote && !m_activateSync )
       {
          if ( MDialog_YesNoDialog
@@ -3802,4 +3833,54 @@
          }
       }
+
+#ifdef OS_WIN
+      String filenameConfig = READ_CONFIG_TEXT(m_Profile, MP_USE_CONFIG_FILE);
+      const int usingConfigFile = !filenameConfig.empty();
+
+      if ( usingConfigFile != m_usingConfigFile )
+      {
+         String title(usingConfigFile ? _("Export settings?")
+                                      : _("Import settings?"));
+
+         String msg(_("You have changed the config file option.\n\n"));
+         if ( usingConfigFile )
+            msg += _("Do you want to export the registry settings "
+                     "to config file?");
+         else
+            msg += _("Do you want to import the existing contents of config "
+                     "file to the reigstry?");
+
+         msg << _T('\n')
+             << _("Note that this may overwrite the existing settings.");
+
+         if ( MDialog_YesNoDialog
+              (
+                  msg,
+                  this,
+                  title,
+                  M_DLG_YES_DEFAULT
+              ) )
+         {
+            ConfigSource_obj
+               configSrc(ConfigSourceLocal::CreateRegistry()),
+               configDst(ConfigSourceLocal::CreateFile(filenameConfig));
+            if ( !usingConfigFile )
+            {
+               // importing to registry, not exporting from it
+               configSrc.Swap(configDst);
+            }
+
+            if ( !ConfigSource::Copy(*configDst.Get(), *configSrc.Get()) )
+            {
+               if ( usingConfigFile )
+                  wxLogError(_("Failed to export settings to the file \"%s\"."),
+                             filenameConfig.c_str());
+               else
+                  wxLogError(_("Failed to import settings from the file \"%s\"."),
+                             filenameConfig.c_str());
+            }
+         }
+      }
+#endif // OS_WIN
    }
 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to