Skip to content

Commit

Permalink
[BUG_FIXED] Fix context menu reload problem (plugin commands reload f…
Browse files Browse the repository at this point in the history
…ails).

- Notepad-plus svn trunk @ 691
  • Loading branch information
donho committed Oct 30, 2010
1 parent e714a63 commit 04034b9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
7 changes: 3 additions & 4 deletions PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}


Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/MISC/PluginsManager/PluginsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PluginsManager {
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);
Expand Down
5 changes: 3 additions & 2 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_pluginsManager.setMenu(_mainMenuHandle, NULL);

//Main menu is loaded, now load context menu items
pNppParam->getContextMenuFromXmlTree(_mainMenuHandle);
pNppParam->getContextMenuFromXmlTree(_mainMenuHandle, _pluginsManager.getMenuHandle());

if (pNppParam->hasCustomContextMenu())
{
Expand All @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,6 @@ bool NppParameters::load()
_pXmlContextMenuDoc = NULL;
isAllLaoded = false;
}
//else
//getContextMenuFromXmlTree();

//----------------------------//
// session.xml : for per user //
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++)
{
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1398,8 +1398,8 @@ class NppParameters
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
Expand Down
6 changes: 0 additions & 6 deletions PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 04034b9

Please sign in to comment.