Apply patch from Yoann Le Montagner to set VTE bold color (thanks,
[geany-mirror.git] / geany.nsi
blob36f7497c971d200b3fa5e5e0a669e981d53b86cb
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 user ; set execution level for Windows Vista
32 ;;;;;;;;;;;;;;;;;;;
33 ; helper defines ;
34 ;;;;;;;;;;;;;;;;;;;
35 !define PRODUCT_NAME "Geany"
36 !define PRODUCT_VERSION "0.19"
37 !define PRODUCT_VERSION_ID "0.19.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.45)"
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\share\icons"
136 File /r "${RESOURCEDIR}\share\icons\*"
138 SetOutPath "$INSTDIR"
140 CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
141 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
142 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
143 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
144 !insertmacro MUI_STARTMENU_WRITE_END
146 ; register the extension .geany
147 ; write information about file type
148 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
149 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
150 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
151 ; write information about file extensions
152 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
153 ; refresh shell
154 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
155 SectionEnd
157 Section "Plugins" SEC02
158 SectionIn 1
159 SetOverwrite ifnewer
160 SetOutPath "$INSTDIR\lib"
161 File "${RESOURCEDIR}\lib\*.dll"
162 SectionEnd
164 Section "Language Files" SEC03
165 SectionIn 1
166 SetOutPath "$INSTDIR\share\locale"
167 File /r "${RESOURCEDIR}\share\locale\*"
168 !ifdef INCLUDE_GTK
169 SetOutPath "$INSTDIR\share"
170 File /r "gtk\share\*"
171 !endif
172 SectionEnd
174 Section "Documentation" SEC04
175 SectionIn 1
176 SetOverwrite ifnewer
177 SetOutPath "$INSTDIR"
178 File /r "${RESOURCEDIR}\doc"
179 WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\doc\Manual.html"
180 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
181 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
182 !insertmacro MUI_STARTMENU_WRITE_END
183 SectionEnd
185 Section "Autocompletion Tags" SEC05
186 SectionIn 1
187 SetOutPath "$INSTDIR\data"
188 SetOverwrite ifnewer
189 File "${RESOURCEDIR}\data\php.tags"
190 File "${RESOURCEDIR}\data\pascal.tags"
191 File "${RESOURCEDIR}\data\python.tags"
192 File "${RESOURCEDIR}\data\html_entities.tags"
193 File "${RESOURCEDIR}\data\c99.tags"
194 SectionEnd
196 ; Include GTK runtime library but only if desired from command line
197 !ifdef INCLUDE_GTK
198 Section "GTK 2.16 Runtime Environment" SEC06
199 SectionIn 1
200 SetOverwrite ifnewer
201 SetOutPath "$INSTDIR\bin"
202 File /r "gtk\bin\*"
203 SetOutPath "$INSTDIR\etc"
204 File /r "gtk\etc\*"
205 SetOutPath "$INSTDIR\lib"
206 File /r "gtk\lib\*"
207 SectionEnd
208 !endif
210 Section "Context Menus" SEC07
211 SectionIn 1
212 WriteRegStr HKCR "*\shell\OpenWithGeany" "" "Open with Geany"
213 WriteRegStr HKCR "*\shell\OpenWithGeany\command" "" '"$INSTDIR\bin\geany.exe" "%1"'
214 SectionEnd
216 Section "Desktop Shortcuts" SEC08
217 SectionIn 1
218 CreateShortCut "$DESKTOP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
219 CreateShortCut "$QUICKLAUNCH\Geany.lnk" "$INSTDIR\bin\Geany.exe"
220 SectionEnd
222 Section -AdditionalIcons
223 SetOutPath $INSTDIR
224 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
225 WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
226 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "$INSTDIR\Website.url"
227 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe"
228 !insertmacro MUI_STARTMENU_WRITE_END
229 SectionEnd
231 Section -Post
232 WriteUninstaller "$INSTDIR\uninst.exe"
233 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
234 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
235 ${if} $Answer == "yes" ; if user is admin
236 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
237 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
238 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
239 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
240 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
241 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
242 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
243 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
244 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
245 ${endif}
246 SectionEnd
248 Section Uninstall
249 Delete "$INSTDIR\Website.url"
250 Delete "$INSTDIR\Documentation.url"
251 Delete "$INSTDIR\uninst.exe"
252 Delete "$INSTDIR\News.txt"
253 Delete "$INSTDIR\ReadMe.txt"
254 Delete "$INSTDIR\Thanks.txt"
255 Delete "$INSTDIR\ToDo.txt"
256 Delete "$INSTDIR\Authors.txt"
257 Delete "$INSTDIR\ChangeLog.txt"
258 Delete "$INSTDIR\Copying.txt"
259 Delete "$INSTDIR\Geany.lnk"
261 ; delete start menu entry
262 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
263 RMDir /r "$0"
265 Delete "$QUICKLAUNCH\Geany.lnk"
266 Delete "$DESKTOP\Geany.lnk"
268 RMDir /r "$INSTDIR\bin"
269 RMDir /r "$INSTDIR\doc"
270 RMDir /r "$INSTDIR\data"
271 RMDir /r "$INSTDIR\etc"
272 RMDir /r "$INSTDIR\lib"
273 RMDir /r "$INSTDIR\share"
274 RMDir "$INSTDIR"
276 ; remove .geany file extension
277 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
278 ${if} $R0 == "${PRODUCT_REGNAME}"
279 DeleteRegKey SHCTX "${PRODUCT_EXT}"
280 DeleteRegKey HKCR "${PRODUCT_EXT}"
281 DeleteRegKey SHCTX "${PRODUCT_REGNAME}"
282 DeleteRegKey HKCR "${PRODUCT_REGNAME}"
283 ${endif}
285 DeleteRegKey HKCR "*\shell\OpenWithGeany"
287 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
288 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
289 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
290 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
292 SetAutoClose true
293 SectionEnd
295 ;;;;;;;;;;;;;;;;;;;;;;;;;
296 ; Section descriptions ;
297 ;;;;;;;;;;;;;;;;;;;;;;;;;
298 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
299 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Required program files. You cannot skip these files."
300 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Available plugins like 'Version Diff', 'Class Builder' and 'Insert Special Characters'."
301 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Various translations of Geany's interface."
302 !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Manual in Text and HTML format."
303 !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "Symbol lists necessary for auto completion of symbols."
304 !ifdef INCLUDE_GTK
305 !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."
306 !endif
307 !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} "Add context menu item 'Open With Geany'"
308 !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Create shortcuts for Geany on the desktop and in the Quicklaunch Bar"
309 !insertmacro MUI_FUNCTION_DESCRIPTION_END
311 ;;;;;;;;;;;;;;;;;;;;;
312 ; helper functions ;
313 ;;;;;;;;;;;;;;;;;;;;;
315 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
316 !macro IsUserAdmin Result UName
317 ClearErrors
318 UserInfo::GetName
319 IfErrors Win9x
320 Pop $0
321 StrCpy ${UName} $0
322 UserInfo::GetAccountType
323 Pop $1
324 ${if} $1 == "Admin"
325 StrCpy ${Result} "yes"
326 ${else}
327 StrCpy ${Result} "no"
328 ${endif}
329 Goto done
331 Win9x:
332 StrCpy ${Result} "yes"
333 done:
334 !macroend
336 Function .onInit
337 StrCpy "$StartmenuFolder" "Geany"
339 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
340 ; If the user does *not* have administrator privileges, abort
341 StrCpy $Answer ""
342 StrCpy $UserName ""
343 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
344 ${if} $Answer == "yes"
345 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
346 ${else}
347 SetShellVarContext current
348 ; TODO is this really what we want? $PROGRAMFILES is not much better because
349 ; probably the unprivileged user can't write it anyways
350 StrCpy $INSTDIR "$PROFILE\$(^Name)"
351 ${endif}
353 ; prevent running multiple instances of the installer
354 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
355 Pop $R0
356 StrCmp $R0 0 +3
357 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
358 Abort
359 ; warn about a new install over an existing installation
360 ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
361 StrCmp $R0 "" finish
363 MessageBox MB_YESNO|MB_ICONEXCLAMATION \
364 "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
365 /SD IDYES IDYES remove IDNO finish
367 remove:
368 ; run the uninstaller
369 ClearErrors
370 ; we read the installation path of the old installation from the Registry
371 ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
372 IfSilent dosilent nonsilent
373 dosilent:
374 ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
375 Goto finish
376 nonsilent:
377 ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
378 finish:
379 FunctionEnd
381 Function un.onUninstSuccess
382 HideWindow
383 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." \
384 /SD IDOK
385 FunctionEnd
387 Function un.onInit
388 ; If the user does *not* have administrator privileges, abort
389 StrCpy $Answer ""
390 !insertmacro IsUserAdmin $Answer $UserName
391 ${if} $Answer == "yes"
392 SetShellVarContext all
393 ${else}
394 ; check if the Geany has been installed with admin permisions
395 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
396 ${if} $0 != ""
397 MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Geany!" \
398 /SD IDOK
399 Abort
400 ${endif}
401 SetShellVarContext current
402 ${endif}
404 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" \
405 /SD IDYES IDYES +2
406 Abort
407 FunctionEnd
409 Function OnDirLeave
410 ClearErrors
411 SetOutPath "$INSTDIR" ; what about IfError creating $INSTDIR?
412 GetTempFileName $1 "$INSTDIR" ; creates tmp file (or fails)
413 FileOpen $0 "$1" "w" ; error to open?
414 FileWriteByte $0 "0"
415 IfErrors notPossible possible
417 notPossible:
418 RMDir "$INSTDIR" ; removes folder if empty
419 MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD IDOK
420 Abort
421 possible:
422 FileClose $0
423 Delete "$1"
424 FunctionEnd