X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fforms%2Fpreferences%2FfrmPreferences.cpp;h=b9919c73f8e0338b08127c52c0c9f576c5a46ef8;hb=49789773e2797383c866dca470fb99e80cb49e41;hp=c10029600e74742dc61fdb994c020934eb591012;hpb=1fe6e43892e5c572949a293a9e19704b5debadad;p=xestiacalendar%2F.git diff --git a/source/forms/preferences/frmPreferences.cpp b/source/forms/preferences/frmPreferences.cpp index c100296..b9919c7 100644 --- a/source/forms/preferences/frmPreferences.cpp +++ b/source/forms/preferences/frmPreferences.cpp @@ -41,6 +41,7 @@ frmPreferencesADT( parent ) NbtPreferences->RemovePage(1); btnAccountAdd->Show(false); + NbtPreferences->ChangeSelection(0); } @@ -323,11 +324,9 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event ) if (!accountDirFull.IsEmpty()){ - accountDirDelFull.Append(wxString::FromUTF8(getenv("HOME"))); - accountDirDelFull.Append(wxT("/.xestiacal/accounts/")); - accountDirDelFull.Append(accountDirFull); + accountDirDelFull.Append(GetAccountDir(accountDirFull, false)); - wxRmDir(accountDirDelFull); + DeleteDirectory(accountDirDelFull); } @@ -424,4 +423,37 @@ void frmPreferences::SetupPointers(bool *reloadAccountInc){ reloadAccountConfig = reloadAccountInc; -} \ No newline at end of file +} + +void frmPreferences::DeleteDirectory(wxString directoryPath) +{ + + // Open the directory and look for files and directories + // to delete. + + wxDir directoryHandle(directoryPath); + + if (!directoryHandle.IsOpened()) + { + return; + } + + wxString directoryFilename; + + bool continueProcessing = directoryHandle.GetFirst(&directoryFilename, wxEmptyString, wxDIR_FILES|wxDIR_DIRS|wxDIR_HIDDEN); + while (continueProcessing) + { + wxString directoryFilenameFull = directoryPath + "/" + directoryFilename; + if (wxDir::Exists(directoryFilenameFull)) + { + DeleteDirectory(directoryFilenameFull); + continueProcessing = directoryHandle.GetNext(&directoryFilename); + continue; + } + wxRemoveFile(directoryFilenameFull); + continueProcessing = directoryHandle.GetNext(&directoryFilename); + } + directoryHandle.Close(); + + wxRmDir(directoryPath); +}