Changeset 373:cf2b6b8a3973 for mlx.nsi


Ignore:
Timestamp:
12/18/12 10:08:43 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Added support for a secondary instance (#157)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mlx.nsi

    r28 r373  
    55
    66  !include "MUI.nsh"
     7  !include "nsDialogs.nsh"
     8  !include "TextFunc.nsh"
    79  !include "mlx-common.nsh"
    810
    911;--------------------------------
    1012;General
     13
     14  Var ApplicationName
     15
     16  Function .onInit
     17    StrCpy $ApplicationName "Mava Logger X"
     18  FunctionEnd
    1119
    1220  ;Name and file
     
    1725  ;Default installation folder
    1826  InstallDir "$PROGRAMFILES\MAVA Logger X"
    19  
    20   ;Get installation folder from registry if available
    21   InstallDirRegKey HKCU "Software\MAVA Logger X" ""
    2227
    2328  ;Vista redirects $SMPROGRAMS to all users without this
     
    2934  Var MUI_TEMP
    3035  Var STARTMENU_FOLDER
     36  Var Variable
     37  Var Secondary
     38  Var Secondary_State
     39  Var LinkName
     40  Var Parameters
    3141
    3242;--------------------------------
     
    4050;Pages
    4151
     52
    4253  !insertmacro MUI_PAGE_LICENSE "license.txt"
     54  Page custom optionsPage ;optionsPageLeave
    4355  !insertmacro MUI_PAGE_COMPONENTS
    4456  !insertmacro MUI_PAGE_DIRECTORY
    4557
    4658  ;Start Menu Folder Page Configuration
    47   !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
    48   !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\MAVA Logger X"
    49   !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
    50  
     59  ;!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
     60  ;!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\MAVA Logger X"
     61  ;!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
     62
    5163  !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
    5264
    5365  !insertmacro MUI_PAGE_INSTFILES
    54  
     66
    5567  !insertmacro MUI_UNPAGE_CONFIRM
    5668  !insertmacro MUI_UNPAGE_INSTFILES
    57  
     69
     70  Function optionsPage
     71     !insertmacro MUI_HEADER_TEXT "Installation Options" "Choose the options for the installation"
     72
     73     nsDialogs::Create 1018
     74     Pop $Variable
     75
     76     ${If} $Variable == error
     77         Abort
     78     ${Endif}
     79
     80     ${NSD_CreateLabel} 0 0 100% 24u "If you select the option below, the program will be installed in a way that it can be used besides another, already existing installation. Read the manual on how to set up this secondary version to avoid conflicting with the primary one."
     81     Pop $Variable
     82
     83     ${NSD_CreateCheckBox} 12 54 100% 12u "Install as secondary"
     84     Pop $Secondary
     85     ${NSD_SetState} $Secondary $Secondary_State
     86     GetFunctionAddress $Variable onSecondaryClicked
     87     nsDialogs::onClick $Secondary $Variable
     88
     89     nsDialogs::Show
     90  FunctionEnd
     91
     92  Function onSecondaryClicked
     93     Pop $Secondary
     94     ${NSD_GetState} $Secondary $Secondary_State
     95     ${If} $Secondary_State == ${BST_CHECKED}
     96         StrCpy $INSTDIR "$PROGRAMFILES\MAVA Logger X (Secondary)"
     97         StrCpy $STARTMENU_FOLDER "MAVA Logger X (Secondary)"
     98     ${Else}
     99         StrCpy $INSTDIR "$PROGRAMFILES\MAVA Logger X"
     100         StrCpy $STARTMENU_FOLDER "MAVA Logger X"
     101     ${EndIf}
     102  FunctionEnd
     103
    58104;--------------------------------
    59105;Languages
    60  
     106
    61107  !insertmacro MUI_LANGUAGE "English"
    62108
     
    67113
    68114  SetOutPath "$INSTDIR"
    69  
     115
     116  ${If} $Secondary_State == ${BST_CHECKED}
     117    StrCpy $LinkName "MAVA Logger X (Secondary)"
     118    StrCpy $Parameters "secondary"
     119  ${Else}
     120    StrCpy $LinkName "MAVA Logger X"
     121    StrCpy $Parameters ""
     122  ${EndIf}
     123
    70124  ;ADD YOUR OWN FILES HERE...
    71125  File /r dist\*.*
    72126
    73   ;Store installation folder
    74   WriteRegStr HKCU "Software\MAVA Logger X" "" $INSTDIR
    75  
     127  ;Create the uninstaller config file
     128  ${ConfigWrite} "$INSTDIR\Uninstall.conf" "StartMenuFolder=" "$STARTMENU_FOLDER" $Variable
     129  ${ConfigWrite} "$INSTDIR\Uninstall.conf" "LinkName=" "$LinkName" $Variable
     130
    76131  ;Create uninstaller
     132
    77133  WriteUninstaller "$INSTDIR\Uninstall.exe"
    78134
     
    80136    ;Create shortcuts
    81137    CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
    82     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe"
     138    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe" "$Parameters"
    83139    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
    84     CreateShortCut "$DESKTOP\MAVA Logger X.lnk" "$INSTDIR\runmlx.exe"
     140    CreateShortCut "$DESKTOP\$LinkName.lnk" "$INSTDIR\runmlx.exe" "$Parameters"
    85141  !insertmacro MUI_STARTMENU_WRITE_END
    86142SectionEnd
     
    102158Section "Uninstall"
    103159
     160  ;Read the uninstaller config file
     161  ${ConfigRead} "$INSTDIR\Uninstall.conf" "StartMenuFolder=" $MUI_TEMP
     162  ${ConfigRead} "$INSTDIR\Uninstall.conf" "LinkName=" $LinkName
     163
    104164  RMDir /r "$INSTDIR"
    105165
    106   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
    107    
    108   Delete "$DESKTOP\MAVA Logger X.lnk"
     166  Delete "$DESKTOP\$LinkName.lnk"
    109167  Delete "$SMPROGRAMS\$MUI_TEMP\MAVA Logger X.lnk"
    110168  Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
    111  
     169
    112170  ;Delete empty start menu parent diretories
    113171  StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
    114  
     172
    115173  startMenuDeleteLoop:
    116174    ClearErrors
    117175    RMDir $MUI_TEMP
    118176    GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
    119    
     177
    120178    IfErrors startMenuDeleteLoopDone
    121  
     179
    122180    StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
    123181  startMenuDeleteLoopDone:
    124 
    125   DeleteRegKey /ifempty HKCU "Software\MAVA Logger X"
    126182SectionEnd
Note: See TracChangeset for help on using the changeset viewer.