Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmPreferences: Make the General tab be the first tab that is shown
[xestiacalendar/.git] / source / forms / preferences / frmPreferences.cpp
index d072475..f35fac1 100644 (file)
@@ -1,3 +1,21 @@
+// frmPreferences.cpp - frmPreferences form functions
+//
+// (c) 2016-2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
 #include "frmPreferences.h"
 
 frmPreferences::frmPreferences( wxWindow* parent )
@@ -9,20 +27,21 @@ frmPreferencesADT( parent )
        wxMemoryInputStream cstream(icons_accunsupported_png, sizeof(icons_accunsupported_png));
 
        wxImage icons_acclocal_png(bstream, wxBITMAP_TYPE_PNG);
-       wxBitmap AccNIcon(icons_acclocal_png, -1);
+       wxBitmap accNIcon(icons_acclocal_png, -1);
        wxIcon wxIAccNIcon;
-       wxIAccNIcon.CopyFromBitmap(AccNIcon);
+       wxIAccNIcon.CopyFromBitmap(accNIcon);
        
        wxImage icons_accunsupported_png(cstream, wxBITMAP_TYPE_PNG);
-       wxBitmap AccUIcon(icons_accunsupported_png, -1);
+       wxBitmap accUIcon(icons_accunsupported_png, -1);
        wxIcon wxIAccUIcon;
-       wxIAccUIcon.CopyFromBitmap(AccUIcon);
+       wxIAccUIcon.CopyFromBitmap(accUIcon);
        
-       AccountID = AccImgList->Add(wxIAccNIcon);
-       AccountUnsupportedID = AccImgList->Add(wxIAccUIcon);
+       accountID = accImgList->Add(wxIAccNIcon);
+       accountUnsupportedID = accImgList->Add(wxIAccUIcon);
 
        NbtPreferences->RemovePage(1);
        btnAccountAdd->Show(false);
+    NbtPreferences->ChangeSelection(0);
        
 }
 
@@ -32,22 +51,22 @@ void frmPreferences::LoadPreferences( wxInitDialogEvent& event )
        // Setup the preferences filename string. Default is the
        // *nix systems one (/home/$USER/.xestiacal/preferences)
     
-       preffilename = GetUserPrefDir();
+       prefFilename = GetUserPrefDir();
 
-       preferences = new XCALPreferences(preffilename);
+       preferences = new XCALPreferences(prefFilename);
   
        // Setup the General Tab.
     
-       bool SaveWindowPos = preferences->GetBoolData(wxT("SaveWindowPosition"));
-       bool HideLocalABs = preferences->GetBoolData(wxT("HideLocalCalendars"));
+       bool saveWindowPos = preferences->GetBoolData(wxT("SaveWindowPosition"));
+       bool hideLocalABs = preferences->GetBoolData(wxT("HideLocalCalendars"));
     
-       if (SaveWindowPos == TRUE){
+       if (saveWindowPos == TRUE){
     
                chkSaveWindowPosition->SetValue(TRUE);
     
        }
     
-       if (HideLocalABs == TRUE){
+       if (hideLocalABs == TRUE){
     
                chkHideLocal->SetValue(TRUE);
     
@@ -72,8 +91,8 @@ frmPreferences::~frmPreferences(){
        
        // Destory the preferences window.
        
-       delete AccImgList;
-       AccImgList = NULL;
+       delete accImgList;
+       accImgList = NULL;
        
 }
 
@@ -81,12 +100,12 @@ void frmPreferences::ReloadAccounts(){
 
        // Reload the accounts in the accounts list.
        
-       if (FirstLoad == FALSE){
+       if (firstLoad == FALSE){
                delete preferences;
                preferences = NULL;
-               preferences = new XCALPreferences(preffilename);
+               preferences = new XCALPreferences(prefFilename);
        } else {
-               FirstLoad = FALSE;
+               firstLoad = FALSE;
        }
 
        wxListItem accountscol0, accountscol1, accountscol2, accountscol3;
@@ -96,7 +115,7 @@ void frmPreferences::ReloadAccounts(){
        accountscol0.SetId(0);
        accountscol0.SetWidth(24);
        lstAccounts->InsertColumn(0,accountscol0);
-       lstAccounts->SetImageList(AccImgList, wxIMAGE_LIST_SMALL);
+       lstAccounts->SetImageList(accImgList, wxIMAGE_LIST_SMALL);
 
        accountscol1.SetId(1);
        accountscol1.SetText(_("Name"));
@@ -108,7 +127,7 @@ void frmPreferences::ReloadAccounts(){
        accountscol2.SetWidth(96);
        lstAccounts->InsertColumn(2,accountscol2);
     
-       wxString AccType;
+       wxString accType;
     
        for (int i = 0; i < preferences->accounts.GetCount() ; i++){
 
@@ -123,11 +142,11 @@ void frmPreferences::ReloadAccounts(){
                
                if (preferences->accounts.GetAccountType(i) == wxT("Local")){
        
-                       col0.SetImage(AccountID);
+                       col0.SetImage(accountID);
        
                } else {
 
-                       col0.SetImage(AccountUnsupportedID);
+                       col0.SetImage(accountUnsupportedID);
                        
                }
        
@@ -174,11 +193,11 @@ void frmPreferences::ModifyAccount( wxCommandEvent& event )
        // with the settings.
     
        long lstAccountsIndex = -1;
-       wxString AccFilename = GetAccountsFile();
-       wxString AccName;
-       wxString AccType;
+       wxString accFilename = GetAccountsFile();
+       wxString accName;
+       wxString accType;
     
-       wxFileConfig *cfgfile = new wxFileConfig("", "", AccFilename);
+       wxFileConfig *cfgFile = new wxFileConfig("", "", accFilename);
        
        // Get the account name.
     
@@ -188,38 +207,38 @@ void frmPreferences::ModifyAccount( wxCommandEvent& event )
        
        // Check that the account type is a supported account type.
        
-       AccType = preferences->accounts.GetAccountType((int)lstAccountsIndex);
+       accType = preferences->accounts.GetAccountType((int)lstAccountsIndex);
        
-       if (AccType != "CardDAV" && AccType != "carddav" &&
-               AccType != "Local" && AccType != "local"){
+       if (accType != "CardDAV" && accType != "carddav" &&
+               accType != "Local" && accType != "local"){
        
                wxMessageBox(_("Cannot modify the selected account settings as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR);
                return;
                        
        }
     
-       AccName = preferences->accounts.GetAccountName((int)lstAccountsIndex);
+       accName = preferences->accounts.GetAccountName((int)lstAccountsIndex);
     
        frmEditAccount *frameEditAccount = new frmEditAccount ( this );
-       frameEditAccount->LoadPointers(cfgfile);
-       frameEditAccount->LoadSettings(AccName);
+       frameEditAccount->LoadPointers(cfgFile);
+       frameEditAccount->LoadSettings(accName);
        frameEditAccount->ShowModal();
 
-       bool DialogResult = frameEditAccount->GetDialogResult();
+       bool dialogResult = frameEditAccount->GetDialogResult();
 
        delete frameEditAccount;
        frameEditAccount = NULL;
-       delete cfgfile;
-       cfgfile = NULL;
+       delete cfgFile;
+       cfgFile = NULL;
 
-       if (DialogResult == false){
+       if (dialogResult == false){
                return;
        }
 
        // Reload the account list in the preferences window.
 
        ReloadAccounts();
-       *ReloadAccountConfig = TRUE;
+       *reloadAccountConfig = TRUE;
        btnAccountModify->Enable(FALSE);
        btnAccountDelete->Enable(FALSE);
        
@@ -243,45 +262,45 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event )
                        wxLIST_NEXT_ALL,
                         wxLIST_STATE_SELECTED);
        
-               bool ContinueAcc = TRUE;
-               wxString AccountDir;
-               wxString AccountType;
-               wxString AccountDirFull;
-               wxString AccountDirDelFull;
-               wxString AccountName;
-               wxString AccName;
-               long itemindex = 0;
+               bool continueAcc = TRUE;
+               wxString accountDir;
+               wxString accountType;
+               wxString accountDirFull;
+               wxString accountDirDelFull;
+               wxString accountName;
+               wxString accName;
+               long itemIndex = 0;
        
-               wxString AccFilename = GetAccountsFile();
+               wxString accFilename = GetAccountsFile();
     
-               wxFileConfig *cfgfile = new wxFileConfig("", "", AccFilename);
+               wxFileConfig *cfgFile = new wxFileConfig("", "", accFilename);
        
-               AccName = preferences->accounts.GetAccountName((int)lstAccounts->GetItemData(lstAccountsIndex));
+               accName = preferences->accounts.GetAccountName((int)lstAccounts->GetItemData(lstAccountsIndex));
        
                // Get the account directory name and account type..
        
-               ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex);
+               continueAcc = cfgFile->GetFirstGroup(accountName, itemIndex);
        
-               while (ContinueAcc){
+               while (continueAcc){
 
-                       if (AccountName == AccName){
+                       if (accountName == accName){
 
-                               cfgfile->SetPath(AccountName);
+                               cfgFile->SetPath(accountName);
                        
-                               cfgfile->Read("accountdir", &AccountDir);
-                               cfgfile->Read("type", &AccountType);
+                               cfgFile->Read("accountdir", &accountDir);
+                               cfgFile->Read("type", &accountType);
                
                                break;
 
                        }
                
-                       cfgfile->SetPath(wxT("/"));
-                       ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
+                       cfgFile->SetPath(wxT("/"));
+                       continueAcc = cfgFile->GetNextGroup(accountName, itemIndex);
        
                }
        
-               AccountDirFull.Append(AccountDir);
-               AccountDirFull.Append(wxT("."));
+               accountDirFull.Append(accountDir);
+               accountDirFull.Append(wxT("."));
        
                /*if (AccountType == wxT("CalDAV")){
        
@@ -289,9 +308,9 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event )
        
                } else */
                
-               if (AccountType == wxT("Local")){
+               if (accountType == wxT("Local")){
        
-                       AccountDirFull.Append(wxT("Local"));
+                       accountDirFull.Append(wxT("Local"));
        
                }/*else {
                        
@@ -303,25 +322,25 @@ void frmPreferences::DeleteAccount( wxCommandEvent& event )
        
                // Delete the directory that contains the account information.
        
-               if (!AccountDirFull.IsEmpty()){
+               if (!accountDirFull.IsEmpty()){
        
-                       AccountDirDelFull.Append(wxString::FromUTF8(getenv("HOME")));
-                       AccountDirDelFull.Append(wxT("/.xestiacal/accounts/"));
-                       AccountDirDelFull.Append(AccountDirFull);
+                       accountDirDelFull.Append(wxString::FromUTF8(getenv("HOME")));
+                       accountDirDelFull.Append(wxT("/.xestiacal/accounts/"));
+                       accountDirDelFull.Append(accountDirFull);
        
-                       wxRmDir(AccountDirDelFull);
+                       wxRmDir(accountDirDelFull);
        
                }
        
                // Delete the account from the configuration file.
        
-               cfgfile->SetPath(wxT("/"));
-               cfgfile->DeleteGroup(AccountName);
-               cfgfile->Flush();
+               cfgFile->SetPath(wxT("/"));
+               cfgFile->DeleteGroup(accountName);
+               cfgFile->Flush();
        
                // Set flag for reloading accounts on window closure.
     
-               *ReloadAccountConfig = TRUE;
+               *reloadAccountConfig = TRUE;
     
        }
 
@@ -335,21 +354,21 @@ void frmPreferences::SavePreferences( wxCommandEvent& event )
 
        // Load up the preferences file.
 
-       wxString SetFilename = GetSettingsFile();
+       wxString setFilename = GetSettingsFile();
 
-       wxFileConfig *cfgfile = new wxFileConfig("", "", SetFilename);
+       wxFileConfig *cfgFile = new wxFileConfig("", "", setFilename);
 
        // Update the settings file.
                
-       cfgfile->DeleteEntry(wxT("SaveWindowPosition"));
-       cfgfile->DeleteEntry(wxT("WindowPositionX"));
-       cfgfile->DeleteEntry(wxT("WindowPositionY"));
-       cfgfile->DeleteEntry(wxT("WindowPositionHeight"));
-       cfgfile->DeleteEntry(wxT("WindowPositionWidth"));
+       cfgFile->DeleteEntry(wxT("SaveWindowPosition"));
+       cfgFile->DeleteEntry(wxT("WindowPositionX"));
+       cfgFile->DeleteEntry(wxT("WindowPositionY"));
+       cfgFile->DeleteEntry(wxT("WindowPositionHeight"));
+       cfgFile->DeleteEntry(wxT("WindowPositionWidth"));
        
        if (chkSaveWindowPosition->GetValue() == TRUE){
        
-               cfgfile->Write(wxT("SaveWindowPosition"), wxT("true"));
+               cfgFile->Write(wxT("SaveWindowPosition"), wxT("true"));
        
                // Get parent window details.
                
@@ -359,33 +378,33 @@ void frmPreferences::SavePreferences( wxCommandEvent& event )
        
                wxRect frmMainPos = frmMainPtr->GetRect();
        
-               cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
-               cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
-               cfgfile->Write(wxT("WindowPositionHeight"), frmMainPos.GetHeight());
-               cfgfile->Write(wxT("WindowPositionWidth"), frmMainPos.GetWidth());
+               cfgFile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
+               cfgFile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
+               cfgFile->Write(wxT("WindowPositionHeight"), frmMainPos.GetHeight());
+               cfgFile->Write(wxT("WindowPositionWidth"), frmMainPos.GetWidth());
 
        } else {
        
-               cfgfile->Write(wxT("SaveWindowPosition"), wxT("false"));
+               cfgFile->Write(wxT("SaveWindowPosition"), wxT("false"));
        
        }
        
-       cfgfile->DeleteEntry(wxT("HideLocalCalendars"));
+       cfgFile->DeleteEntry(wxT("HideLocalCalendars"));
        
        if (chkHideLocal->GetValue() == TRUE){
 
-               cfgfile->Write(wxT("HideLocalCalendars"), wxT("true"));
-               *ReloadAccountConfig = TRUE;
+               cfgFile->Write(wxT("HideLocalCalendars"), wxT("true"));
+               *reloadAccountConfig = TRUE;
        
        } else {
        
-               cfgfile->Write(wxT("HideLocalCalendars"), wxT("false"));
-               *ReloadAccountConfig = TRUE;
+               cfgFile->Write(wxT("HideLocalCalendars"), wxT("false"));
+               *reloadAccountConfig = TRUE;
        
        }
 
-       delete cfgfile;
-       cfgfile = NULL;
+       delete cfgFile;
+       cfgFile = NULL;
 
        this->Close();
        
@@ -400,10 +419,10 @@ void frmPreferences::CloseWindow( wxCommandEvent& event )
        
 }
 
-void frmPreferences::SetupPointers(bool *ReloadAccountInc){
+void frmPreferences::SetupPointers(bool *reloadAccountInc){
 
        // Setup the pointers for the preferences form.
        
-       ReloadAccountConfig = ReloadAccountInc;
+       reloadAccountConfig = reloadAccountInc;
 
 }
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy