From 1dfa92c4b7e3f4acb26fe6dbfb632618c7a21d43 Mon Sep 17 00:00:00 2001 From: Pavel Nedev Date: Fri, 11 Jan 2019 16:36:01 +0200 Subject: [PATCH] Add 'Open Plugins Folder...' command Closes #5224, closees #5225 --- .../MISC/PluginsManager/PluginsManager.cpp | 38 ++++++++++--------- PowerEditor/src/NppCommands.cpp | 10 +++++ PowerEditor/src/menuCmdID.h | 3 +- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index ef4cd0d4..7a099761 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -477,31 +477,33 @@ void PluginsManager::addInMenuFromPMIndex(int i) HMENU PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName, bool enablePluginAdmin) { - if (hasPlugins() || enablePluginAdmin) + const TCHAR *nom_menu = (menuName && menuName[0])?menuName:TEXT("&Plugins"); + size_t nbPlugin = _pluginInfos.size(); + + if (!_hPluginsMenu) { - const TCHAR *nom_menu = (menuName && menuName[0])?menuName:TEXT("&Plugins"); - size_t nbPlugin = _pluginInfos.size(); + _hPluginsMenu = ::CreateMenu(); + ::InsertMenu(hMenu, MENUINDEX_PLUGINS, MF_BYPOSITION | MF_POPUP, (UINT_PTR)_hPluginsMenu, nom_menu); - if (!_hPluginsMenu) - { - _hPluginsMenu = ::CreateMenu(); - ::InsertMenu(hMenu, MENUINDEX_PLUGINS, MF_BYPOSITION | MF_POPUP, (UINT_PTR)_hPluginsMenu, nom_menu); + int i = 1; - if (enablePluginAdmin) - { - if (nbPlugin > 0) - ::InsertMenu(_hPluginsMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); - ::InsertMenu(_hPluginsMenu, 1, MF_BYPOSITION, IDM_SETTING_PLUGINADM, TEXT("Plugins Admin...")); - } - } + if (nbPlugin > 0) + ::InsertMenu(_hPluginsMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); - for (size_t i = 0; i < nbPlugin; ++i) + if (enablePluginAdmin) { - addInMenuFromPMIndex(static_cast(i)); + ::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION, IDM_SETTING_PLUGINADM, TEXT("Plugins Admin...")); + ::InsertMenu(_hPluginsMenu, i++, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); } - return _hPluginsMenu; + + ::InsertMenu(_hPluginsMenu, i, MF_BYPOSITION, IDM_SETTING_OPENPLUGINSDIR, TEXT("Open Plugins Folder...")); } - return NULL; + + for (size_t i = 0; i < nbPlugin; ++i) + { + addInMenuFromPMIndex(static_cast(i)); + } + return _hPluginsMenu; } diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 6165a0ce..93fbdfd3 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2499,6 +2499,16 @@ void Notepad_plus::command(int id) break; } + case IDM_SETTING_OPENPLUGINSDIR: + { + const TCHAR* pluginHomePath = NppParameters::getInstance()->getPluginRootDir(); + if (pluginHomePath && pluginHomePath[0]) + { + ::ShellExecute(NULL, NULL, pluginHomePath, NULL, NULL, SW_SHOWNORMAL); + } + break; + } + case IDM_SETTING_SHORTCUT_MAPPER : case IDM_SETTING_SHORTCUT_MAPPER_MACRO : case IDM_SETTING_SHORTCUT_MAPPER_RUN : diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 2c60cdba..3f2b2de7 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -548,7 +548,8 @@ #define IDM_SETTING_SHORTCUT_MAPPER (IDM_SETTING + 9) #define IDM_SETTING_REMEMBER_LAST_SESSION (IDM_SETTING + 10) #define IDM_SETTING_PREFERECE (IDM_SETTING + 11) - #define IDM_SETTING_PLUGINADM (IDM_SETTING + 15) + #define IDM_SETTING_PLUGINADM (IDM_SETTING + 14) + #define IDM_SETTING_OPENPLUGINSDIR (IDM_SETTING + 15) #define IDM_SETTING_SHORTCUT_MAPPER_MACRO (IDM_SETTING + 16) #define IDM_SETTING_SHORTCUT_MAPPER_RUN (IDM_SETTING + 17) #define IDM_SETTING_EDITCONTEXTMENU (IDM_SETTING + 18)