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

Modified Files:
        wxMenuDefs.cpp wxMFrame.cpp 
Log Message:
added export/import settings to/from file (bug 533)

Index: wxMenuDefs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMenuDefs.cpp,v
retrieving revision 1.207
retrieving revision 1.208
diff -b -u -2 -r1.207 -r1.208
--- wxMenuDefs.cpp      19 Sep 2003 13:31:21 -0000      1.207
+++ wxMenuDefs.cpp      27 Sep 2003 23:35:05 -0000      1.208
@@ -300,5 +300,5 @@
 
    // the available accelerators for this menu:
-   // BHIJKLNOQVWXYZ
+   // BHJKLNOQVWYZ
    { WXMENU_EDIT_CUT,  gettext_noop("C&ut\tCtrl-X"), gettext_noop("Cut selection and 
copy it to clipboard")           , wxITEM_NORMAL },
    { WXMENU_EDIT_COPY, gettext_noop("&Copy\tCtrl-C"), gettext_noop("Copy selection to 
clipboard")           , wxITEM_NORMAL },
@@ -314,5 +314,7 @@
    { WXMENU_EDIT_TEMPLATES,gettext_noop("&Templates..."), gettext_noop("Edit 
templates used for message composition")   , wxITEM_NORMAL },
    { WXMENU_SEPARATOR,     "",                  ""                         , 
wxITEM_NORMAL },
-   { WXMENU_EDIT_SAVE_PREF,gettext_noop("&Save Preferences"), gettext_noop("Save 
options")             , wxITEM_NORMAL },
+   { WXMENU_EDIT_SAVE_PREF,gettext_noop("&Save preferences"), gettext_noop("Save 
options")             , wxITEM_NORMAL },
+   { WXMENU_EDIT_EXPORT_PREF,gettext_noop("E&xport preferences..."), 
gettext_noop("Save options")             , wxITEM_NORMAL },
+   { WXMENU_EDIT_IMPORT_PREF,gettext_noop("&Import preferences..."), 
gettext_noop("Save options")             , wxITEM_NORMAL },
    { WXMENU_EDIT_RESTORE_PREF,
                            gettext_noop("Restore &defaults..."), 
gettext_noop("Restore default options values") , wxITEM_NORMAL },

Index: wxMFrame.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMFrame.cpp,v
retrieving revision 1.163
retrieving revision 1.164
diff -b -u -2 -r1.163 -r1.164
--- wxMFrame.cpp        19 Sep 2003 13:31:21 -0000      1.163
+++ wxMFrame.cpp        27 Sep 2003 23:35:05 -0000      1.164
@@ -44,4 +44,5 @@
 #endif // Python
 
+#include "ConfigSource.h"
 #include "FolderMonitor.h"
 
@@ -652,22 +653,73 @@
          (void)ShowRestoreDefaultsDialog(mApplication->GetProfile(), this);
          break;
+
       case WXMENU_EDIT_SAVE_PREF:
+         if ( Profile::FlushAll() )
          {
-            // FIXME any proper way to flush all profiles at once?
-            wxConfigBase *config = mApplication->GetProfile()->GetConfig();
-            bool ok = config != NULL;
-            if ( ok )
-               ok = config->Flush();
+            wxLogStatus(this, _("Program preferences successfully saved."));
+         }
+         else
+         {
+            ERRORMESSAGE((_("Couldn't save preferences.")));
+         }
+         break;
 
+      case WXMENU_EDIT_EXPORT_PREF:
+      case WXMENU_EDIT_IMPORT_PREF:
+         {
+            const bool doExport = id == WXMENU_EDIT_EXPORT_PREF;
+
+            String path = MDialog_FileRequester
+                          (
+                              doExport ? _("Choose file to export settings to")
+                                       : _("Choose file to import settings from"),
+                              this,
+                              "", "", "", "",
+                              doExport    // true => save, false => load
+                          );
+            if ( path.empty() )
+               break;
+
+            ConfigSource_obj
+               configSrc(ConfigSourceLocal::CreateDefault()),
+               configDst(ConfigSourceLocal::CreateFile(path));
+            if ( !doExport )
+            {
+               configSrc.Swap(configDst);
+            }
+
+            bool ok = ConfigSource::Copy(*configDst.Get(), *configSrc.Get());
+
+            if ( doExport )
+            {
             if ( ok )
             {
-               wxLogStatus(this, _("Program preferences successfully saved."));
+                  wxLogStatus(this,
+                              _("Settings successfully exported to file \"%s\""),
+                              path.c_str());
             }
             else
             {
-               ERRORMESSAGE((_("Couldn't save preferences.")));
+                  wxLogError(_("Failed to export settings to the file \"%s\"."),
+                             path.c_str());
+               }
+            }
+            else // import
+            {
+               if ( ok )
+               {
+                  wxLogStatus(this,
+                              _("Settings successfully imported from \"%s\""),
+                              path.c_str());
+               }
+               else
+               {
+                  wxLogError(_("Failed to import settings from the file \"%s\"."),
+                             path.c_str());
+               }
             }
          }
          break;
+
 
       case WXMENU_HELP_ABOUT:



-------------------------------------------------------
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