2007-02-08 21:09:30 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
LyX for Windows Launcher
|
|
|
|
Author: Joost Verburg
|
|
|
|
|
2010-07-16 14:17:03 +00:00
|
|
|
This will be installed as LyXLauncher.exe.
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2010-07-16 14:17:03 +00:00
|
|
|
The launcher application hides the lyx.exe console window.
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
!include MUI.nsh
|
|
|
|
!include LogicLib.nsh
|
|
|
|
!include FileFunc.nsh
|
|
|
|
!include StrFunc.nsh
|
2007-02-08 21:09:30 +00:00
|
|
|
${StrStr}
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Configuration from installer
|
|
|
|
!include "..\packaging\installer\settings.nsh"
|
|
|
|
!include "..\packaging\installer\include\declarations.nsh"
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2007-06-28 17:00:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Settings
|
2007-06-28 17:00:30 +00:00
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
Caption "${APP_NAME} ${APP_VERSION}"
|
2008-05-01 18:33:36 +00:00
|
|
|
OutFile LyXLauncher.exe
|
2007-02-08 21:09:30 +00:00
|
|
|
BrandingText " "
|
|
|
|
|
2007-06-28 17:00:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Windows Vista settings
|
2007-06-28 17:00:30 +00:00
|
|
|
|
|
|
|
RequestExecutionLevel user
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Variables
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Var Parameters
|
|
|
|
Var Debug
|
|
|
|
Var ReturnValue
|
2008-05-01 18:33:36 +00:00
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
Var ResultText
|
|
|
|
Var ResultSubText
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
Var LyXFolder
|
|
|
|
|
|
|
|
Var EnvironmentVariable
|
|
|
|
Var EnvironmentVariableValue
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# User interface for debug output
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-04-07 12:50:54 +00:00
|
|
|
!define MUI_ICON "..\packaging\icons\lyx.ico"
|
2007-02-08 21:09:30 +00:00
|
|
|
!define MUI_CUSTOMFUNCTION_GUIINIT InitInterface
|
|
|
|
|
|
|
|
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT $ResultText
|
|
|
|
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT $ResultSubText
|
|
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
|
|
|
|
|
|
!insertmacro MUI_LANGUAGE English
|
|
|
|
|
|
|
|
ShowInstDetails show
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Windows API constants
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
!define SWP_NOSIZE 0x1
|
|
|
|
!define MONITOR_DEFAULTTONEAREST 0x2
|
|
|
|
|
|
|
|
!define SM_CYCAPTION 4
|
|
|
|
!define SM_CXSIZEFRAME 32
|
|
|
|
!define SM_CYSIZEFRAME 33
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Version information
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
VIProductVersion "${APP_VERSION_NUMBER}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_INFO}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
|
|
|
|
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "${APP_COPYRIGHT}"
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Macros
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
!macro SystemCall STACK
|
|
|
|
|
|
|
|
Push "${STACK}"
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
|
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro GetLyXSetting NAME VAR
|
|
|
|
|
|
|
|
Push "${NAME}"
|
|
|
|
Call GetLyXSetting
|
|
|
|
Pop "${VAR}"
|
|
|
|
|
|
|
|
!macroend
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
2008-05-01 18:33:36 +00:00
|
|
|
# Main application
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Section -Prepare
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $Debug == ${FALSE}
|
2007-02-08 21:09:30 +00:00
|
|
|
HideWindow
|
2008-05-01 18:33:36 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Hide controls we don't need
|
2007-02-08 21:09:30 +00:00
|
|
|
FindWindow $R0 "#32770" "" $HWNDPARENT
|
|
|
|
GetDlgItem $R0 $R0 1004
|
2008-05-01 18:33:36 +00:00
|
|
|
ShowWindow $R0 ${SW_HIDE}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Get LyX folder
|
|
|
|
${GetParent} $EXEDIR $LyXFolder
|
|
|
|
|
|
|
|
# Debug info
|
2007-02-08 21:09:30 +00:00
|
|
|
!insertmacro MUI_HEADER_TEXT "Debugging LyX" "The events you have chosen \
|
|
|
|
are being logged."
|
|
|
|
SetDetailsPrint textonly
|
|
|
|
DetailPrint "Debug log:"
|
|
|
|
SetDetailsPrint listonly
|
2010-07-16 14:17:03 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Location of Aiksaurus data
|
2007-02-08 21:09:30 +00:00
|
|
|
Push AIK_DATA_DIR
|
2008-05-01 18:33:36 +00:00
|
|
|
Push "$LyXFolder\aiksaurus"
|
|
|
|
Call SetEnvironmentVariable
|
2009-08-21 22:35:41 +00:00
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
Section -Launch
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Start LyX and capture the command line output
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
Push '"$EXEDIR\lyx.exe" $Parameters'
|
2007-02-08 21:09:30 +00:00
|
|
|
CallInstDLL "$EXEDIR\Console.dll" ExecToLog
|
2007-02-28 20:48:30 +00:00
|
|
|
Pop $ReturnValue #Return value
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
Section -Debug
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $Debug == ${FALSE}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Check whether something went wrong
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $ReturnValue == "error"
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Probably the file does not exist
|
2007-02-08 21:09:30 +00:00
|
|
|
MessageBox MB_OK|MB_ICONSTOP "Failed to start LyX."
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${ElseIf} $ReturnValue != 0
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# LyX has crashed
|
2007-02-08 21:09:30 +00:00
|
|
|
MessageBox MB_YESNO|MB_ICONSTOP \
|
|
|
|
"LyX has been closed because of an unexpected situation.$\n\
|
|
|
|
This is most likely caused by a flaw in the software.$\n$\n\
|
|
|
|
When you open your documents again, you will be able$\n\
|
|
|
|
to restore an emergency save and continue working.$\n$\n\
|
|
|
|
Would you like to view detailed information about this error?" \
|
|
|
|
IDYES debug IDNO no_debug
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
no_debug:
|
|
|
|
|
|
|
|
Quit
|
|
|
|
|
|
|
|
debug:
|
|
|
|
|
|
|
|
ShowWindow $R0 ${SW_HIDE}
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $ReturnValue != 0
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
StrCpy $ResultText "Error Information"
|
|
|
|
StrCpy $ResultSubText "See Chapter 3 of the LyX Introduction \
|
|
|
|
(Help > Introduction) for information about reporting this issue."
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${Else}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
StrCpy $ResultText "Debugging Completed"
|
|
|
|
StrCpy $ResultSubText "The events you have chosen are logged below."
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $Debug == ${FALSE}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Put the log window on the screen again
|
2007-02-08 21:09:30 +00:00
|
|
|
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i 133, i 100, i 0, i 0, i ${SWP_NOSIZE})"
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
BringToFront
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#--------------------------------
|
|
|
|
#Functions
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Function InitInterface
|
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Command line parameters
|
2009-08-21 22:35:41 +00:00
|
|
|
${GetParameters} $Parameters
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2007-02-28 20:48:30 +00:00
|
|
|
#Check for debug mode
|
2007-02-08 21:09:30 +00:00
|
|
|
${StrStr} $R0 $Parameters "-dbg"
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $R0 == ""
|
2007-02-08 21:09:30 +00:00
|
|
|
StrCpy $Debug ${FALSE}
|
2008-05-01 18:33:36 +00:00
|
|
|
${Else}
|
2007-02-08 21:09:30 +00:00
|
|
|
StrCpy $Debug ${TRUE}
|
2008-05-01 18:33:36 +00:00
|
|
|
${Endif}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${If} $Debug == ${FALSE}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Keep the log window outside the screen to ensure that there will be no flickering
|
2007-02-08 21:09:30 +00:00
|
|
|
Push "user32::SetWindowPos(i $HWNDPARENT, i 0, i -32000, i -32000, i 0, i 0, i ${SWP_NOSIZE})"
|
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Function SetEnvironmentVariable
|
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
# Sets the value of an environment variable
|
|
|
|
# Input on stack: name of variable, value
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
Pop $EnvironmentVariableValue
|
|
|
|
Pop $EnvironmentVariable
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-05-01 18:33:36 +00:00
|
|
|
Push 'kernel32::SetEnvironmentVariable(t, t) i("$EnvironmentVariable", "$EnvironmentVariableValue")'
|
2007-02-08 21:09:30 +00:00
|
|
|
CallInstDLL "$EXEDIR\System.dll" Call
|
|
|
|
|
|
|
|
FunctionEnd
|