| 1 | package Padre::Plugin::HG::UserPassPrompt; | ||
| 2 | |||
| 3 | =pod | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Padre::Plugin::HG::UserPassPrompt | ||
| 8 | provides the username and password prompts for Padre::Plugin::HG | ||
| 9 | |||
| 10 | =head1 SYNOPSIS | ||
| 11 | |||
| 12 | my $object = Padre::Plugin::HG::UserPassPrompt->new( | ||
| 13 | title => 'project X', | ||
| 14 | default_username => 'fred', | ||
| 15 | default_password => 'XXXX', | ||
| 16 | |||
| 17 | ); | ||
| 18 | |||
| 19 | $password = $object->{password}; | ||
| 20 | $username = $object->{username}; | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | This module diplays a username and password prompt for actions like | ||
| 25 | pushing in Padre::Plugin::HG | ||
| 26 | |||
| 27 | =head1 METHODS | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | use 5.006; | ||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Wx qw[:everything]; | ||
| 35 | use Wx::Event qw( EVT_BUTTON ); | ||
| 36 | use base 'Wx::Panel'; | ||
| 37 | our $VERSION = '0.01'; | ||
| 38 | |||
| 39 | =pod | ||
| 40 | |||
| 41 | =head2 new | ||
| 42 | |||
| 43 | my $object = adre::Plugin::HG::UserPassPrompt->new( | ||
| 44 | title => 'project X', | ||
| 45 | default_username => 'fred', | ||
| 46 | default_password => 'XXXX', | ||
| 47 | |||
| 48 | ); | ||
| 49 | |||
| 50 | The C<new> constructor is the only method. | ||
| 51 | it will display the username and password prompts | ||
| 52 | |||
| 53 | Access the results via | ||
| 54 | $object->{username} and $object->{password} | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | sub new | ||
| 59 | { | ||
| 60 | my ($class, %params) = @_; | ||
| 61 | my $self = $class->SUPER::new( Padre::Current->main); | ||
| 62 | |||
| 63 | my $user_name = Wx::TextEntryDialog->new(undef, 'Enter your User Name',$params{title},$params{default_username}); | ||
| 64 | $user_name->ShowModal(); | ||
| 65 | $self->{username} = $user_name->GetValue(); | ||
| 66 | |||
| 67 | my $user_pass = Wx::PasswordEntryDialog->new(undef, 'Enter your Password',$params{title},$params{default_password},wxOK|wxCANCEL); | ||
| 68 | $user_pass->ShowModal(); | ||
| 69 | $self->{password} = $user_pass->GetValue(); | ||
| 70 | |||
| 71 | return $self; | ||
| 72 | } | ||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | 1; | ||
| 77 | |||
| 78 | =pod | ||
| 79 | |||
| 80 | =head1 SUPPORT | ||
| 81 | |||
| 82 | http://bitbucket.org/code4pay/padre-plugin-hg/ | ||
| 83 | |||
| 84 | =head1 AUTHOR | ||
| 85 | |||
| 86 | Copyright 2008 Michael Mueller . | ||
| 87 | |||
| 88 | =cut |