Code

474c589e9a1024021a2439cabe29142304269d19
[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}"
18 ; #######################################
19 ; MUI   SETTINGS
20 ; #######################################
21 ; MUI 1.67 compatible ------
22 SetCompressor /SOLID lzma
23 !include "MUI.nsh"
24 !include "sections.nsh"
25 !define MUI_ABORTWARNING
26 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
27 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
28 !define MUI_HEADERIMAGE
29 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
30 !define MUI_COMPONENTSPAGE_SMALLDESC
33 ; Welcome page
34 !insertmacro MUI_PAGE_WELCOME
35 ; License page
36 ; !define MUI_LICENSEPAGE_RADIOBUTTONS
37 LicenseForceSelection off
38 !define MUI_LICENSEPAGE_BUTTON $(lng_LICENSE_BUTTON)
39 !define MUI_LICENSEPAGE_TEXT_BOTTOM $(lng_LICENSE_BOTTOM_TEXT)
40 !insertmacro MUI_PAGE_LICENSE "..\..\Copying"
41 !insertmacro MUI_PAGE_COMPONENTS
42 ; InstType $(lng_Full)
43 ; InstType $(lng_Optimal)
44 ; InstType $(lng_Minimal)
45 ; Directory page
46 !insertmacro MUI_PAGE_DIRECTORY
47 ; Instfiles page
48 !insertmacro MUI_PAGE_INSTFILES
49 ; Finish page
50 !define MUI_FINISHPAGE_RUN "$INSTDIR\inkscape.exe"
51 !insertmacro MUI_PAGE_FINISH
53 ; Uninstaller pages
54 !insertmacro MUI_UNPAGE_CONFIRM
55 UninstPage custom un.CustomPageUninstall
56 !insertmacro MUI_UNPAGE_INSTFILES
57 ShowUninstDetails hide
58 !insertmacro MUI_UNPAGE_FINISH
60 ; #######################################
61 ; STRING   LOCALIZATION
62 ; #######################################
63 ; Thanks to Adib Taraben and Luca Bruno for getting this started
64 ; Add your translation here!  :-)
65 ; I had wanted to list the languages alphabetically, but apparently
66 ; the first is the default.  So putting English first is just being
67 ; practical.  It is not chauvinism or hubris, I swear!  ;-)
68 ; default language first
70 ; Language files
71 !include "english.nsh" 
72 !include "catalan.nsh" 
73 !include "czech.nsh" 
74 !include "finnish.nsh" 
75 !include "french.nsh" 
76 !include "german.nsh" 
77 !include "italian.nsh" 
78 !include "japanese.nsh"
79 !include "slovak.nsh" 
80 !include "polish.nsh" 
81 !include "spanish.nsh" 
82 !include "slovenian.nsh" 
84 ReserveFile "inkscape.nsi.uninstall"
87 ; #######################################
88 ; SETTINGS
89 ; #######################################
91 Name              "${PRODUCT_NAME} ${PRODUCT_VERSION}"
92 Caption           $(lng_Caption)
93 OutFile           "Inkscape-${PRODUCT_VERSION}-1.win32.exe"
94 InstallDir        "$PROGRAMFILES\Inkscape"
95 InstallDirRegKey  HKLM "${PRODUCT_DIR_REGKEY}" ""
96 ShowInstDetails   hide
97 ShowUnInstDetails hide
99 var askMultiUser
100 Var MultiUser
101 var User
103 ; #######################################
104 ;  I N S T A L L E R    S E C T I O N S
105 ; #######################################
107 ; Turn off old selected section
108 ; GetWindowsVersion
110 ; Based on Yazno's function, http://yazno.tripod.com/powerpimpit/
111 ; Updated by Joost Verburg
112 ; Updated for Windows 98 SE by Matthew Win Tibbals 5-21-03
114 ; Returns on top of stack
116 ; Windows Version (95, 98, ME, NT x.x, 2000, XP, 2003)
117 ; or
118 ; '' (Unknown Windows Version)
120 ; Usage:
121 ;   Call GetWindowsVersion
122 ;   Pop $R0
123 ;   ; at this point $R0 is "NT 4.0" or whatnot
124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
125 Function GetWindowsVersion
126  
127   Push $R0
128   Push $R1
129  
130   ClearErrors
131  
132   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
133  
134   IfErrors 0 lbl_winnt
135  
136   ; we are not NT
137   ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
138  
139   StrCpy $R1 $R0 1
140   StrCmp $R1 '4' 0 lbl_error
141  
142   StrCpy $R1 $R0 3
143  
144   StrCmp $R1 '4.0' lbl_win32_95
145   StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98
146  
147   lbl_win32_95:
148     StrCpy $R0 '95'
149         StrCpy $AskMultiUser "0"
150   Goto lbl_done
151  
152   lbl_win32_98:
153     StrCpy $R0 '98'
154         StrCpy $AskMultiUser "0"
155   Goto lbl_done
156   lbl_win32_ME:
157     StrCpy $R0 'ME'
158         StrCpy $AskMultiUser "0"
159   Goto lbl_done
160  
161   lbl_winnt:
162  
163   StrCpy $R1 $R0 1
164  
165   StrCmp $R1 '3' lbl_winnt_x
166   StrCmp $R1 '4' lbl_winnt_x
167  
168   StrCpy $R1 $R0 3
169  
170   StrCmp $R1 '5.0' lbl_winnt_2000
171   StrCmp $R1 '5.1' lbl_winnt_XP
172   StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error
173  
174   lbl_winnt_x:
175     StrCpy $R0 "NT $R0" 6
176   Goto lbl_done
177  
178   lbl_winnt_2000:
179     Strcpy $R0 '2000'
180   Goto lbl_done
181  
182   lbl_winnt_XP:
183     Strcpy $R0 'XP'
184   Goto lbl_done
185  
186   lbl_winnt_2003:
187     Strcpy $R0 '2003'
188   Goto lbl_done
189  
190   lbl_error:
191     Strcpy $R0 ''
192   lbl_done:
193  
194   Pop $R1
195   Exch $R0
197 FunctionEnd
199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
201  ; StrStr
202  ; input, top of stack = string to search for
203  ;        top of stack-1 = string to search in
204  ; output, top of stack (replaces with the portion of the string remaining)
205  ; modifies no other variables.
206  ;
207  ; Usage:
208  ;   Push "this is a long ass string"
209  ;   Push "ass"
210  ;   Call StrStr
211  ;   Pop $R0
212  ;  ($R0 at this point is "ass string")
214  Function StrStr
215    Exch $R1 ; st=haystack,old$R1, $R1=needle
216    Exch    ; st=old$R1,haystack
217    Exch $R2 ; st=old$R1,old$R2, $R2=haystack
218    Push $R3
219    Push $R4
220    Push $R5
221    StrLen $R3 $R1
222    StrCpy $R4 0
223    ; $R1=needle
224    ; $R2=haystack
225    ; $R3=len(needle)
226    ; $R4=cnt
227    ; $R5=tmp
228    loop:
229      StrCpy $R5 $R2 $R3 $R4
230      StrCmp $R5 $R1 done
231      StrCmp $R5 "" done
232      IntOp $R4 $R4 + 1
233      Goto loop
234  done:
235    StrCpy $R1 $R2 "" $R4
236    Pop $R5
237    Pop $R4
238    Pop $R3
239    Pop $R2
240    Exch $R1
241  FunctionEnd
243 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245  ; GetParameters
246  ; input, none
247  ; output, top of stack (replaces, with e.g. whatever)
248  ; modifies no other variables.
249  
250  Function GetParameters
251  
252    Push $R0
253    Push $R1
254    Push $R2
255    Push $R3
256    
257    StrCpy $R2 1
258    StrLen $R3 $CMDLINE
259    
260    ;Check for quote or space
261    StrCpy $R0 $CMDLINE $R2
262    StrCmp $R0 '"' 0 +3
263      StrCpy $R1 '"'
264      Goto loop
265    StrCpy $R1 " "
266    
267    loop:
268      IntOp $R2 $R2 + 1
269      StrCpy $R0 $CMDLINE 1 $R2
270      StrCmp $R0 $R1 get
271      StrCmp $R2 $R3 get
272      Goto loop
273    
274    get:
275      IntOp $R2 $R2 + 1
276      StrCpy $R0 $CMDLINE 1 $R2
277      StrCmp $R0 " " get
278      StrCpy $R0 $CMDLINE "" $R2
279    
280    Pop $R3
281    Pop $R2
282    Pop $R1
283    Exch $R0
284  
285  FunctionEnd
287 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
288 ; GetParameterValue
289 ; Chris Morgan<cmorgan@alum.wpi.edu> 5/10/2004
290 ; -Updated 4/7/2005 to add support for retrieving a command line switch
291 ;  and additional documentation
293 ; Searches the command line input, retrieved using GetParameters, for the
294 ; value of an option given the option name.  If no option is found the
295 ; default value is placed on the top of the stack upon function return.
297 ; This function can also be used to detect the existence of just a
298 ; command line switch like /OUTPUT  Pass the default and "OUTPUT"
299 ; on the stack like normal.  An empty return string "" will indicate
300 ; that the switch was found, the default value indicates that
301 ; neither a parameter or switch was found.
303 ; Inputs - Top of stack is default if parameter isn't found,
304 ;  second in stack is parameter to search for, ex. "OUTPUT"
305 ; Outputs - Top of the stack contains the value of this parameter
306 ;  So if the command line contained /OUTPUT=somedirectory, "somedirectory"
307 ;  will be on the top of the stack when this function returns
309 ; Register usage
310 ;$R0 - default return value if the parameter isn't found
311 ;$R1 - input parameter, for example OUTPUT from the above example
312 ;$R2 - the length of the search, this is the search parameter+2
313 ;      as we have '/OUTPUT='
314 ;$R3 - the command line string
315 ;$R4 - result from StrStr calls
316 ;$R5 - search for ' ' or '"'
317  
318 Function GetParameterValue
319   Exch $R0  ; get the top of the stack(default parameter) into R0
320   Exch      ; exchange the top of the stack(default) with
321             ; the second in the stack(parameter to search for)
322   Exch $R1  ; get the top of the stack(search parameter) into $R1
323  
324   ;Preserve on the stack the registers used in this function
325   Push $R2
326   Push $R3
327   Push $R4
328   Push $R5
329  
330   Strlen $R2 $R1+2    ; store the length of the search string into R2
331  
332   Call GetParameters  ; get the command line parameters
333   Pop $R3             ; store the command line string in R3
334  
335   # search for quoted search string
336   StrCpy $R5 '"'      ; later on we want to search for a open quote
337   Push $R3            ; push the 'search in' string onto the stack
338   Push '"/$R1='       ; push the 'search for'
339   Call StrStr         ; search for the quoted parameter value
340   Pop $R4
341   StrCpy $R4 $R4 "" 1   ; skip over open quote character, "" means no maxlen
342   StrCmp $R4 "" "" next ; if we didn't find an empty string go to next
343  
344   # search for non-quoted search string
345   StrCpy $R5 ' '      ; later on we want to search for a space since we
346                       ; didn't start with an open quote '"' we shouldn't
347                       ; look for a close quote '"'
348   Push $R3            ; push the command line back on the stack for searching
349   Push '/$R1='        ; search for the non-quoted search string
350   Call StrStr
351   Pop $R4
352  
353   ; $R4 now contains the parameter string starting at the search string,
354   ; if it was found
355 next:
356   StrCmp $R4 "" check_for_switch ; if we didn't find anything then look for
357                                  ; usage as a command line switch
358   # copy the value after /$R1= by using StrCpy with an offset of $R2,
359   # the length of '/OUTPUT='
360   StrCpy $R0 $R4 "" $R2  ; copy commandline text beyond parameter into $R0
361   # search for the next parameter so we can trim this extra text off
362   Push $R0
363   Push $R5            ; search for either the first space ' ', or the first
364                       ; quote '"'
365                       ; if we found '"/output' then we want to find the
366                       ; ending ", as in '"/output=somevalue"'
367                       ; if we found '/output' then we want to find the first
368                       ; space after '/output=somevalue'
369   Call StrStr         ; search for the next parameter
370   Pop $R4
371   StrCmp $R4 "" done  ; if 'somevalue' is missing, we are done
372   StrLen $R4 $R4      ; get the length of 'somevalue' so we can copy this
373                       ; text into our output buffer
374   StrCpy $R0 $R0 -$R4 ; using the length of the string beyond the value,
375                       ; copy only the value into $R0
376   goto done           ; if we are in the parameter retrieval path skip over
377                       ; the check for a command line switch
378  
379 ; See if the parameter was specified as a command line switch, like '/output'
380 check_for_switch:
381   Push $R3            ; push the command line back on the stack for searching
382   Push '/$R1'         ; search for the non-quoted search string
383   Call StrStr
384   Pop $R4
385   StrCmp $R4 "" done  ; if we didn't find anything then use the default
386   StrCpy $R0 ""       ; otherwise copy in an empty string since we found the
387                       ; parameter, just didn't find a value
388  
389 done:
390   Pop $R5
391   Pop $R4
392   Pop $R3
393   Pop $R2
394   Pop $R1
395   Exch $R0 ; put the value in $R0 at the top of the stack
396 FunctionEnd
398 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
400 !macro Language polng lng
401   SectionIn 1 2 3
402   SetOutPath $INSTDIR
403   File /nonfatal /a "..\..\inkscape\*.${lng}.txt"
404   SetOutPath $INSTDIR\locale
405   File /nonfatal /a /r "..\..\inkscape\locale\${polng}"
406   SetOutPath $INSTDIR\lib\locale
407   File /nonfatal /a /r "..\..\inkscape\lib\locale\${polng}"
408   ; the keyboard tables
409   SetOutPath $INSTDIR\share\screens
410   File /nonfatal /a /r "..\..\inkscape\share\screens\keys.${polng}.svg"  
411   SetOutPath $INSTDIR\share\templates
412   File /nonfatal /a /r "..\..\inkscape\share\templates\default.${polng}.svg"  
413   SetOutPath $INSTDIR\doc
414   File /nonfatal /a /r "..\..\inkscape\doc\keys.${polng}.xml"  
415   File /nonfatal /a /r "..\..\inkscape\doc\keys.${polng}.html"  
416   SectionGetFlags ${SecTutorials} $R1 
417   IntOp $R1 $R1 & ${SF_SELECTED} 
418   IntCmp $R1 ${SF_SELECTED} 0 skip_tutorials 
419     SetOutPath $INSTDIR\share\tutorials
420     File /nonfatal /a "..\..\inkscape\share\tutorials\*.${polng}.*"
421   skip_tutorials:
422 !macroend
424 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
426 ;;;;;;;;;;;;;;;;;;;;;;;;;;
427 ; Delete prefs
428 ; code taken from the vlc project
429 ;;;;;;;;;;;;;;;;;;;;;;;;;;
430 !macro delprefs
431   StrCpy $0 0
432         DetailPrint "Delete personal preferences ..."
433         DetailPrint "try to find all users ..."
434         delprefs-Loop:
435  ; FIXME
436   ; this will loop through all the logged users and "virtual" windows users
437   ; (it looks like users are only present in HKEY_USERS when they are logged in)
438     ClearErrors
439     EnumRegKey $1 HKU "" $0
440     StrCmp $1 "" delprefs-End
441     IntOp $0 $0 + 1
442     ReadRegStr $2 HKU "$1\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" AppData
443     StrCmp $2 "" delprefs-Loop
444         DetailPrint "$2\Inkscape will be removed"
445     RMDir /r "$2\Inkscape"
446     Goto delprefs-Loop
447   delprefs-End:
448 !macroend
451 ;--------------------------------
452 ; Installer Sections
453 ; @todo better idea is to call the original uninstaller first
454 Section -removeInkscape
455   ; check for an old installation and clean that dlls and stuff
456   ClearErrors
457   IfFileExists $INSTDIR\etc 0 doDeleteLib
458     DetailPrint "$INSTDIR\etc exists, will be removed"
459     RmDir /r $INSTDIR\etc
460         IfErrors 0 +4
461       DetailPrint "fatal: failed to delete $INSTDIR\etc"
462       DetailPrint "aborting installation"
463           Abort
464   doDeleteLib:
466   ClearErrors
467   IfFileExists $INSTDIR\lib 0 doDeleteLocale
468     DetailPrint "$INSTDIR\lib exists, will be removed"  
469     RmDir /r $INSTDIR\lib
470         IfErrors 0 +4
471       DetailPrint "fatal: failed to delete $INSTDIR\lib"
472       DetailPrint "aborting installation"
473           Abort
474   doDeleteLocale:
476   ClearErrors
477   IfFileExists $INSTDIR\locale 0 doDeleteDll
478     DetailPrint "$INSTDIR\locale exists, will be removed"
479     RmDir /r $INSTDIR\locale
480         IfErrors 0 +4
481       DetailPrint "fatal: failed to delete $INSTDIR\locale"
482       DetailPrint "aborting installation"
483           Abort
484   doDeleteDll:
486   ClearErrors
487   FindFirst $0 $1 $INSTDIR\*.dll
488     FindNextLoop:
489     StrCmp $1 "" FindNextDone
490     DetailPrint "$INSTDIR\$1 exists, will be removed"
491     Delete $INSTDIR\$1
492     IfErrors 0 +4
493       DetailPrint "fatal: failed to delete $INSTDIR\$1"
494       DetailPrint "aborting installation"
495       Abort
496     FindNext $0 $1
497     Goto FindNextLoop
498   FindNextDone:
499   
500   ;remove the old inkscape shortcuts from the startmenu
501   ;just in case they are still there
502   SetShellVarContext current
503   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
504   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
505   RMDir  "$SMPROGRAMS\Inkscape"
506   Delete "$SMPROGRAMS\Inkscape.lnk"
507   SetShellVarContext all
508   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
509   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
510   RMDir  "$SMPROGRAMS\Inkscape"
511   Delete "$SMPROGRAMS\Inkscape.lnk"
512   
513 SectionEnd
515 Section $(lng_Core) SecCore
517   DetailPrint "Installing Inkscape Core Files ..."
519   SectionIn 1 2 3 RO
520   SetOutPath $INSTDIR
521   SetOverwrite on
522   SetAutoClose false
524   File /a "..\..\inkscape\ink*.exe"
525   File /a "..\..\inkscape\AUTHORS"
526   File /a "..\..\inkscape\COPYING"
527   File /a "..\..\inkscape\COPYING.LIB"
528   File /a "..\..\inkscape\NEWS"
529   File /nonfatal /a "..\..\inkscape\HACKING.txt"
530   File /a "..\..\inkscape\README"
531   File /nonfatal /a "..\..\inkscape\README.txt"
532   File /a "..\..\inkscape\TRANSLATORS"
533   File /nonfatal /a /r "..\..\inkscape\data"
534   File /nonfatal /a /r "..\..\inkscape\doc"
535   File /nonfatal /a /r "..\..\inkscape\plugins"
536   File /nonfatal /a /r /x *.??*.???* /x "examples" /x "tutorials" "..\..\inkscape\share"
537   ; this files are added because it slips through the filter
538   SetOutPath $INSTDIR\share\clipart
539   File /a "..\..\inkscape\share\clipart\inkscape.logo.svg"
540   ;File /a "..\..\inkscape\share\clipart\inkscape.logo.classic.svg"  
541   SetOutPath $INSTDIR\share\extensions
542   File /a "..\..\inkscape\share\extensions\pdf_output.inx.txt"
543   File /a "..\..\inkscape\share\extensions\pdf_output_via_gs_on_win32.inx.txt"
544   SetOutPath $INSTDIR\share\icons
545   File /a "..\..\inkscape\share\icons\inkscape.file.png"
546   File /a "..\..\inkscape\share\icons\inkscape.file.svg"
547   SetOutPath $INSTDIR\modules
548   File /nonfatal /a /r "..\..\inkscape\modules\*.*"
549   SetOutPath $INSTDIR\python
550   File /nonfatal /a /r "..\..\inkscape\python\*.*"
552   
553 SectionEnd
555 Section $(lng_GTKFiles) SecGTK
557   DetailPrint "Installing GTK Files ..."
558   
559   SectionIn 1 2 3 RO
560   SetOutPath $INSTDIR
561   SetOverwrite on
562   File /a /r "..\..\inkscape\*.dll"
563   File /a /r /x "locale" "..\..\inkscape\lib"
564   File /a /r "..\..\inkscape\etc"
565 SectionEnd
567 Section $(lng_Alluser) SecAlluser
568   ; disable this option in Win95/Win98/WinME
569   SectionIn 1 2 3 
570   StrCpy $MultiUser "1"
571   StrCmp $MultiUser "1" "" SingleUser
572     DetailPrint "admin mode, registry root will be HKLM"
573     SetShellVarContext all
574     Goto endSingleUser
575   SingleUser:
576     DetailPrint "single user mode, registry root will be HKCU"
577     SetShellVarContext current
578   endSingleUser:                
579 SectionEnd
581 SectionGroup $(lng_Shortcuts) SecShortcuts
583 Section /o $(lng_Desktop) SecDesktop
584   ClearErrors
585   CreateShortCut "$DESKTOP\Inkscape.lnk" "$INSTDIR\inkscape.exe"
586   IfErrors 0 +2
587     DetailPrint "Uups! Problems creating desktop shortcuts"
588 SectionEnd
590 Section /o $(lng_Quicklaunch) SecQuicklaunch
591   ClearErrors
592   StrCmp $QUICKLAUNCH $TEMP +2
593     CreateShortCut "$QUICKLAUNCH\Inkscape.lnk" "$INSTDIR\inkscape.exe"
594   IfErrors 0 +2
595     DetailPrint "Uups! Problems creating quicklaunch shortcuts"
596 SectionEnd
598 Section $(lng_SVGWriter) SecSVGWriter 
599   SectionIn 1 2 3
600   ; create file associations, test before if needed
601   DetailPrint "creating file associations"
602   ClearErrors
603   ReadRegStr $0 HKCR ".svg" ""
604   StrCmp $0 "" 0 +3
605     WriteRegStr HKCR ".svg" "" "svgfile"
606     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
607   ReadRegStr $0 HKCR ".svgz" ""
608   StrCmp $0 "" 0 +3
609     WriteRegStr HKCR ".svgz" "" "svgfile"
610     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
611   IfErrors 0 +2
612     DetailPrint "Uups! Problems creating file assoziations for svg writer"
613   
614   DetailPrint "creating default editor"
615   ClearErrors
616   ReadRegStr $0 HKCR ".svg" ""
617   WriteRegStr HKCR "$0\shell\edit\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
618   ReadRegStr $0 HKCR ".svgz" ""
619   WriteRegStr HKCR "$0\shell\edit\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
620   IfErrors 0 +2
621     DetailPrint "Uups! Problems creating default editor"
622 SectionEnd
624 Section $(lng_ContextMenu) SecContextMenu
625   SectionIn 1 2 3
626   ; create file associations, test before if needed
627   DetailPrint "creating file associations"
628   ClearErrors
629   ReadRegStr $0 HKCR ".svg" ""
630   StrCmp $0 "" 0 +3
631     WriteRegStr HKCR ".svg" "" "svgfile"
632     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
633   ReadRegStr $0 HKCR ".svgz" ""
634   StrCmp $0 "" 0 +3
635     WriteRegStr HKCR ".svgz" "" "svgfile"
636     WriteRegStr HKCR "svgfile" "" "Scalable Vector Graphics file"
637   IfErrors 0 +2
638     DetailPrint "Uups! Problems creating file assoziations for context menu"
639   
640   DetailPrint "creating context menue"
641   ClearErrors
642   ReadRegStr $0 HKCR ".svg" ""
643   WriteRegStr HKCR "$0\shell\${PRODUCT_NAME}\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
644   ReadRegStr $0 HKCR ".svgz" ""
645   WriteRegStr HKCR "$0\shell\${PRODUCT_NAME}\command" "" '"$INSTDIR\Inkscape.exe" "%1"'
646   IfErrors 0 +2
647     DetailPrint "Uups! Problems creating context menue integration"
649 SectionEnd
651 SectionGroupEnd
653 Section /o $(lng_DeletePrefs) SecPrefs
654         !insertmacro delprefs
655 SectionEnd
657 SectionGroup $(lng_Addfiles) SecAddfiles
659 Section $(lng_Examples) SecExamples
660   SectionIn 1 2
661   SetOutPath $INSTDIR\share
662   File /nonfatal /a /r /x "*.??*.???*" "..\..\inkscape\share\examples"
663 SectionEnd
665 Section $(lng_Tutorials) SecTutorials
666   SectionIn 1 2
667   SetOutPath $INSTDIR\share
668   File /nonfatal /a /r /x "*.??*.???*" "..\..\inkscape\share\tutorials"
669 SectionEnd
671 SectionGroupEnd
673 SectionGroup /e $(lng_Languages) SecLanguages
675 Section $(lng_am) SecAmharic
676   !insertmacro Language am am
677 SectionEnd
679 Section $(lng_az) SecAzerbaijani
680   !insertmacro Language az az
681 SectionEnd
683 Section $(lng_be) SecByelorussian
684   !insertmacro Language be be
685 SectionEnd
687 Section $(lng_bg) SecBulgarian
688   !insertmacro Language bg bg
689 SectionEnd
691 Section $(lng_ca) SecCatalan
692   !insertmacro Language ca ca
693 SectionEnd
695 Section $(lng_cs) SecCzech
696   !insertmacro Language cs cs
697 SectionEnd
699 Section $(lng_da) SecDanish
700   !insertmacro Language da da
701 SectionEnd
703 Section $(lng_de) SecGerman
704   !insertmacro Language 'de' 'de'
705 SectionEnd
707 Section $(lng_dz) SecDzongkha
708   !insertmacro Language dz dz
709 SectionEnd
711 Section $(lng_el) SecGreek
712   !insertmacro Language el el
713 SectionEnd
715 Section $(lng_en) SecEnglish
716   SectionIn 1 2 3 RO
717 SectionEnd
719 Section $(lng_en_CA) SecEnglishCanadian
720   !insertmacro Language en_CA en_CA
721 SectionEnd
723 Section $(lng_en_GB) SecEnglishBritain
724   !insertmacro Language en_GB en_GB
725 SectionEnd
727 Section $(lng_en_US@piglatin) SecEnglishPiglatin
728   !insertmacro Language en_US@piglatin en_US@Piglatin
729 SectionEnd
731 Section $(lng_es) SecSpanish
732   !insertmacro Language 'es' 'es'
733 SectionEnd
735 Section $(lng_es_MX) SecSpanishMexico
736   !insertmacro Language 'es_MX' 'es_MX'
737 SectionEnd
739 Section $(lng_et) SecEstonian
740   !insertmacro Language et et
741 SectionEnd
743 Section $(lng_eu) SecBasque
744   !insertmacro Language eu eu
745 SectionEnd
747 Section $(lng_fr) SecFrench
748   !insertmacro Language 'fr' 'fr'
749 SectionEnd
751 Section $(lng_fi) SecFinish
752   !insertmacro Language 'fi' 'fi'
753 SectionEnd
755 Section $(lng_ga) SecIrish
756   !insertmacro Language ga ga
757 SectionEnd
759 Section $(lng_gl) SecGallegan
760   !insertmacro Language gl gl
761   SectionIn 1 2 3
762 SectionEnd
764 Section $(lng_hr) SecCroatian
765   !insertmacro Language hr hr
766   SectionIn 1 2 3
767 SectionEnd
769 Section $(lng_hu) SecHungarian
770   !insertmacro Language hu hu
771   SectionIn 1 2 3
772 SectionEnd
774 Section $(lng_it) SecItalian
775   !insertmacro Language it it
776   SectionIn 1 2 3
777 SectionEnd
779 Section $(lng_ja) SecJapanese
780   !insertmacro Language 'ja' 'jp'
781 SectionEnd
783 Section $(lng_km) SecKhmer
784   !insertmacro Language km km
785 SectionEnd
787 Section $(lng_ko) SecKorean
788   !insertmacro Language 'ko' 'ko'
789 SectionEnd
791 Section $(lng_lt) SecLithuanian
792   !insertmacro Language 'lt' 'lt'
793 SectionEnd
795 Section $(lng_mn) SecMongolian
796   !insertmacro Language mn mn
797 SectionEnd
799 Section $(lng_mk) SecMacedonian
800   !insertmacro Language mk mk
801 SectionEnd
803 Section $(lng_nb) SecNorwegianBokmal
804   !insertmacro Language nb nb
805 SectionEnd
807 Section $(lng_ne) SecNepali
808   !insertmacro Language ne ne
809 SectionEnd
811 Section $(lng_nl) SecDutch
812   !insertmacro Language nl nl
813 SectionEnd
815 Section $(lng_nn) SecNorwegianNynorsk
816   !insertmacro Language nn nn
817 SectionEnd
819 Section $(lng_pa) SecPanjabi
820   !insertmacro Language pa pa
821 SectionEnd
823 Section $(lng_pl) SecPolish
824   !insertmacro Language pl pl
825 SectionEnd
827 Section $(lng_pt) SecPortuguese
828   !insertmacro Language pt pt
829 SectionEnd
831 Section $(lng_pt_BR) SecPortugueseBrazil
832   !insertmacro Language pt_BR pt_BR
833 SectionEnd
835 Section $(lng_ru) SecRussian
836   !insertmacro Language ru ru
837 SectionEnd
839 Section $(lng_rw) SecKinyarwanda
840   !insertmacro Language rw rw
841 SectionEnd
843 Section $(lng_sk) SecSlovak
844   !insertmacro Language sk sk
845 SectionEnd
847 Section $(lng_sl) SecSlovenian
848   !insertmacro Language sl sl
849 SectionEnd
851 Section $(lng_sq) SecAlbanian
852   !insertmacro Language sq sq
853 SectionEnd
855 Section $(lng_sr) SecSerbian
856   !insertmacro Language sr sr
857 SectionEnd
859 Section $(lng_sr@Latn) SecSerbianLatin
860   !insertmacro Language 'sr@Latn' 'sr@Latn'
861 SectionEnd
863 Section $(lng_sv) SecSwedish
864   !insertmacro Language sv sv
865 SectionEnd
867 Section $(lng_th) SecThai
868   !insertmacro Language th th
869 SectionEnd
871 Section $(lng_tr) SecTurkish
872   !insertmacro Language tr tr
873 SectionEnd
875 Section $(lng_uk) SecUkrainian
876   !insertmacro Language uk uk
877 SectionEnd
879 Section $(lng_vi) SecVietnamese
880   !insertmacro Language vi vi
881 SectionEnd
883 Section $(lng_zh_CN) SecChineseSimplified
884   !insertmacro Language zh_CN zh_CN
885 SectionEnd
887 Section $(lng_zh_TW) SecChineseTaiwan
888   !insertmacro Language zh_TW zh_TW
889 SectionEnd
891 SectionGroupEnd
894 Section -FinalizeInstallation
895   StrCmp $MultiUser "1" "" SingleUser
896     DetailPrint "admin mode, registry root will be HKLM"
897     SetShellVarContext all
898     Goto endSingleUser
899   SingleUser:
900     DetailPrint "single user mode, registry root will be HKCU"
901     SetShellVarContext current
902   endSingleUser:                
904   ; check for writing registry
905   ClearErrors
906   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\inkscape.exe"  
907   ;IfErrors 0 +4
908   ;  DetailPrint "fatal: failed to write to ${PRODUCT_DIR_REGKEY}"
909   ;  DetailPrint "aborting installation"
910   ;     Abort
911   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "MultiUser" "$MultiUser"  
912   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "askMultiUser" "$askMultiUser"
913   WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "User" "$User"
914   IfErrors 0 +2
915     DetailPrint "fatal: failed to write to registry installation info"
917   ; start menu entries
918   ClearErrors
919   CreateShortCut "$SMPROGRAMS\Inkscape.lnk" "$INSTDIR\inkscape.exe"
920   IfErrors 0 +2
921     DetailPrint "fatal: failed to write to start menu info"
923   ; uninstall settings
924   ClearErrors
925   WriteUninstaller "$INSTDIR\uninst.exe"
926   WriteRegExpandStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" '"$INSTDIR\uninst.exe"'
927   WriteRegExpandStr SHCTX "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
928   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
929   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\Inkscape.exe,0"
930   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
931   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" "1"
932   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" "1"
933   IfErrors 0 +2
934     DetailPrint "fatal: failed to write to registry un-installation info"
935 SectionEnd
936  
937 ; Last the Descriptions
938 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
939   !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(lng_CoreDesc)
940   !insertmacro MUI_DESCRIPTION_TEXT ${SecGTK} $(lng_GTKFilesDesc)
941   !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} $(lng_ShortcutsDesc)
942   !insertmacro MUI_DESCRIPTION_TEXT ${SecAlluser} $(lng_AlluserDesc) 
943   !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} $(lng_DesktopDesc)
944   !insertmacro MUI_DESCRIPTION_TEXT ${SecQuicklaunch} $(lng_QuicklaunchDesc)
945   !insertmacro MUI_DESCRIPTION_TEXT ${SecSVGWriter} $(lng_SVGWriterDesc)
946   !insertmacro MUI_DESCRIPTION_TEXT ${SecContextMenu} $(lng_ContextMenuDesc)
947   !insertmacro MUI_DESCRIPTION_TEXT ${SecPrefs} $(lng_DeletePrefsDesc)
948   !insertmacro MUI_DESCRIPTION_TEXT ${SecAddfiles} $(lng_AddfilesDesc)
949   !insertmacro MUI_DESCRIPTION_TEXT ${SecExamples} $(lng_ExamplesDesc)
950   !insertmacro MUI_DESCRIPTION_TEXT ${SecTutorials} $(lng_TutorialsDesc)
951   !insertmacro MUI_DESCRIPTION_TEXT ${SecLanguages} $(lng_LanguagesDesc)
952 !insertmacro MUI_FUNCTION_DESCRIPTION_END
954 !macro Parameter key Section
955   Push ${key}
956   Push ""
957   Call GetParameterValue
958   Pop $1
959   StrCmp $1 "OFF" 0 +5
960     SectionGetFlags ${Section} $0
961     IntOp $2 ${SF_SELECTED} ~
962     IntOp $0 $0 & $2
963     SectionSetFlags ${Section} $0
964   StrCmp $1 "ON" 0 +4
965     SectionGetFlags ${Section} $0
966     IntOp $0 $0 | ${SF_SELECTED}
967     SectionSetFlags ${Section} $0
968 !macroend
970 Function .onInit
971   ;Extract InstallOptions INI files
972   StrCpy $AskMultiUser "1"
973   StrCpy $MultiUser "0"
974   ; this resets AskMultiUser if Win95/98/ME
975   Call GetWindowsVersion
976   Pop $R0
977   DetailPrint "detected operating system $R0"
978   ;MessageBox MB_OK "operating system: $R0; AskMultiuser: $AskMultiUser"
979   
980   ; hide all user section if win98
981   StrCmp $AskMultiUser "1" +2
982     SectionSetText ${SecAlluser} ""
984   ; hide if quick launch if not available
985   StrCmp $QUICKLAUNCH $TEMP 0 +2
986     SectionSetText ${SecQuicklaunch} ""
988   ;check if user is admin
989   ClearErrors
990         UserInfo::GetName
991         IfErrors info_Win9x
992         Pop $0
993         StrCpy $User $0
994         UserInfo::GetAccountType
995         Pop $1
996         StrCmp $1 "Admin" info_done
998         MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_NO_ADMIN)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK info_done IDCANCEL +1
999                 Quit
1000                 
1001         Goto info_done
1003         info_Win9x:
1004                 # This one means you don't need to care about admin or
1005                 # not admin because Windows 9x doesn't either
1006                 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_NOT_SUPPORTED)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK info_done IDCANCEL +1
1007                         Quit
1008                         
1009         info_done:
1011   ;check for previous installation
1012   ReadRegStr $0 HKLM "${PRODUCT_DIR_REGKEY}" "User"
1013   StrCmp $0 "" +1 +2
1014   ReadRegStr $0 HKCU "${PRODUCT_DIR_REGKEY}" "User"
1015   ;check user if applicable
1016   StrCmp $0 "" diff_user_install_done
1017     StrCmp $0 $User diff_user_install_done
1018           MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_DIFFERENT_USER)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK diff_user_install_done IDCANCEL +1
1019                 Quit
1020    diff_user_install_done:
1021           
1022   ; call uninstall first
1023   ; code taken from the vlc project
1024     ReadRegStr $R0  HKLM ${PRODUCT_UNINST_KEY} "UninstallString"
1025         ReadRegStr $R1  HKLM ${PRODUCT_UNINST_KEY} "DisplayName"
1026         StrCmp $R0 "" +1 +3
1027     ReadRegStr $R0  HKCU ${PRODUCT_UNINST_KEY} "UninstallString"
1028         ReadRegStr $R1  HKCU ${PRODUCT_UNINST_KEY} "DisplayName"
1029         StrCmp $R0 "" uninstall_before_done
1030          
1031           MessageBox MB_YESNO|MB_ICONEXCLAMATION $(lng_WANT_UNINSTALL_BEFORE) /SD IDNO IDYES +1 IDNO uninstall_before_done 
1032           ;Run the uninstaller
1033           ;uninst:
1034             ClearErrors
1035             ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
1036           uninstall_before_done:
1037           
1038   ; proccess command line parameter
1039   !insertmacro Parameter "GTK" ${SecGTK}
1040   !insertmacro Parameter "SHORTCUTS" ${secShortcuts}
1041   !insertmacro Parameter "ALLUSER" ${SecAlluser}
1042   !insertmacro Parameter "DESKTOP" ${SecDesktop}
1043   !insertmacro Parameter "QUICKLAUNCH" ${SecQUICKlaunch}
1044   !insertmacro Parameter "SVGEDITOR" ${SecSVGWriter}
1045   !insertmacro Parameter "CONTEXTMENUE" ${SecContextMenu}
1046   !insertmacro Parameter "PREFERENCES" ${SecPrefs}
1047   !insertmacro Parameter "ADDFILES" ${SecAddfiles}
1048   !insertmacro Parameter "EXAMPLES" ${SecExamples}
1049   !insertmacro Parameter "TUTORIALS" ${SecTutorials}
1050   !insertmacro Parameter "LANGUAGES" ${SecLanguages}
1051   !insertmacro Parameter "am" ${SecAmharic}
1052   !insertmacro Parameter "az" ${SecAzerbaijani}
1053   !insertmacro Parameter "be" ${SecByelorussian}
1054   !insertmacro Parameter "bg" ${SecBulgarian}
1055   !insertmacro Parameter "ca" ${SecCatalan}
1056   !insertmacro Parameter "cs" ${SecCzech}
1057   !insertmacro Parameter "da" ${SecDanish}
1058   !insertmacro Parameter "de" ${SecGerman}
1059   !insertmacro Parameter "dz" ${SecDzongkha}
1060   !insertmacro Parameter "el" ${SecGreek}
1061   !insertmacro Parameter "en_CA" ${SecEnglishCanadian}
1062   !insertmacro Parameter "en_GB" ${SecEnglishBritain}
1063   !insertmacro Parameter "en_US@piglatin" ${SecEnglishPiglatin}
1064   !insertmacro Parameter "es" ${SecSpanish}
1065   !insertmacro Parameter "es_MX" ${SecSpanishMexico}
1066   !insertmacro Parameter "et" ${SecEstonian}
1067   !insertmacro Parameter "eu" ${SecBasque}
1068   !insertmacro Parameter "fi" ${SecFinish}
1069   !insertmacro Parameter "fr" ${SecFrench}
1070   !insertmacro Parameter "ga" ${SecIrish}
1071   !insertmacro Parameter "gl" ${SecGallegan}
1072   !insertmacro Parameter "hr" ${SecCroatian}
1073   !insertmacro Parameter "hu" ${SecHungarian}
1074   !insertmacro Parameter "it" ${SecItalian}
1075   !insertmacro Parameter "ja" ${SecJapanese}
1076   !insertmacro Parameter "km" ${SecKhmer}
1077   !insertmacro Parameter "ko" ${SecKorean}
1078   !insertmacro Parameter "lt" ${SecLithuanian}
1079   !insertmacro Parameter "mk" ${SecMacedonian}
1080   !insertmacro Parameter "mn" ${SecMongolian}
1081   !insertmacro Parameter "nb" ${SecNorwegianBokmal}
1082   !insertmacro Parameter "ne" ${SecNepali}
1083   !insertmacro Parameter "nl" ${SecDutch}
1084   !insertmacro Parameter "nn" ${SecNorwegianNynorsk}
1085   !insertmacro Parameter "pa" ${SecPanjabi}
1086   !insertmacro Parameter "pl" ${SecPolish}
1087   !insertmacro Parameter "pt" ${SecPortuguese}
1088   !insertmacro Parameter "pt_BR" ${SecPortugueseBrazil}
1089   !insertmacro Parameter "ru" ${SecRussian}
1090   !insertmacro Parameter "rw" ${SecKinyarwanda}
1091   !insertmacro Parameter "sk" ${SecSlovak}
1092   !insertmacro Parameter "sl" ${SecSlovenian}
1093   !insertmacro Parameter "sq" ${SecAlbanian}
1094   !insertmacro Parameter "sr" ${SecSerbian}
1095   !insertmacro Parameter "sr@Latn" ${SecSerbianLatin}
1096   !insertmacro Parameter "sv" ${SecSwedish}
1097   !insertmacro Parameter "th" ${SecThai}
1098   !insertmacro Parameter "tr" ${SecTurkish}
1099   !insertmacro Parameter "uk" ${SecUkrainian}
1100   !insertmacro Parameter "vi" ${SecVietnamese}
1101   !insertmacro Parameter "zh_CN" ${SecChineseSimplified}
1102   !insertmacro Parameter "zh_TW" ${SecChineseTaiwan}
1103   
1104   Push "?"
1105   Push "TEST"
1106   Call GetParameterValue
1107   Pop $1
1108   StrCmp $1 "TEST" +3
1109     MessageBox MB_OK "possible parameters for installer:$\r$\n \
1110       /?: this help screen$\r$\n \
1111       /S: silent$\r$\n \
1112       /D=(directory): where to install inkscape$\r$\n \
1113       /GTK=(OFF/ON): GTK+ Runtime environment$\r$\n \
1114       /SHORTCUTS=(OFF/ON): shortcuts to start inkscape$\r$\n \
1115       /ALLUSER=(OFF/ON): for all users on the computer$\r$\n \
1116       /DESKTOP=(OFF/ON): Desktop icon$\r$\n \
1117       /QUICKLAUNCH=(OFF/ON): quick launch icon$\r$\n \
1118       /SVGEDITOR=(OFF/ON): default SVG editor$\r$\n \
1119       /CONTEXTMENUE=(OFF/ON): context menue integration$\r$\n \
1120       /PREFERENCES=(OFF/ON): delete users preference files$\r$\n \
1121       /ADDFILES=(OFF/ON): additional files$\r$\n \
1122       /EXAMPLES=(OFF/ON): examples$\r$\n \
1123       /TUTORIALS=(OFF/ON): tutorials$\r$\n \
1124       /LANGUAGES=(OFF/ON): translated menues, examples, etc.$\r$\n \
1125       /[locale code]=(OFF/ON): e.g am, es, es_MX as in Inkscape supported"
1126     Abort
1127 FunctionEnd
1129 Function .onSelChange
1130 FunctionEnd
1132 ; --------------------------------------------------
1134 Function un.CustomPageUninstall
1135   !insertmacro MUI_HEADER_TEXT "$(lng_UInstOpt)" "$(lng_UInstOpt1)"
1136   !insertmacro MUI_INSTALLOPTIONS_WRITE "inkscape.nsi.uninstall" "Field 1" "Text" "$APPDATA\Inkscape\"
1137   !insertmacro MUI_INSTALLOPTIONS_WRITE "inkscape.nsi.uninstall" "Field 2" "Text" "$(lng_PurgePrefs)"
1139   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "inkscape.nsi.uninstall"
1140   !insertmacro MUI_INSTALLOPTIONS_READ $MultiUser "inkscape.nsi.uninstall" "Field 2" "State"
1141   DetailPrint "keepfiles = $MultiUser" 
1142           ;MessageBox MB_OK "adminmode = $MultiUser MultiUserOS = $askMultiUser" 
1144 FunctionEnd
1147 Function un.onInit
1148   ClearErrors
1149   StrCpy $User ""
1150         UserInfo::GetName
1151         IfErrors +3
1152         Pop $0
1153         StrCpy $User $0
1155   StrCpy $askMultiUser "1"
1156   StrCpy $MultiUser "1"
1157  
1158   ; Test if this was a multiuser installation
1159   ReadRegStr $0 HKLM "${PRODUCT_DIR_REGKEY}" ""
1160   StrCmp $0  "$INSTDIR\inkscape.exe" 0 hkcu_user_uninstall  
1161     ReadRegStr $MultiUser HKLM "${PRODUCT_DIR_REGKEY}" "MultiUser"
1162     ReadRegStr $askMultiUser HKLM "${PRODUCT_DIR_REGKEY}" "askMultiUser"
1163         ReadRegStr $0 HKLM "${PRODUCT_DIR_REGKEY}" "User"
1164         Goto check_user_uninstall
1165   hkcu_user_uninstall:
1166   ReadRegStr $MultiUser HKCU "${PRODUCT_DIR_REGKEY}" "MultiUser"
1167   ReadRegStr $askMultiUser HKCU "${PRODUCT_DIR_REGKEY}" "askMultiUser"
1168   ReadRegStr $0 HKCU "${PRODUCT_DIR_REGKEY}" "User"
1169   ;check user if applicable
1170   check_user_uninstall:
1171   StrCmp $0 "" diff_user_uninstall_done
1172         StrCmp $0 $User diff_user_uninstall_done
1173           MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(lng_DIFFERENT_USER)$(lng_OK_CANCEL_DESC)" /SD IDOK IDOK diff_user_uninstall_done IDCANCEL +1
1174                 Quit
1175   diff_user_uninstall_done:
1176     
1177  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "inkscape.nsi.uninstall"
1179  ;check whether Multi user installation ?
1180  SetShellVarContext all
1181  StrCmp $MultiUser "0" 0 +2 
1182  SetShellVarContext current
1183  ;MessageBox MB_OK "adminmode = $MultiUser MultiUserOS = $askMultiUser" 
1184    
1185 FunctionEnd
1187 Section Uninstall
1189   ; remove personal settings
1190   Delete "$APPDATA\Inkscape\extension-errors.log"
1191   StrCmp $MultiUser "0" 0 endPurge  ; multiuser assigned in dialog
1192     DetailPrint "purge personal settings in $APPDATA\Inkscape"
1193     ;RMDir /r "$APPDATA\Inkscape"
1194         !insertmacro delprefs
1195   endPurge:
1197   ; Remove file associations for svg editor
1198   DetailPrint "removing file associations for svg editor"
1199   ClearErrors
1200   ReadRegStr $0 HKCR ".svg" ""
1201   DetailPrint ".svg associated as $0"
1202   IfErrors endUninstSVGEdit  
1203     ReadRegStr $1 HKCR "$0\shell\edit\command" ""
1204         IfErrors 0 +2  
1205       DetailPrint "svg editor is $1"
1206     StrCmp $1 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1207       DetailPrint "removing default .svg editor"
1208       DeleteRegKey HKCR "$0\shell\edit\command"
1209     DeleteRegKey /ifempty HKCR "$0\shell\edit"
1210     DeleteRegKey /ifempty HKCR "$0\shell"
1211     DeleteRegKey /ifempty HKCR "$0"
1212   endUninstSVGEdit:
1213   
1214   ClearErrors
1215   ReadRegStr $2 HKCR ".svgz" ""
1216   DetailPrint ".svgz associated as $2"
1217   IfErrors endUninstSVGZEdit  
1218     ReadRegStr $3 HKCR "$2\shell\edit\command" ""
1219     IfErrors 0 +2  
1220       DetailPrint "svgz editor is $1"
1221     StrCmp $3 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1222       DetailPrint "removing default .svgz editor"
1223       DeleteRegKey HKCR "$2\shell\edit\command"
1224     DeleteRegKey /ifempty HKCR "$2\shell\edit"
1225     DeleteRegKey /ifempty HKCR "$2\shell"
1226     DeleteRegKey /ifempty HKCR "$2"
1227   endUninstSVGZEdit:
1228   
1229   ; Remove file associations for svg editor
1230   DetailPrint "removing file associations for svg editor"
1231   ClearErrors
1232   ReadRegStr $0 HKCR ".svg" ""
1233   IfErrors endUninstSVGView
1234     ReadRegStr $1 HKCR "$0\shell\open\command" ""
1235     IfErrors 0 +2  
1236       DetailPrint "svg viewer is $1"
1237     StrCmp $1 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1238       DetailPrint "removing default .svg viewer"
1239       DeleteRegKey HKCR "$0\shell\open\command"
1240     DeleteRegKey /ifempty HKCR "$0\shell\open"
1241     DeleteRegKey /ifempty HKCR "$0\shell"
1242     DeleteRegKey /ifempty HKCR "$0"
1243   endUninstSVGView:
1244   
1245   ClearErrors
1246   ReadRegStr $2 HKCR ".svgz" ""
1247   IfErrors endUninstSVGZView
1248     ReadRegStr $3 HKCR "$2\shell\open\command" ""
1249     IfErrors 0 +2  
1250       DetailPrint "svgz viewer is $1"
1251     StrCmp $3 '"$INSTDIR\Inkscape.exe" "%1"' 0 +3
1252       DetailPrint "removing default .svgz viewer"
1253       DeleteRegKey HKCR "$2\shell\open\command"
1254     DeleteRegKey /ifempty HKCR "$2\shell\open"
1255     DeleteRegKey /ifempty HKCR "$2\shell"
1256     DeleteRegKey /ifempty HKCR "$2"
1257   endUninstSVGZView:
1258   
1259   ; Remove file associations for context menue
1260   DetailPrint "removing file associations for svg editor"
1261   ClearErrors
1262   ReadRegStr $0 HKCR ".svg" ""
1263   IfErrors endUninstSVGContext
1264   DetailPrint "removing default .svg context menue"
1265   DeleteRegKey HKCR "$0\shell\${PRODUCT_NAME}"
1266   DeleteRegKey /ifempty HKCR "$0\shell"
1267   DeleteRegKey /ifempty HKCR "$0"
1268   endUninstSVGContext:
1269   
1270   ClearErrors
1271   ReadRegStr $2 HKCR ".svgz" ""
1272   IfErrors endUninstSVGZContext
1273   DetailPrint "removing default .svgzcontext menue"
1274   DeleteRegKey HKCR "$2\shell\${PRODUCT_NAME}"
1275   DeleteRegKey /ifempty HKCR "$2\shell"
1276   DeleteRegKey /ifempty HKCR "$2"
1277   endUninstSVGZContext:
1279   ReadRegStr $1 HKCR "$0" ""
1280   StrCmp $1 "" 0 +3
1281     DetailPrint "removing filetype .svg $0"
1282     DeleteRegKey HKCR ".svg"
1283   
1284   ReadRegStr $3 HKCR "$2" ""
1285   StrCmp $3 "" 0 +3
1286     DetailPrint "removing filetype .svgz $2"
1287     DeleteRegKey HKCR ".svgz"
1288   
1289     
1290   SetShellVarContext all
1291   DetailPrint "removing product regkey"
1292   DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
1293   DetailPrint "removing uninstall info"
1294   DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
1295   DetailPrint "removing shortcuts"
1296   Delete "$DESKTOP\Inkscape.lnk"
1297   Delete "$QUICKLAUNCH\Inkscape.lnk"
1298   Delete "$SMPROGRAMS\Inkscape.lnk"
1299   ;just in case they are still there
1300   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
1301   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
1302   RMDir  "$SMPROGRAMS\Inkscape"
1304   SetShellVarContext current
1305   DetailPrint "removing product regkey"
1306   DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
1307   DetailPrint "removing uninstall info"
1308   DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
1309   DetailPrint "removing shortcuts"
1310   Delete "$DESKTOP\Inkscape.lnk"
1311   Delete "$QUICKLAUNCH\Inkscape.lnk"
1312   Delete "$SMPROGRAMS\Inkscape.lnk"
1313   ;just in case they are still there
1314   Delete "$SMPROGRAMS\Inkscape\Uninstall Inkscape.lnk"
1315   Delete "$SMPROGRAMS\Inkscape\Inkscape.lnk"
1316   RMDir  "$SMPROGRAMS\Inkscape"
1318   DetailPrint "removing uninstall info"
1319   RMDir /r "$INSTDIR"
1321   SetAutoClose false
1323 SectionEnd