diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 0c4834f68..fddf12276 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -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 & 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; } diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 371fe12f2..8273e19c1 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -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); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 0989fd897..c3fdb698f 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -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); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 6a0c7c014..c83382a60 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -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++) { diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 6a3ce628a..0146b1dd8 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -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 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 304aa7bdc..77250226b 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -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();