Rework GtkBuilder code to behave more like old Glade 2 code
[geany-mirror.git] / geany.nsi
blob429f8a14b76d8ee2a551399d19693e6eb05f9b0f
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; geany.nsi - this file is part of Geany, a fast and lightweight IDE
4 ; Copyright 2007-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 ; Copyright 2007-2011 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 "1.22"
36 !define PRODUCT_VERSION_ID "1.22.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}"
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-2011 by the Geany developer team"
54 VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer"
56 BrandingText "$(^NAME) installer (NSIS 2.46)"
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 !define MUI_ABORTWARNING
80 !define MUI_ICON "icons\geany.ico"
81 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
83 ; Welcome page
84 !insertmacro MUI_PAGE_WELCOME
85 ; License page
86 ;!define MUI_LICENSEPAGE_RADIOBUTTONS
87 !insertmacro MUI_PAGE_LICENSE "${RESOURCEDIR}\Copying.txt"
88 ; Components page
89 !insertmacro MUI_PAGE_COMPONENTS
90 ; Directory page
91 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDirLeave
92 !insertmacro MUI_PAGE_DIRECTORY
93 ; Start menu page
94 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Geany"
95 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
96 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
97 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
98 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} "$StartmenuFolder"
99 ; Instfiles page
100 !insertmacro MUI_PAGE_INSTFILES
101 ; Finish page
102 !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\News.txt"
103 !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show Release Notes"
104 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
105 !define MUI_FINISHPAGE_RUN "$INSTDIR\bin\Geany.exe"
106 !define MUI_FINISHPAGE_RUN_NOTCHECKED
107 !insertmacro MUI_PAGE_FINISH
109 !insertmacro MUI_UNPAGE_INSTFILES ; Uninstaller page
110 !insertmacro MUI_LANGUAGE "English" ; Language file
112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
113 ; Sections and InstTypes ;
114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
115 InstType "Full"
116 InstType "Minimal"
118 Section "!Program Files" SEC01
119 SectionIn RO 1 2
120 SetOverwrite ifnewer
122 SetOutPath "$INSTDIR"
123 File "${RESOURCEDIR}\*.txt"
125 SetOutPath "$INSTDIR\bin"
126 File "${RESOURCEDIR}\bin\Geany.exe"
128 SetOutPath "$INSTDIR\data"
129 File "${RESOURCEDIR}\data\GPL-2"
130 File "${RESOURCEDIR}\data\file*"
131 File "${RESOURCEDIR}\data\snippets.conf"
132 File "${RESOURCEDIR}\data\ui_toolbar.xml"
134 SetOutPath "$INSTDIR\data\templates"
135 File /r "${RESOURCEDIR}\data\templates\*"
137 SetOutPath "$INSTDIR\share\icons"
138 File /r "${RESOURCEDIR}\share\icons\*"
140 SetOutPath "$INSTDIR"
142 CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
143 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
144 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
145 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
146 !insertmacro MUI_STARTMENU_WRITE_END
148 ; register the extension .geany
149 ; write information about file type
150 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
151 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
152 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
153 ; write information about file extensions
154 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
155 ; refresh shell
156 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
157 SectionEnd
159 Section "Plugins" SEC02
160 SectionIn 1
161 SetOverwrite ifnewer
162 SetOutPath "$INSTDIR\lib"
163 File "${RESOURCEDIR}\lib\*.dll"
164 SectionEnd
166 Section "Language Files" SEC03
167 SectionIn 1
168 SetOutPath "$INSTDIR\share\locale"
169 File /r "${RESOURCEDIR}\share\locale\*"
170 !ifdef INCLUDE_GTK
171 SetOutPath "$INSTDIR\share"
172 File /r "gtk\share\*"
173 !endif
174 SectionEnd
176 Section "Documentation" SEC04
177 SectionIn 1
178 SetOverwrite ifnewer
179 SetOutPath "$INSTDIR"
180 File /r "${RESOURCEDIR}\doc"
181 WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\doc\Manual.html"
182 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
183 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
184 !insertmacro MUI_STARTMENU_WRITE_END
185 SectionEnd
187 Section "Autocompletion Tags" SEC05
188 SectionIn 1
189 SetOutPath "$INSTDIR\data"
190 SetOverwrite ifnewer
191 File "${RESOURCEDIR}\data\php.tags"
192 File "${RESOURCEDIR}\data\pascal.tags"
193 File "${RESOURCEDIR}\data\python.tags"
194 File "${RESOURCEDIR}\data\html_entities.tags"
195 File "${RESOURCEDIR}\data\c99.tags"
196 SectionEnd
198 ; Include GTK runtime library but only if desired from command line
199 !ifdef INCLUDE_GTK
200 Section "GTK 2.16 Runtime Environment" SEC06
201 SectionIn 1
202 SetOverwrite ifnewer
203 SetOutPath "$INSTDIR\bin"
204 File /r "gtk\bin\*"
205 SetOutPath "$INSTDIR\etc"
206 File /r "gtk\etc\*"
207 SetOutPath "$INSTDIR\lib"
208 File /r "gtk\lib\*"
209 SectionEnd
210 !endif
212 Section "Context Menus" SEC07
213 SectionIn 1
214 WriteRegStr HKCR "*\shell\OpenWithGeany" "" "Open with Geany"
215 WriteRegStr HKCR "*\shell\OpenWithGeany\command" "" '"$INSTDIR\bin\geany.exe" "%1"'
216 SectionEnd
218 Section "Desktop Shortcuts" SEC08
219 SectionIn 1
220 CreateShortCut "$DESKTOP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
221 CreateShortCut "$QUICKLAUNCH\Geany.lnk" "$INSTDIR\bin\Geany.exe"
222 SectionEnd
224 Section -AdditionalIcons
225 SetOutPath $INSTDIR
226 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
227 WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
228 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "$INSTDIR\Website.url"
229 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe"
230 !insertmacro MUI_STARTMENU_WRITE_END
231 SectionEnd
233 Section -Post
234 WriteUninstaller "$INSTDIR\uninst.exe"
235 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
236 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
237 ${if} $Answer == "yes" ; if user is admin
238 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
239 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
240 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
241 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
242 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
243 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
244 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
245 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
246 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
247 ${endif}
248 SectionEnd
250 Section Uninstall
251 Delete "$INSTDIR\Website.url"
252 Delete "$INSTDIR\Documentation.url"
253 Delete "$INSTDIR\uninst.exe"
254 Delete "$INSTDIR\News.txt"
255 Delete "$INSTDIR\ReadMe.txt"
256 Delete "$INSTDIR\Thanks.txt"
257 Delete "$INSTDIR\ToDo.txt"
258 Delete "$INSTDIR\Authors.txt"
259 Delete "$INSTDIR\ChangeLog.txt"
260 Delete "$INSTDIR\Copying.txt"
261 Delete "$INSTDIR\Geany.lnk"
263 ; delete start menu entry
264 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
265 RMDir /r "$0"
267 Delete "$QUICKLAUNCH\Geany.lnk"
268 Delete "$DESKTOP\Geany.lnk"
270 RMDir /r "$INSTDIR\bin"
271 RMDir /r "$INSTDIR\doc"
272 RMDir /r "$INSTDIR\data"
273 RMDir /r "$INSTDIR\etc"
274 RMDir /r "$INSTDIR\lib"
275 RMDir /r "$INSTDIR\share"
276 RMDir "$INSTDIR"
278 ; remove .geany file extension
279 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
280 ${if} $R0 == "${PRODUCT_REGNAME}"
281 DeleteRegKey SHCTX "${PRODUCT_EXT}"
282 DeleteRegKey HKCR "${PRODUCT_EXT}"
283 DeleteRegKey SHCTX "${PRODUCT_REGNAME}"
284 DeleteRegKey HKCR "${PRODUCT_REGNAME}"
285 ${endif}
287 DeleteRegKey HKCR "*\shell\OpenWithGeany"
289 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
290 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
291 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
292 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
294 SetAutoClose true
295 SectionEnd
297 ;;;;;;;;;;;;;;;;;;;;;;;;;
298 ; Section descriptions ;
299 ;;;;;;;;;;;;;;;;;;;;;;;;;
300 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
301 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Required program files. You cannot skip these files."
302 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Available plugins like 'Version Diff', 'Class Builder' and 'Insert Special Characters'."
303 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Various translations of Geany's interface."
304 !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Manual in Text and HTML format."
305 !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "Symbol lists necessary for auto completion of symbols."
306 !ifdef INCLUDE_GTK
307 !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."
308 !endif
309 !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} "Add context menu item 'Open With Geany'"
310 !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Create shortcuts for Geany on the desktop and in the Quicklaunch Bar"
311 !insertmacro MUI_FUNCTION_DESCRIPTION_END
313 ;;;;;;;;;;;;;;;;;;;;;
314 ; helper functions ;
315 ;;;;;;;;;;;;;;;;;;;;;
317 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
318 !macro IsUserAdmin Result UName
319 ClearErrors
320 UserInfo::GetName
321 IfErrors Win9x
322 Pop $0
323 StrCpy ${UName} $0
324 UserInfo::GetAccountType
325 Pop $1
326 ${if} $1 == "Admin"
327 StrCpy ${Result} "yes"
328 ${else}
329 StrCpy ${Result} "no"
330 ${endif}
331 Goto done
333 Win9x:
334 StrCpy ${Result} "yes"
335 done:
336 !macroend
338 Function .onInit
339 StrCpy "$StartmenuFolder" "Geany"
341 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
342 ; If the user does *not* have administrator privileges, abort
343 StrCpy $Answer ""
344 StrCpy $UserName ""
345 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
346 ${if} $Answer == "yes"
347 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
348 ${else}
349 SetShellVarContext current
350 ; TODO is this really what we want? $PROGRAMFILES is not much better because
351 ; probably the unprivileged user can't write it anyways
352 StrCpy $INSTDIR "$PROFILE\$(^Name)"
353 ${endif}
355 ; prevent running multiple instances of the installer
356 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
357 Pop $R0
358 StrCmp $R0 0 +3
359 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
360 Abort
361 ; warn about a new install over an existing installation
362 ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
363 StrCmp $R0 "" finish
365 MessageBox MB_YESNO|MB_ICONEXCLAMATION \
366 "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
367 /SD IDYES IDYES remove IDNO finish
369 remove:
370 ; run the uninstaller
371 ClearErrors
372 ; we read the installation path of the old installation from the Registry
373 ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
374 IfSilent dosilent nonsilent
375 dosilent:
376 ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
377 Goto finish
378 nonsilent:
379 ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
380 finish:
381 FunctionEnd
383 Function un.onUninstSuccess
384 HideWindow
385 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." \
386 /SD IDOK
387 FunctionEnd
389 Function un.onInit
390 ; If the user does *not* have administrator privileges, abort
391 StrCpy $Answer ""
392 !insertmacro IsUserAdmin $Answer $UserName
393 ${if} $Answer == "yes"
394 SetShellVarContext all
395 ${else}
396 ; check if the Geany has been installed with admin permisions
397 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
398 ${if} $0 != ""
399 MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Geany!" \
400 /SD IDOK
401 Abort
402 ${endif}
403 SetShellVarContext current
404 ${endif}
406 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" \
407 /SD IDYES IDYES +2
408 Abort
409 FunctionEnd
411 Function OnDirLeave
412 ClearErrors
413 SetOutPath "$INSTDIR" ; what about IfError creating $INSTDIR?
414 GetTempFileName $1 "$INSTDIR" ; creates tmp file (or fails)
415 FileOpen $0 "$1" "w" ; error to open?
416 FileWriteByte $0 "0"
417 IfErrors notPossible possible
419 notPossible:
420 RMDir "$INSTDIR" ; removes folder if empty
421 MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD IDOK
422 Abort
423 possible:
424 FileClose $0
425 Delete "$1"
426 FunctionEnd