Code

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