Code

Win32 uninstaller: remove empty directory lib/locale
[inkscape.git] / packaging / win32 / inkscape.nsi
1 ; Instructions for compilers
2 ; ==========================
3 ; This file generates the Inkscape installer, which is currently the
4 ; preferred deployment method on Windows.
5 ; 1. Install NSIS 2.46 or later on Windows (2.45 has a !searchparse bug
6 ;    which breaks it and earlier doesn't support Windows 7 properly, and
7 ;    cross-compilation probably won't work due to some !system magic)
8 ; 2. Compile Inkscape (http://wiki.inkscape.org/wiki/index.php/Win32Port)
9 ; 3. Compile this file with NSIS. There should be no need to set version
10 ;    numbers in this file as it gets them from the Bazaar branch info and
11 ;    ..\..\src\inkscape-version.cpp. However, if the version number comes
12 ;    out wrong or this script didn't compile properly then you can define
13 ;    INKSCAPE_VERSION by uncommenting the next line and setting the correct
14 ;    value:
15 ;      !define INKSCAPE_VERSION "0.48"
16 ;    If you ever need to do a second, third or Nth release of the build or
17 ;    of the installer, then change the RELEASE_REVISION value below:
18        !define RELEASE_REVISION 1
20 ; There should never be any need for packagers to touch anything below
21 ; this line.  That's my job - Chris Morgan
23 ; Installer code {{{1
24 ; Compression and admin requirement {{{2
25 SetCompressor /SOLID lzma
26 SetCompressorDictSize 32
27 RequestExecutionLevel admin
29 ; Include required files {{{2
30 !include RequireLatestNSIS.nsh
31 !include ifexist.nsh
32 !include VersionCompleteXXXX.nsh
33 !include LogicLib.nsh
34 !include Sections.nsh
36 !macro !redef VAR VAL
37   !define _!redef_${VAR} `${VAL}`
38   !ifdef ${VAR}
39     !undef ${VAR}
40   !endif
41   !define ${VAR} `${VAL}`
42   !undef _!redef_${VAR}
43 !macroend
44 !define !redef `!insertmacro !redef`
46 ; Advanced Uninstall Log {{{3
47 ; We're abusing this script terribly and it's time to fix the broken uninstaller.
48 ; However, for the moment, this is what we're using.
49 !define INSTDIR_REG_ROOT HKLM
50 !define INSTDIR_REG_KEY "${UNINST_KEY}"
51 !include AdvUninstLog.nsh
52 !insertmacro INTERACTIVE_UNINSTALL
54 ; Initialise NSIS plug-ins {{{3
55 ; The plugins used are md5dll and messagebox
56 !addplugindir .
58 ; FileFunc bits and pieces {{{3
59 !include FileFunc.nsh
60 !insertmacro GetParameters
61 !insertmacro GetOptions
62 !insertmacro un.GetParent
64 ; User interface {{{3
65 !include MUI.nsh
66 ; MUI Configuration {{{4
67 !define MUI_ABORTWARNING
68 !define MUI_ICON ..\..\inkscape.ico
69 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
70 !define MUI_HEADERIMAGE
71 !define MUI_HEADERIMAGE_BITMAP header.bmp
72 !define MUI_WELCOMEFINISHPAGE_BITMAP welcomefinish.bmp
73 !define MUI_COMPONENTSPAGE_SMALLDESC
75 ; Pages {{{4
76 ; Installer pages {{{5
77 ; Welcome page {{{6
78 !insertmacro MUI_PAGE_WELCOME
79 ; License page {{{6
80 LicenseForceSelection off
81 ;!define MUI_LICENSEPAGE_RADIOBUTTONS
82 !define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)"
83 !define MUI_LICENSEPAGE_TEXT_BOTTOM "$(LICENSE_BOTTOM_TEXT)"
84 !insertmacro MUI_PAGE_LICENSE ..\..\Copying
85 ; Components page {{{6
86 !insertmacro MUI_PAGE_COMPONENTS
87 ; InstType "$(Full)"
88 ; InstType "$(Optimal)"
89 ; InstType "$(Minimal)"
90 ; Directory page {{{6
91 !insertmacro MUI_PAGE_DIRECTORY
92 ; Instfiles page {{{6
93 !insertmacro MUI_PAGE_INSTFILES
94 ; Finish page {{{6
95 !define MUI_FINISHPAGE_RUN "$INSTDIR\inkscape.exe"
96 !insertmacro MUI_PAGE_FINISH
98 ; Uninstaller pages {{{5
99 !insertmacro MUI_UNPAGE_CONFIRM
100 UninstPage custom un.CustomPageUninstall
101 !insertmacro MUI_UNPAGE_INSTFILES
102 ShowUninstDetails hide
103 !insertmacro MUI_UNPAGE_FINISH
105 ; Localization {{{3
106 ; See also the "Languages sections" SectionGroup lower down.
107 !insertmacro MUI_RESERVEFILE_LANGDLL
108 ;TODO: check if `!insertmacro LANGFILE "English" "English"`-style lines are needed (don't think it should be due to MUI_LANGUAGE)
109 !echo `Loading language files...`
110 !verbose push
111 !verbose 3
112 !insertmacro MUI_LANGUAGE "English"
113 !insertmacro LANGFILE_INCLUDE "languages\English.nsh"
114 !macro INKLANGFILE _LANG
115   !insertmacro MUI_LANGUAGE "${_LANG}"
116   !insertmacro LANGFILE_INCLUDE_WITHDEFAULT "languages\${_LANG}.nsh" "languages\English.nsh"
117 !macroend
118 !insertmacro INKLANGFILE Breton
119 !insertmacro INKLANGFILE Catalan
120 !insertmacro INKLANGFILE Czech
121 !insertmacro INKLANGFILE Finnish
122 !insertmacro INKLANGFILE French
123 !insertmacro INKLANGFILE Galician
124 !insertmacro INKLANGFILE German
125 !insertmacro INKLANGFILE Italian
126 !insertmacro INKLANGFILE Japanese
127 !insertmacro INKLANGFILE Polish
128 !insertmacro INKLANGFILE Romanian
129 !insertmacro INKLANGFILE Russian
130 !insertmacro INKLANGFILE Slovak
131 !insertmacro INKLANGFILE Slovenian
132 !insertmacro INKLANGFILE Spanish
133 !insertmacro INKLANGFILE SimpChinese
134 !insertmacro INKLANGFILE TradChinese
135 !verbose pop
137 ReserveFile inkscape.nsi.uninstall
138 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
139 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
141 ; #######################################
142 ; SETTINGS
143 ; #######################################
145 ; Product details (version, name, registry keys etc.) {{{2
146 ; Find the version number in inkscape-version.cpp (e.g. 0.47+devel) {{{3
147 !ifndef INKSCAPE_VERSION
148   ; Official release format (no newlines)
149   !searchparse /noerrors /file ..\..\src\inkscape-version.cpp `namespace Inkscape {  char const *version_string = "` INKSCAPE_VERSION ` r` BZR_REVISION `";  }`
150   !ifndef INKSCAPE_VERSION
151     ; Other format; sorry, it has to be done in two steps.
152     !searchparse /noerrors /file ..\..\src\inkscape-version.cpp `char const *version_string = "` INKSCAPE_VERSION `";`
153     !searchparse /noerrors `${INKSCAPE_VERSION}` `` INKSCAPE_VERSION ` r` BZR_REVISION
154     !ifndef INKSCAPE_VERSION
155       !error "INKSCAPE_VERSION not defined and unable to get version number from ..\..\src\inkscape-version.cpp!"
156     !endif
157   !endif
158 !endif
159 !echo `Got version number from ..\..\src\inkscape-version.cpp: ${INKSCAPE_VERSION}`
160 !define FILENAME Inkscape-${INKSCAPE_VERSION}
161 !define BrandingText `Inkscape ${INKSCAPE_VERSION}`
163 ; Check for the Bazaar revision number for lp:inkscape {{{3
164 ${!ifexist} ..\..\.bzr\branch\last-revision
165   !if `${BZR_REVISION}` == ``
166     !undef BZR_REVISION
167   !endif
168   !ifndef BZR_REVISION
169     !searchparse /noerrors /file ..\..\.bzr\branch\last-revision "" BZR_REVISION " "
170   !endif
171 !endif
173 ; Check for devel builds and clear up bzr revision number define {{{3
174 !searchparse /noerrors ${INKSCAPE_VERSION} "" INKSCAPE_VERSION_NUMBER "+devel"
175 !if ${INKSCAPE_VERSION_NUMBER} != ${INKSCAPE_VERSION}
176   !define DEVEL
177 !endif
178 !if `${BZR_REVISION}` == ``
179   !undef BZR_REVISION
180 !endif
182 ; Handle display version number and complete X.X version numbers into X.X.X.X {{{3
183 !ifdef DEVEL & BZR_REVISION
184   ${!redef} FILENAME `${FILENAME}-r${BZR_REVISION}`
185   ${!redef} BrandingText `${BrandingText} r${BZR_REVISION}`
186   !define VERSION_X.X.X.X_REVISION ${BZR_REVISION}
187 ; Handle the installer revision number {{{4
188 !else ifdef RELEASE_REVISION
189   ${!redef} FILENAME `${FILENAME}-${RELEASE_REVISION}`
190   ${!redef} BrandingText `${BrandingText}, revision ${BZR_REVISION}`
191   !define VERSION_X.X.X.X_REVISION ${RELEASE_REVISION}
192 !else
193   !define VERSION_X.X.X.X_REVISION 0
194 !endif
196 ${VersionCompleteXXXN} ${INKSCAPE_VERSION_NUMBER} VERSION_X.X.X.X ${VERSION_X.X.X.X_REVISION}
198 ; Product definitions {{{3
199 !define PRODUCT_NAME "Inkscape" ; TODO: fix up the language files to not use this and kill this line
200 !define INSTDIR_KEY "Software\Microsoft\Windows\CurrentVersion\App Paths\inkscape.exe"
201 !define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Inkscape"
202 ;!define DUMMYINSTALL ; Define this to make it build quickly, not including any of the files or code in the sections, for quick testing of features of the installer and development thereof.
203 !define _FILENAME ${FILENAME}.exe
204 !undef FILENAME
205 !define FILENAME ${_FILENAME}
206 !undef _FILENAME
208 ; Product information {{{3
209 Name              `Inkscape`
210 Caption           `Inkscape - $(CaptionDescription)`
211 BrandingText      `${BrandingText}`
212 OutFile           `${FILENAME}`
213 InstallDir        "$PROGRAMFILES\Inkscape"
214 InstallDirRegKey  HKLM "${INSTDIR_KEY}" ""
216 ; Version information {{{3
217 VIProductVersion ${VERSION_X.X.X.X}
218 VIAddVersionKey ProductName Inkscape
219 VIAddVersionKey Comments "Licensed under the GNU GPL"
220 VIAddVersionKey CompanyName inkscape.org
221 VIAddVersionKey LegalCopyright "© 2009 Inkscape"
222 VIAddVersionKey FileDescription Inkscape
223 VIAddVersionKey FileVersion ${VERSION_X.X.X.X}
224 VIAddVersionKey ProductVersion ${VERSION_X.X.X.X}
225 VIAddVersionKey InternalName Inkscape
227 ; Variables {{{2
228 Var askMultiUser
229 Var filename
230 Var MultiUser
231 Var User
232 Var CMDARGS
234 !macro delprefs ; Delete preferences (originally from VLC) {{{2
235   StrCpy $0 0
236   DetailPrint "Deleting personal preferences..."
237   DetailPrint "Finding all users..."
238   ${Do}
239   ; this will loop through all the logged users and "virtual" windows users
240   ; (it looks like users are only present in HKEY_USERS when they are logged in)
241     ClearErrors
242     EnumRegKey $1 HKU "" $0
243     ${IfThen} $1 == "" ${|} ${ExitDo} ${|}
244     IntOp $0 $0 + 1
245     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
246     ${IfThen} $2 == "" ${|} ${Continue} ${|}
247     DetailPrint "Removing $2\Inkscape"
248     Delete $2\Inkscape\preferences.xml
249     Delete $2\Inkscape\extension-errors.log
250     RMDir  $2\Inkscape
251   ${Loop}
252 !macroend
254 ; Sections (these do the work) {{{2
256 Section -removeInkscape ; Hidden, mandatory section to clean a previous installation {{{
257 !ifndef DUMMYINSTALL
258   ;remove the old Inkscape shortcuts from the startmenu
259   ;just in case they are still there
260   SetShellVarContext current
261   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
262   Delete  $SMPROGRAMS\Inkscape\Inkscape.lnk
263   RMDir   $SMPROGRAMS\Inkscape
264   Delete  $SMPROGRAMS\Inkscape.lnk
265   SetShellVarContext all
266   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
267   Delete  $SMPROGRAMS\Inkscape\Inkscape.lnk
268   RMDir   $SMPROGRAMS\Inkscape
269   Delete  $SMPROGRAMS\Inkscape.lnk
270 !endif
271 SectionEnd ; -removeInkscape }}}
273 Section $(Core) SecCore ; Mandatory Inkscape core files section {{{
274   SectionIn 1 2 3 RO
275 !ifndef DUMMYINSTALL
276   DetailPrint "Installing Inkscape core files..."
277   SetOutPath $INSTDIR
278   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
279   SetOverwrite on
280   SetAutoClose false
282   File           /a    ..\..\inkscape\ink*.exe
283   File           /a    ..\..\inkscape\AUTHORS
284   File           /a    ..\..\inkscape\COPYING
285   File           /a    ..\..\inkscape\COPYING.LIB
286   File           /a    ..\..\inkscape\NEWS
287   File           /a    ..\..\inkscape\gspawn-win32-helper.exe
288   File           /a    ..\..\inkscape\gspawn-win32-helper-console.exe
289   File /nonfatal /a    ..\..\inkscape\HACKING.txt
290   File           /a    ..\..\inkscape\README
291   File /nonfatal /a    ..\..\inkscape\README.txt
292   File           /a    ..\..\inkscape\TRANSLATORS
293   File /nonfatal /a /r ..\..\inkscape\data
294   File /nonfatal /a /r ..\..\inkscape\doc
295   File /nonfatal /a /r ..\..\inkscape\plugins
296   File /nonfatal /a /r /x *.??*.???* /x examples /x tutorials ..\..\inkscape\share
297   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
298   ; this files are added because it slips through the filter
299   SetOutPath $INSTDIR\share\clipart
300   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
301   File /a ..\..\inkscape\share\clipart\inkscape.logo.svg
302   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
303   SetOutPath $INSTDIR\share\icons
304   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
305   File /a ..\..\inkscape\share\icons\inkscape.file.png
306   File /a ..\..\inkscape\share\icons\inkscape.file.svg
307   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
308   SetOutPath $INSTDIR\modules
309   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
310   File /nonfatal /a /r ..\..\inkscape\modules\*.*
311   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
312   SetOutPath $INSTDIR\python
313   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
314   File /nonfatal /a /r ..\..\inkscape\python\*.*
315   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
316 !endif
317 SectionEnd ; SecCore }}}
319 Section $(GTKFiles) SecGTK ; Mandatory GTK files section {{{
320   SectionIn 1 2 3 RO
321 !ifndef DUMMYINSTALL
322   DetailPrint "Installing GTK files..."
323   SetOutPath $INSTDIR
324   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
325   SetOverwrite on
326   File /a /r ..\..\inkscape\*.dll
327   File /a /r /x locale ..\..\inkscape\lib
328   File /a /r ..\..\inkscape\etc
329   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
330 !endif
331 SectionEnd ; SecGTK }}}
333 Section -SetCurrentUserOnly ; Set the installation to "current user" only by default {{{
334 !ifndef DUMMYINSTALL
335   StrCpy $MultiUser 0
336   SetShellVarContext current
337 !endif
338 SectionEnd ; -SetCurrentUserOnly }}}
340 Section $(Alluser) SecAlluser ; Then offer the user the option to make it global (default) {{{
341   SectionIn 1 2 3
342 !ifndef DUMMYINSTALL
343   ; disable this option in Win95/Win98/WinME
344   StrCpy $MultiUser 1
345   DetailPrint "Installing in administrator mode (registry root will be HKLM)"
346   SetShellVarContext all
347 !endif
348 SectionEnd ; SecAllUser }}}
350 SectionGroup "$(Shortcuts)" SecShortcuts ; Create shortcuts for the user {{{
352 Section $(Desktop) SecDesktop ; Desktop shortcut {{{
353 !ifndef DUMMYINSTALL
354   CreateShortCut $DESKTOP\Inkscape.lnk $INSTDIR\inkscape.exe
355 !endif
356 SectionEnd ; SecDesktop }}}
358 Section $(Quicklaunch) SecQuickLaunch ; Quick Launch shortcut {{{
359 !ifndef DUMMYINSTALL
360   ${IfThen} $QUICKLAUNCH != $TEMP ${|} CreateShortCut $QUICKLAUNCH\Inkscape.lnk $INSTDIR\inkscape.exe ${|}
361 !endif
362 SectionEnd ; SecQuickLaunch }}}
364 Section $(SVGWriter) SecSVGWriter ; Register Inkscape as the default application for .svg[z] {{{
365   SectionIn 1 2 3
366 !ifndef DUMMYINSTALL
367   DetailPrint "Associating SVG files with Inkscape"
368   StrCpy $3 svg
369   ${For} $2 0 1
370     ${IfThen} $2 = 1 ${|} StrCpy $3 $3z ${|}
371     ReadRegStr $0 HKCR ".$3" ""
372     ${If} $0 == ""
373       StrCpy $0 "$3file"
374       WriteRegStr HKCR ".$3" "" $0
375       WriteRegStr HKCR $0 "" "Scalable Vector Graphics file"
376     ${EndIf}
377     WriteRegStr HKCR $0\shell\edit\command "" `"$INSTDIR\Inkscape.exe" "%1"`
378   ${Next}
379 !endif
380 SectionEnd ; SecSVGWriter }}}
382 Section $(ContextMenu) SecContextMenu ; Put Inkscape in the .svg[z] context menus (but not as default) {{{
383   SectionIn 1 2 3
384 !ifndef DUMMYINSTALL
385   DetailPrint "Adding Inkscape to SVG file context menu"
386   ReadRegStr $0 HKCR .svg ""
387   ${If} $0 == ""
388     StrCpy $0 svgfile
389     WriteRegStr HKCR .svg "" $0
390     WriteRegStr HKCR $0 "" "Scalable Vector Graphics file"
391   ${EndIf}
392   WriteRegStr HKCR $0\shell\Inkscape\command "" `"$INSTDIR\Inkscape.exe" "%1"`
394   ReadRegStr $0 HKCR .svgz ""
395   ${If} $0 == ""
396     StrCpy $0 svgzfile
397     WriteRegStr HKCR .svgz "" $0
398     WriteRegStr HKCR $0 "" "Scalable Vector Graphics file"
399   ${EndIf}
400   WriteRegStr HKCR $0\shell\Inkscape\command "" `"$INSTDIR\Inkscape.exe" "%1"`
401 !endif
402 SectionEnd ; SecContextMenu }}}
404 SectionGroupEnd ; SecShortcuts }}}
406 Section /o "$(DeletePrefs)" SecPrefs ; Delete user preferences before installation {{{
407 !ifndef DUMMYINSTALL
408   !insertmacro delprefs
409 !endif
410 SectionEnd ; SecPrefs }}}
412 SectionGroup "$(Addfiles)" SecAddfiles ; Additional files {{{
414 Section $(Examples) SecExamples ; Install example SVG files {{{
415   SectionIn 1 2
416 !ifndef DUMMYINSTALL
417   SetOutPath $INSTDIR\share
418   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
419   File /nonfatal /a /r /x *.??*.???* ..\..\inkscape\share\examples
420   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
421 !endif
422 SectionEnd ; SecExamples }}}
424 Section $(Tutorials) SecTutorials ; Install tutorials {{{
425   SectionIn 1 2
426 !ifndef DUMMYINSTALL
427   SetOutPath $INSTDIR\share
428   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
429   File /nonfatal /a /r /x *.??*.???* ..\..\inkscape\share\tutorials
430   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
431 !endif
432 SectionEnd ; SecTutorials }}}
434 SectionGroupEnd ; SecAddfiles }}}
436 SectionGroup "$(Languages)" SecLanguages ; Languages sections {{{
437   !macro Language SecName lng ; A macro to create each section {{{
438     Section /o "$(lng_${lng}) (${lng})" Sec${SecName}
439       ;SectionIn 1 2 3
440     !ifndef DUMMYINSTALL
441       SetOutPath $INSTDIR
442       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
443       File /nonfatal /a ..\..\inkscape\*.${lng}.txt ; FIXME: remove this?  No such files.
444       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
445       SetOutPath $INSTDIR\locale
446       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
447       File /nonfatal /a /r ..\..\inkscape\locale\${lng}
448       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
449       SetOutPath $INSTDIR\lib\locale
450       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
451       File /nonfatal /a /r ..\..\inkscape\lib\locale\${lng}
452       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
453       SetOutPath $INSTDIR\share\clipart
454       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
455       File /nonfatal /a /r ..\..\inkscape\share\clipart\*.${lng}.svg
456       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
457       ; the keyboard tables
458       SetOutPath $INSTDIR\share\screens
459       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
460       File /nonfatal /a /r ..\..\inkscape\share\screens\*.${lng}.svg
461       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
462       SetOutPath $INSTDIR\share\templates
463       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
464       File /nonfatal /a /r ..\..\inkscape\share\templates\*.${lng}.svg
465       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
466       SetOutPath $INSTDIR\doc
467       !insertmacro UNINSTALL.LOG_OPEN_INSTALL
468       File /nonfatal /a /r ..\..\inkscape\doc\keys.${lng}.xml
469       File /nonfatal /a /r ..\..\inkscape\doc\keys.${lng}.html
470       !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
471       SectionGetFlags ${SecTutorials} $R1
472       IntOp $R1 $R1 & ${SF_SELECTED}
473       ${If} $R1 >= ${SF_SELECTED}
474         SetOutPath $INSTDIR\share\tutorials
475         !insertmacro UNINSTALL.LOG_OPEN_INSTALL
476         File /nonfatal /a ..\..\inkscape\share\tutorials\*.${lng}.*
477         !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
478       ${EndIf}
479     !endif
480     SectionEnd
481   !macroend ; Language }}}
483   ; Now create each section with the Language macro {{{
484   !insertmacro Language Amharic           am
485   !insertmacro Language Arabic            ar
486   !insertmacro Language Azerbaijani       az
487   !insertmacro Language Byelorussian      be
488   !insertmacro Language Bulgarian         bg
489   !insertmacro Language Bengali           bn
490   !insertmacro Language Breton            br
491   !insertmacro Language Catalan           ca
492   !insertmacro Language CatalanValencia   ca@valencia
493   !insertmacro Language Czech             cs
494   !insertmacro Language Danish            da
495   !insertmacro Language German            de
496   !insertmacro Language Dzongkha          dz
497   !insertmacro Language Greek             el
498   !insertmacro Language EnglishAustralian en_AU
499   !insertmacro Language EnglishCanadian   en_CA
500   !insertmacro Language EnglishBritain    en_GB
501   !insertmacro Language EnglishPiglatin   en_US@piglatin
502   !insertmacro Language Esperanto         eo
503   !insertmacro Language Spanish           es
504   !insertmacro Language SpanishMexico     es_MX
505   !insertmacro Language Estonian          et
506   !insertmacro Language Basque            eu
507   !insertmacro Language French            fr
508   !insertmacro Language Finnish           fi
509   !insertmacro Language Irish             ga
510   !insertmacro Language Gallegan          gl
511   !insertmacro Language Hebrew            he
512   !insertmacro Language Croatian          hr
513   !insertmacro Language Hungarian         hu
514   !insertmacro Language Indonesian        id
515   !insertmacro Language Italian           it
516   !insertmacro Language Japanese          ja
517   !insertmacro Language Khmer             km
518   !insertmacro Language Korean            ko
519   !insertmacro Language Lithuanian        lt
520   !insertmacro Language Mongolian         mn
521   !insertmacro Language Macedonian        mk
522   !insertmacro Language NorwegianBokmal   nb
523   !insertmacro Language Nepali            ne
524   !insertmacro Language Dutch             nl
525   !insertmacro Language NorwegianNynorsk  nn
526   !insertmacro Language Panjabi           pa
527   !insertmacro Language Polish            pl
528   !insertmacro Language Portuguese        pt
529   !insertmacro Language PortugueseBrazil  pt_BR
530   !insertmacro Language Romanian          ro
531   !insertmacro Language Russian           ru
532   !insertmacro Language Kinyarwanda       rw
533   !insertmacro Language Slovak            sk
534   !insertmacro Language Slovenian         sl
535   !insertmacro Language Albanian          sq
536   !insertmacro Language Serbian           sr
537   !insertmacro Language SerbianLatin      sr@latin
538   !insertmacro Language Swedish           sv
539   !insertmacro Language Thai              th
540   !insertmacro Language Turkish           tr
541   !insertmacro Language Ukrainian         uk
542   !insertmacro Language Vietnamese        vi
543   !insertmacro Language ChineseSimplified zh_CN
544   !insertmacro Language ChineseTaiwan     zh_TW
545   ; }}}
546 SectionGroupEnd ; SecLanguages }}}
548 Section -FinalizeInstallation ; Hidden, mandatory section to finalize installation {{{
549 !ifndef DUMMYINSTALL
550   DetailPrint "Finalizing installation"
551   ${IfThen} $MultiUser  = 1 ${|} SetShellVarContext all ${|}
552   ${IfThen} $MultiUser != 1 ${|} SetShellVarContext current ${|}
554   WriteRegStr SHCTX "${INSTDIR_KEY}" ""           $INSTDIR\inkscape.exe
555   WriteRegStr SHCTX "${INSTDIR_KEY}" MultiUser    $MultiUser
556   WriteRegStr SHCTX "${INSTDIR_KEY}" askMultiUser $askMultiUser
557   WriteRegStr SHCTX "${INSTDIR_KEY}" User         $User
559   ; start menu entries
560   CreateShortcut $SMPROGRAMS\Inkscape.lnk $INSTDIR\inkscape.exe
562   ; uninstall settings
563   ; WriteUninstaller $INSTDIR\uninst.exe
564   WriteRegExpandStr SHCTX "${UNINST_KEY}" UninstallString ${UNINST_EXE}
565   WriteRegExpandStr SHCTX "${UNINST_KEY}" InstallDir      $INSTDIR
566   WriteRegExpandStr SHCTX "${UNINST_KEY}" InstallLocation $INSTDIR
567   WriteRegStr       SHCTX "${UNINST_KEY}" DisplayName     "Inkscape ${INKSCAPE_VERSION}"
568   WriteRegStr       SHCTX "${UNINST_KEY}" DisplayIcon     $INSTDIR\Inkscape.exe,0
569   WriteRegStr       SHCTX "${UNINST_KEY}" DisplayVersion  ${INKSCAPE_VERSION}
570   WriteRegDWORD     SHCTX "${UNINST_KEY}" NoModify        1
571   WriteRegDWORD     SHCTX "${UNINST_KEY}" NoRepair        1
573   ;create/update log always within .onInstSuccess function
574   !insertmacro UNINSTALL.LOG_UPDATE_INSTALL
576   DetailPrint "Creating MD5 checksums"
577   ClearErrors
578   FileOpen $0 $INSTDIR\Uninstall.dat r
579   FileOpen $9 $INSTDIR\Uninstall.log w
580   ${IfNot} ${Errors}
581     ${Do}
582       ClearErrors
583       FileRead $0 $1
584       ${IfThen} ${Errors} ${|} ${ExitDo} ${|}
585       StrCpy $1 $1 -2
586       md5dll::GetMD5File /NOUNLOAD $1
587       Pop $2
588       ${IfThen} $2 != "" ${|} FileWrite $9 "$2  $1$\r$\n" ${|}
589     ${Loop}
590   ${EndIf}
591   FileClose $0
592   FileClose $9
593   ; Not needed any more
594   Delete $INSTDIR\Uninstall.dat
595 !endif
596 SectionEnd ; -FinalizeInstallation }}}
598 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN ; Section descriptions {{{
599   !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(CoreDesc)"
600   !insertmacro MUI_DESCRIPTION_TEXT ${SecGTK} "$(GTKFilesDesc)"
601   !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} "$(ShortcutsDesc)"
602   !insertmacro MUI_DESCRIPTION_TEXT ${SecAlluser} "$(AlluserDesc)"
603   !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(DesktopDesc)"
604   !insertmacro MUI_DESCRIPTION_TEXT ${SecQuicklaunch} "$(QuicklaunchDesc)"
605   !insertmacro MUI_DESCRIPTION_TEXT ${SecSVGWriter} "$(SVGWriterDesc)"
606   !insertmacro MUI_DESCRIPTION_TEXT ${SecContextMenu} "$(ContextMenuDesc)"
607   !insertmacro MUI_DESCRIPTION_TEXT ${SecPrefs} "$(DeletePrefsDesc)"
608   !insertmacro MUI_DESCRIPTION_TEXT ${SecAddfiles} "$(AddfilesDesc)"
609   !insertmacro MUI_DESCRIPTION_TEXT ${SecExamples} "$(ExamplesDesc)"
610   !insertmacro MUI_DESCRIPTION_TEXT ${SecTutorials} "$(TutorialsDesc)"
611   !insertmacro MUI_DESCRIPTION_TEXT ${SecLanguages} "$(LanguagesDesc)"
612 !insertmacro MUI_FUNCTION_DESCRIPTION_END ; Section descriptions }}}
615 Function .onInit ; initialise the installer {{{2
616   ; This code will be executed before the sections, but due to the
617   ; language code in the sections it must come after it in the code.
619   ; Language detection {{{
620   !insertmacro MUI_LANGDLL_DISPLAY
622   !macro LanguageAutoSelect SecName LocaleID
623     ${If} $LANGUAGE = ${LocaleID}
624       SectionGetFlags ${Sec${SecName}} $0
625       IntOp $0 $0 | ${SF_SELECTED}
626       SectionSetFlags ${Sec${SecName}} $0
627     ${EndIf}
628   !macroend
630   ; No need for English to be detected as it's the default
631   !insertmacro LanguageAutoSelect Breton        1150
632   !insertmacro LanguageAutoSelect Catalan       1027
633   !insertmacro LanguageAutoSelect Czech         1029
634   !insertmacro LanguageAutoSelect Finnish       1035
635   !insertmacro LanguageAutoSelect French        1036
636   !insertmacro LanguageAutoSelect Gallegan      1110 ; Galician, but section is called Gallegan
637   !insertmacro LanguageAutoSelect German        1031
638   !insertmacro LanguageAutoSelect Italian       1040
639   !insertmacro LanguageAutoSelect Japanese      1041
640   !insertmacro LanguageAutoSelect Polish        1045
641   !insertmacro LanguageAutoSelect Romanian      1048
642   !insertmacro LanguageAutoSelect Russian       1049
643   !insertmacro LanguageAutoSelect Slovak        1051
644   !insertmacro LanguageAutoSelect Slovenian     1060
645   !insertmacro LanguageAutoSelect Spanish       1034
646   !insertmacro LanguageAutoSelect ChineseTaiwan 1028 ; TradChinese, but section is called ChineseTaiwan
647   ; End of language detection }}}
649   !insertmacro UNINSTALL.LOG_PREPARE_INSTALL ; prepare advanced uninstallation log script
651   ;Extract InstallOptions INI files
652   StrCpy $AskMultiUser 1
653   StrCpy $MultiUser 0
654   ; this resets AskMultiUser if Win95/98/ME
655   ClearErrors
656   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
657   ${If} ${Errors}
658     ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
659     StrCpy $R0 $R0 1
660     ${IfThen} $R0 = 4 ${|} StrCpy $AskMultiUser 0 ${|}
661   ${EndIf}
663   ; hide all user section if ME/9x
664   ${IfThen} $AskMultiUser != 1 ${|} SectionSetText ${SecAlluser} "" ${|}
666   ; hide if quick launch if not available
667   ${IfThen} $QUICKLAUNCH == $TEMP ${|} SectionSetText ${SecQuicklaunch} "" ${|}
669   ; Check for administrative privileges {{{
670   ClearErrors
671   UserInfo::GetName
672   ${If} ${Errors}
673     ; This one means you don't need to care about admin or
674     ; not admin because Windows 9x doesn't either
675     ${IfCmd} MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(NOT_SUPPORTED)$(OK_CANCEL_DESC)" /SD IDOK IDCANCEL ${||} Quit ${|}
676   ${Else}
677     Pop $User
678     UserInfo::GetAccountType
679     Pop $1
680     ${If} $1 != Admin
681     ${AndIf} ${Cmd} ${|} MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(NO_ADMIN)$(OK_CANCEL_DESC)" /SD IDOK IDCANCEL ${|}
682       Quit
683     ${EndIf}
684   ${EndIf} ; }}}
686   ; Detect an Inkscape installation by another user {{{
687   ReadRegStr $0 HKLM "${INSTDIR_KEY}" User                              ; first global...
688   ${IfThen} $0 == "" ${|} ReadRegStr $0 HKCU "${INSTDIR_KEY}" User ${|} ; then current user
689   ${If} $0 != ""
690   ${AndIf} $0 != $User
691   ${AndIf} ${Cmd} ${|} MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(DIFFERENT_USER)$(OK_CANCEL_DESC)" /SD IDOK IDCANCEL ${|}
692     Quit
693   ${EndIf} ; }}}
695   ; Request uninstallation of an old Inkscape installation {{{
696   ReadRegStr $R0 HKLM "${UNINST_KEY}" UninstallString
697   ${IfThen} $R0 == "" ${|} ReadRegStr $R0 HKCU "${UNINST_KEY}" UninstallString ${|}
698   ${If} $R0 != ""
699   ${AndIf} ${Cmd} ${|} MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WANT_UNINSTALL_BEFORE)" /SD IDNO IDYES ${|}
700     ExecWait $R0
701   ${EndIf} ; }}}
703   ; Process command-line arguments (for automation) {{{
704   !echo `Creating code to process command-line arguments...`
705   !verbose push
706   !verbose 3
707   ${GetParameters} $CMDARGS
709   !macro Parameter key Section
710     ${GetOptions} $CMDARGS /${key}= $1
711     ${If} $1 == OFF
712       SectionGetFlags ${Section} $0
713       IntOp $2 ${SF_SELECTED} ~
714       IntOp $0 $0 & $2
715       SectionSetFlags ${Section} $0
716     ${EndIf}
717     ${If} $1 == ON
718       SectionGetFlags ${Section} $0
719       IntOp $0 $0 | ${SF_SELECTED}
720       SectionSetFlags ${Section} $0
721     ${EndIf}
722   !macroend
724   !insertmacro Parameter GTK            ${SecGTK}
725   !insertmacro Parameter SHORTCUTS      ${secShortcuts}
726   !insertmacro Parameter ALLUSER        ${SecAlluser}
727   !insertmacro Parameter DESKTOP        ${SecDesktop}
728   !insertmacro Parameter QUICKLAUNCH    ${SecQUICKlaunch}
729   !insertmacro Parameter SVGEDITOR      ${SecSVGWriter}
730   !insertmacro Parameter CONTEXTMENUE   ${SecContextMenu}
731   !insertmacro Parameter PREFERENCES    ${SecPrefs}
732   !insertmacro Parameter ADDFILES       ${SecAddfiles}
733   !insertmacro Parameter EXAMPLES       ${SecExamples}
734   !insertmacro Parameter TUTORIALS      ${SecTutorials}
735   !insertmacro Parameter LANGUAGES      ${SecLanguages}
736   !insertmacro Parameter am             ${SecAmharic}
737   !insertmacro Parameter ar             ${SecArabic}
738   !insertmacro Parameter az             ${SecAzerbaijani}
739   !insertmacro Parameter be             ${SecByelorussian}
740   !insertmacro Parameter bg             ${SecBulgarian}
741   !insertmacro Parameter bn             ${SecBengali}
742   !insertmacro Parameter br             ${SecBreton}
743   !insertmacro Parameter ca             ${SecCatalan}
744   !insertmacro Parameter ca@valencia    ${SecCatalanValencia}
745   !insertmacro Parameter cs             ${SecCzech}
746   !insertmacro Parameter da             ${SecDanish}
747   !insertmacro Parameter de             ${SecGerman}
748   !insertmacro Parameter dz             ${SecDzongkha}
749   !insertmacro Parameter el             ${SecGreek}
750   !insertmacro Parameter en_AU          ${SecEnglishAustralian}
751   !insertmacro Parameter en_CA          ${SecEnglishCanadian}
752   !insertmacro Parameter en_GB          ${SecEnglishBritain}
753   !insertmacro Parameter en_US@piglatin ${SecEnglishPiglatin}
754   !insertmacro Parameter eo             ${SecEsperanto}
755   !insertmacro Parameter es             ${SecSpanish}
756   !insertmacro Parameter es_MX          ${SecSpanishMexico}
757   !insertmacro Parameter et             ${SecEstonian}
758   !insertmacro Parameter eu             ${SecBasque}
759   !insertmacro Parameter fi             ${SecFinnish}
760   !insertmacro Parameter fr             ${SecFrench}
761   !insertmacro Parameter ga             ${SecIrish}
762   !insertmacro Parameter gl             ${SecGallegan}
763   !insertmacro Parameter he             ${SecHebrew}
764   !insertmacro Parameter hr             ${SecCroatian}
765   !insertmacro Parameter hu             ${SecHungarian}
766   !insertmacro Parameter id             ${SecIndonesian}
767   !insertmacro Parameter it             ${SecItalian}
768   !insertmacro Parameter ja             ${SecJapanese}
769   !insertmacro Parameter km             ${SecKhmer}
770   !insertmacro Parameter ko             ${SecKorean}
771   !insertmacro Parameter lt             ${SecLithuanian}
772   !insertmacro Parameter mk             ${SecMacedonian}
773   !insertmacro Parameter mn             ${SecMongolian}
774   !insertmacro Parameter nb             ${SecNorwegianBokmal}
775   !insertmacro Parameter ne             ${SecNepali}
776   !insertmacro Parameter nl             ${SecDutch}
777   !insertmacro Parameter nn             ${SecNorwegianNynorsk}
778   !insertmacro Parameter pa             ${SecPanjabi}
779   !insertmacro Parameter pl             ${SecPolish}
780   !insertmacro Parameter pt             ${SecPortuguese}
781   !insertmacro Parameter pt_BR          ${SecPortugueseBrazil}
782   !insertmacro Parameter ro             ${SecRomanian}
783   !insertmacro Parameter ru             ${SecRussian}
784   !insertmacro Parameter rw             ${SecKinyarwanda}
785   !insertmacro Parameter sk             ${SecSlovak}
786   !insertmacro Parameter sl             ${SecSlovenian}
787   !insertmacro Parameter sq             ${SecAlbanian}
788   !insertmacro Parameter sr             ${SecSerbian}
789   !insertmacro Parameter sr@latin       ${SecSerbianLatin}
790   !insertmacro Parameter sv             ${SecSwedish}
791   !insertmacro Parameter th             ${SecThai}
792   !insertmacro Parameter tr             ${SecTurkish}
793   !insertmacro Parameter uk             ${SecUkrainian}
794   !insertmacro Parameter vi             ${SecVietnamese}
795   !insertmacro Parameter zh_CN          ${SecChineseSimplified}
796   !insertmacro Parameter zh_TW          ${SecChineseTaiwan}
798   ClearErrors
799   ${GetOptions} $CMDARGS /? $1
800   ${IfNot} ${Errors}
801     MessageBox MB_OK "Possible parameters for installer:$\r$\n \
802       /?: this help screen$\r$\n \
803       /S: silent$\r$\n \
804       /D=(directory): where to install Inkscape$\r$\n \
805       /GTK=(OFF/ON): GTK+ Runtime environment$\r$\n \
806       /SHORTCUTS=(OFF/ON): shortcuts to start Inkscape$\r$\n \
807       /ALLUSER=(OFF/ON): for all users on the computer$\r$\n \
808       /DESKTOP=(OFF/ON): Desktop icon$\r$\n \
809       /QUICKLAUNCH=(OFF/ON): quick launch icon$\r$\n \
810       /SVGEDITOR=(OFF/ON): default SVG editor$\r$\n \
811       /CONTEXTMENUE=(OFF/ON): context menue integration$\r$\n \
812       /PREFERENCES=(OFF/ON): delete users preference files$\r$\n \
813       /ADDFILES=(OFF/ON): additional files$\r$\n \
814       /EXAMPLES=(OFF/ON): examples$\r$\n \
815       /TUTORIALS=(OFF/ON): tutorials$\r$\n \
816       /LANGUAGES=(OFF/ON): translated menues, examples, etc.$\r$\n \
817       /[locale code]=(OFF/ON): e.g am, es, es_MX as in Inkscape supported"
818     Abort
819     !verbose pop
820   ${EndIf} ; }}}
821 FunctionEnd ; .onInit }}}
822 ; Uninstaller code {{{1
823 Function un.onInit ; initialise uninstaller {{{
824   ;begin uninstall, could be added on top of uninstall section instead
825   ;!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
826   ${IfNot} ${FileExists} $INSTDIR\uninstall.log
827     MessageBox MB_OK|MB_ICONEXCLAMATION "$(UninstallLogNotFound)" /SD IDOK
828     Quit
829   ${EndIf}
830   ClearErrors
831   StrCpy $User ""
832   UserInfo::GetName
833   ${IfNot} ${Errors}
834     Pop $0
835     StrCpy $User $0
836   ${EndIf}
837   StrCpy $askMultiUser 1
838   StrCpy $MultiUser 1
840   ; Test if this was a multiuser installation
841     ReadRegStr $0            HKLM "${INSTDIR_KEY}" ""
842   ${If} $0 == $INSTDIR\inkscape.exe
843     ReadRegStr $MultiUser    HKLM "${INSTDIR_KEY}" MultiUser
844     ReadRegStr $askMultiUser HKLM "${INSTDIR_KEY}" askMultiUser
845     ReadRegStr $0            HKLM "${INSTDIR_KEY}" User
846   ${Else}
847     ReadRegStr $MultiUser    HKCU "${INSTDIR_KEY}" MultiUser
848     ReadRegStr $askMultiUser HKCU "${INSTDIR_KEY}" askMultiUser
849     ReadRegStr $0            HKCU "${INSTDIR_KEY}" User
850   ${EndIf}
851   ;check user if applicable
852   ${If} $0 != ""
853   ${AndIf} $0 != $User
854   ${AndIf} ${Cmd} ${|} MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(DIFFERENT_USER)$(OK_CANCEL_DESC)" /SD IDOK IDCANCEL ${|}
855     Quit
856   ${EndIf}
858   !insertmacro MUI_INSTALLOPTIONS_EXTRACT inkscape.nsi.uninstall
860   SetShellVarContext all
861   ${IfThen} $MultiUser = 0 ${|} SetShellVarContext current ${|}
862 FunctionEnd ; un.onInit }}}
864 Function un.CustomPageUninstall ; {{{
865   !insertmacro MUI_HEADER_TEXT "$(UInstOpt)" "$(UInstOpt1)"
866   !insertmacro MUI_INSTALLOPTIONS_WRITE inkscape.nsi.uninstall "Field 1" Text "$APPDATA\Inkscape\"
867   !insertmacro MUI_INSTALLOPTIONS_WRITE inkscape.nsi.uninstall "Field 2" Text "$(PurgePrefs)"
868   !insertmacro MUI_INSTALLOPTIONS_DISPLAY inkscape.nsi.uninstall
869   !insertmacro MUI_INSTALLOPTIONS_READ $MultiUser inkscape.nsi.uninstall "Field 2" State
870 FunctionEnd ; un.CustomPageUninstall }}}
872 Section Uninstall ; do the uninstalling {{{
873 !ifndef DUMMYINSTALL
874   ; remove personal settings
875   Delete $APPDATA\Inkscape\extension-errors.log
876   ${If} $MultiUser = 0
877     DetailPrint "Purging personal settings in $APPDATA\Inkscape"
878     ;RMDir /r $APPDATA\Inkscape
879     !insertmacro delprefs
880   ${EndIf}
882   ; Remove file associations for svg editor
883   StrCpy $3 svg
884   ${For} $2 0 1
885     ${IfThen} $2 = 1 ${|} StrCpy $3 $3z ${|}
886     DetailPrint "Removing file associations for $3 editor"
887     ClearErrors
888     ReadRegStr $0 HKCR .$3 ""
889     ${IfNot} ${Errors}
890       ReadRegStr $1 HKCR $0\shell\edit\command ""
891       ${If} $1 == `"$INSTDIR\Inkscape.exe" "%1"`
892         DeleteRegKey HKCR $0\shell\edit\command
893       ${EndIf}
895       ClearErrors
896       ReadRegStr $1 HKCR $0\shell\open\command ""
897       ${If} $1 == `"$INSTDIR\Inkscape.exe" "%1"`
898         DeleteRegKey HKCR $0\shell\open\command
899       ${EndIf}
901       DeleteRegKey HKCR $0\shell\Inkscape
902       DeleteRegKey /ifempty HKCR $0\shell\edit
903       DeleteRegKey /ifempty HKCR $0\shell\open
904       DeleteRegKey /ifempty HKCR $0\shell
905       DeleteRegKey /ifempty HKCR $0
906       DeleteRegKey /ifempty HKCR .$3
907     ${EndIf}
908   ${Next}
910   SetShellVarContext all
911   DeleteRegKey SHCTX "${INSTDIR_KEY}"
912   DeleteRegKey SHCTX "${UNINST_KEY}"
913   Delete $DESKTOP\Inkscape.lnk
914   Delete $QUICKLAUNCH\Inkscape.lnk
915   Delete $SMPROGRAMS\Inkscape.lnk
916   ;just in case they are still there
917   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
918   Delete  $SMPROGRAMS\Inkscape\Inkscape.lnk
919   RMDir   $SMPROGRAMS\Inkscape
921   SetShellVarContext current
922   DeleteRegKey SHCTX "${INSTDIR_KEY}"
923   DeleteRegKey SHCTX "${UNINST_KEY}"
924   Delete $DESKTOP\Inkscape.lnk
925   Delete $QUICKLAUNCH\Inkscape.lnk
926   Delete $SMPROGRAMS\Inkscape.lnk
927   ;just in case they are still there
928   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
929   Delete $SMPROGRAMS\Inkscape\Inkscape.lnk
930   RMDir  $SMPROGRAMS\Inkscape
932   InitPluginsDir
933   SetPluginUnload manual
935   ClearErrors
936   FileOpen $0 $INSTDIR\uninstall.log r
937   ${If} ${Errors} ;else uninstallnotfound
938     MessageBox MB_OK|MB_ICONEXCLAMATION "$(UninstallLogNotFound)" /SD IDOK
939   ${Else}
940     ${Do}
941       ClearErrors
942       FileRead $0 $1
943       ${IfThen} ${Errors} ${|} ${ExitDo} ${|}
944       ; cat the line into md5 and filename
945       StrLen $2 $1
946       ${IfThen} $2 <= 35 ${|} ${Continue} ${|}
947       StrCpy $3 $1 32
948       StrCpy $filename $1 $2-36 34 ;remove trailing CR/LF
949       StrCpy $filename $filename -2
950       ; $3 = MD5 when installed, then deletion choice
951       ; $filename = file
952       ; $5 = MD5 now
953       ; $6 = always/never remove files touched by user
955       ${If} ${FileExists} $filename
956         ${If} $6 == always
957           StrCpy $3 2
958         ${Else}
959           md5dll::GetMD5File /NOUNLOAD $filename
960           Pop $5 ;md5 of file
961           ${If} $3 == $5
962             StrCpy $3 1 ; yes
963           ${ElseIf} $6 != never
964             ; the md5 sums does not match so we ask
965             messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" 0,103 \
966               "$(FileChanged)" "$(Yes)" "$(AlwaysYes)" "$(No)" "$(AlwaysNo)"
967             Pop $3
968             ${IfThen} $3 = 2 ${|} StrCpy $6 always ${|}
969             ${IfThen} $3 = 4 ${|} StrCpy $6 never ${|}
970           ${EndIf}
971         ${EndIf}
973         ${If}   $3 = 1 ; yes
974         ${OrIf} $3 = 2 ; always
975           ; Remove File
976           ClearErrors
977           Delete $filename
978           ;now recursivly remove the path
979           ${Do}
980             ClearErrors
981             ${un.GetParent} $filename $filename
982             ${IfThen} ${Errors} ${|} ${ExitDo} ${|}
983             RMDir $filename
984             ${IfThen} ${Errors} ${|} ${ExitDo} ${|}
985           ${Loop}
986         ${EndIf}
987       ${EndIf}
988     ${Loop}
989   ${EndIf}
990   FileClose $0
991   Delete $INSTDIR\uninstall.log
992   Delete $INSTDIR\uninstall.exe
993   ; remove empty directories
994   RMDir $INSTDIR\lib\locale
995   RMDir $INSTDIR\lib
996   RMDir $INSTDIR\data
997   RMDir $INSTDIR\doc
998   RMDir $INSTDIR\modules
999   RMDir $INSTDIR\plugins
1000   RMDir $INSTDIR
1001   SetAutoClose false
1002 !endif
1003 SectionEnd ; Uninstall }}}
1004 ; }}}
1006 ; This file has been optimised for use in Vim with folding.
1007 ; (If you can't cope, :set nofoldenable) vim:fen:fdm=marker