comparison nsis/python-module.nsh @ 0:1fd2201f5c36

Initial commit of parpg-core.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 14 May 2011 01:12:35 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1fd2201f5c36
1 !include nsDialogs.nsh
2 !include LogicLib.nsh
3 !macro _FileExists2 _a _b _t _f
4 StrCmp `${_b}` `` `${_f}` 0
5 IfFileExists `${_b}` `0` `${_f}` ;returns true if this is a directory
6 IfFileExists `${_b}\*.*` `${_f}` `${_t}` ;so if it is a directory, jump to false
7 !macroend
8 !undef FileExists
9 !define FileExists `"" FileExists2`
10 !macro _DirExists _a _b _t _f
11 StrCmp `${_b}` `` `${_f}` 0
12 IfFileExists `${_b}\*.*` `${_t}` `${_f}`
13 !macroend
14 !define DirExists `"" DirExists`
15 !include mui2.nsh
16 !include WinMessages.nsh
17
18 Var PythonList
19 Var Directory
20 Var Browse
21 Var PythonPath
22 Var PythonVer
23 !macro PAGE_PYTHON_MODULE
24 Page custom PythonModulePage PythonModulePage_OnLeave
25 !macroend
26
27 Function PythonModulePage
28 !insertmacro MUI_HEADER_TEXT_PAGE "Install Python Module" "Please select where to install the Python module"
29 nsDialogs::Create 1018
30 Pop $0
31
32 ${NSD_CreateListBox} 0 0 300u 120u ""
33 Pop $PythonList
34
35 StrCpy $0 0
36 EnumRegKey $1 HKLM SOFTWARE\Python\PythonCore $0
37 ${DoWhile} $1 != ""
38 ReadRegStr $2 HKLM SOFTWARE\Python\PythonCore\$1\InstallPath ""
39 ${if} $2 != ""
40 ${NSD_LB_AddString} $PythonList "$1"
41 ${endif}
42 IntOp $0 $0 + 1
43 EnumRegKey $1 HKLM SOFTWARE\Python\PythonCore $0
44 ${Loop}
45 ${NSD_LB_GetCount} $PythonList $0
46 ${if} $0 == 0
47 MessageBox MB_ICONINFORMATION|MB_OK "No Python version detected. If you don't have Python installed you should install it first. Otherwise you can input the python directory below."
48 ${endif}
49 ${NSD_LB_AddString} $PythonList "Custom"
50 ${NSD_LB_SelectString} $PythonList $PythonVer
51 ${NSD_OnChange} $PythonList PythonModulePage_OnLeave_OnChange_PythonList
52
53 ${NSD_CreateDirRequest} 0 121u 280u 15u ""
54 Pop $Directory
55
56 ${NSD_CreateButton} 281u 121u 19u 15u "..."
57 Pop $Browse
58 GetFunctionAddress $0 PythonModulePage_OnClick_Browse
59
60
61 nsDialogs::OnClick /NOUNLOAD $Browse $0
62
63 nsDialogs::Show
64 FunctionEnd
65
66 Function PythonModulePage_OnLeave
67 ${NSD_GetText} $Directory $PythonPath
68 ${NSD_LB_GetSelection} $PythonList $PythonVer
69 ${If} $PythonPath == ""
70 ${OrIfNot} ${DirExists} $PythonPath
71 Abort
72 ${endif}
73 FunctionEnd
74
75 Function PythonModulePage_OnLeave_OnChange_PythonList
76 ${NSD_LB_GetSelection} $PythonList $0
77 ${if} $0 != "Custom"
78 EnableWindow $Directory 0
79 EnableWindow $Browse 0
80 ${if} $0 != ""
81 ReadRegStr $1 HKLM SOFTWARE\Python\PythonCore\$0\InstallPath ""
82 ${NSD_SetText} $Directory $1
83 ${endif}
84 ${else}
85 EnableWindow $Directory 1
86 EnableWindow $Browse 1
87 ${endif}
88
89 FunctionEnd
90
91 Function PythonModulePage_OnClick_Browse
92
93 ${NSD_GetText} $Directory $0
94
95 nsDialogs::SelectFolderDialog /NOUNLOAD "Please select a target directory" "$0"
96
97 Pop $0
98 ${If} $0 == error
99
100 Abort
101
102 ${EndIf}
103
104 ${NSD_SetText} $Directory $0
105
106 FunctionEnd