From 44baa33d1eddc68fe22a8fddf429d1bd9d503bea Mon Sep 17 00:00:00 2001 From: Don HO Date: Sat, 24 Nov 2018 17:30:19 +0100 Subject: [PATCH] Add the option to installer for installing the plugins in %PROGRAMDATA% --- PowerEditor/bin/pluginsForAllUsers_dummy.xml | 0 PowerEditor/installer/nppSetup.nsi | 18 ++++++++++++++++-- .../nsisInclude/mainSectionFuncs.nsh | 12 +++++++++++- PowerEditor/installer/nsisInclude/tools.nsh | 19 ++++++++++++++++++- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 PowerEditor/bin/pluginsForAllUsers_dummy.xml diff --git a/PowerEditor/bin/pluginsForAllUsers_dummy.xml b/PowerEditor/bin/pluginsForAllUsers_dummy.xml new file mode 100644 index 000000000..e69de29bb diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index c9f639428..46261028d 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -41,6 +41,8 @@ SetCompressor /SOLID lzma ; This reduces installer size by approx 30~35% ; Installer is DPI-aware: not scaled by the DWM, no blurry text ManifestDPIAware true +Var arePlugins4AllUsers + !include "nsisInclude\winVer.nsh" !include "nsisInclude\globalDef.nsh" !include "nsisInclude\tools.nsh" @@ -118,6 +120,7 @@ InstType "Minimalist" Var diffArchDir2Remove Var noUpdater + Function .onInit ${GetParameters} $R0 @@ -130,6 +133,16 @@ withoutUpdater: StrCpy $noUpdater "true" updaterDone: + ${GetOptions} $R0 "/pliginsForAllUsers" $R1 ;case insensitive + IfErrors withoutPlugins4AllUsers withPlugins4AllUsers +withPlugins4AllUsers: + StrCpy $arePlugins4AllUsers "true" + Goto plugins4AllUsersDone +withoutPlugins4AllUsers: + StrCpy $arePlugins4AllUsers "false" +plugins4AllUsersDone: + + ${If} $noUpdater == "true" !insertmacro UnSelectSection ${AutoUpdater} SectionSetText ${AutoUpdater} "" @@ -137,6 +150,7 @@ updaterDone: SectionSetText ${PluginsAdmin} "" ${EndIf} + ${If} ${SectionIsSelected} ${PluginsAdmin} !insertmacro SetSectionFlag ${AutoUpdater} ${SF_RO} !insertmacro SelectSection ${AutoUpdater} @@ -204,9 +218,9 @@ Section -"Notepad++" mainSection Call removeUnstablePlugins Call removeOldContextMenu - + Call shortcutLinkManagement - + SectionEnd ; Please **DONOT** move this function (SetRoughEstimation) anywhere else diff --git a/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh b/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh index 5ec167645..0fa283774 100644 --- a/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh +++ b/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh @@ -56,6 +56,16 @@ initUpdatePath: StrCpy $UPDATE_PATH "$APPDATA\${APPNAME}" CreateDirectory $UPDATE_PATH\plugins\config ${EndIf} + + ; override PLUGIN_INST_PATH + ${If} $arePlugins4AllUsers == "true" + ReadEnvStr $0 "ALLUSERSPROFILE" + StrCpy $PLUGIN_INST_PATH "$0\Notepad++\plugins" + File /oname=$INSTDIR\pluginsForAllUsers.xml "..\bin\pluginsForAllUsers_dummy.xml" + ${ELSE} + Delete $INSTDIR\pluginsForAllUsers.xml + ${EndIf} + alreadyDone: FunctionEnd @@ -121,7 +131,7 @@ Function removeUnstablePlugins Delete "$INSTDIR\plugins\HexEditorPlugin.dll" IfFileExists "$INSTDIR\plugins\HexEditor.dll" 0 +4 - MessageBox MB_OK "Due to the stability issue,$\nHexEditor.dll will be moved to the directory $\"disabled$\"" /SD IDOK + MessageBox MB_OK "Due to the stability issue,$\nHexEditor.dll will be moved to the directory $\"disabled$\"" /SD IDOK Rename "$INSTDIR\plugins\HexEditor.dll" "$INSTDIR\plugins\disabled\HexEditor.dll" Delete "$INSTDIR\plugins\HexEditor.dll" diff --git a/PowerEditor/installer/nsisInclude/tools.nsh b/PowerEditor/installer/nsisInclude/tools.nsh index 2ee287e4d..60fd46cb0 100644 --- a/PowerEditor/installer/nsisInclude/tools.nsh +++ b/PowerEditor/installer/nsisInclude/tools.nsh @@ -81,6 +81,7 @@ FunctionEnd ;Installer Functions Var Dialog Var NoUserDataCheckboxHandle +Var Plugin4AllUsersCheckboxHandle Var ShortcutCheckboxHandle Var WinVer @@ -98,7 +99,14 @@ Function ExtraOptions ${NSD_Check} $ShortcutCheckboxHandle ${NSD_OnClick} $ShortcutCheckboxHandle OnChange_ShortcutCheckBox - ${NSD_CreateCheckbox} 0 80 100% 30u "Don't use %APPDATA%$\nEnable this option to make Notepad++ load/write the configuration files from/to its install directory. Check it if you use Notepad++ in a USB device." + ${NSD_CreateCheckbox} 0 80 100% 30u "Check this will make your plugin installed for all users on this PC." + Pop $Plugin4AllUsersCheckboxHandle + ${If} $arePlugins4AllUsers == "true" + ${NSD_Check} $Plugin4AllUsersCheckboxHandle + ${EndIf} + ${NSD_OnClick} $Plugin4AllUsersCheckboxHandle OnChange_Plugin4AllUsersCheckBox + + ${NSD_CreateCheckbox} 0 160 100% 30u "Don't use %APPDATA%$\nEnable this option to make Notepad++ load/write the configuration files from/to its install directory. Check it if you use Notepad++ in a USB device." Pop $NoUserDataCheckboxHandle ${NSD_OnClick} $NoUserDataCheckboxHandle OnChange_NoUserDataCheckBox @@ -134,6 +142,15 @@ Function OnChange_ShortcutCheckBox ${NSD_GetState} $ShortcutCheckboxHandle $createShortcutChecked FunctionEnd +Function OnChange_Plugin4AllUsersCheckBox + ${NSD_GetState} $ShortcutCheckboxHandle $0 + ${If} $0 == ${BST_CHECKED} + StrCpy $arePlugins4AllUsers "true" + ${ELSE} + StrCpy $arePlugins4AllUsers "false" + ${EndIf} +FunctionEnd + Function writeInstallInfoInRegistry WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad++.exe" "" "$INSTDIR\notepad++.exe"