Bump API version for new plugin entry points (oops)
[geany-mirror.git] / geany.nsi.in
blob9f55362c3d99934bf9253922fd5565566175c7cb
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; geany.nsi - this file is part of Geany, a fast and lightweight IDE
4 ; Copyright 2007-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 ; Copyright 2007-2012 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.
22 ; Installer script for Geany (Windows Installer)
23 ; (Script originally generated by the HM NIS Edit Script Wizard)
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ; Do a Cyclic Redundancy Check to make sure the installer was not corrupted by the download
28 CRCCheck force
29 RequestExecutionLevel highest ; set execution level for Windows Vista
31 ;;;;;;;;;;;;;;;;;;;
32 ; helper defines ;
33 ;;;;;;;;;;;;;;;;;;;
34 !define PRODUCT_NAME "Geany"
35 !define PRODUCT_VERSION "@VERSION@"
36 !define PRODUCT_VERSION_ID "@VERSION@.0.0"
37 !define PRODUCT_PUBLISHER "The Geany developer team"
38 !define PRODUCT_WEB_SITE "http://www.geany.org/"
39 !define PRODUCT_DIR_REGKEY "Software\Geany"
40 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
41 !define PRODUCT_EXE "$INSTDIR\bin\Geany.exe"
42 !define PRODUCT_REGNAME "Geany.ProjectFile"
43 !define PRODUCT_EXT ".geany"
44 !define RESOURCEDIR "geany-${PRODUCT_VERSION}"
45 !define GTK_VERSION @GTK_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-2014 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"
128 File "${RESOURCEDIR}\bin\*Geany*.dll"
130 SetOutPath "$INSTDIR\data"
131 File "${RESOURCEDIR}\data\GPL-2"
132 File "${RESOURCEDIR}\data\file*"
133 File "${RESOURCEDIR}\data\geany.glade"
134 !if ${GTK_VERSION} >= 3
135 File "${RESOURCEDIR}\data\geany.css"
136 !else
137 File "${RESOURCEDIR}\data\geany.gtkrc"
138 !endif
139 File "${RESOURCEDIR}\data\snippets.conf"
140 File "${RESOURCEDIR}\data\ui_toolbar.xml"
142 SetOutPath "$INSTDIR\data\templates"
143 File /r "${RESOURCEDIR}\data\templates\*"
145 SetOutPath "$INSTDIR\data\colorschemes"
146 File /r "${RESOURCEDIR}\data\colorschemes\*"
147 # Geany color schemes project, don't bail out if they are missing
148 File /nonfatal /r "..\geany-themes\colorschemes\*.conf"
150 SetOutPath "$INSTDIR\share\icons"
151 File /r "${RESOURCEDIR}\share\icons\*"
153 SetOutPath "$INSTDIR"
155 CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
156 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
157 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
158 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
159 !insertmacro MUI_STARTMENU_WRITE_END
161 ; register the extension .geany
162 ; write information about file type
163 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
164 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
165 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
166 ; write information about file extensions
167 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
168 ; refresh shell
169 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
170 SectionEnd
172 Section "Plugins" SEC02
173 SectionIn 1
174 SetOverwrite ifnewer
175 SetOutPath "$INSTDIR\lib\geany"
176 File "${RESOURCEDIR}\lib\geany\*.dll"
177 SectionEnd
179 Section "Language Files" SEC03
180 SectionIn 1
181 SetOutPath "$INSTDIR\share\locale"
182 File /r "${RESOURCEDIR}\share\locale\*"
183 !ifdef INCLUDE_GTK
184 SetOutPath "$INSTDIR\share\locale"
185 File /r "gtk\share\locale\*"
186 !endif
187 SectionEnd
189 Section "Documentation" SEC04
190 SectionIn 1
191 SetOverwrite ifnewer
192 SetOutPath "$INSTDIR"
193 File /r "${RESOURCEDIR}\doc"
194 WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\doc\Manual.html"
195 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
196 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
197 !insertmacro MUI_STARTMENU_WRITE_END
198 SectionEnd
200 Section "Autocompletion Tags" SEC05
201 SectionIn 1
202 SetOutPath "$INSTDIR\data"
203 SetOverwrite ifnewer
204 File "${RESOURCEDIR}\data\php.tags"
205 File "${RESOURCEDIR}\data\pascal.tags"
206 File "${RESOURCEDIR}\data\python.tags"
207 File "${RESOURCEDIR}\data\html_entities.tags"
208 File "${RESOURCEDIR}\data\c99.tags"
209 SectionEnd
211 ; Include GTK runtime library but only if desired from command line
212 !ifdef INCLUDE_GTK
213 Section "GTK ${GTK_VERSION} Runtime Environment" SEC06
214 SectionIn 1
215 SetOverwrite ifnewer
216 SetOutPath "$INSTDIR\bin"
217 File /r "gtk\bin\*"
218 SetOutPath "$INSTDIR\etc"
219 File /r "gtk\etc\*"
220 SetOutPath "$INSTDIR\lib"
221 File /r "gtk\lib\*"
222 SetOutPath "$INSTDIR\share\themes"
223 File /r "gtk\share\themes\*"
224 !if ${GTK_VERSION} >= 3
225 SetOutPath "$INSTDIR\share\icons"
226 File /r "gtk\share\icons\*"
227 SetOutPath "$INSTDIR\share\glib-2.0"
228 File /r "gtk\share\glib-2.0\*"
229 SetOutPath "$INSTDIR\share\gtk-3.0"
230 File /r "gtk\share\gtk-3.0\*"
231 !endif
232 SectionEnd
233 !endif
235 Section "Context Menus" SEC07
236 SectionIn 1
237 WriteRegStr HKCR "*\shell\OpenWithGeany" "" "Open with Geany"
238 WriteRegStr HKCR "*\shell\OpenWithGeany" "Icon" "$INSTDIR\bin\geany.exe"
239 WriteRegStr HKCR "*\shell\OpenWithGeany\command" "" '"$INSTDIR\bin\geany.exe" "%1"'
240 SectionEnd
242 Section "Desktop Shortcuts" SEC08
243 SectionIn 1
244 CreateShortCut "$DESKTOP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
245 CreateShortCut "$QUICKLAUNCH\Geany.lnk" "$INSTDIR\bin\Geany.exe"
246 SectionEnd
248 ; Development files
249 Section "Development files" SEC09
250 SetOverwrite ifnewer
251 SetOutPath "$INSTDIR\include"
252 File /r "${RESOURCEDIR}\include\*"
254 SetOutPath "$INSTDIR\lib\pkgconfig"
255 File "${RESOURCEDIR}\lib\pkgconfig\geany.pc"
256 SectionEnd
258 Section -AdditionalIcons
259 SetOutPath $INSTDIR
260 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
261 WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
262 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "$INSTDIR\Website.url"
263 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe"
264 !insertmacro MUI_STARTMENU_WRITE_END
265 SectionEnd
267 Section -Post
268 WriteUninstaller "$INSTDIR\uninst.exe"
269 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
270 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
271 ${if} $Answer == "yes" ; if user is admin
272 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
273 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
274 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
275 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
276 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
277 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
278 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
279 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
280 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
281 ${endif}
282 SectionEnd
284 Section Uninstall
285 Delete "$INSTDIR\Website.url"
286 Delete "$INSTDIR\Documentation.url"
287 Delete "$INSTDIR\uninst.exe"
288 Delete "$INSTDIR\News.txt"
289 Delete "$INSTDIR\ReadMe.txt"
290 Delete "$INSTDIR\Thanks.txt"
291 Delete "$INSTDIR\ToDo.txt"
292 Delete "$INSTDIR\Authors.txt"
293 Delete "$INSTDIR\ChangeLog.txt"
294 Delete "$INSTDIR\Copying.txt"
295 Delete "$INSTDIR\Geany.lnk"
297 ; delete start menu entry
298 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
299 RMDir /r "$0"
301 Delete "$QUICKLAUNCH\Geany.lnk"
302 Delete "$DESKTOP\Geany.lnk"
304 RMDir /r "$INSTDIR\bin"
305 RMDir /r "$INSTDIR\doc"
306 RMDir /r "$INSTDIR\data"
307 RMDir /r "$INSTDIR\etc"
308 RMDir /r "$INSTDIR\include"
309 RMDir /r "$INSTDIR\lib"
310 RMDir /r "$INSTDIR\share"
311 RMDir "$INSTDIR"
313 ; remove .geany file extension
314 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
315 ${if} $R0 == "${PRODUCT_REGNAME}"
316 DeleteRegKey SHCTX "${PRODUCT_EXT}"
317 DeleteRegKey HKCR "${PRODUCT_EXT}"
318 DeleteRegKey SHCTX "${PRODUCT_REGNAME}"
319 DeleteRegKey HKCR "${PRODUCT_REGNAME}"
320 ${endif}
322 DeleteRegKey HKCR "*\shell\OpenWithGeany"
324 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
325 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
326 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
327 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
329 SetAutoClose true
330 SectionEnd
332 ;;;;;;;;;;;;;;;;;;;;;;;;;
333 ; Section descriptions ;
334 ;;;;;;;;;;;;;;;;;;;;;;;;;
335 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
336 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Required program files. You cannot skip these files."
337 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Available plugins like 'Version Diff', 'Class Builder' and 'Insert Special Characters'."
338 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Various translations of Geany's interface."
339 !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Manual in Text and HTML format."
340 !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "Symbol lists necessary for auto completion of symbols."
341 !ifdef INCLUDE_GTK
342 !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."
343 !endif
344 !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} "Add context menu item 'Open With Geany'"
345 !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Create shortcuts for Geany on the desktop and in the Quicklaunch Bar"
346 !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."
347 !insertmacro MUI_FUNCTION_DESCRIPTION_END
349 ;;;;;;;;;;;;;;;;;;;;;
350 ; helper functions ;
351 ;;;;;;;;;;;;;;;;;;;;;
353 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
354 !macro IsUserAdmin Result UName
355 ClearErrors
356 UserInfo::GetName
357 IfErrors Win9x
358 Pop $0
359 StrCpy ${UName} $0
360 UserInfo::GetAccountType
361 Pop $1
362 ${if} $1 == "Admin"
363 StrCpy ${Result} "yes"
364 ${else}
365 StrCpy ${Result} "no"
366 ${endif}
367 Goto done
369 Win9x:
370 StrCpy ${Result} "yes"
371 done:
372 !macroend
374 Function .onInit
375 StrCpy "$StartmenuFolder" "Geany"
377 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
378 ; If the user does *not* have administrator privileges, abort
379 StrCpy $Answer ""
380 StrCpy $UserName ""
381 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
382 ${if} $Answer == "yes"
383 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
384 ${else}
385 SetShellVarContext current
386 ; TODO is this really what we want? $PROGRAMFILES is not much better because
387 ; probably the unprivileged user can't write it anyways
388 StrCpy $INSTDIR "$PROFILE\$(^Name)"
389 ${endif}
391 ; prevent running multiple instances of the installer
392 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
393 Pop $R0
394 StrCmp $R0 0 +3
395 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
396 Abort
397 ; warn about a new install over an existing installation
398 ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
399 StrCmp $R0 "" finish
401 MessageBox MB_YESNO|MB_ICONEXCLAMATION \
402 "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
403 /SD IDYES IDYES remove IDNO finish
405 remove:
406 ; run the uninstaller
407 ClearErrors
408 ; we read the installation path of the old installation from the Registry
409 ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
410 IfSilent dosilent nonsilent
411 dosilent:
412 ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
413 Goto finish
414 nonsilent:
415 ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
416 finish:
417 FunctionEnd
419 Function un.onUninstSuccess
420 HideWindow
421 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." \
422 /SD IDOK
423 FunctionEnd
425 Function un.onInit
426 ; If the user does *not* have administrator privileges, abort
427 StrCpy $Answer ""
428 !insertmacro IsUserAdmin $Answer $UserName
429 ${if} $Answer == "yes"
430 SetShellVarContext all
431 ${else}
432 ; check if the Geany has been installed with admin permisions
433 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
434 ${if} $0 != ""
435 MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Geany!" \
436 /SD IDOK
437 Abort
438 ${endif}
439 SetShellVarContext current
440 ${endif}
442 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" \
443 /SD IDYES IDYES +2
444 Abort
445 FunctionEnd
447 Function OnDirLeave
448 ClearErrors
449 SetOutPath "$INSTDIR" ; what about IfError creating $INSTDIR?
450 GetTempFileName $1 "$INSTDIR" ; creates tmp file (or fails)
451 FileOpen $0 "$1" "w" ; error to open?
452 FileWriteByte $0 "0"
453 IfErrors notPossible possible
455 notPossible:
456 RMDir "$INSTDIR" ; removes folder if empty
457 MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD IDOK
458 Abort
459 possible:
460 FileClose $0
461 Delete "$1"
462 FunctionEnd