]> git.lyx.org Git - features.git/blob - development/Win32/packaging/AltInstaller/ConfigLyX.nsh
acf9693c727a6aa42ded49c24937b69cfe2b27fe
[features.git] / development / Win32 / packaging / AltInstaller / ConfigLyX.nsh
1 Function ConfigureLyX
2  # configures LyX
3
4   # create the PathPrefix
5   StrCpy $PathPrefix "$INSTDIR\bin"
6   ${if} $PythonPath != ""
7     StrCpy $PathPrefix "$PathPrefix;$PythonPath"
8   ${endif}
9   ${if} $LatexPath != ""
10     StrCpy $PathPrefix "$PathPrefix;$LatexPath"
11   ${endif}
12   ${if} $GhostscriptPath != ""
13     StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
14   ${endif}
15   ${if} $ImageMagickPath != ""
16     StrCpy $PathPrefix "$PathPrefix;$ImageMagickPath"
17   ${endif}
18   ${if} $PSVPath != ""
19     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
20   ${endif}
21   ${if} $EditorPath != ""
22     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
23   ${endif}
24   ${if} $ImageEditorPath != ""
25     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
26   ${endif}
27   ${if} $SVGPath != ""
28    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
29   ${endif}
30   
31   # Create a batch file to start LyX with the environment variables set
32   ClearErrors
33   Delete "${PRODUCT_BAT}"
34   FileOpen $R1 "${PRODUCT_BAT}" w
35   FileWrite $R1 '@echo off$\r$\n\
36                  SET LANG=$LangCode$\r$\n\
37                  SET AIK_DATA_DIR=${AiksaurusDir}$\r$\n\
38                  start "${PRODUCT_NAME}" "${LAUNCHER_EXE}" %*$\r$\n'
39   FileClose $R1
40   IfErrors 0 +2
41    MessageBox MB_OK|MB_ICONEXCLAMATION "$(CreateCmdFilesFailed)"
42    
43   # Set the path prefix in lyxrc.dist
44   ClearErrors
45   Delete "$INSTDIR\Resources\lyxrc.dist"
46   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
47   # set some general things
48   FileWrite $R1 '\preview_scale_factor "1.0"$\r$\n\
49                  \screen_zoom "120"$\r$\n'
50   ${if} "$PathPrefix" != ""
51    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
52   ${endif}
53   # if Acrobat or Adobe Reader is used
54   ${if} $Acrobat == "Yes" # used for Acrobat / Adobe Reader
55    FileWrite $R1 '\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector"$\r$\n\
56                   \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector"$\r$\n\
57                   \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector"$\r$\n'
58   ${endif}
59   # if a SVG to PDF converter ws found (e.g. Inkscape)
60   ${if} $SVGPath != ""
61    FileWrite $R1 '\format "svg" "svg" "SVG" "" "inkscape --file=$$$$i" "inkscape --file=$$$$i" "vector"$\r$\n\
62                   \converter "svg" "png" "inkscape --without-gui --file=$$$$i --export-png=$$$$o" ""$\r$\n\
63                   \converter "svg" "pdf" "inkscape --file=$$$$i --export-area-drawing --without-gui --export-pdf=$$$$o" ""$\r$\n\
64                   \converter "svg" "pdf2" "inkscape --file=$$$$i --export-area-drawing --without-gui --export-pdf=$$$$o" ""'
65   ${endif}
66   FileClose $R1
67   IfErrors 0 +2
68   MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
69   
70   # register LyX
71   ${if} $CreateFileAssociations == "true"
72    WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
73   ${endif}
74   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "RootKey" "$ProductRootKey"
75   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
76   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${PRODUCT_UNINSTALL_EXE}"
77   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
78   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
79   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
80   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_INFO_URL}"
81   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_ABOUT_URL}"
82   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "LyX Team"
83   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_HELP_LINK}"
84   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
85   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
86
87   # create start menu entry
88   SetOutPath "$INSTDIR\bin"
89   CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
90   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
91   SetOutPath "$INSTDIR"
92   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${PRODUCT_UNINSTALL_EXE}"
93
94   # create desktop icon
95   ${if} $CreateDesktopIcon == "true"
96    SetOutPath "$INSTDIR\bin"
97    CreateShortCut "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
98   ${endif}
99
100   # register the extension .lyx
101   ${if} $CreateFileAssociations == "true"
102    WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" # special entry to test if they were registered by this LyX version
103    # write informations about file type
104    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Document"
105    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE}"
106    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_BAT}" "%1"'
107    # write informations about file extensions
108    WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
109    WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "Content Type" "${PRODUCT_MIME_TYPE}"  
110    # refresh shell
111    System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
112   ${endif}
113
114   # create the LyX Application Data folder for all users
115   # this folder is automatically created by LyX when it is first started but we want to start LyX with a specific session file,
116   # so we create this folder before LyX starts and copy there the session file
117   StrCpy $AppSubfolder ${PRODUCT_SUBFOLDER}
118   StrCpy $AppFiles "$INSTDIR\Resources\session"
119   Call CreateAppPathSub # function from LyXUtils.nsh
120   Delete "$INSTDIR\Resources\session" # delete the session file in the INSTDIR because it is unneeded there
121   
122   # delete unnecessary files
123   ${if} $DelPythonFiles == "True"
124    Delete $INSTDIR\bin\python.exe
125    Delete $INSTDIR\bin\python25.dll
126    Delete $INSTDIR\bin\Python-License.txt
127    RMDir /r $INSTDIR\bin\Lib
128    RMDir /r $INSTDIR\bin\DLLs
129   ${endif}
130   RMDir /r $INSTDIR\external
131
132   # create a bat-file to start configure in a console window so that the user see the progress
133   # of the configuration and to have a signal when the configuration is ready to start LyX
134   # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
135   # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
136   # a batch file is needed because simply calling
137   # ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
138   # creates the config files in $PythonPath
139   ${if} $PythonPath == ""
140    StrCpy $PythonPath "$INSTDIR\bin"
141   ${endif}
142   StrCpy $1 $INSTDIR 2 # get drive letter
143   FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
144   FileWrite $R1 '$1$\r$\n\
145                  cd $INSTDIR\Resources\$\r$\n\
146                  "$PythonPath\python.exe" configure.py'
147   FileClose $R1
148
149 FunctionEnd
150