Code

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