Skip to content
This repository
tree: edd52926d2
Fetching contributors…

Cannot retrieve contributors at this time

file 251 lines (205 sloc) 6.99 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
; Evars pages
!ifndef PAGE_CONFIG_EVARS
!define PAGE_CONFIG_EVARS
var filemanager
var texteditor
var commandprompt
var audioplayer
var mediaplayer
var gfxviewer
var gfxeditor
var browser
var dun
var email
var irc
var ftp
var im

var tmp

var evars_skipArrayInit

!include GetInQuotes.nsh
!include IndexOf.nsh
!include GetExecutablePath.nsh
!include Evars.nsh
!include nsDialogs.nsh
!include LogicLib.nsh
!include winmessages.nsh
!include SectionsInclude.nsh
!include NSISArray.nsh

${Array} EvarNames 13 ${NSIS_MAX_STRLEN} ; 13 different evars
${ArrayFunc} WriteList
${ArrayFunc} Read
${ArrayFunc} Inited
${ArrayFunc} Debug

${Array} EvarPaths 13 ${NSIS_MAX_STRLEN}
${ArrayFunc} WriteList
${ArrayFunc} Read
${ArrayFunc} Write

${Array} InputHwnds 13 ${NSIS_MAX_STRLEN}
${ArrayFunc} Read
${ArrayFunc} Write

Section "$(NAME_SecConfigEvars)" SecConfigEvars
SectionEnd

Page custom ioEvars saveToArray1
Page custom ioEvars2 saveToArray2

Function saveToArray1
; This is needed to save anything that's manually typed in to the
; file path input fields
${For} $R0 0 6
${InputHwnds->Read} $R1 $R0
System::Call "user32::SendMessage(i $R1, i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t .R2)"
${If} $R2 == ""
StrCpy $R2 "..."
${EndIf}
${EvarPaths->Write} $R0 $R2
${Next}
FunctionEnd

Function saveToArray2
; This is needed to save anything that's manually typed in to the
; file path input fields
${For} $R0 7 12
${InputHwnds->Read} $R1 $R0
System::Call "user32::SendMessage(i $R1, i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t .R2)"
${If} $R2 == ""
StrCpy $R2 "..."
${EndIf}
${EvarPaths->Write} $R0 $R2
${Next}

StrCpy $evars_skipArrayInit "true"
FunctionEnd

Function ioEvars
; The function below is smart about only doing this if the evar
; variables aren't already populated.
; By having this function call before the ${SectionIsSelected} check
; the evars will always get good values
Call PopulateEvarVariables

${If} ${SectionIsSelected} ${SecConfigEvars}
${If} $evars_skipArrayInit != "true"
${EvarNames->Init}
${EvarPaths->Init}
${InputHwnds->Init}

${EvarNames->WriteList} '"File Manager:" \
"Text Editor:" \
"Command Prompt:" \
"Audio Player:" \
"Media Player:" \
"Graphics Viewer:" \
"Graphics Editor:" \
"Browser:" \
"Dial-up Networking:" \
"E-Mail Client:" \
"IRC Client:" \
"FTP:" \
"Instant Messaging:"'

${EvarPaths->WriteList} '"$filemanager" \
"$texteditor" \
"$commandprompt" \
"$audioplayer" \
"$mediaplayer" \
"$gfxviewer" \
"$gfxeditor" \
"$browser" \
"$dun" \
"$email" \
"$irc" \
"$ftp" \
"$im"'

${EndIf}
;Call WriteEvarsToEdit

nsDialogs::Create /NOUNLOAD 1018
Pop $R0

${For} $R0 0 6
IntOp $R9 $R0 * 14
IntOp $R8 $R9 + 1

${EvarNames->Read} $R7 $R0
${EvarPaths->Read} $R6 $R0

${If} $R6 == ""
StrCpy $R6 "..."
${EndIf}

${NSD_CreateLabel} 0 $R8u 96 12u $R7

${NSD_CreateFileRequest} 100 $R9u 322 12u "$R6"
Pop $R1
${InputHwnds->Write} $R0 $R1

${NSD_CreateBrowseButton} 426 $R9u 24 12u "..."
Pop $R2

GetFunctionAddress $R3 FileBrowse
nsDialogs::OnClick /NOUNLOAD $R2 $R3
nsDialogs::SetUserData /NOUNLOAD $R2 $R0
${Next}

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE_EVARS)" "$(TEXT_IO_EVARS)"
;!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioEvars.ini"

GetFunctionAddress $R0 SaveToArray1
nsDialogs::OnBack /NOUNLOAD $R0

nsDialogs::Show
${EndIf}
FunctionEnd

Function ioEvars2
${If} ${SectionIsSelected} ${SecConfigEvars}
nsDialogs::Create /NOUNLOAD 1018
Pop $R0

${For} $R0 7 12
IntOp $R9 $R0 - 7 ; This will make $R9 go from 0 to 6
IntOp $R9 $R9 * 14 ; This will make $R9 go from 0 to 84
IntOp $R8 $R9 + 1 ; This will make $R8 = $R9 + 1

${EvarNames->Read} $R7 $R0
${EvarPaths->Read} $R6 $R0

${If} $R6 == ""
StrCpy $R6 "..."
${EndIf}

${NSD_CreateLabel} 0 $R8u 96 12u $R7

${NSD_CreateFileRequest} 100 $R9u 322 12u "$R6"
Pop $R1
${InputHwnds->Write} $R0 $R1

${NSD_CreateBrowseButton} 426 $R9u 24 12u "..."
Pop $R2

GetFunctionAddress $R3 FileBrowse
nsDialogs::OnClick /NOUNLOAD $R2 $R3
nsDialogs::SetUserData /NOUNLOAD $R2 $R0
${Next}

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE_EVARS)" "$(TEXT_IO_EVARS)"
;!insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioEvars2.ini"

GetFunctionAddress $R0 SaveToArray2
nsDialogs::OnBack /NOUNLOAD $R0

nsDialogs::Show

;Call ReadEvarsFromEdit
${EvarPaths->Read} $filemanager 0
${EvarPaths->Read} $texteditor 1
${EvarPaths->Read} $commandprompt 2
${EvarPaths->Read} $audioplayer 3
${EvarPaths->Read} $mediaplayer 4
${EvarPaths->Read} $gfxviewer 5
${EvarPaths->Read} $gfxeditor 6
${EvarPaths->Read} $browser 7
${EvarPaths->Read} $dun 8
${EvarPaths->Read} $email 9
${EvarPaths->Read} $irc 10
${EvarPaths->Read} $ftp 11
${EvarPaths->Read} $im 12
${EndIf}

Call WriteEvars
FunctionEnd

Function FileBrowse
Pop $R9
nsDialogs::GetUserData /NOUNLOAD $R9
Pop $R9

${InputHwnds->Read} $R0 $R9

System::Call "user32::SendMessage(i $R0, i ${WM_GETTEXT}, i ${NSIS_MAX_STRLEN}, t .R1)"

StrLen $R2 "$WINDIR"
StrCpy $R3 $R1 $R2

${If} "$R3" == "$WINDIR"
StrCpy $R2 "$PROGRAMFILES"
${Else}
StrCpy $R3 $R1 2 1
${IfNot} $R3 == ":\"
StrCpy $R2 "$PROGRAMFILES"
${Else}
StrCpy $R2 $R1
${EndIf}
${EndIf}

nsDialogs::SelectFileDialog /NOUNLOAD open $R2 "*.exe|*.exe"
Pop $R2
${If} $R2 != ""
SendMessage $R0 ${WM_SETTEXT} 0 STR:$R2
${EvarPaths->Write} $R9 $R2
${EndIf}
FunctionEnd
!endif
Something went wrong with that request. Please try again.