[BUG_FIXED] Fix localization combo box unselected in preference dialog bug after startup (when a localization file is in use).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@581 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-12-04 00:27:29 +00:00
parent 44913da6f2
commit 88958a855e
4 changed files with 39 additions and 6 deletions

View File

@ -85,6 +85,22 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
if (rtl)
_isRTL = (strcmp(rtl, "yes") == 0);
// get original file name (defined by Notpad++) from the attribute
LocalizationSwitcher & localizationSwitcher = (NppParameters::getInstance())->getLocalizationSwitcher();
const char *fn = element->Attribute("fileName");
#ifdef UNICODE
if (fn)
{
localizationSwitcher.setFileName(fn);
}
#endif
if (stricmp("english.xml", fn) == 0)
{
_nativeLangA = NULL;
_toolIcons = NULL;
return;
}
// get encoding
TiXmlDeclarationA *declaration = _nativeLangA->GetDocument()->FirstChild()->ToDeclaration();
if (declaration)
@ -95,7 +111,7 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
}
}
}
}
}
else
_nativeLangA = NULL;

View File

@ -446,7 +446,7 @@ static int getKwClassFromName(const TCHAR *str) {
#ifdef UNICODE
#include "localizationString.h"
wstring LocalizationSwitcher::getLangFromXmlFileName(wchar_t *fn) const
wstring LocalizationSwitcher::getLangFromXmlFileName(const wchar_t *fn) const
{
size_t nbItem = sizeof(localizationDefs)/sizeof(LocalizationSwitcher::LocalizationDefinition);
for (size_t i = 0 ; i < nbItem ; i++)
@ -457,7 +457,7 @@ wstring LocalizationSwitcher::getLangFromXmlFileName(wchar_t *fn) const
return TEXT("");
}
wstring LocalizationSwitcher::getXmlFilePathFromLangName(wchar_t *langName) const
wstring LocalizationSwitcher::getXmlFilePathFromLangName(const wchar_t *langName) const
{
for (size_t i = 0 ; i < _localizationList.size() ; i++)
{

View File

@ -985,7 +985,7 @@ struct FindHistory {
class LocalizationSwitcher {
friend class NppParameters;
public :
LocalizationSwitcher() {};
LocalizationSwitcher() : _fileName("") {};
struct LocalizationDefinition {
wchar_t *_langName;
@ -993,9 +993,9 @@ public :
};
bool addLanguageFromXml(wstring xmlFullPath);
wstring getLangFromXmlFileName(wchar_t *fn) const;
wstring getLangFromXmlFileName(const wchar_t *fn) const;
wstring getXmlFilePathFromLangName(wchar_t *langName) const;
wstring getXmlFilePathFromLangName(const wchar_t *langName) const;
bool switchToLang(wchar_t *lang2switch) const;
size_t size() const {
@ -1008,9 +1008,19 @@ public :
return _localizationList[index];
};
void setFileName(const char *fn) {
if (fn)
_fileName = fn;
};
string getFileName() const {
return _fileName;
};
private :
vector< pair< wstring, wstring > > _localizationList;
wstring _nativeLangPath;
string _fileName;
};
#endif

View File

@ -182,6 +182,13 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
pair<wstring, wstring> localizationInfo = localizationSwitcher.getElementFromIndex(i);
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_ADDSTRING, 0, (LPARAM)localizationInfo.first.c_str());
}
string fn = localizationSwitcher.getFileName();
wstring fnW(fn.begin(), fn.end());
fnW.assign(fn.begin(), fn.end());
wstring lang = localizationSwitcher.getLangFromXmlFileName(fnW.c_str());
int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)lang.c_str());
if (index != CB_ERR)
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_SETCURSEL, index, 0);
#endif
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();