Unify Find Selection strings.
[geany-mirror.git] / geany.nsi
blob91ee67e1c1e78ceb0d2aa0a75be805c52c4ba66a
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; geany.nsi - this file is part of Geany, a fast and lightweight IDE
4 ; Copyright 2007-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 ; Copyright 2007-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 ; This program is free software; you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation; either version 2 of the License, or
10 ; (at your option) any later version.
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program; if not, write to the Free Software
19 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 ; $Id$
23 ; Installer script for Geany (Windows Installer)
24 ; (Script originally generated by the HM NIS Edit Script Wizard)
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ; Do a Cyclic Redundancy Check to make sure the installer was not corrupted by the download
29 CRCCheck force
30 RequestExecutionLevel highest ; set execution level for Windows Vista
32 ;;;;;;;;;;;;;;;;;;;
33 ; helper defines ;
34 ;;;;;;;;;;;;;;;;;;;
35 !define PRODUCT_NAME "Geany"
36 !define PRODUCT_VERSION "0.20"
37 !define PRODUCT_VERSION_ID "0.20.0.0"
38 !define PRODUCT_PUBLISHER "The Geany developer team"
39 !define PRODUCT_WEB_SITE "http://www.geany.org/"
40 !define PRODUCT_DIR_REGKEY "Software\Geany"
41 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
42 !define PRODUCT_EXE "$INSTDIR\bin\Geany.exe"
43 !define PRODUCT_REGNAME "Geany.ProjectFile"
44 !define PRODUCT_EXT ".geany"
45 !define RESOURCEDIR "geany-${PRODUCT_VERSION}"
47 ;;;;;;;;;;;;;;;;;;;;;
48 ; Version resource ;
49 ;;;;;;;;;;;;;;;;;;;;;
50 VIProductVersion "${PRODUCT_VERSION_ID}"
51 VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
52 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
53 VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
54 VIAddVersionKey "LegalCopyright" "Copyright 2005-2010 by the Geany developer team"
55 VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer"
57 BrandingText "$(^NAME) installer (NSIS 2.46)"
58 InstallDir "$PROGRAMFILES\Geany"
59 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
60 SetCompressor /SOLID lzma
61 ShowInstDetails hide
62 ShowUnInstDetails hide
63 XPStyle on
64 !ifdef INCLUDE_GTK
65 OutFile "geany-${PRODUCT_VERSION}_setup.exe"
66 !else
67 OutFile "geany-${PRODUCT_VERSION}_nogtk_setup.exe"
68 !endif
70 Var Answer
71 Var UserName
72 Var StartmenuFolder
73 Var UNINSTDIR
75 ;;;;;;;;;;;;;;;;
76 ; MUI Settings ;
77 ;;;;;;;;;;;;;;;;
78 !include "MUI2.nsh"
80 !define MUI_ABORTWARNING
81 !define MUI_ICON "icons\geany.ico"
82 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
84 ; Welcome page
85 !insertmacro MUI_PAGE_WELCOME
86 ; License page
87 ;!define MUI_LICENSEPAGE_RADIOBUTTONS
88 !insertmacro MUI_PAGE_LICENSE "${RESOURCEDIR}\Copying.txt"
89 ; Components page
90 !insertmacro MUI_PAGE_COMPONENTS
91 ; Directory page
92 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDirLeave
93 !insertmacro MUI_PAGE_DIRECTORY
94 ; Start menu page
95 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Geany"
96 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
97 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
98 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
99 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} "$StartmenuFolder"
100 ; Instfiles page
101 !insertmacro MUI_PAGE_INSTFILES
102 ; Finish page
103 !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\News.txt"
104 !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show Release Notes"
105 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
106 !define MUI_FINISHPAGE_RUN "$INSTDIR\bin\Geany.exe"
107 !define MUI_FINISHPAGE_RUN_NOTCHECKED
108 !insertmacro MUI_PAGE_FINISH
110 !insertmacro MUI_UNPAGE_INSTFILES ; Uninstaller page
111 !insertmacro MUI_LANGUAGE "English" ; Language file
113 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
114 ; Sections and InstTypes ;
115 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
116 InstType "Full"
117 InstType "Minimal"
119 Section "!Program Files" SEC01
120 SectionIn RO 1 2
121 SetOverwrite ifnewer
123 SetOutPath "$INSTDIR"
124 File "${RESOURCEDIR}\*.txt"
126 SetOutPath "$INSTDIR\bin"
127 File "${RESOURCEDIR}\bin\Geany.exe"
129 SetOutPath "$INSTDIR\data"
130 File "${RESOURCEDIR}\data\GPL-2"
131 File "${RESOURCEDIR}\data\file*"
132 File "${RESOURCEDIR}\data\snippets.conf"
133 File "${RESOURCEDIR}\data\ui_toolbar.xml"
135 SetOutPath "$INSTDIR\data\templates"
136 File /r "${RESOURCEDIR}\data\templates\*"
138 SetOutPath "$INSTDIR\share\icons"
139 File /r "${RESOURCEDIR}\share\icons\*"
141 SetOutPath "$INSTDIR"
143 CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
144 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
145 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
146 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
147 !insertmacro MUI_STARTMENU_WRITE_END
149 ; register the extension .geany
150 ; write information about file type
151 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
152 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
153 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
154 ; write information about file extensions
155 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
156 ; refresh shell
157 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
158 SectionEnd
160 Section "Plugins" SEC02
161 SectionIn 1
162 SetOverwrite ifnewer
163 SetOutPath "$INSTDIR\lib"
164 File "${RESOURCEDIR}\lib\*.dll"
165 SectionEnd
167 Section "Language Files" SEC03
168 SectionIn 1
169 SetOutPath "$INSTDIR\share\locale"
170 File /r "${RESOURCEDIR}\share\locale\*"
171 !ifdef INCLUDE_GTK
172 SetOutPath "$INSTDIR\share"
173 File /r "gtk\share\*"
174 !endif
175 SectionEnd
177 Section "Documentation" SEC04
178 SectionIn 1
179 SetOverwrite ifnewer
180 SetOutPath "$INSTDIR"
181 File /r "${RESOURCEDIR}\doc"
182 WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\doc\Manual.html"
183 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
184 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
185 !insertmacro MUI_STARTMENU_WRITE_END
186 SectionEnd
188 Section "Autocompletion Tags" SEC05
189 SectionIn 1
190 SetOutPath "$INSTDIR\data"
191 SetOverwrite ifnewer
192 File "${RESOURCEDIR}\data\php.tags"
193 File "${RESOURCEDIR}\data\pascal.tags"
194 File "${RESOURCEDIR}\data\python.tags"
195 File "${RESOURCEDIR}\data\html_entities.tags"
196 File "${RESOURCEDIR}\data\c99.tags"
197 SectionEnd
199 ; Include GTK runtime library but only if desired from command line
200 !ifdef INCLUDE_GTK
201 Section "GTK 2.16 Runtime Environment" SEC06
202 SectionIn 1
203 SetOverwrite ifnewer
204 SetOutPath "$INSTDIR\bin"
205 File /r "gtk\bin\*"
206 SetOutPath "$INSTDIR\etc"
207 File /r "gtk\etc\*"
208 SetOutPath "$INSTDIR\lib"
209 File /r "gtk\lib\*"
210 SectionEnd
211 !endif
213 Section "Context Menus" SEC07
214 SectionIn 1
215 WriteRegStr HKCR "*\shell\OpenWithGeany" "" "Open with Geany"
216 WriteRegStr HKCR "*\shell\OpenWithGeany\command" "" '"$INSTDIR\bin\geany.exe" "%1"'
217 SectionEnd
219 Section "Desktop Shortcuts" SEC08
220 SectionIn 1
221 CreateShortCut "$DESKTOP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
222 CreateShortCut "$QUICKLAUNCH\Geany.lnk" "$INSTDIR\bin\Geany.exe"
223 SectionEnd
225 Section -AdditionalIcons
226 SetOutPath $INSTDIR
227 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
228 WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
229 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "$INSTDIR\Website.url"
230 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe"
231 !insertmacro MUI_STARTMENU_WRITE_END
232 SectionEnd
234 Section -Post
235 WriteUninstaller "$INSTDIR\uninst.exe"
236 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
237 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
238 ${if} $Answer == "yes" ; if user is admin
239 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
240 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
241 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
242 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
243 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
244 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
245 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
246 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
247 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
248 ${endif}
249 SectionEnd
251 Section Uninstall
252 Delete "$INSTDIR\Website.url"
253 Delete "$INSTDIR\Documentation.url"
254 Delete "$INSTDIR\uninst.exe"
255 Delete "$INSTDIR\News.txt"
256 Delete "$INSTDIR\ReadMe.txt"
257 Delete "$INSTDIR\Thanks.txt"
258 Delete "$INSTDIR\ToDo.txt"
259 Delete "$INSTDIR\Authors.txt"
260 Delete "$INSTDIR\ChangeLog.txt"
261 Delete "$INSTDIR\Copying.txt"
262 Delete "$INSTDIR\Geany.lnk"
264 ; delete start menu entry
265 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
266 RMDir /r "$0"
268 Delete "$QUICKLAUNCH\Geany.lnk"
269 Delete "$DESKTOP\Geany.lnk"
271 RMDir /r "$INSTDIR\bin"
272 RMDir /r "$INSTDIR\doc"
273 RMDir /r "$INSTDIR\data"
274 RMDir /r "$INSTDIR\etc"
275 RMDir /r "$INSTDIR\lib"
276 RMDir /r "$INSTDIR\share"
277 RMDir "$INSTDIR"
279 ; remove .geany file extension
280 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
281 ${if} $R0 == "${PRODUCT_REGNAME}"
282 DeleteRegKey SHCTX "${PRODUCT_EXT}"
283 DeleteRegKey HKCR "${PRODUCT_EXT}"
284 DeleteRegKey SHCTX "${PRODUCT_REGNAME}"
285 DeleteRegKey HKCR "${PRODUCT_REGNAME}"
286 ${endif}
288 DeleteRegKey HKCR "*\shell\OpenWithGeany"
290 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
291 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
292 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
293 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
295 SetAutoClose true
296 SectionEnd
298 ;;;;;;;;;;;;;;;;;;;;;;;;;
299 ; Section descriptions ;
300 ;;;;;;;;;;;;;;;;;;;;;;;;;
301 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
302 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Required program files. You cannot skip these files."
303 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Available plugins like 'Version Diff', 'Class Builder' and 'Insert Special Characters'."
304 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Various translations of Geany's interface."
305 !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Manual in Text and HTML format."
306 !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "Symbol lists necessary for auto completion of symbols."
307 !ifdef INCLUDE_GTK
308 !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} "You need these files to run Geany. If you have already installed a GTK Runtime Environment (2.16 or higher), you can skip it."
309 !endif
310 !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} "Add context menu item 'Open With Geany'"
311 !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Create shortcuts for Geany on the desktop and in the Quicklaunch Bar"
312 !insertmacro MUI_FUNCTION_DESCRIPTION_END
314 ;;;;;;;;;;;;;;;;;;;;;
315 ; helper functions ;
316 ;;;;;;;;;;;;;;;;;;;;;
318 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
319 !macro IsUserAdmin Result UName
320 ClearErrors
321 UserInfo::GetName
322 IfErrors Win9x
323 Pop $0
324 StrCpy ${UName} $0
325 UserInfo::GetAccountType
326 Pop $1
327 ${if} $1 == "Admin"
328 StrCpy ${Result} "yes"
329 ${else}
330 StrCpy ${Result} "no"
331 ${endif}
332 Goto done
334 Win9x:
335 StrCpy ${Result} "yes"
336 done:
337 !macroend
339 Function .onInit
340 StrCpy "$StartmenuFolder" "Geany"
342 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
343 ; If the user does *not* have administrator privileges, abort
344 StrCpy $Answer ""
345 StrCpy $UserName ""
346 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
347 ${if} $Answer == "yes"
348 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
349 ${else}
350 SetShellVarContext current
351 ; TODO is this really what we want? $PROGRAMFILES is not much better because
352 ; probably the unprivileged user can't write it anyways
353 StrCpy $INSTDIR "$PROFILE\$(^Name)"
354 ${endif}
356 ; prevent running multiple instances of the installer
357 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
358 Pop $R0
359 StrCmp $R0 0 +3
360 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
361 Abort
362 ; warn about a new install over an existing installation
363 ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
364 StrCmp $R0 "" finish
366 MessageBox MB_YESNO|MB_ICONEXCLAMATION \
367 "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
368 /SD IDYES IDYES remove IDNO finish
370 remove:
371 ; run the uninstaller
372 ClearErrors
373 ; we read the installation path of the old installation from the Registry
374 ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
375 IfSilent dosilent nonsilent
376 dosilent:
377 ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
378 Goto finish
379 nonsilent:
380 ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
381 finish:
382 FunctionEnd
384 Function un.onUninstSuccess
385 HideWindow
386 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." \
387 /SD IDOK
388 FunctionEnd
390 Function un.onInit
391 ; If the user does *not* have administrator privileges, abort
392 StrCpy $Answer ""
393 !insertmacro IsUserAdmin $Answer $UserName
394 ${if} $Answer == "yes"
395 SetShellVarContext all
396 ${else}
397 ; check if the Geany has been installed with admin permisions
398 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
399 ${if} $0 != ""
400 MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Geany!" \
401 /SD IDOK
402 Abort
403 ${endif}
404 SetShellVarContext current
405 ${endif}
407 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" \
408 /SD IDYES IDYES +2
409 Abort
410 FunctionEnd
412 Function OnDirLeave
413 ClearErrors
414 SetOutPath "$INSTDIR" ; what about IfError creating $INSTDIR?
415 GetTempFileName $1 "$INSTDIR" ; creates tmp file (or fails)
416 FileOpen $0 "$1" "w" ; error to open?
417 FileWriteByte $0 "0"
418 IfErrors notPossible possible
420 notPossible:
421 RMDir "$INSTDIR" ; removes folder if empty
422 MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD IDOK
423 Abort
424 possible:
425 FileClose $0
426 Delete "$1"
427 FunctionEnd