mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 22:04:55 +02:00
[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:
parent
44913da6f2
commit
88958a855e
@ -85,6 +85,22 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
|
|||||||
if (rtl)
|
if (rtl)
|
||||||
_isRTL = (strcmp(rtl, "yes") == 0);
|
_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
|
// get encoding
|
||||||
TiXmlDeclarationA *declaration = _nativeLangA->GetDocument()->FirstChild()->ToDeclaration();
|
TiXmlDeclarationA *declaration = _nativeLangA->GetDocument()->FirstChild()->ToDeclaration();
|
||||||
if (declaration)
|
if (declaration)
|
||||||
@ -95,7 +111,7 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_nativeLangA = NULL;
|
_nativeLangA = NULL;
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ static int getKwClassFromName(const TCHAR *str) {
|
|||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
#include "localizationString.h"
|
#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);
|
size_t nbItem = sizeof(localizationDefs)/sizeof(LocalizationSwitcher::LocalizationDefinition);
|
||||||
for (size_t i = 0 ; i < nbItem ; i++)
|
for (size_t i = 0 ; i < nbItem ; i++)
|
||||||
@ -457,7 +457,7 @@ wstring LocalizationSwitcher::getLangFromXmlFileName(wchar_t *fn) const
|
|||||||
return TEXT("");
|
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++)
|
for (size_t i = 0 ; i < _localizationList.size() ; i++)
|
||||||
{
|
{
|
||||||
|
@ -985,7 +985,7 @@ struct FindHistory {
|
|||||||
class LocalizationSwitcher {
|
class LocalizationSwitcher {
|
||||||
friend class NppParameters;
|
friend class NppParameters;
|
||||||
public :
|
public :
|
||||||
LocalizationSwitcher() {};
|
LocalizationSwitcher() : _fileName("") {};
|
||||||
|
|
||||||
struct LocalizationDefinition {
|
struct LocalizationDefinition {
|
||||||
wchar_t *_langName;
|
wchar_t *_langName;
|
||||||
@ -993,9 +993,9 @@ public :
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool addLanguageFromXml(wstring xmlFullPath);
|
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;
|
bool switchToLang(wchar_t *lang2switch) const;
|
||||||
|
|
||||||
size_t size() const {
|
size_t size() const {
|
||||||
@ -1008,9 +1008,19 @@ public :
|
|||||||
return _localizationList[index];
|
return _localizationList[index];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void setFileName(const char *fn) {
|
||||||
|
if (fn)
|
||||||
|
_fileName = fn;
|
||||||
|
};
|
||||||
|
|
||||||
|
string getFileName() const {
|
||||||
|
return _fileName;
|
||||||
|
};
|
||||||
|
|
||||||
private :
|
private :
|
||||||
vector< pair< wstring, wstring > > _localizationList;
|
vector< pair< wstring, wstring > > _localizationList;
|
||||||
wstring _nativeLangPath;
|
wstring _nativeLangPath;
|
||||||
|
string _fileName;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -182,6 +182,13 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
|||||||
pair<wstring, wstring> localizationInfo = localizationSwitcher.getElementFromIndex(i);
|
pair<wstring, wstring> localizationInfo = localizationSwitcher.getElementFromIndex(i);
|
||||||
::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_ADDSTRING, 0, (LPARAM)localizationInfo.first.c_str());
|
::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
|
#endif
|
||||||
|
|
||||||
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
|
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user