[BUG_FIXED] Fix context menu reload problem (plugin commands reload fails).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@691 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2010-10-30 15:38:51 +00:00
parent 25755fd810
commit df0f0b3a30
6 changed files with 15 additions and 23 deletions

View File

@ -337,11 +337,10 @@ void PluginsManager::addInMenuFromPMIndex(int i)
*/
}
void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
HMENU PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
{
if (hasPlugins())
{
//vector<PluginCmdShortcut> & pluginCmdSCList = (NppParameters::getInstance())->getPluginCommandList();
const TCHAR *nom_menu = (menuName && menuName[0])?menuName:TEXT("Plugins");
if (!_hPluginsMenu)
@ -355,9 +354,9 @@ void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
{
addInMenuFromPMIndex(i);
}
//::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION, (unsigned int)-1, 0);
//::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION, (UINT_PTR)_hPluginsMenu, TEXT("BlackList"));
return _hPluginsMenu;
}
return NULL;
}

View File

@ -95,7 +95,7 @@ public:
void runPluginCommand(const TCHAR *pluginName, int commandID);
void addInMenuFromPMIndex(int i);
void setMenu(HMENU hMenu, const TCHAR *menuName);
HMENU setMenu(HMENU hMenu, const TCHAR *menuName);
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
void notify(SCNotification *notification);

View File

@ -425,9 +425,9 @@ LRESULT Notepad_plus::init(HWND hwnd)
//Plugin menu
_pluginsManager.setMenu(_mainMenuHandle, NULL);
//Main menu is loaded, now load context menu items
pNppParam->getContextMenuFromXmlTree(_mainMenuHandle);
pNppParam->getContextMenuFromXmlTree(_mainMenuHandle, _pluginsManager.getMenuHandle());
if (pNppParam->hasCustomContextMenu())
{
@ -439,6 +439,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_nativeLangSpeaker.changeMenuLang(_mainMenuHandle, pluginsTrans, windowTrans);
::DrawMenuBar(hwnd);
if (_pluginsManager.hasPlugins() && pluginsTrans != TEXT(""))
{
::ModifyMenu(_mainMenuHandle, MENUINDEX_PLUGINS, MF_BYPOSITION, 0, pluginsTrans.c_str());
@ -4390,7 +4391,7 @@ bool Notepad_plus::reloadLang()
_nativeLangSpeaker.init(nativeLangDocRootA, true);
pNppParam->reloadContextMenuFromXmlTree(_mainMenuHandle);
pNppParam->reloadContextMenuFromXmlTree(_mainMenuHandle, _pluginsManager.getMenuHandle());
generic_string pluginsTrans, windowTrans;
_nativeLangSpeaker.changeMenuLang(_mainMenuHandle, pluginsTrans, windowTrans);

View File

@ -1046,8 +1046,6 @@ bool NppParameters::load()
_pXmlContextMenuDoc = NULL;
isAllLaoded = false;
}
//else
//getContextMenuFromXmlTree();
//----------------------------//
// session.xml : for per user //
@ -1356,13 +1354,13 @@ void NppParameters::initScintillaKeys() {
prevID = skd.functionId;
}
}
bool NppParameters::reloadContextMenuFromXmlTree(HMENU mainMenuHadle)
bool NppParameters::reloadContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU pluginsMenu)
{
_contextMenuItems.clear();
return getContextMenuFromXmlTree(mainMenuHadle);
return getContextMenuFromXmlTree(mainMenuHadle, pluginsMenu);
}
bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle)
bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU pluginsMenu)
{
if (!_pXmlContextMenuDoc)
return false;
@ -1448,9 +1446,9 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle)
const TCHAR *pluginName = (childNode->ToElement())->Attribute(TEXT("PluginEntryName"));
const TCHAR *pluginCmdName = (childNode->ToElement())->Attribute(TEXT("PluginCommandItemName"));
if (pluginName && pluginCmdName)
// if plugin menu existing plls the value of PluginEntryName and PluginCommandItemName are valid
if (pluginsMenu && pluginName && pluginCmdName)
{
HMENU pluginsMenu = ::GetSubMenu(mainMenuHadle, MENUINDEX_PLUGINS);
int nbPlugins = ::GetMenuItemCount(pluginsMenu);
for (int i = 0 ; i < nbPlugins ; i++)
{

View File

@ -1398,8 +1398,8 @@ public:
return getPluginCmdsFromXmlTree();
}
bool getContextMenuFromXmlTree(HMENU mainMenuHadle);
bool reloadContextMenuFromXmlTree(HMENU mainMenuHadle);
bool getContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU pluginsMenu);
bool reloadContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU pluginsMenu);
winVer getWinVersion() { return _winVersion;};
FindHistory & getFindHistory() {return _findHistory;};
bool _isFindReplacing; // an on the fly variable for find/replace functions

View File

@ -51,10 +51,6 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
_printSettingsDlg.init(_hInst, _hSelf);
_printSettingsDlg.create(IDD_PREFERENCE_PRINT_BOX);
/*
_printSettings2Dlg.init(_hInst, _hSelf);
_printSettings2Dlg.create(IDD_PREFERENCE_PRINT2_BOX);
*/
_langMenuDlg.init(_hInst, _hSelf);
_langMenuDlg.create(IDD_PREFERENCE_LANG_BOX);
@ -67,7 +63,6 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
_wVector.push_back(DlgInfo(&_fileAssocDlg, TEXT("File Association"), TEXT("FileAssoc")));
_wVector.push_back(DlgInfo(&_langMenuDlg, TEXT("Language Menu/Tab Settings"), TEXT("LangMenu")));
_wVector.push_back(DlgInfo(&_printSettingsDlg, TEXT("Print"), TEXT("Print")));
//_wVector.push_back(DlgInfo(&_printSettings2Dlg, TEXT("Print - Header and Footer"), TEXT("Print2")));
_wVector.push_back(DlgInfo(&_backupDlg, TEXT("Backup/Auto-Completion"), TEXT("Backup")));
_wVector.push_back(DlgInfo(&_settingsDlg, TEXT("MISC."), TEXT("MISC")));
_ctrlTab.createTabs(_wVector);
@ -84,7 +79,6 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
_fileAssocDlg.reSizeTo(rc);
_langMenuDlg.reSizeTo(rc);
_printSettingsDlg.reSizeTo(rc);
//_printSettings2Dlg.reSizeTo(rc);
_backupDlg.reSizeTo(rc);
NppParameters *pNppParam = NppParameters::getInstance();