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