EC/PasswordDialog.pm untested

filter: Statementstmt 0.0% 0 / 66 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 82 CC 1 SCAR 6.9
CC
1
Cov
0%
Password
2.0
Populate
2.0
WaitForInput
2.0
CRAP 2.0
1 package EC::PasswordDialog;
2 my $RCSRevKey = '$Revision: 1.2 $';
3 $RCSRevKey =~ /Revision: (.*?) /;
4 $VERSION=$1;
5 use vars qw($VERSION @EXPORT_OK);
6 @EXPORT_OK = qw(glob_to_re);
7  
8 =head1 NAME
9  
10 PasswordDialog - Password entry.
11  
12 =head1 SYNOPSIS
13  
14 $d = $mw -> PasswordDialog (-username => 'login' );
15 $d -> WaitForInput
16  
17 The -font option defaults to *-helvetica-medium-r-*-*-12-*.
18 The -username option supplies the default text for the user
19 name entry box.
20  
21 =head1 DESCRIPTION
22  
23 A widget for the ec email program - refer to the ec documentation.
24  
25 =cut
26  
27 use Tk qw(Ev);
28 use strict;
29 use Carp;
30 use base qw(Tk::Toplevel);
31 use Tk::widgets qw(LabEntry Button Frame);
32  
33 Construct Tk::Widget 'PasswordDialog';
34  
35 sub Password {
36 my ($w) = @_;
37 $w -> {Configure}{'-password'} =
38 $w -> Subwidget( 'passwordentry' ) -> get;
39 }
40  
41 sub Populate {
42 my ($w,$args) = @_;
43 require Tk::Button;
44 require Tk::Toplevel;
45 require Tk::Label;
46 require Tk::Entry;
47 $w->SUPER::Populate($args);
48  
49 $w -> configure( -title => 'Enter Password' );
50  
51 $w->ConfigSpecs( -font => ['CHILDREN',undef,undef,
52 '*-helvetica-medium-r-*-*-12-*'],
53 -username => ['PASSIVE',undef,undef,''],
54 -password => ['PASSIVE',undef,undef,undef] );
55  
56 my $l1 = $w -> Component ( Label => 'usernamelabel',
57 -text => 'User Name:', );
58 $l1 -> grid ( -column => 1, -row => 1, -padx => 5, -pady => 5,
59 -sticky => 'w', -columnspan => 2 );
60 my $e1 = $w -> Component (Entry => 'usernameentry',
61 -width => 20,
62 -textvariable => \$w->{'Configure'}{'-username'});
63 $e1 -> grid ( -column => 3, -row => 1, -padx => 5, -pady => 5,
64 -sticky => 'w', -columnspan => 3 );
65 my $l2 = $w -> Component (Label => 'passwordlabel',
66 -text => 'Password:', );
67 $l2 -> grid ( -column => 1, -row => 2, -padx => 5, -pady => 5,
68 -sticky => 'w', -columnspan => 2 );
69 my $e2 = $w -> Component (Entry => 'passwordentry',
70 -width => 20,
71 -show => '*' );
72 $e2 -> bind( '<Return>', sub {$w -> Password} );
73 $e2 -> grid ( -column => 3, -row => 2, -padx => 5, -pady => 5,
74 -sticky => 'w', -columnspan => 3 );
75 my $b1 = $w -> Component (Button => 'okbutton',
76 -text => 'Ok',
77 -command => sub {$w -> Password},
78 -default => 'active' );
79 $b1->grid( -column => 2, -row => 3, -padx => 5, -pady => 5,
80 -sticky => 'new' );
81 $b1->focus;
82 my $b2 = $w -> Component (Button => 'cancelbutton',
83 -text => 'Cancel',
84 -command => sub{$w -> WmDeleteWindow},
85 -default => 'normal' );
86 $b2->grid( -column => 4, -row => 3, -padx => 5, -pady => 5,
87 -sticky => 'new' );
88  
89 return $w;
90 }
91  
92 sub WaitForInput {
93 my ($w, @args) = @_;
94 $w -> waitVariable( \$w->{'Configure'}{'-password'} );
95 $w -> withdraw;
96 return $w -> {'Configure'}{'-password'};
97 }
98  
99 1;