1 { This file is part of WineLauncher.
3 WineLauncher is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
8 WineLauncher is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with WineLauncher. If not, see <http://www.gnu.org/licenses/>.
17 {Made with Lazarus 0.9.28.2 fixes branch.}
18 {Free Pascal Compiler version 2.2.5.}
27 Classes
, SysUtils
, LResources
, Forms
, Controls
, Graphics
, Dialogs
, StdCtrls
,
28 DbCtrls
, BaseUnix
, Process
, CheckLst
, ExtCtrls
, ComCtrls
, UnitCreatePrefix
, UnitAbout
, Errors
;
36 Btn_Settings
: TButton
;
37 Btn_StopScan
: TButton
;
38 Button_Regedit
: TButton
;
39 Button_Winecfg
: TButton
;
40 CheckBox_UseSoundWrapper
: TCheckBox
;
41 CheckListBox_Flags
: TCheckListBox
;
42 Check_Terminal
: TCheckBox
;
43 ComboBox_WineVersion
: TComboBox
;
44 ComboBox_ProgramsList
: TComboBox
;
45 ComboBox_PreFix
: TComboBox
;
46 ComboBox_SoundWrapper
: TComboBox
;
47 ComboBox_TerminalName
: TComboBox
;
48 EditBox_ProgramPath
: TEdit
;
49 Label_WineVersion
: TLabel
;
51 Label_ProgramPath
: TLabel
;
52 Label_ProgramsList
: TLabel
;
53 Label_WinePreFix
: TLabel
;
54 Memo_LogOutPut
: TMemo
;
55 PageControl1
: TPageControl
;
57 TogBtn_Listdrive
: TToggleBox
;
59 procedure Btn_RunClick(Sender
: TObject
);
60 procedure Btn_SettingsClick(Sender
: TObject
);
61 procedure Btn_StopScanClick(Sender
: TObject
);
62 procedure Button_RegeditClick(Sender
: TObject
);
63 procedure Button_WinecfgClick(Sender
: TObject
);
64 procedure ComboBox_PreFixChange(Sender
: TObject
);
65 procedure ComboBox_ProgramsListChange(Sender
: TObject
);
66 procedure ComboBox_WineVersionEditingDone(Sender
: TObject
);
67 procedure ComboBox_WineVersionEnter(Sender
: TObject
);
68 procedure EditBox_ProgramPathChange(Sender
: TObject
);
69 procedure FormClose(Sender
: TObject
; var CloseAction
: TCloseAction
);
70 procedure FormCreate(Sender
: TObject
);
71 procedure FormDestroy(Sender
: TObject
);
72 procedure TogBtn_ListdriveChange(Sender
: TObject
);
73 procedure TimerOnTimer(Sender
: TObject
);
75 private { private declarations }
77 public { public declarations }
83 NoError
:Boolean; { Tbh this should not be here but im not sure need to check. }
84 Sh_Path
:string; { Path for the shell }
86 Channel
:string; { Debug channel name }
87 UnixDirPath
:string; { Needed for setting the working dir at 'Run'. }
89 Timer
:TTimer
; {The timer is a workaround.}
91 FrameCreatePrefix
:TFrameCreatePrefix
;
92 FrameAbout
:TFrameAbout
;
102 procedure TForm1
.FormCreate(Sender
: TObject
);
104 {The timer is a workaround.}
105 Timer
:= TTimer
.Create(nil) ;
106 Timer
.OnTimer
:= @TimerOnTimer
;
107 Timer
.Enabled
:= false;
108 Timer
.Interval
:= 100;
111 ComboBox_WineVersionEnter(Self
);
114 if ComboBox_SoundWrapper
.items
.Count
<> 0 then ComboBox_SoundWrapper
.Text := ComboBox_SoundWrapper
.Items
[0];
115 if ComboBox_TerminalName
.items
.Count
<> 0 then ComboBox_TerminalName
.Text := ComboBox_TerminalName
.Items
[0];
116 if ComboBox_WineVersion
.Items
.Count
<> 0 then ComboBox_WineVersion
.Text := ComboBox_WineVersion
.Items
[0];
118 {Frame Create prefix.}
119 AddTabToPageControl(PageControl1
, 'Create prefix');
120 FrameCreatePrefix
:= TFrameCreatePrefix
.Create(Self
);
121 EmbedFrame(FrameCreatePrefix
, PageControl1
.PageCount
-1);
123 AddTabToPageControl(PageControl1
, 'About');
124 FrameAbout
:= TFrameAbout
.Create(Self
);
125 EmbedFrame(FrameAbout
, PageControl1
.PageCount
-1);
127 FrameAbout
.Memo_About
.Lines
.Add('');
128 {When the is a new release update the version number in the file called 'VERSION.inc'.}
129 FrameAbout
.Memo_About
.Lines
.Add('WineLauncher Version: ' + WineLauncherVersion
);
130 FrameAbout
.Memo_About
.Lines
.Add(BuiltWithLazarusVersion
);
131 FrameAbout
.Memo_About
.Lines
.Add(BuiltWithFpcVersion
);
133 {Load LastUsedConfig.}
134 LoadLastUsedConfig();
137 Btn_StopScan
.Visible
:= true;
141 procedure TForm1
.FormDestroy(Sender
: TObject
);
144 XmlLastUsedConfig
.Destroy
;
145 SetLength(TabSheets
, 0);
148 FreeAndNil(CdDataName
);
150 {stuff configed in UnitInitialization.}
152 CreatePrefixProcess
.Destroy
;
153 AsyncProcessScan
.Destroy
;
156 procedure TForm1
.TimerOnTimer(Sender
: TObject
);
160 {We should not use a timer to check this. The is a bug in lazarus, 'OnTerminate' of AsyncProcess never runs.}
161 if AsyncProcessScan
.Active
= true then
163 Timer
.Enabled
:= true;
164 Btn_StopScan
.Visible
:= true;
168 Btn_StopScan
.Visible
:= false;
169 TempList
:= TStringlist
.Create
;
170 Timer
.Enabled
:= false;
171 TempList
.LoadFromStream(AsyncProcessScan
.OutPut
);
173 if TempList
.Count
= 0 then
175 DiscErrorText
:= 'Drive' + wrap('D' + ':') + 'has no executable files.';
176 LastReadLinkPath
:= '';
183 while TempList
.Count
<> 0 do
185 CdData
.Add(UnixToWinPath(TempList
.Strings
[0],'d'));
189 ComboBox_PreFixChange(self
);
192 CheckListBox_Flags
.Clear
;
196 procedure TForm1
.TogBtn_ListdriveChange(Sender
: TObject
);
201 AsyncProcessScan
.Active
:= false;
202 Btn_StopScan
.Visible
:= false;
203 CheckListBox_Flags
.Enabled
:= true;
204 EditBox_ProgramPath
.Clear
;
207 FreeAndNil(CdDataName
);
209 ComboBox_PreFixChange(self
);
210 ComboBox_ProgramsListChange(self
);
215 CdData
:= TStringlist
.Create
;
216 CdDataName
:= TStringlist
.Create
;
218 log(0,'', LastReadLinkPath
);
219 ComboBox_PreFixChange(self
);
220 CheckListBox_Flags
.Clear
;
221 EditBox_ProgramPath
.Clear
;
228 procedure TForm1
.Btn_RunClick(Sender
: TObject
);
230 RunWineCheck( '', '' );
233 procedure TForm1
.Btn_SettingsClick(Sender
: TObject
);
235 UnitSettings
.Form4
.Show
;
238 procedure TForm1
.Btn_StopScanClick(Sender
: TObject
);
240 AsyncProcessScan
.Active
:= false;
243 procedure TForm1
.Button_RegeditClick(Sender
: TObject
);
245 RunWineCheck( 'Regedit', '' );
248 procedure TForm1
.Button_WinecfgClick(Sender
: TObject
);
250 RunWineCheck( 'winecfg', '' );
254 procedure TForm1
.ComboBox_PreFixChange(Sender
: TObject
);
258 ComboBox_ProgramsList
.Items
.Clear
;
260 EditBox_ProgramPath
.Enabled
:= true;
261 ComboBox_ProgramsList
.Enabled
:= true;
265 for myloop
:= 1 to (Data
[ComboBox_PreFix
.ItemIndex
].Grid
.RowCount
-1) do
267 if Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
] <> '' then
269 ComboBox_ProgramsList
.Items
.Add(Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
]);
277 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
279 ComboBox_ProgramsList
.ItemIndex
:= 0;
280 EditBox_ProgramPath
.Enabled
:= true;
281 ComboBox_ProgramsList
.Enabled
:= true;
282 ComboBox_ProgramsListChange(Self
);
286 ComboBox_ProgramsList
.Text := '';
287 EditBox_ProgramPath
.Text := '';
288 EditBox_ProgramPath
.Enabled
:= false;
289 ComboBox_ProgramsList
.Enabled
:= false;
295 ListProgramsOnDisc(CdData
, 'D');
296 if CdData
.Text <> '' then
299 CdDataName
.AddStrings(CdData
);
301 {Write some code to clean up the names, keep then usefull and unique.}
303 ComboBox_ProgramsList
.Items
:= CdDataName
;
304 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
306 ComboBox_ProgramsList
.Text := ComboBox_ProgramsList
.Items
[0];
307 EditBox_ProgramPath
.Enabled
:= true;
308 ComboBox_ProgramsList
.Enabled
:= true;
309 ComboBox_ProgramsListChange(self
);
315 ComboBox_ProgramsList
.Items
.Add(DiscErrorText
);
316 ComboBox_ProgramsList
.ItemIndex
:= 0;
317 EditBox_ProgramPath
.Text := '';
318 EditBox_ProgramPath
.Enabled
:= false;
319 ComboBox_ProgramsList
.Enabled
:= false;
320 CheckListBox_Flags
.Clear
;
326 procedure TForm1
.ComboBox_ProgramsListChange(Sender
: TObject
);
328 ProgramsListSelectedItem
:integer;
333 PrefixInt
:= FindPrefixInt(ComboBox_PreFix
.Items
.Strings
[ComboBox_PreFix
.ItemIndex
]);
334 EditBox_ProgramPath
.Enabled
:= true;
335 {Plus one to line it up with the grid}
336 ProgramsListSelectedItem
:= (Data
[PrefixInt
].Grid
.cols
[DataNameCol
].IndexOf(Data
[PrefixInt
].Grid
.cols
[DataNameCol
].Strings
[ComboBox_ProgramsList
.ItemIndex
]) +1);
338 EditBox_ProgramPath
.Text := Data
[PrefixInt
].Grid
.Cells
[DataPathCol
, ProgramsListSelectedItem
] ;
339 CutUpFlags(Data
[PrefixInt
].Grid
.Cells
[DataFlagsCol
, ProgramsListSelectedItem
]);
343 if CdData
.Text <> '' then
345 EditBox_ProgramPath
.Text := CdData
.Strings
[CdDataName
.IndexOf(ComboBox_ProgramsList
.Text)] ;
350 procedure TForm1
.ComboBox_WineVersionEditingDone(Sender
: TObject
);
352 OnWineVersionChange();
355 procedure TForm1
.ComboBox_WineVersionEnter(Sender
: TObject
);
358 SystemSidePath
:string;
360 {Note FpSymLink does not have a string version with fpc 2.2.5.}
361 {This is not best way adding the system side wine but it works.}
362 SystemSidePath
:= PathToWine
+ '/System Side Wine';
364 a
:= SearchForBin('wine');
365 if SearchForBin(a
) <> '' then
367 if DirExistsIfNotMakeIt(SystemSidePath
) = true then
369 if DirExistsIfNotMakeIt(SystemSidePath
+ '/bin') = true then
371 SystemSidePath
:= (SystemSidePath
+ '/bin');
372 FpUnlink(SystemSidePath
+ '/wine');
373 if FpSymLink(PChar(a
), PChar(SystemSidePath
+ '/wine') ) <> 0 then
375 log(1,'','Can not create symlink: ' + StrError(fpgeterrno
));
377 {link wineprefixcreate.}
378 a
:= SearchForBin('wineprefixcreate');
379 if SearchForBin(a
) <> '' then
381 FpUnlink(SystemSidePath
+ '/wineprefixcreate');
382 if FpSymLink(PChar(a
), PChar(SystemSidePath
+ '/wineprefixcreate') ) <> 0 then
384 log(1,'','Can not create symlink: ' + StrError(fpgeterrno
));
391 FolderScan(ComboBox_WineVersion
, PathToWine
);
392 OnWineVersionChange();
395 procedure TForm1
.EditBox_ProgramPathChange(Sender
: TObject
);
397 ColourCheck(EditBox_ProgramPath
);
400 procedure TForm1
.FormClose(Sender
: TObject
; var CloseAction
: TCloseAction
);
402 SaveLastUsedConfig();