Code

ab48f61e3ed7f889e13417416a9099ba8bdf1ba6
[inkscape.git] / packaging / win32 / inkscape.nsi
1 ; #######################################
2 ; Inkscape NSIS installer project file
3 ; Used as of 0.40
4 ; #######################################
6 ; #######################################
7 ; DEFINES
8 ; #######################################
9 !define PRODUCT_NAME "Inkscape"
10 !define PRODUCT_VERSION "0.45+devel"
11 !define PRODUCT_PUBLISHER "Inkscape Organization"
12 !define PRODUCT_WEB_SITE "http://www.inkscape.org"
13 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\inkscape.exe"
14 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
15 ;!define UNINST_EXE "uninstall.exe"
19 ; #######################################
20 ; MUI   SETTINGS
21 ; #######################################
22 ; MUI 1.67 compatible ------
23 SetCompressor /SOLID lzma
24 !include "MUI.nsh"
25 !include "sections.nsh"
26 !define MUI_ABORTWARNING
27 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
28 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
29 !define MUI_HEADERIMAGE
30 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
31 !define MUI_COMPONENTSPAGE_SMALLDESC
33 ;..................................................................................................
34 ;Following two definitions required. Uninstall log will use these definitions.
35 ;You may use these definitions also, when you want to set up the InstallDirRagKey,
36 ;store the language selection, store Start Menu folder etc.
37 ;Enter the windows uninstall reg sub key to add uninstall information to Add/Remove Programs also.
39 !define INSTDIR_REG_ROOT "HKLM"
40 !define INSTDIR_REG_KEY ${PRODUCT_UNINST_KEY}
42 ;include the Uninstall log header
43 !include AdvUninstLog.nsh
45 ;Specify the preferred uninstaller operation mode, either unattended or interactive.
46 ;You have to type either !insertmacro UNATTENDED_UNINSTALL, or !insertmacro INTERACTIVE_UNINSTALL.
47 ;Be aware only one of the following two macros has to be inserted, neither both, neither none.
49 ;!insertmacro UNATTENDED_UNINSTALL
50 !insertmacro INTERACTIVE_UNINSTALL
52 !addplugindir .
53 !include "FileFunc.nsh"
54 !insertmacro un.GetParent
57 ; Welcome page
58 !insertmacro MUI_PAGE_WELCOME
59 ; License page
60 ; !define MUI_LICENSEPAGE_RADIOBUTTONS
61 LicenseForceSelection off
62 !define MUI_LICENSEPAGE_BUTTON $(lng_LICENSE_BUTTON)
63 !define MUI_LICENSEPAGE_TEXT_BOTTOM $(lng_LICENSE_BOTTOM_TEXT)
64 !insertmacro MUI_PAGE_LICENSE "..\..\Copying"
65 !insertmacro MUI_PAGE_COMPONENTS
66 ; InstType $(lng_Full)
67 ; InstType $(lng_Optimal)
68 ; InstType $(lng_Minimal)
69 ; Directory page
70 !insertmacro MUI_PAGE_DIRECTORY
71 ; Instfiles page
72 !insertmacro MUI_PAGE_INSTFILES
73 ; Finish page
74 !define MUI_FINISHPAGE_RUN "$INSTDIR\inkscape.exe"
75 !insertmacro MUI_PAGE_FINISH
77 ; Uninstaller pages
78 !insertmacro MUI_UNPAGE_CONFIRM
79 UninstPage custom un.CustomPageUninstall
80 !insertmacro MUI_UNPAGE_INSTFILES
81 ShowUninstDetails hide
82 !insertmacro MUI_UNPAGE_FINISH
84 ; #######################################
85 ; STRING   LOCALIZATION
86 ; #######################################
87 ; Thanks to Adib Taraben and Luca Bruno for getting this started
88 ; Add your translation here!  :-)
89 ; I had wanted to list the languages alphabetically, but apparently
90 ; the first is the default.  So putting English first is just being
91 ; practical.  It is not chauvinism or hubris, I swear!  ;-)
92 ; default language first
94 ; Language files
95 !include "english.nsh" 
96 !include "breton.nsh"
97 !include "catalan.nsh"
98 !include "czech.nsh" 
99 !include "finnish.nsh" 
100 !include "french.nsh" 
101 !include "galician.nsh" 
102 !include "german.nsh" 
103 !include "italian.nsh" 
104 !include "japanese.nsh"
105 !include "polish.nsh" 
106 !include "russian.nsh" 
107 !include "slovak.nsh" 
108 !include "slovenian.nsh" 
109 !include "spanish.nsh" 
111 ReserveFile "inkscape.nsi.uninstall"
112 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
113 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;InstallOptions
116 ; #######################################
117 ; SETTINGS
118 ; #######################################
120 Name              "${PRODUCT_NAME} ${PRODUCT_VERSION}"
121 Caption           $(lng_Caption)
122 OutFile           "Inkscape-${PRODUCT_VERSION}-1.win32.exe"
123 InstallDir        "$PROGRAMFILES\Inkscape"
124 InstallDirRegKey  HKLM "${PRODUCT_DIR_REGKEY}" ""
125 ShowInstDetails   hide
126 ShowUnInstDetails hide
128 var askMultiUser
129 Var MultiUser
130 var User
132 ; #######################################
133 ;  I N S T A L L E R    S E C T I O N S
134 ; #######################################
136 ; Turn off old selected section
137 ; GetWindowsVersion
139 ; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
140 ; Updated by Joost Verburg
141 ; Updated for Windows 98 SE by Matthew Win Tibbals 5-21-03
143 ; Returns on top of stack
145 ; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003)
146 ; or
147 ; '' (Unknown Windows Version)
149 ; Usage:
150 ;   Call GetWindowsVersion
151 ;   Pop $R0
152 ;   ; at this point $R0 is "NT 4.0" or whatnot
153 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
154 Function GetWindowsVersion
155  
156   Push $R0
157   Push $R1
158  
159   ClearErrors
160  
161   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
162  
163   IfErrors 0 lbl_winnt
164  
165   ; we are not NT
166   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
167  
168   StrCpy $R1 $R0 1
169   StrCmp $R1 '4' 0 lbl_error
170  
171   StrCpy $R1 $R0 3
172  
173   StrCmp $R1 '4.0' lbl_win32_95
174   StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
175  
176   lbl_win32_95:
177     StrCpy $R0 '95'
178         StrCpy $AskMultiUser "0"
179   Goto lbl_done
180  
181   lbl_win32_98:
182     StrCpy $R0 '98'
183         StrCpy $AskMultiUser "0"
184   Goto lbl_done
185   lbl_win32_ME:
186     StrCpy $R0 'ME'
187         StrCpy $AskMultiUser "0"
188   Goto lbl_done
189  
190   lbl_winnt:
191  
192   StrCpy $R1 $R0 1
193  
194   StrCmp $R1 '3' lbl_winnt_x
195   StrCmp $R1 '4' lbl_winnt_x
196  
197   StrCpy $R1 $R0 3
198  
199   StrCmp $R1 '5.0' lbl_winnt_2000
200   StrCmp $R1 '5.1' lbl_winnt_XP
201   StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error
202  
203   lbl_winnt_x:
204     StrCpy $R0 "NT $R0" 6
205   Goto lbl_done
206  
207   lbl_winnt_2000:
208     Strcpy $R0 '2000'
209   Goto lbl_done
210  
211   lbl_winnt_XP:
212     Strcpy $R0 'XP'
213   Goto lbl_done
214  
215   lbl_winnt_2003:
216     Strcpy $R0 '2003'
217   Goto lbl_done
218  
219   lbl_error:
220     Strcpy $R0 ''
221   lbl_done:
222  
223   Pop $R1
224   Exch $R0
226 FunctionEnd
228 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
230  ; StrStr
231  ; input, top of stack = string to search for
232  ;        top of stack-1 = string to search in
233  ; output, top of stack (replaces with the portion of the string remaining)
234  ; modifies no other variables.
235  ;
236  ; Usage:
237  ;   Push "this is a long ass string"
238  ;   Push "ass"
239  ;   Call StrStr
240  ;   Pop $R0
241  ;  ($R0 at this point is "ass string")
243  Function StrStr
244    Exch $R1 ; st=haystack,old$R1, $R1=needle
245    Exch    ; st=old$R1,haystack
246    Exch $R2 ; st=old$R1,old$R2, $R2=haystack
247    Push $R3
248    Push $R4
249    Push $R5
250    StrLen $R3 $R1
251    StrCpy $R4 0
252    ; $R1=needle
253    ; $R2=haystack
254    ; $R3=len(needle)
255    ; $R4=cnt
256    ; $R5=tmp
257    loop:
258      StrCpy $R5 $R2 $R3 $R4
259      StrCmp $R5 $R1 done
260      StrCmp $R5 "" done
261      IntOp $R4 $R4 + 1
262      Goto loop
263  done:
264    StrCpy $R1 $R2 "" $R4
265    Pop $R5
266    Pop $R4
267    Pop $R3
268    Pop $R2
269    Exch $R1
270  FunctionEnd
272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
274  ; GetParameters
275  ; input, none
276  ; output, top of stack (replaces, with e.g. whatever)
277  ; modifies no other variables.
278  
279  Function GetParameters
280  
281    Push $R0
282    Push $R1
283    Push $R2
284    Push $R3
285    
286    StrCpy $R2 1
287    StrLen $R3 $CMDLINE
288    
289    ;Check for quote or space
290    StrCpy $R0 $CMDLINE $R2
291    StrCmp $R0 '"' 0 +3
292      StrCpy $R1 '"'
293      Goto loop
294    StrCpy $R1 " "
295    
296    loop:
297      IntOp $R2 $R2 + 1
298      StrCpy $R0 $CMDLINE 1 $R2
299      StrCmp $R0 $R1 get
300      StrCmp $R2 $R3 get
301      Goto loop
302    
303    get:
304      IntOp $R2 $R2 + 1
305      StrCpy $R0 $CMDLINE 1 $R2
306      StrCmp $R0 " " get
307      StrCpy $R0 $CMDLINE "" $R2
308    
309    Pop $R3
310    Pop $R2
311    Pop $R1
312    Exch $R0
313  
314  FunctionEnd
316 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
317 ; GetParameterValue
318 ; Chris Morgan<cmorgan@alum.wpi.edu> 5/10/2004
319 ; -Updated 4/7/2005 to add support for retrieving a command line switch
320 ;  and additional documentation
322 ; Searches the command line input, retrieved using GetParameters, for the
323 ; value of an option given the option name.  If no option is found the
324 ; default value is placed on the top of the stack upon function return.
326 ; This function can also be used to detect the existence of just a
327 ; command line switch like /OUTPUT  Pass the default and "OUTPUT"
328 ; on the stack like normal.  An empty return string "" will indicate
329 ; that the switch was found, the default value indicates that
330 ; neither a parameter or switch was found.
332 ; Inputs - Top of stack is default if parameter isn't found,
333 ;  second in stack is parameter to search for, ex. "OUTPUT"
334 ; Outputs - Top of the stack contains the value of this parameter
335 ;  So if the command line contained /OUTPUT=somedirectory, "somedirectory"
336 ;  will be on the top of the stack when this function returns
338 ; Register usage
339 ;$R0 - default return value if the parameter isn't found
340 ;$R1 - input parameter, for example OUTPUT from the above example
341 ;$R2 - the length of the search, this is the search parameter+2
342 ;      as we have '/OUTPUT='
343 ;$R3 - the command line string
344 ;$R4 - result from StrStr calls
345 ;$R5 - search for ' ' or '"'
346  
347 Function GetParameterValue
348   Exch $R0  ; get the top of the stack(default parameter) into R0
349   Exch      ; exchange the top of the stack(default) with
350             ; the second in the stack(parameter to search for)
351   Exch $R1  ; get the top of the stack(search parameter) into $R1
352  
353   ;Preserve on the stack the registers used in this function
354   Push $R2
355   Push $R3
356   Push $R4
357   Push $R5
358  
359   Strlen $R2 $R1+2    ; store the length of the search string into R2
360  
361   Call GetParameters  ; get the command line parameters
362   Pop $R3             ; store the command line string in R3
363  
364   # search for quoted search string
365   StrCpy $R5 '"'      ; later on we want to search for a open quote
366   Push $R3            ; push the 'search in' string onto the stack
367   Push '"/$R1='       ; push the 'search for'
368   Call StrStr         ; search for the quoted parameter value
369   Pop $R4
370   StrCpy $R4 $R4 "" 1   ; skip over open quote character, "" means no maxlen
371   StrCmp $R4 "" "" next ; if we didn't find an empty string go to next
372  
373   # search for non-quoted search string
374   StrCpy $R5 ' '      ; later on we want to search for a space since we
375                       ; didn't start with an open quote '"' we shouldn't
376                       ; look for a close quote '"'
377   Push $R3            ; push the command line back on the stack for searching
378   Push '/$R1='        ; search for the non-quoted search string
379   Call StrStr
380   Pop $R4
381  
382   ; $R4 now contains the parameter string starting at the search string,
383   ; if it was found
384 next:
385   StrCmp $R4 "" check_for_switch ; if we didn't find anything then look for
386                                  ; usage as a command line switch
387   # copy the value after /$R1= by using StrCpy with an offset of $R2,
388   # the length of '/OUTPUT='
389   StrCpy $R0 $R4 "" $R2  ; copy commandline text beyond parameter into $R0
390   # search for the next parameter so we can trim this extra text off
391   Push $R0
392   Push $R5            ; search for either the first space ' ', or the first
393                       ; quote '"'
394                       ; if we found '"/output' then we want to find the
395                       ; ending ", as in '"/output=somevalue"'
396                       ; if we found '/output' then we want to find the first
397                       ; space after '/output=somevalue'
398   Call StrStr         ; search for the next parameter
399   Pop $R4
400   StrCmp $R4 "" done  ; if 'somevalue' is missing, we are done
401   StrLen $R4 $R4      ; get the length of 'somevalue' so we can copy this
402                       ; text into our output buffer
403   StrCpy $R0 $R0 -$R4 ; using the length of the string beyond the value,
404                       ; copy only the value into $R0
405   goto done           ; if we are in the parameter retrieval path skip over
406                       ; the check for a command line switch
407  
408 ; See if the parameter was specified as a command line switch, like '/output'
409 check_for_switch:
410   Push $R3            ; push the command line back on the stack for searching
411   Push '/$R1'         ; search for the non-quoted search string
412   Call StrStr
413   Pop $R4
414   StrCmp $R4 "" done  ; if we didn't find anything then use the default
415   StrCpy $R0 ""       ; otherwise copy in an empty string since we found the
416                       ; parameter, just didn't find a value
417  
418 done:
419   Pop $R5
420   Pop $R4
421   Pop $R3
422   Pop $R2
423   Pop $R1
424   Exch $R0 ; put the value in $R0 at the top of the stack
425 FunctionEnd
427 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
429 !macro Language polng lng
430   SectionIn 1 2 3
431   SetOutPath $INSTDIR
432   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
433   File /nonfatal /a "..\..\inkscape\*.${lng}.txt"
434   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
435   SetOutPath $INSTDIR\locale
436   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
437   File /nonfatal /a /r "..\..\inkscape\locale\${polng}"
438   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
439   SetOutPath $INSTDIR\lib\locale
440   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
441   File /nonfatal /a /r "..\..\inkscape\lib\locale\${polng}"
442   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
443   SetOutPath $INSTDIR\share\clipart
444   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
445   File /nonfatal /a /r "..\..\inkscape\share\clipart\*.${polng}.svg"  
446   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
447   ; the keyboard tables
448   SetOutPath $INSTDIR\share\screens
449   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
450   File /nonfatal /a /r "..\..\inkscape\share\screens\*.${polng}.svg"  
451   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
452   SetOutPath $INSTDIR\share\templates
453   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
454   File /nonfatal /a /r "..\..\inkscape\share\templates\*.${polng}.svg"  
455   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
456   SetOutPath $INSTDIR\doc
457   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
458   File /nonfatal /a /r "..\..\inkscape\doc\keys.${polng}.xml"  
459   File /nonfatal /a /r "..\..\inkscape\doc\keys.${polng}.html"  
460   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
461   SectionGetFlags ${SecTutorials} $R1 
462   IntOp $R1 $R1 & ${SF_SELECTED} 
463   IntCmp $R1 ${SF_SELECTED} 0 skip_tutorials 
464     SetOutPath $INSTDIR\share\tutorials
465     !insertmacro UNINSTALL.LOG_OPEN_INSTALL
466     File /nonfatal /a "..\..\inkscape\share\tutorials\*.${polng}.*"
467     !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
468   skip_tutorials:
469 !macroend
471 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
473 ;;;;;;;;;;;;;;;;;;;;;;;;;;
474 ; Delete prefs
475 ; code taken from the vlc project
476 ;;;;;;;;;;;;;;;;;;;;;;;;;;
477 !macro delprefs
478   StrCpy $0 0
479         DetailPrint "Delete personal preferences ..."
480         DetailPrint "try to find all users ..."
481         delprefs-Loop:
482  ; FIXME
483   ; this will loop through all the logged users and "virtual" windows users
484   ; (it looks like users are only present in HKEY_USERS when they are logged in)
485     ClearErrors
486     EnumRegKey $1 HKU "" $0
487     StrCmp $1 "" delprefs-End
488     IntOp $0 $0 + 1
489     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
490     StrCmp $2 "" delprefs-Loop
491         DetailPrint "$2\Inkscape will be removed"
492     Delete "$2\Inkscape\preferences.xml"
493     Delete "$2\Inkscape\extension-errors.log"
494     RMDir "$2\Inkscape"
495     Goto delprefs-Loop
496   delprefs-End:
497 !macroend
500 ;--------------------------------
501 ; Installer Sections
502 Section -removeInkscape
503   ; check for an old installation and clean that dlls and stuff
505 FindFirstINSTDIR:
506     FindFirst $0 $1 $INSTDIR\*.*
507 FindINSTDIR:
508     StrCmp $1 "" FindNextDoneINSTDIR
509     StrCmp $1 "." FindNextINSTDIR
510         StrCmp $1 ".." FindNextINSTDIR
511         Goto FoundSomethingINSTDIR
512 FindNextINSTDIR:
513     FindNext $0 $1
514         Goto FindINSTDIR
515 FoundSomethingINSTDIR:
516         MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(lng_ClearDirectoryBefore)" /SD IDCANCEL IDRETRY FindFirstINSTDIR
517         Quit
518 FindNextDoneINSTDIR:
520     ;remove the old inkscape shortcuts from the startmenu
521   ;just in case they are still there
522   SetShellVarContext current
523   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
524   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
525   RMDir  "$SMPROGRAMS\Inkscape"
526   Delete "$SMPROGRAMS\Inkscape.lnk"
527   SetShellVarContext all
528   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
529   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
530   RMDir  "$SMPROGRAMS\Inkscape"
531   Delete "$SMPROGRAMS\Inkscape.lnk"
532   
533 SectionEnd
535 Section $(lng_Core) SecCore
537   DetailPrint "Installing Inkscape Core Files ..."
539   SectionIn 1 2 3 RO
540   SetOutPath $INSTDIR
541   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
542   SetOverwrite on
543   SetAutoClose false
545   File /a "..\..\inkscape\ink*.exe"
546   File /a "..\..\inkscape\AUTHORS"
547   File /a "..\..\inkscape\COPYING"
548   File /a "..\..\inkscape\COPYING.LIB"
549   File /a "..\..\inkscape\NEWS"
550   File /a "..\..\inkscape\gspawn-win32-helper.exe"
551   File /a "..\..\inkscape\gspawn-win32-helper-console.exe"
552   File /nonfatal /a "..\..\inkscape\HACKING.txt"
553   File /a "..\..\inkscape\README"
554   File /nonfatal /a "..\..\inkscape\README.txt"
555   File /a "..\..\inkscape\TRANSLATORS"
556   File /nonfatal /a /r "..\..\inkscape\data"
557   File /nonfatal /a /r "..\..\inkscape\doc"
558   File /nonfatal /a /r "..\..\inkscape\plugins"
559   File /nonfatal /a /r /x *.??*.???* /x "examples" /x "tutorials" "..\..\inkscape\share"
560   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
561   ; this files are added because it slips through the filter
562   SetOutPath $INSTDIR\share\clipart
563   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
564   File /a "..\..\inkscape\share\clipart\inkscape.logo.svg"
565   ;File /a "..\..\inkscape\share\clipart\inkscape.logo.classic.svg"  
566   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
567   SetOutPath $INSTDIR\share\icons
568   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
569   File /a "..\..\inkscape\share\icons\inkscape.file.png"
570   File /a "..\..\inkscape\share\icons\inkscape.file.svg"
571   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
572   SetOutPath $INSTDIR\modules
573   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
574   File /nonfatal /a /r "..\..\inkscape\modules\*.*"
575   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
576   SetOutPath $INSTDIR\python
577   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
578   File /nonfatal /a /r "..\..\inkscape\python\*.*" 
579   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
580 SectionEnd
582 Section $(lng_GTKFiles) SecGTK
584   DetailPrint "Installing GTK Files ..."
585   
586   SectionIn 1 2 3 RO
587   SetOutPath $INSTDIR
588   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
589   SetOverwrite on
590   File /a /r "..\..\inkscape\*.dll"
591   File /a /r /x "locale" "..\..\inkscape\lib"
592   File /a /r "..\..\inkscape\etc"
593   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
594 SectionEnd
596 Section $(lng_Alluser) SecAlluser
597   ; disable this option in Win95/Win98/WinME
598   SectionIn 1 2 3 
599   StrCpy $MultiUser "1"
600   StrCmp $MultiUser "1" "" SingleUser
601     DetailPrint "admin mode, registry root will be HKLM"
602     SetShellVarContext all
603     Goto endSingleUser
604   SingleUser:
605     DetailPrint "single user mode, registry root will be HKCU"
606     SetShellVarContext current
607   endSingleUser:                
608 SectionEnd
610 SectionGroup $(lng_Shortcuts) SecShortcuts
612 Section /o $(lng_Desktop) SecDesktop
613   ClearErrors
614   CreateShortCut "$DESKTOP\Inkscape.lnk" "$INSTDIR\inkscape.exe"
615   IfErrors 0 +2
616     DetailPrint "Uups! Problems creating desktop shortcuts"
617 SectionEnd
619 Section /o $(lng_Quicklaunch) SecQuicklaunch
620   ClearErrors
621   StrCmp $QUICKLAUNCH $TEMP +2
622     CreateShortCut "$QUICKLAUNCH\Inkscape.lnk" "$INSTDIR\inkscape.exe"
623   IfErrors 0 +2
624     DetailPrint "Uups! Problems creating quicklaunch shortcuts"
625 SectionEnd
627 Section $(lng_SVGWriter) SecSVGWriter 
628   SectionIn 1 2 3
629   ; create file associations, test before if needed
630   DetailPrint "creating file associations"
631   ClearErrors
632   ReadRegStr $0 HKCR ".svg" ""
633   StrCmp $0 "" 0 +3
634     WriteRegStr HKCR ".svg" "" "svgfile"
635     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
636   ReadRegStr $0 HKCR ".svgz" ""
637   StrCmp $0 "" 0 +3
638     WriteRegStr HKCR ".svgz" "" "svgfile"
639     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
640   IfErrors 0 +2
641     DetailPrint "Uups! Problems creating file assoziations for svg writer"
642   
643   DetailPrint "creating default editor"
644   ClearErrors
645   ReadRegStr $0 HKCR ".svg" ""
646   WriteRegStr HKCR "$0\shell\edit\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
647   ReadRegStr $0 HKCR ".svgz" ""
648   WriteRegStr HKCR "$0\shell\edit\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
649   IfErrors 0 +2
650     DetailPrint "Uups! Problems creating default editor"
651 SectionEnd
653 Section $(lng_ContextMenu) SecContextMenu
654   SectionIn 1 2 3
655   ; create file associations, test before if needed
656   DetailPrint "creating file associations"
657   ClearErrors
658   ReadRegStr $0 HKCR ".svg" ""
659   StrCmp $0 "" 0 +3
660     WriteRegStr HKCR ".svg" "" "svgfile"
661     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
662   ReadRegStr $0 HKCR ".svgz" ""
663   StrCmp $0 "" 0 +3
664     WriteRegStr HKCR ".svgz" "" "svgfile"
665     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
666   IfErrors 0 +2
667     DetailPrint "Uups! Problems creating file assoziations for context menu"
668   
669   DetailPrint "creating context menue"
670   ClearErrors
671   ReadRegStr $0 HKCR ".svg" ""
672   WriteRegStr HKCR "$0\shell\${PRODUCT_NAME}\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
673   ReadRegStr $0 HKCR ".svgz" ""
674   WriteRegStr HKCR "$0\shell\${PRODUCT_NAME}\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
675   IfErrors 0 +2
676     DetailPrint "Uups! Problems creating context menue integration"
678 SectionEnd
680 SectionGroupEnd
682 Section /o $(lng_DeletePrefs) SecPrefs
683         !insertmacro delprefs
684 SectionEnd
686 SectionGroup $(lng_Addfiles) SecAddfiles
688 Section $(lng_Examples) SecExamples
689   SectionIn 1 2
690   SetOutPath $INSTDIR\share
691   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
692   File /nonfatal /a /r /x "*.??*.???*" "..\..\inkscape\share\examples"
693   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
694 SectionEnd
696 Section $(lng_Tutorials) SecTutorials
697   SectionIn 1 2
698   SetOutPath $INSTDIR\share
699   !insertmacro UNINSTALL.LOG_OPEN_INSTALL
700   File /nonfatal /a /r /x "*.??*.???*" "..\..\inkscape\share\tutorials"
701   !insertmacro UNINSTALL.LOG_CLOSE_INSTALL
702 SectionEnd
704 SectionGroupEnd
706 SectionGroup /e $(lng_Languages) SecLanguages
708 Section $(lng_am) SecAmharic
709   !insertmacro Language am am
710 SectionEnd
712 Section $(lng_ar) SecArabic
713   !insertmacro Language ar ar
714 SectionEnd
716 Section $(lng_az) SecAzerbaijani
717   !insertmacro Language az az
718 SectionEnd
720 Section $(lng_be) SecByelorussian
721   !insertmacro Language be be
722 SectionEnd
724 Section $(lng_bg) SecBulgarian
725   !insertmacro Language bg bg
726 SectionEnd
728 Section $(lng_bn) SecBengali
729   !insertmacro Language bn bn
730 SectionEnd
732 Section $(lng_br) SecBreton
733   !insertmacro Language br br
734 SectionEnd
736 Section $(lng_ca) SecCatalan
737   !insertmacro Language ca ca
738 SectionEnd
740 Section $(lng_ca@valencia) SecCatalanValencia
741   !insertmacro Language ca@valencia ca@valencia
742 SectionEnd
744 Section $(lng_cs) SecCzech
745   !insertmacro Language cs cs
746 SectionEnd
748 Section $(lng_da) SecDanish
749   !insertmacro Language da da
750 SectionEnd
752 Section $(lng_de) SecGerman
753   !insertmacro Language 'de' 'de'
754 SectionEnd
756 Section $(lng_dz) SecDzongkha
757   !insertmacro Language dz dz
758 SectionEnd
760 Section $(lng_el) SecGreek
761   !insertmacro Language el el
762 SectionEnd
764 Section $(lng_en) SecEnglish
765   SectionIn 1 2 3 RO
766 SectionEnd
768 Section $(lng_en_AU) SecEnglishAustralian
769   !insertmacro Language en_AU en_AU
770 SectionEnd
772 Section $(lng_en_CA) SecEnglishCanadian
773   !insertmacro Language en_CA en_CA
774 SectionEnd
776 Section $(lng_en_GB) SecEnglishBritain
777   !insertmacro Language en_GB en_GB
778 SectionEnd
780 Section $(lng_en_US@piglatin) SecEnglishPiglatin
781   !insertmacro Language en_US@piglatin en_US@Piglatin
782 SectionEnd
784 Section $(lng_eo) SecEsperanto
785   !insertmacro Language eo eo
786 SectionEnd
788 Section $(lng_es) SecSpanish
789   !insertmacro Language 'es' 'es'
790 SectionEnd
792 Section $(lng_es_MX) SecSpanishMexico
793   !insertmacro Language 'es_MX' 'es_MX'
794 SectionEnd
796 Section $(lng_et) SecEstonian
797   !insertmacro Language et et
798 SectionEnd
800 Section $(lng_eu) SecBasque
801   !insertmacro Language eu eu
802 SectionEnd
804 Section $(lng_fr) SecFrench
805   !insertmacro Language 'fr' 'fr'
806 SectionEnd
808 Section $(lng_fi) SecFinnish
809   !insertmacro Language 'fi' 'fi'
810 SectionEnd
812 Section $(lng_ga) SecIrish
813   !insertmacro Language ga ga
814 SectionEnd
816 Section $(lng_gl) SecGallegan
817   !insertmacro Language gl gl
818   SectionIn 1 2 3
819 SectionEnd
821 Section $(lng_he) SecHebrew
822   !insertmacro Language he he
823   SectionIn 1 2 3
824 SectionEnd
826 Section $(lng_hr) SecCroatian
827   !insertmacro Language hr hr
828   SectionIn 1 2 3
829 SectionEnd
831 Section $(lng_hu) SecHungarian
832   !insertmacro Language hu hu
833   SectionIn 1 2 3
834 SectionEnd
836 Section $(lng_id) SecIndonesian
837   !insertmacro Language id id
838   SectionIn 1 2 3
839 SectionEnd
841 Section $(lng_it) SecItalian
842   !insertmacro Language it it
843   SectionIn 1 2 3
844 SectionEnd
846 Section $(lng_ja) SecJapanese
847   !insertmacro Language 'ja' 'jp'
848 SectionEnd
850 Section $(lng_km) SecKhmer
851   !insertmacro Language km km
852 SectionEnd
854 Section $(lng_ko) SecKorean
855   !insertmacro Language 'ko' 'ko'
856 SectionEnd
858 Section $(lng_lt) SecLithuanian
859   !insertmacro Language 'lt' 'lt'
860 SectionEnd
862 Section $(lng_mn) SecMongolian
863   !insertmacro Language mn mn
864 SectionEnd
866 Section $(lng_mk) SecMacedonian
867   !insertmacro Language mk mk
868 SectionEnd
870 Section $(lng_nb) SecNorwegianBokmal
871   !insertmacro Language nb nb
872 SectionEnd
874 Section $(lng_ne) SecNepali
875   !insertmacro Language ne ne
876 SectionEnd
878 Section $(lng_nl) SecDutch
879   !insertmacro Language nl nl
880 SectionEnd
882 Section $(lng_nn) SecNorwegianNynorsk
883   !insertmacro Language nn nn
884 SectionEnd
886 Section $(lng_pa) SecPanjabi
887   !insertmacro Language pa pa
888 SectionEnd
890 Section $(lng_pl) SecPolish
891   !insertmacro Language pl pl
892 SectionEnd
894 Section $(lng_pt) SecPortuguese
895   !insertmacro Language pt pt
896 SectionEnd
898 Section $(lng_pt_BR) SecPortugueseBrazil
899   !insertmacro Language pt_BR pt_BR
900 SectionEnd
902 Section $(lng_ro) SecRomanian
903   !insertmacro Language ro ro
904 SectionEnd
906 Section $(lng_ru) SecRussian
907   !insertmacro Language ru ru
908 SectionEnd
910 Section $(lng_rw) SecKinyarwanda
911   !insertmacro Language rw rw
912 SectionEnd
914 Section $(lng_sk) SecSlovak
915   !insertmacro Language sk sk
916 SectionEnd
918 Section $(lng_sl) SecSlovenian
919   !insertmacro Language sl sl
920 SectionEnd
922 Section $(lng_sq) SecAlbanian
923   !insertmacro Language sq sq
924 SectionEnd
926 Section $(lng_sr) SecSerbian
927   !insertmacro Language sr sr
928 SectionEnd
930 Section $(lng_sr@latin) SecSerbianLatin
931   !insertmacro Language 'sr@latin' 'sr@latin'
932 SectionEnd
934 Section $(lng_sv) SecSwedish
935   !insertmacro Language sv sv
936 SectionEnd
938 Section $(lng_th) SecThai
939   !insertmacro Language th th
940 SectionEnd
942 Section $(lng_tr) SecTurkish
943   !insertmacro Language tr tr
944 SectionEnd
946 Section $(lng_uk) SecUkrainian
947   !insertmacro Language uk uk
948 SectionEnd
950 Section $(lng_vi) SecVietnamese
951   !insertmacro Language vi vi
952 SectionEnd
954 Section $(lng_zh_CN) SecChineseSimplified
955   !insertmacro Language zh_CN zh_CN
956 SectionEnd
958 Section $(lng_zh_TW) SecChineseTaiwan
959   !insertmacro Language zh_TW zh_TW
960 SectionEnd
962 SectionGroupEnd
965 Section -FinalizeInstallation
966         DetailPrint "finalize installation"
967   StrCmp $MultiUser "1" "" SingleUser
968     DetailPrint "admin mode, registry root will be HKLM"
969     SetShellVarContext all
970     Goto endSingleUser
971   SingleUser:
972     DetailPrint "single user mode, registry root will be HKCU"
973     SetShellVarContext current
974   endSingleUser:                
976   ; check for writing registry
977   ClearErrors
978   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\inkscape.exe"  
979   ;IfErrors 0 +4
980   ;  DetailPrint "fatal: failed to write to ${PRODUCT_DIR_REGKEY}"
981   ;  DetailPrint "aborting installation"
982   ;     Abort
983   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "MultiUser" "$MultiUser"  
984   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "askMultiUser" "$askMultiUser"
985   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "User" "$User"
986   IfErrors 0 +2
987     DetailPrint "fatal: failed to write to registry installation info"
989   ; start menu entries
990   ClearErrors
991   CreateShortCut "$SMPROGRAMS\Inkscape.lnk" "$INSTDIR\inkscape.exe"
992   IfErrors 0 +2
993     DetailPrint "fatal: failed to write to start menu info"
995   ; uninstall settings
996   ClearErrors
997   ; WriteUninstaller "$INSTDIR\uninst.exe"
998   WriteRegExpandStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${UNINST_EXE}"
999   WriteRegExpandStr SHCTX "${PRODUCT_UNINST_KEY}" "InstallDir" "$INSTDIR"
1000   WriteRegExpandStr SHCTX "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
1001   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
1002   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Inkscape.exe,0"
1003   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
1004   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" "1"
1005   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" "1"
1006   IfErrors 0 +2
1007     DetailPrint "fatal: failed to write to registry un-installation info"
1009   ;create/update log always within .onInstSuccess function
1010   !insertmacro UNINSTALL.LOG_UPDATE_INSTALL
1011   
1012         DetailPrint "create MD5 sums"
1013         ClearErrors
1014         FileOpen $0 $INSTDIR\uninstall.dat r
1015         FileOpen $9 $INSTDIR\uninstall.log w
1016         IfErrors doneinstall
1017 readnextlineinstall:
1018         ClearErrors
1019         FileRead $0 $1
1020         IfErrors doneinstall
1021         StrCpy $1 $1 -2
1022         ;DetailPrint $1
1023         md5dll::GetMD5File /NOUNLOAD $1
1024         Pop $2
1025         ;DetailPrint $2
1026         StrCmp $2 "" +2
1027         FileWrite $9 "$2  $1$\r$\n"
1028         Goto readnextlineinstall
1029 doneinstall:
1030         FileClose $0
1031         FileClose $9
1032         ; this file is not needed anymore
1033         Delete $INSTDIR\uninstall.dat
1034         
1035 SectionEnd
1036  
1037 ; Last the Descriptions
1038 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
1039   !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(lng_CoreDesc)
1040   !insertmacro MUI_DESCRIPTION_TEXT ${SecGTK} $(lng_GTKFilesDesc)
1041   !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} $(lng_ShortcutsDesc)
1042   !insertmacro MUI_DESCRIPTION_TEXT ${SecAlluser} $(lng_AlluserDesc) 
1043   !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} $(lng_DesktopDesc)
1044   !insertmacro MUI_DESCRIPTION_TEXT ${SecQuicklaunch} $(lng_QuicklaunchDesc)
1045   !insertmacro MUI_DESCRIPTION_TEXT ${SecSVGWriter} $(lng_SVGWriterDesc)
1046   !insertmacro MUI_DESCRIPTION_TEXT ${SecContextMenu} $(lng_ContextMenuDesc)
1047   !insertmacro MUI_DESCRIPTION_TEXT ${SecPrefs} $(lng_DeletePrefsDesc)
1048   !insertmacro MUI_DESCRIPTION_TEXT ${SecAddfiles} $(lng_AddfilesDesc)
1049   !insertmacro MUI_DESCRIPTION_TEXT ${SecExamples} $(lng_ExamplesDesc)
1050   !insertmacro MUI_DESCRIPTION_TEXT ${SecTutorials} $(lng_TutorialsDesc)
1051   !insertmacro MUI_DESCRIPTION_TEXT ${SecLanguages} $(lng_LanguagesDesc)
1052 !insertmacro MUI_FUNCTION_DESCRIPTION_END
1054 !macro Parameter key Section
1055   Push ${key}
1056   Push ""
1057   Call GetParameterValue
1058   Pop $1
1059   StrCmp $1 "OFF" 0 +5
1060     SectionGetFlags ${Section} $0
1061     IntOp $2 ${SF_SELECTED} ~
1062     IntOp $0 $0 & $2
1063     SectionSetFlags ${Section} $0
1064   StrCmp $1 "ON" 0 +4
1065     SectionGetFlags ${Section} $0
1066     IntOp $0 $0 | ${SF_SELECTED}
1067     SectionSetFlags ${Section} $0
1068 !macroend
1070 Function .onInit
1071   ;prepare log always within .onInit function
1072   !insertmacro UNINSTALL.LOG_PREPARE_INSTALL
1074   ;Extract InstallOptions INI files
1075   StrCpy $AskMultiUser "1"
1076   StrCpy $MultiUser "0"
1077   ; this resets AskMultiUser if Win95/98/ME
1078   Call GetWindowsVersion
1079   Pop $R0
1080   DetailPrint "detected operating system $R0"
1081   ;MessageBox MB_OK "operating system: $R0; AskMultiuser: $AskMultiUser"
1082   
1083   ; hide all user section if win98
1084   StrCmp $AskMultiUser "1" +2
1085     SectionSetText ${SecAlluser} ""
1087   ; hide if quick launch if not available
1088   StrCmp $QUICKLAUNCH $TEMP 0 +2
1089     SectionSetText ${SecQuicklaunch} ""
1091   ;check if user is admin
1092   ClearErrors
1093         UserInfo::GetName
1094         IfErrors info_Win9x
1095         Pop $0
1096         StrCpy $User $0
1097         UserInfo::GetAccountType
1098         Pop $1
1099         StrCmp $1 "Admin" info_done
1101         MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_NO_ADMIN)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK info_done IDCANCEL +1
1102                 Quit
1103                 
1104         Goto info_done
1106         info_Win9x:
1107                 # This one means you don't need to care about admin or
1108                 # not admin because Windows 9x doesn't either
1109                 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_NOT_SUPPORTED)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK info_done IDCANCEL +1
1110                         Quit
1111                         
1112         info_done:
1114   ;check for previous installation
1115   ReadRegStr $0 HKLM "${PRODUCT_DIR_REGKEY}" "User"
1116   StrCmp $0 "" +1 +2
1117   ReadRegStr $0 HKCU "${PRODUCT_DIR_REGKEY}" "User"
1118   ;check user if applicable
1119   StrCmp $0 "" diff_user_install_done
1120     StrCmp $0 $User diff_user_install_done
1121           MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_DIFFERENT_USER)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK diff_user_install_done IDCANCEL +1
1122                 Quit
1123    diff_user_install_done:
1124           
1125   ; call uninstall first
1126   ; code taken from the vlc project
1127     ReadRegStr $R0  HKLM ${PRODUCT_UNINST_KEY} "UninstallString"
1128         ReadRegStr $R1  HKLM ${PRODUCT_UNINST_KEY} "DisplayName"
1129         StrCmp $R0 "" +1 +3
1130     ReadRegStr $R0  HKCU ${PRODUCT_UNINST_KEY} "UninstallString"
1131         ReadRegStr $R1  HKCU ${PRODUCT_UNINST_KEY} "DisplayName"
1132         StrCmp $R0 "" uninstall_before_done
1133          
1134           MessageBox MB_YESNO|MB_ICONEXCLAMATION $(lng_WANT_UNINSTALL_BEFORE) /SD IDNO IDNO uninstall_before_done 
1135           ;Run the uninstaller
1136           ;uninst:
1137                 DetailPrint "execute $R0 in $INSTDIR"
1138             ClearErrors
1139             ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
1140           uninstall_before_done:
1141           
1142   ; proccess command line parameter
1143   !insertmacro Parameter "GTK" ${SecGTK}
1144   !insertmacro Parameter "SHORTCUTS" ${secShortcuts}
1145   !insertmacro Parameter "ALLUSER" ${SecAlluser}
1146   !insertmacro Parameter "DESKTOP" ${SecDesktop}
1147   !insertmacro Parameter "QUICKLAUNCH" ${SecQUICKlaunch}
1148   !insertmacro Parameter "SVGEDITOR" ${SecSVGWriter}
1149   !insertmacro Parameter "CONTEXTMENUE" ${SecContextMenu}
1150   !insertmacro Parameter "PREFERENCES" ${SecPrefs}
1151   !insertmacro Parameter "ADDFILES" ${SecAddfiles}
1152   !insertmacro Parameter "EXAMPLES" ${SecExamples}
1153   !insertmacro Parameter "TUTORIALS" ${SecTutorials}
1154   !insertmacro Parameter "LANGUAGES" ${SecLanguages}
1155   !insertmacro Parameter "am" ${SecAmharic}
1156   !insertmacro Parameter "ar" ${SecArabic}
1157   !insertmacro Parameter "az" ${SecAzerbaijani}
1158   !insertmacro Parameter "be" ${SecByelorussian}
1159   !insertmacro Parameter "bg" ${SecBulgarian}
1160   !insertmacro Parameter "bn" ${SecBengali}
1161   !insertmacro Parameter "br" ${SecBreton}
1162   !insertmacro Parameter "ca" ${SecCatalan}
1163   !insertmacro Parameter "ca@valencia" ${SecCatalanValencia}
1164   !insertmacro Parameter "cs" ${SecCzech}
1165   !insertmacro Parameter "da" ${SecDanish}
1166   !insertmacro Parameter "de" ${SecGerman}
1167   !insertmacro Parameter "dz" ${SecDzongkha}
1168   !insertmacro Parameter "el" ${SecGreek}
1169   !insertmacro Parameter "en_AU" ${SecEnglishAustralian}
1170   !insertmacro Parameter "en_CA" ${SecEnglishCanadian}
1171   !insertmacro Parameter "en_GB" ${SecEnglishBritain}
1172   !insertmacro Parameter "en_US@piglatin" ${SecEnglishPiglatin}
1173   !insertmacro Parameter "eo" ${SecEsperanto}
1174   !insertmacro Parameter "es" ${SecSpanish}
1175   !insertmacro Parameter "es_MX" ${SecSpanishMexico}
1176   !insertmacro Parameter "et" ${SecEstonian}
1177   !insertmacro Parameter "eu" ${SecBasque}
1178   !insertmacro Parameter "fi" ${SecFinnish}
1179   !insertmacro Parameter "fr" ${SecFrench}
1180   !insertmacro Parameter "ga" ${SecIrish}
1181   !insertmacro Parameter "gl" ${SecGallegan}
1182   !insertmacro Parameter "he" ${SecHebrew}
1183   !insertmacro Parameter "hr" ${SecCroatian}
1184   !insertmacro Parameter "hu" ${SecHungarian}
1185   !insertmacro Parameter "id" ${SecIndonesian}
1186   !insertmacro Parameter "it" ${SecItalian}
1187   !insertmacro Parameter "ja" ${SecJapanese}
1188   !insertmacro Parameter "km" ${SecKhmer}
1189   !insertmacro Parameter "ko" ${SecKorean}
1190   !insertmacro Parameter "lt" ${SecLithuanian}
1191   !insertmacro Parameter "mk" ${SecMacedonian}
1192   !insertmacro Parameter "mn" ${SecMongolian}
1193   !insertmacro Parameter "nb" ${SecNorwegianBokmal}
1194   !insertmacro Parameter "ne" ${SecNepali}
1195   !insertmacro Parameter "nl" ${SecDutch}
1196   !insertmacro Parameter "nn" ${SecNorwegianNynorsk}
1197   !insertmacro Parameter "pa" ${SecPanjabi}
1198   !insertmacro Parameter "pl" ${SecPolish}
1199   !insertmacro Parameter "pt" ${SecPortuguese}
1200   !insertmacro Parameter "pt_BR" ${SecPortugueseBrazil}
1201   !insertmacro Parameter "ro" ${SecRomanian}
1202   !insertmacro Parameter "ru" ${SecRussian}
1203   !insertmacro Parameter "rw" ${SecKinyarwanda}
1204   !insertmacro Parameter "sk" ${SecSlovak}
1205   !insertmacro Parameter "sl" ${SecSlovenian}
1206   !insertmacro Parameter "sq" ${SecAlbanian}
1207   !insertmacro Parameter "sr" ${SecSerbian}
1208   !insertmacro Parameter "sr@latin" ${SecSerbianLatin}
1209   !insertmacro Parameter "sv" ${SecSwedish}
1210   !insertmacro Parameter "th" ${SecThai}
1211   !insertmacro Parameter "tr" ${SecTurkish}
1212   !insertmacro Parameter "uk" ${SecUkrainian}
1213   !insertmacro Parameter "vi" ${SecVietnamese}
1214   !insertmacro Parameter "zh_CN" ${SecChineseSimplified}
1215   !insertmacro Parameter "zh_TW" ${SecChineseTaiwan}
1216   
1217   Push "?"
1218   Push "TEST"
1219   Call GetParameterValue
1220   Pop $1
1221   StrCmp $1 "TEST" +3
1222     MessageBox MB_OK "possible parameters for installer:$\r$\n \
1223       /?: this help screen$\r$\n \
1224       /S: silent$\r$\n \
1225       /D=(directory): where to install inkscape$\r$\n \
1226       /GTK=(OFF/ON): GTK+ Runtime environment$\r$\n \
1227       /SHORTCUTS=(OFF/ON): shortcuts to start inkscape$\r$\n \
1228       /ALLUSER=(OFF/ON): for all users on the computer$\r$\n \
1229       /DESKTOP=(OFF/ON): Desktop icon$\r$\n \
1230       /QUICKLAUNCH=(OFF/ON): quick launch icon$\r$\n \
1231       /SVGEDITOR=(OFF/ON): default SVG editor$\r$\n \
1232       /CONTEXTMENUE=(OFF/ON): context menue integration$\r$\n \
1233       /PREFERENCES=(OFF/ON): delete users preference files$\r$\n \
1234       /ADDFILES=(OFF/ON): additional files$\r$\n \
1235       /EXAMPLES=(OFF/ON): examples$\r$\n \
1236       /TUTORIALS=(OFF/ON): tutorials$\r$\n \
1237       /LANGUAGES=(OFF/ON): translated menues, examples, etc.$\r$\n \
1238       /[locale code]=(OFF/ON): e.g am, es, es_MX as in Inkscape supported"
1239     Abort
1240 FunctionEnd
1242 Function .onSelChange
1243 FunctionEnd
1246 Function .onInstSuccess
1248 FunctionEnd
1250 ; --------------------------------------------------
1252 Function un.CustomPageUninstall
1253   !insertmacro MUI_HEADER_TEXT "$(lng_UInstOpt)" "$(lng_UInstOpt1)"
1254   !insertmacro MUI_INSTALLOPTIONS_WRITE "inkscape.nsi.uninstall" "Field 1" "Text" "$APPDATA\Inkscape\"
1255   !insertmacro MUI_INSTALLOPTIONS_WRITE "inkscape.nsi.uninstall" "Field 2" "Text" "$(lng_PurgePrefs)"
1257   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "inkscape.nsi.uninstall"
1258   !insertmacro MUI_INSTALLOPTIONS_READ $MultiUser "inkscape.nsi.uninstall" "Field 2" "State"
1259   DetailPrint "keepfiles = $MultiUser" 
1260           ;MessageBox MB_OK "adminmode = $MultiUser MultiUserOS = $askMultiUser"
1262 FunctionEnd
1265 Function un.onInit
1266   ;begin uninstall, could be added on top of uninstall section instead
1267   ;!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
1268         IfFileExists $INSTDIR\uninstall.log uninstalllogpresent
1269         MessageBox MB_OK|MB_ICONEXCLAMATION "$(lng_UninstallLogNotFound)" /SD IDOK
1270         Quit
1271 uninstalllogpresent:
1272   ClearErrors
1273   StrCpy $User ""
1274         UserInfo::GetName
1275         IfErrors +3
1276         Pop $0
1277         StrCpy $User $0
1279   StrCpy $askMultiUser "1"
1280   StrCpy $MultiUser "1"
1281  
1282   ; Test if this was a multiuser installation
1283   ReadRegStr $0 HKLM "${PRODUCT_DIR_REGKEY}" ""
1284   StrCmp $0  "$INSTDIR\inkscape.exe" 0 hkcu_user_uninstall  
1285     ReadRegStr $MultiUser HKLM "${PRODUCT_DIR_REGKEY}" "MultiUser"
1286     ReadRegStr $askMultiUser HKLM "${PRODUCT_DIR_REGKEY}" "askMultiUser"
1287         ReadRegStr $0 HKLM "${PRODUCT_DIR_REGKEY}" "User"
1288         Goto check_user_uninstall
1289   hkcu_user_uninstall:
1290   ReadRegStr $MultiUser HKCU "${PRODUCT_DIR_REGKEY}" "MultiUser"
1291   ReadRegStr $askMultiUser HKCU "${PRODUCT_DIR_REGKEY}" "askMultiUser"
1292   ReadRegStr $0 HKCU "${PRODUCT_DIR_REGKEY}" "User"
1293   ;check user if applicable
1294   check_user_uninstall:
1295   StrCmp $0 "" diff_user_uninstall_done
1296         StrCmp $0 $User diff_user_uninstall_done
1297           MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_DIFFERENT_USER)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK diff_user_uninstall_done IDCANCEL +1
1298                 Quit
1299   diff_user_uninstall_done:
1300     
1301  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "inkscape.nsi.uninstall"
1303  ;check whether Multi user installation ?
1304  SetShellVarContext all
1305  StrCmp $MultiUser "0" 0 +2 
1306  SetShellVarContext current
1307  ;MessageBox MB_OK "adminmode = $MultiUser MultiUserOS = $askMultiUser" 
1308    
1309 FunctionEnd
1311 # removes a file and if the directory is empty afterwards the directory also
1312 # push md5, push filename, call unremovefilename
1313 Function un.RemoveFile
1314         Var /Global filename
1315         Var /Global md5sum
1316         Var /Global ismd5sum
1317         Var /Global removenever ; never remove a touched file
1318         Var /Global removealways        ; always remove files touched by user
1319         Pop $filename
1320         Pop $md5sum
1321         
1322         IfFileExists $filename +2 0
1323                 Return
1324         StrCmp $removealways "always" unremovefile 0
1325         md5dll::GetMD5File /NOUNLOAD $filename
1326         Pop $ismd5sum ;md5 of file
1327         StrCmp $md5sum $ismd5sum  unremovefile 0
1328         ;DetailPrint "uups MD5 does not match"
1329         StrCmp $removenever "never" 0 +2
1330                 Return
1331         ; the md5 sums does not match so we ask
1332         messagebox::show MB_DEFBUTTON3|MB_TOPMOST "" "0,103" \
1333                 "$(lng_FileChanged)" "$(lng_Yes)" "$(lng_AlwaysYes)" "$(lng_No)" "$(lng_AlwaysNo)"
1334         ;DetailPrint "messagebox finished"
1335         Pop $md5sum
1336         ;DetailPrint "messagebox call returned... $md5sum"
1337         StrCmp $md5sum "1" unremovefile 0       ; Yes
1338         StrCmp $md5sum "2" 0 unremoveno ; Yes always
1339         StrCpy $removealways "always"
1340         ;DetailPrint "removealways"
1341         Goto unremovefile
1342 unremoveno:
1343         StrCmp $md5sum "3" 0 unremovenever      ; No
1344         ;DetailPrint "No remove"
1345         Return
1346 unremovenever:
1347         StrCpy $removenever "never"
1348         ;DetailPrint "removenever"
1349         Return
1350 unremovefile:
1351         ;DetailPrint "removefile"
1352         ClearErrors
1353         Delete $filename
1354         ;now recursivly remove the path
1355 unrmdir:
1356         ${un.GetParent} $filename $filename
1357         IfErrors 0 +2
1358                 Return
1359         RMDir $filename
1360         IfErrors +2
1361                 Goto unrmdir
1362 FunctionEnd
1364 Section Uninstall
1366   ; remove personal settings
1367   Delete "$APPDATA\Inkscape\extension-errors.log"
1368   StrCmp $MultiUser "0" 0 endPurge  ; multiuser assigned in dialog
1369     DetailPrint "purge personal settings in $APPDATA\Inkscape"
1370     ;RMDir /r "$APPDATA\Inkscape"
1371         !insertmacro delprefs
1372         endPurge:
1374   ; Remove file associations for svg editor
1375   DetailPrint "removing file associations for svg editor"
1376   ClearErrors
1377   ReadRegStr $0 HKCR ".svg" ""
1378   DetailPrint ".svg associated as $0"
1379   IfErrors endUninstSVGEdit  
1380     ReadRegStr $1 HKCR "$0\shell\edit\command" ""
1381         IfErrors 0 +2  
1382       DetailPrint "svg editor is $1"
1383     StrCmp $1 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1384       DetailPrint "removing default .svg editor"
1385       DeleteRegKey HKCR "$0\shell\edit\command"
1386     DeleteRegKey /ifempty HKCR "$0\shell\edit"
1387     DeleteRegKey /ifempty HKCR "$0\shell"
1388     DeleteRegKey /ifempty HKCR "$0"
1389   endUninstSVGEdit:
1390   
1391   ClearErrors
1392   ReadRegStr $2 HKCR ".svgz" ""
1393   DetailPrint ".svgz associated as $2"
1394   IfErrors endUninstSVGZEdit  
1395     ReadRegStr $3 HKCR "$2\shell\edit\command" ""
1396     IfErrors 0 +2  
1397       DetailPrint "svgz editor is $1"
1398     StrCmp $3 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1399       DetailPrint "removing default .svgz editor"
1400       DeleteRegKey HKCR "$2\shell\edit\command"
1401     DeleteRegKey /ifempty HKCR "$2\shell\edit"
1402     DeleteRegKey /ifempty HKCR "$2\shell"
1403     DeleteRegKey /ifempty HKCR "$2"
1404   endUninstSVGZEdit:
1405   
1406   ; Remove file associations for svg editor
1407   DetailPrint "removing file associations for svg editor"
1408   ClearErrors
1409   ReadRegStr $0 HKCR ".svg" ""
1410   IfErrors endUninstSVGView
1411     ReadRegStr $1 HKCR "$0\shell\open\command" ""
1412     IfErrors 0 +2  
1413       DetailPrint "svg viewer is $1"
1414     StrCmp $1 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1415       DetailPrint "removing default .svg viewer"
1416       DeleteRegKey HKCR "$0\shell\open\command"
1417     DeleteRegKey /ifempty HKCR "$0\shell\open"
1418     DeleteRegKey /ifempty HKCR "$0\shell"
1419     DeleteRegKey /ifempty HKCR "$0"
1420   endUninstSVGView:
1421   
1422   ClearErrors
1423   ReadRegStr $2 HKCR ".svgz" ""
1424   IfErrors endUninstSVGZView
1425     ReadRegStr $3 HKCR "$2\shell\open\command" ""
1426     IfErrors 0 +2  
1427       DetailPrint "svgz viewer is $1"
1428     StrCmp $3 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1429       DetailPrint "removing default .svgz viewer"
1430       DeleteRegKey HKCR "$2\shell\open\command"
1431     DeleteRegKey /ifempty HKCR "$2\shell\open"
1432     DeleteRegKey /ifempty HKCR "$2\shell"
1433     DeleteRegKey /ifempty HKCR "$2"
1434   endUninstSVGZView:
1435   
1436   ; Remove file associations for context menue
1437   DetailPrint "removing file associations for svg editor"
1438   ClearErrors
1439   ReadRegStr $0 HKCR ".svg" ""
1440   IfErrors endUninstSVGContext
1441   DetailPrint "removing default .svg context menue"
1442   DeleteRegKey HKCR "$0\shell\${PRODUCT_NAME}"
1443   DeleteRegKey /ifempty HKCR "$0\shell"
1444   DeleteRegKey /ifempty HKCR "$0"
1445   endUninstSVGContext:
1446   
1447   ClearErrors
1448   ReadRegStr $2 HKCR ".svgz" ""
1449   IfErrors endUninstSVGZContext
1450   DetailPrint "removing default .svgzcontext menue"
1451   DeleteRegKey HKCR "$2\shell\${PRODUCT_NAME}"
1452   DeleteRegKey /ifempty HKCR "$2\shell"
1453   DeleteRegKey /ifempty HKCR "$2"
1454   endUninstSVGZContext:
1456   ReadRegStr $1 HKCR "$0" ""
1457   StrCmp $1 "" 0 +3
1458     DetailPrint "removing filetype .svg $0"
1459     DeleteRegKey HKCR ".svg"
1460   
1461   ReadRegStr $3 HKCR "$2" ""
1462   StrCmp $3 "" 0 +3
1463     DetailPrint "removing filetype .svgz $2"
1464     DeleteRegKey HKCR ".svgz"
1465   
1466     
1467   SetShellVarContext all
1468   DetailPrint "removing product regkey"
1469   DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
1470   DetailPrint "removing uninstall info"
1471   DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
1472   DetailPrint "removing shortcuts"
1473   Delete "$DESKTOP\Inkscape.lnk"
1474   Delete "$QUICKLAUNCH\Inkscape.lnk"
1475   Delete "$SMPROGRAMS\Inkscape.lnk"
1476   ;just in case they are still there
1477   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
1478   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
1479   RMDir  "$SMPROGRAMS\Inkscape"
1481   SetShellVarContext current
1482   DetailPrint "removing product regkey"
1483   DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
1484   DetailPrint "removing uninstall info"
1485   DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
1486   DetailPrint "removing shortcuts"
1487   Delete "$DESKTOP\Inkscape.lnk"
1488   Delete "$QUICKLAUNCH\Inkscape.lnk"
1489   Delete "$SMPROGRAMS\Inkscape.lnk"
1490   ;just in case they are still there
1491   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
1492   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
1493   RMDir  "$SMPROGRAMS\Inkscape"
1495   DetailPrint "removing uninstall info"
1497   ;uninstall from path, must be repeated for every install logged path individual
1498   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\lib\locale"
1499   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\locale"
1500   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\doc"
1501   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share\tutorials"
1502   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share\templates"
1503   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share\screens"
1504   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share\clipart"
1505   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share\extensions"
1506   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share\icons"
1507   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\share"
1508   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\modules"
1509   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR\python"
1510   ;!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
1512   ;end uninstall, after uninstall from all logged paths has been performed
1513   ;!insertmacro UNINSTALL.LOG_END_UNINSTALL
1515   ;RMDir /r "$INSTDIR"
1516   
1517         StrCpy $removenever ""
1518         StrCpy $removealways ""
1519         
1520         InitPluginsDir
1521         SetPluginUnload manual
1522         
1523         ClearErrors
1524         FileOpen $0 $INSTDIR\uninstall.log r
1525         IfErrors uninstallnotfound
1526 readnextline:  
1527         ClearErrors
1528         FileRead $0 $1
1529         IfErrors done
1530         ; cat the line into md5 and filename
1531         StrLen $2 $1
1532         IntCmp $2 35 readnextline readnextline
1533         StrCpy $3 $1 32
1534         StrCpy $4 $1 $2-36 34   #remove trailing CR/LF
1535         StrCpy $4 $4 -2
1536         Push $3
1537         Push $4
1538         Call un.RemoveFile
1539         Goto readnextline
1540 uninstallnotfound:
1541         MessageBox MB_OK|MB_ICONEXCLAMATION "$(lng_UninstallLogNotFound)" /SD IDOK
1542 done:
1543         FileClose $0
1545         Delete "$INSTDIR\uninstall.log"
1546         Delete "$INSTDIR\uninstall.exe"
1547         ; remove empty directories
1548         RMDir "$INSTDIR\data"
1549         RMDir "$INSTDIR\doc"
1550         RMDir "$INSTDIR\modules"
1551         RMDir "$INSTDIR\plugins"
1552         
1553         RMDir $INSTDIR
1555   SetAutoClose false
1557 SectionEnd