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
|
(*
Tux Commander - USetPassword - Password prompt dialog
Copyright (C) 2008 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 USetPassword;
interface
uses
glib2, gtk2, pango, SysUtils, Types, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView,
GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses;
type
TFSetPassword = class(TGTKDialog)
Label1, Label2: TGTKLabel;
DialogIcon: TGTKImage;
Entry: TGTKEntry;
Table: TGTKTable;
ShowPasswordCheckButton: TGTKCheckButton;
procedure FormCreate(Sender: TObject); override;
procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
procedure ShowPasswordCheckButtonClick(Sender: TObject);
end;
var
FSetPassword: TFSetPassword;
implementation
uses ULocale, UFileAssoc;
procedure TFSetPassword.FormCreate(Sender: TObject);
begin
SetDefaultSize(400, -1);
Buttons := [mbOK, mbCancel];
Caption := LANGFSetPassword_Caption;
Table := TGTKTable.Create(Self);
DialogIcon := TGTKImage.Create(Self);
if gtk_style_lookup_icon_set(gtk_widget_get_style(FWidget), 'gtk-dialog-authentication') <> nil
then DialogIcon.SetFromStock('gtk-dialog-authentication', isDialog)
else DialogIcon.CopyFromPixbuf(StockLock48);
Label1 := TGTKLabel.Create(Self);
Label1.Caption := Format('<span size="x-large" weight="bold">%s</span>', [LANGFSetPassword_Label1_Caption]);
Label1.UseMarkup := True;
Label1.XAlign := 0;
Label2 := TGTKLabel.Create(Self);
Label2.Caption := LANGFSetPassword_Label2_Caption;
Label2.LineWrap := True;
Label2.XAlign := 0;
Label2.SetSizeRequest(270, -1);
Entry := TGTKEntry.Create(Self);
Entry.Visibility := False;
ShowPasswordCheckButton := TGTKCheckButton.CreateWithLabel(Self, LANGFSetPassword_ShowPasswordCheckButton);
ShowPasswordCheckButton.OnToggled := ShowPasswordCheckButtonClick;
Table.AddControlEx(0, 0, 2, 1, Label1, [taoExpand, taoFill], [taoShrink], 20, 3);
Table.AddControlEx(0, 1, 1, 1, DialogIcon, [taoShrink], [taoShrink], 10, 5);
Table.AddControlEx(1, 1, 1, 1, Label2, [taoExpand, taoFill], [taoShrink], 5, 0);
Table.AddControlEx(0, 2, 1, 1, TGTKVBox.Create(Self), [taoShrink], [taoShrink, taoExpand, taoFill], 2, 6);
Table.AddControlEx(0, 3, 2, 1, Entry, [taoExpand, taoFill], [taoShrink], 5, 0);
Table.AddControlEx(0, 4, 2, 1, ShowPasswordCheckButton, [taoExpand, taoFill], [taoShrink], 15, 5);
Table.BorderWidth := 10;
ClientArea.AddControlEx(Table, True, True, 0);
OnKeyDown := FormKeyDown;
Entry.SetFocus;
end;
procedure TFSetPassword.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
begin
case Key of
GDK_RETURN, GDK_KP_ENTER: ModalResult := mbOK;
GDK_ESCAPE: ModalResult := mbCancel;
GDK_M, GDK_Capital_M: if (Shift = [ssAlt]) then begin
ShowPasswordCheckButton.Checked := not ShowPasswordCheckButton.Checked;
Accept := False;
end;
end;
end;
procedure TFSetPassword.ShowPasswordCheckButtonClick(Sender: TObject);
begin
Entry.Visibility := ShowPasswordCheckButton.Checked;
end;
end.
|