summaryrefslogtreecommitdiff
path: root/UTestPlugin.pas
blob: 5e90de498df2b415deac15be3d2bd747fdb1b2e3 (plain)
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
(*
    Tux Commander - UTestPlugin - Plugin testing
    Copyright (C) 2004 Tomas Bzatek <tbzatek@users.sourceforge.net>
    Check for updates on tuxcmd.sourceforge.net

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*)
unit UTestPlugin;

interface

uses
  SysUtils, Classes, lazgdk3, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKPixbuf;

type
  TFTestPlugin = class(TGTKDialog)
    TitleFrame: TGTKFrame;
    TitleLabel: TGTKLabel;
    TitleEventBox: TGTKEventBox;
    TitleIcon: TGTKImage;
    TitleHBox: TGTKHBox;
    Grid: TGTKGrid;
    Label1, Label2, Label3, Label4: TGTKLabel;
    PluginComboBox: TGTKComboBoxText;
    CommandEntry, UserEntry, PasswordEntry: TGTKEntry;
    ExperimentalWarningLabel: TGTKLabel;
    ExperimentalWarningIcon: TGTKImage;
    AnonymousCheckButton: TGTKCheckButton;
    HBox4: TGTKHBox;
    procedure FormCreate(Sender: TObject); override;
    procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
    procedure AnonymousCheckButtonToggled(Sender: TObject);
  end;

var
  FTestPlugin: TFTestPlugin;

implementation

uses UVFSCore, ULocale;



procedure TFTestPlugin.FormCreate(Sender: TObject);
var i: integer;
    VBox: TGTKVBox;
begin
  SetDefaultSize(400, 200);
  Caption := LANGTestPlugin_Caption;
  Buttons := [mbOK, mbCancel];
  DefaultButton := mbOK;
  TitleEventBox := TGTKEventBox.Create(Self);
  TitleLabel := TGTKLabel.Create(Self);
  TitleLabel.Caption := Format('<span size="x-large" weight="ultrabold">%s</span>', [LANGTestPlugin_Title]);
  TitleLabel.UseMarkup := True;
  TitleLabel.XAlign := 0;
  TitleLabel.MarginStart := 0;
  TitleLabel.MarginEnd := 0;
  TitleLabel.MarginTop := 3;
  TitleLabel.MarginBottom := 3;
  TitleEventBox.ControlState := csPrelight;
  TitleFrame := TGTKFrame.CreateWithoutLabel(Self);
  TitleFrame.ShadowType := stShadowOut;
  TitleIcon := TGTKImage.Create(Self);
  TitleIcon.SetFromIconName('gtk-justify-center', isLargeToolbar);
  TitleHBox := TGTKHBox.Create(Self);
  TitleHBox.Homogeneous := False;
  TitleHBox.AddControlEx(TGTKEventBox.Create(Self), False, False, 5);
  TitleHBox.AddControlEx(TitleIcon, False, False, 0);
  TitleHBox.AddControlEx(TitleLabel, True, True, 10);
  TitleEventBox.AddControl(TitleHBox);
  TitleFrame.AddControl(TitleEventBox);
  ClientArea.AddControlEx(TitleFrame, False, True, 0);

  HBox4 := TGTKHBox.Create(Self);
  HBox4.Homogeneous := False;
  HBox4.MarginStart := 5;
  HBox4.MarginEnd := 5;
  HBox4.MarginTop := 2;
  HBox4.MarginBottom := 2;
  ExperimentalWarningLabel := TGTKLabel.Create(Self);
  ExperimentalWarningLabel.Caption := LANGTestPlugin_ExperimentalWarningLabelCaption; 
  ExperimentalWarningLabel.UseMarkup := True;
  ExperimentalWarningLabel.LineWrap := True;
  ExperimentalWarningLabel.SetSizeRequest(300, -1);
  ExperimentalWarningIcon := TGTKImage.Create(Self);
  ExperimentalWarningIcon.SetFromIconName('gtk-dialog-warning', isDialog);
  HBox4.AddControlEx(TGTKEventBox.Create(Self), False, False, 5);
  HBox4.AddControlEx(ExperimentalWarningIcon, False, False, 7);
  HBox4.AddControlEx(ExperimentalWarningLabel, True, True, 7);
  HBox4.AddControlEx(TGTKEventBox.Create(Self), False, False, 8);

  Grid := TGTKGrid.Create(Self);
  Grid.BorderWidth := 20;
  ClientArea.AddControlEx(Grid, True, True, 0);
  Grid.AddControl(0, 0, 2, 1, HBox4);
  VBox := TGTKVBox.Create(Self);
  VBox.MarginStart := 5;
  VBox.MarginEnd := 5;
  VBox.MarginTop := 10;
  VBox.MarginBottom := 10;
  Grid.AddControl(0, 1, 2, 1, VBox);
  Label1 := TGTKLabel.Create(Self);
  Label1.Caption := LANGTestPlugin_Plugin;
  Label1.XAlign := 0;
  Label1.MarginStart := 5;
  Label1.MarginEnd := 5;
  Label1.MarginTop := 2;
  Label1.MarginBottom := 2;
  Label2 := TGTKLabel.Create(Self);
  Label2.Caption := LANGTestPlugin_Command;
  Label2.XAlign := 0;
  Label2.MarginStart := 5;
  Label2.MarginEnd := 5;
  Label2.MarginTop := 2;
  Label2.MarginBottom := 2;
  PluginComboBox := TGTKComboBoxText.Create(Self);
  PluginComboBox.MarginStart := 5;
  PluginComboBox.MarginEnd := 5;
  PluginComboBox.MarginTop := 2;
  PluginComboBox.MarginBottom := 2;
  Label1.FocusControl := PluginComboBox;
  Label1.UseUnderline := True;
  CommandEntry := TGTKEntry.Create(Self);
  CommandEntry.MarginStart := 5;
  CommandEntry.MarginEnd := 5;
  CommandEntry.MarginTop := 2;
  CommandEntry.MarginBottom := 2;
  Label2.FocusControl := CommandEntry;
  Label2.UseUnderline := True;
  Grid.AddControl(0, 2, 1, 1, Label1);
  Grid.AddControl(0, 3, 1, 1, Label2);
  Grid.AddControl(1, 2, 1, 1, PluginComboBox);
  Grid.AddControl(1, 3, 1, 1, CommandEntry);
  Label3 := TGTKLabel.Create(Self);
  Label3.Caption := LANGTestPlugin_Username;
  UserEntry := TGTKEntry.Create(Self);
  UserEntry.MarginStart := 5;
  UserEntry.MarginEnd := 5;
  UserEntry.MarginTop := 2;
  UserEntry.MarginBottom := 2;
  Label3.FocusControl := UserEntry;
  Label3.UseUnderline := True;
  Label3.XAlign := 0;
  Label3.MarginStart := 5;
  Label3.MarginEnd := 5;
  Label3.MarginTop := 2;
  Label3.MarginBottom := 2;
  Label4 := TGTKLabel.Create(Self);
  Label4.XAlign := 0;
  Label4.Caption := LANGTestPlugin_Password;
  Label4.MarginStart := 5;
  Label4.MarginEnd := 5;
  Label4.MarginTop := 2;
  Label4.MarginBottom := 2;
  PasswordEntry := TGTKEntry.Create(Self);
  PasswordEntry.MarginStart := 5;
  PasswordEntry.MarginEnd := 5;
  PasswordEntry.MarginTop := 2;
  PasswordEntry.MarginBottom := 2;
  Label4.FocusControl := PasswordEntry;
  Label4.UseUnderline := True;
  AnonymousCheckButton := TGTKCheckButton.CreateWithLabel(Self, LANGTestPlugin_AnonymousCheckButton);
  AnonymousCheckButton.OnToggled := @AnonymousCheckButtonToggled;
  AnonymousCheckButton.Checked := True;
  AnonymousCheckButton.MarginStart := 20;
  AnonymousCheckButton.MarginEnd := 20;
  AnonymousCheckButton.MarginTop := 2;
  AnonymousCheckButton.MarginBottom := 2;
  VBox := TGTKVBox.Create(Self);
  VBox.MarginStart := 5;
  VBox.MarginEnd := 5;
  VBox.MarginTop := 4;
  VBox.MarginBottom := 4;
  Grid.AddControl(0, 4, 2, 1, VBox);
  Grid.AddControl(0, 5, 1, 1, Label3);
  Grid.AddControl(1, 5, 1, 1, UserEntry);
  Grid.AddControl(0, 6, 1, 1, Label4);
  Grid.AddControl(1, 6, 1, 1, PasswordEntry);
  Grid.AddControl(0, 7, 2, 1, AnonymousCheckButton);



  if PluginList.Count = 0 then begin
    PluginComboBox.AppendItem(LANGTestPlugin_NoPluginsFound);
    PluginComboBox.Enabled := False;
  end else
    for i := 0 to PluginList.Count - 1 do begin
      PluginComboBox.AppendItemID(TVFSPlugin(PluginList[i]).ModuleID, 
                                  Format('%s [%s]', [TVFSPlugin(PluginList[i]).ModuleName,
                                                     ExtractFileName(TVFSPlugin(PluginList[i]).FullModulePath)]));
    end;

  OnKeyDown := @FormKeyDown;
end;

procedure TFTestPlugin.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
begin
  case Key of
    GDK_KEY_Return, GDK_KEY_KP_Enter: ModalResult := mbOK;
    GDK_KEY_Escape: ModalResult := mbCancel;
  end;
end;

procedure TFTestPlugin.AnonymousCheckButtonToggled(Sender: TObject);
begin
  Label3.Enabled := not AnonymousCheckButton.Checked;
  Label4.Enabled := not AnonymousCheckButton.Checked;
  UserEntry.Enabled := not AnonymousCheckButton.Checked;
  PasswordEntry.Enabled := not AnonymousCheckButton.Checked;
end;


end.