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, version 3 of the License.
7 WineLauncher is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with WineLauncher. If not, see <http://www.gnu.org/licenses/>.
16 {Made with Lazarus 0.9.26.3 fixes branch.}
17 {Free Pascal Compiler version 2.2.3.}
26 Classes
, SysUtils
, LResources
, Forms
, Controls
, Graphics
, Dialogs
, StdCtrls
,
27 DbCtrls
, strutils
, BaseUnix
, Process
, CheckLst
, Math
, ExtCtrls
;
35 Btn_DebugChannelsConfig
: TButton
;
37 Btn_Settings
: TButton
;
38 Btn_StopScan
: TButton
;
39 Button_Regedit
: TButton
;
40 Button_Winecfg
: TButton
;
41 CheckBox_UseSoundWrapper
: TCheckBox
;
42 CheckBox_DebugChannelUse
: TCheckBox
;
43 CheckListBox_Flags
: TCheckListBox
;
44 Check_Terminal
: TCheckBox
;
45 ComboBox_ProgramsList
: TComboBox
;
46 ComboBox_Architecture
: TComboBox
;
47 ComboBox_DistributionVersion
: TComboBox
;
48 ComboBox_DistributionName
: TComboBox
;
49 ComboBox_PreFix
: TComboBox
;
50 ComboBox_SoundWrapper
: TComboBox
;
51 ComboBox_TerminalName
: TComboBox
;
52 ComboBox_WineVersion
: TComboBox
;
53 EditBox_ProgramPath
: TEdit
;
54 Label_WineVersion
: TLabel
;
56 Label_ProgramPath
: TLabel
;
57 Label_ProgramsList
: TLabel
;
58 Label_WinePreFix
: TLabel
;
59 Label_DistributionName
: TLabel
;
60 Label_DistributionVersion
: TLabel
;
61 Label_Architecture
: TLabel
;
62 Memo_LogOutPut
: TMemo
;
63 TogBtn_Listdrive
: TToggleBox
;
65 procedure Btn_AboutClick(Sender
: TObject
);
66 procedure Btn_DebugChannelsConfigClick(Sender
: TObject
);
67 procedure Btn_RunClick(Sender
: TObject
);
68 procedure Btn_SettingsClick(Sender
: TObject
);
69 procedure Btn_StopScanClick(Sender
: TObject
);
70 procedure Button_RegeditClick(Sender
: TObject
);
71 procedure Button_WinecfgClick(Sender
: TObject
);
72 procedure CheckBox_UseSoundWrapperChange(Sender
: TObject
);
73 procedure Check_TerminalChange(Sender
: TObject
);
74 procedure ComboBox_ArchitectureChange(Sender
: TObject
);
75 procedure ComboBox_DistributionNameEditingDone(Sender
: TObject
);
76 procedure ComboBox_DistributionVersionEditingDone(Sender
: TObject
);
77 procedure ComboBox_PreFixChange(Sender
: TObject
);
78 procedure ComboBox_ProgramsListChange(Sender
: TObject
);
79 procedure ComboBox_WineVersionEditingDone(Sender
: TObject
);
80 procedure EditBox_ProgramPathChange(Sender
: TObject
);
81 procedure FormCreate(Sender
: TObject
);
82 procedure FormResize(Sender
: TObject
);
83 procedure TogBtn_ListdriveChange(Sender
: TObject
);
84 procedure TimerOnTimer(Sender
: TObject
);
86 private { private declarations }
87 procedure CheckWineVersion();
89 function Isblocked(Path
:string): longint ;
91 public { public declarations }
92 procedure ListFileDir({0} Path
: string; {1} FileList
: TStrings
; {2} GroupList
: TStrings
; {3} DirListClean
: TStrings
; {4} DirListPath
: TStrings
; {5} isFileList
: Boolean );
97 start_S1
:string; { Script to write to the file. }
98 wine_version_full
:string; { New code uses this to. }
99 RunIn
:string; { terminal or shell set here }
100 NoError
:Boolean; { Tbh this should not be here but im not sure need to check. }
101 Sh_Path
:string; { Path for the shell }
102 GetCurrentDir
:string;
103 Channel
:string; { Debug channel name }
104 WinePath
:string; { New var for "~/[wine-stuff]/wine/[OS name]/[OS version]/[Architecture] }
105 UnixDirPath
:string; { Needed for setting the working dir at 'Run'. }
107 Timer
:TTimer
; {The timer is a workaround.}
119 function TForm1
.Isblocked(Path
:string): longint ;
125 { Checks to see string is backup "~" or / and hided "." }
126 if AnsiStartsText( '.', Path
) = true then
128 log( 1, CL
, 'This can not be hided');
137 if AnsiEndsText( '~', Path
) = true then
139 log( 1, CL
, 'This can not be a backup file');
150 procedure TForm1
.ListFileDir({0} Path
: string; {1} FileList
: TStrings
; {2} GroupList
: TStrings
; {3} DirListClean
: TStrings
; {4} DirListPath
: TStrings
; {5} isFileList
: Boolean );
155 if FindFirst(Path
+ '*', faAnyFile
, SR
) = 0 then
158 if ((SR
.Attr
and faDirectory
= 0) = isFileList
) then
160 { removes folders called "." & ".." }
161 if SR
.Name
<> '.' then if SR
.Name
<> '..' then
163 if ( DirListPath
<> nil) then
164 DirListPath
.Add( (path
+ SR
.Name
+ '/') );
166 if ( FileList
<> nil) then
167 FileList
.Add(SR
.Name
);
170 until FindNext(SR
) <> 0;
180 procedure TForm1
.CheckWineVersion();
184 { TODO : Add better filtering. }
186 {Get Distribution name. }
187 WineCheck
:= ( GetEnvironmentVariable('HOME') + '/' + WineUserFolder
+ '/wine/' );
188 ComboBox_DistributionName
.Items
.Clear
;
189 ListFileDir( {0} WineCheck
, {1} ComboBox_DistributionName
.Items
, {2} nil , {3} nil , {4} nil , {5} false );
191 { Get Distribution version. }
192 if DoesFolderExists( WineCheck
, ComboBox_DistributionName
.Text ) = true then
194 ComboBox_DistributionVersion
.Items
.Clear
;
195 ListFileDir( {0} ( WineCheck
+ ComboBox_DistributionName
.Text + '/' ) , {1} ComboBox_DistributionVersion
.Items
, {2} nil , {3} nil , {4} nil , {5} false );
198 { Get Architecture. }
199 WineCheck
:= ( WineCheck
+ ComboBox_DistributionName
.Text );
200 if DoesFolderExists( WineCheck
, ( '/' + ComboBox_DistributionVersion
.Text )) = true then
202 ComboBox_Architecture
.Items
.Clear
;
203 ListFileDir( {0} ( WineCheck
+ '/' + ComboBox_DistributionVersion
.Text + '/' ) , {1} ComboBox_Architecture
.Items
, {2} nil , {3} nil , {4} nil , {5} false );
206 { Get Wine version. }
207 WineCheck
:= ( WineCheck
+ '/' + ComboBox_DistributionVersion
.Text + '/' + ComboBox_Architecture
.Text );
208 ComboBox_WineVersion
.Items
.Clear
;
209 ListFileDir( {0} WineCheck
+ '/' , {1} ComboBox_WineVersion
.Items
, {2} nil , {3} nil , {4} nil , {5} false );
211 WineCheck
:= ( WineCheck
+ '/' + ComboBox_WineVersion
.Text );
213 WinePath
:= WineCheck
;
216 SaveLastUsedConfig();
220 procedure TForm1
.FormCreate(Sender
: TObject
);
222 {The timer is a workaround.}
223 Timer
:= TTimer
.Create(nil) ;
224 Timer
.OnTimer
:= @TimerOnTimer
;
225 Timer
.Enabled
:= false;
226 Timer
.Interval
:= 100;
229 if ComboBox_SoundWrapper
.items
.Count
<> 0 then ComboBox_SoundWrapper
.Text := ComboBox_SoundWrapper
.Items
[0];
230 if ComboBox_TerminalName
.items
.Count
<> 0 then ComboBox_TerminalName
.Text := ComboBox_TerminalName
.Items
[0];
232 {Load LastUsedConfig.}
233 LoadLastUsedConfig();
235 {Get Wine path info.}
240 Btn_StopScan
.Visible
:= true;
244 procedure TForm1
.FormResize(Sender
: TObject
);
246 if Btn_StopScan
.Visible
= true then Btn_StopScan
.Left
:= (floor(form1
.Width
/ 2) - floor(Btn_StopScan
.Width
/ 2));
249 procedure TForm1
.TimerOnTimer(Sender
: TObject
);
253 {We should not use a timer to check this. The is a bug in lazarus, 'OnTerminate' of AsyncProcess never runs.}
254 if AsyncProcessScan
.Active
= true then
256 Timer
.Enabled
:= true;
257 Btn_StopScan
.Visible
:= true;
262 Btn_StopScan
.Visible
:= false;
263 TempList
:= TStringlist
.Create
;
264 Timer
.Enabled
:= false;
265 TempList
.LoadFromStream(AsyncProcessScan
.OutPut
);
267 if TempList
.Count
= 0 then
269 DiscErrorText
:= 'Drive' + wrap('D' + ':') + 'has no executable files.';
270 LastReadLinkPath
:= '';
277 while TempList
.Count
<> 0 do
279 CdData
.Add(UnixToWinPath(TempList
.Strings
[0],'d'));
283 ComboBox_PreFixChange(self
);
286 CheckListBox_Flags
.Clear
;
290 procedure TForm1
.TogBtn_ListdriveChange(Sender
: TObject
);
295 AsyncProcessScan
.Active
:= false;
296 Btn_StopScan
.Visible
:= false;
297 CheckListBox_Flags
.Enabled
:= true;
298 EditBox_ProgramPath
.Clear
;
299 ComboBox_PreFixChange(self
);
300 ComboBox_ProgramsListChange(self
);
305 if CdData
= nil then CdData
:= TStringlist
.Create
;
306 if CdDataName
= nil then CdDataName
:= TStringlist
.Create
;
308 log(0,'', LastReadLinkPath
);
309 ComboBox_PreFixChange(self
);
310 CheckListBox_Flags
.Clear
;
311 EditBox_ProgramPath
.Clear
;
318 procedure TForm1
.Btn_RunClick(Sender
: TObject
);
320 RunWineCheck( '', '' );
323 procedure TForm1
.Btn_SettingsClick(Sender
: TObject
);
325 UnitSettings
.Form4
.Show
;
328 procedure TForm1
.Btn_StopScanClick(Sender
: TObject
);
330 AsyncProcessScan
.Active
:= false;
333 procedure TForm1
.Button_RegeditClick(Sender
: TObject
);
335 RunWineCheck( 'Regedit', '' );
338 procedure TForm1
.Button_WinecfgClick(Sender
: TObject
);
340 RunWineCheck( 'winecfg', '' );
343 procedure TForm1
.CheckBox_UseSoundWrapperChange(Sender
: TObject
);
345 SaveLastUsedConfig();
348 procedure TForm1
.Check_TerminalChange(Sender
: TObject
);
350 SaveLastUsedConfig();
353 procedure TForm1
.ComboBox_ArchitectureChange(Sender
: TObject
);
358 procedure TForm1
.ComboBox_DistributionNameEditingDone(Sender
: TObject
);
363 procedure TForm1
.ComboBox_DistributionVersionEditingDone(Sender
: TObject
);
368 procedure TForm1
.ComboBox_PreFixChange(Sender
: TObject
);
376 ComboBox_ProgramsList
.Items
.Clear
;
380 EditBox_ProgramPath
.Enabled
:= true;
381 ComboBox_ProgramsList
.Enabled
:= true;
387 if Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
] <> '' then
389 ComboBox_ProgramsList
.Items
.Add(Data
[ComboBox_PreFix
.ItemIndex
].Grid
.Cells
[DataNameCol
, myloop
]);
398 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
400 ComboBox_ProgramsList
.ItemIndex
:= 0;
401 EditBox_ProgramPath
.Enabled
:= true;
402 ComboBox_ProgramsList
.Enabled
:= true;
403 ComboBox_ProgramsListChange(Self
);
407 ComboBox_ProgramsList
.Text := '';
408 EditBox_ProgramPath
.Text := '';
409 EditBox_ProgramPath
.Enabled
:= false;
410 ComboBox_ProgramsList
.Enabled
:= false;
416 ListProgramsOnDisc(CdData
, 'D');
417 if CdData
.Text <> '' then
420 CdDataName
.AddStrings(CdData
);
422 for myloop
:= 0 to CdDataName
.Count
-1 do
424 {Take path and return the file name only.}
425 CdDataName
.Strings
[myloop
] := GetWinFileName(CdDataName
.Strings
[myloop
]);
427 ComboBox_ProgramsList
.Items
:= CdDataName
;
428 if ComboBox_ProgramsList
.Items
.Count
<> 0 then
430 ComboBox_ProgramsList
.Text := ComboBox_ProgramsList
.Items
[0];
431 EditBox_ProgramPath
.Enabled
:= true;
432 ComboBox_ProgramsList
.Enabled
:= true;
433 ComboBox_ProgramsListChange(self
);
439 ComboBox_ProgramsList
.Text := DiscErrorText
;
440 EditBox_ProgramPath
.Text := '';
441 EditBox_ProgramPath
.Enabled
:= false;
442 ComboBox_ProgramsList
.Enabled
:= false;
443 CheckListBox_Flags
.Clear
;
449 procedure TForm1
.ComboBox_ProgramsListChange(Sender
: TObject
);
451 ProgramsListSelectedItem
:integer;
456 PrefixInt
:= FindPrefixInt(ComboBox_PreFix
.Items
.Strings
[ComboBox_PreFix
.ItemIndex
]);
457 EditBox_ProgramPath
.Enabled
:= true;
458 {Plus one to line it up with the grid}
459 ProgramsListSelectedItem
:= (Data
[PrefixInt
].Grid
.cols
[DataNameCol
].IndexOf(Data
[PrefixInt
].Grid
.cols
[DataNameCol
].Strings
[ComboBox_ProgramsList
.ItemIndex
]) +1);
461 EditBox_ProgramPath
.Text := Data
[PrefixInt
].Grid
.Cells
[DataPathCol
, ProgramsListSelectedItem
] ;
462 CutUpFlags(Data
[PrefixInt
].Grid
.Cells
[DataFlagsCol
, ProgramsListSelectedItem
]);
466 if CdData
.Text <> '' then
468 EditBox_ProgramPath
.Text := CdData
.Strings
[CdDataName
.IndexOf(ComboBox_ProgramsList
.Text)] ;
473 procedure TForm1
.ComboBox_WineVersionEditingDone(Sender
: TObject
);
478 procedure TForm1
.EditBox_ProgramPathChange(Sender
: TObject
);
480 ColourCheck(EditBox_ProgramPath
);
484 procedure TForm1
.Btn_AboutClick(Sender
: TObject
);
486 UnitAbout
.Form3
.Show
;
489 procedure TForm1
.Btn_DebugChannelsConfigClick(Sender
: TObject
);
491 UnitDebugConfig
.Form2
.Show
;