source: extras/pLoader/trunk/src/Uploader/GUI/wxLoginDlg.pm @ 3227

Last change on this file since 3227 was 3227, checked in by ronosman, 15 years ago

Feature 955 added : add a "Work Offline" mode to pLoader login.

  • Property svn:eol-style set to LF
File size: 3.6 KB
Line 
1# +-----------------------------------------------------------------------+
2# | pLoader - a Perl photo uploader for Piwigo                            |
3# +-----------------------------------------------------------------------+
4# | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
5# +-----------------------------------------------------------------------+
6# | This program is free software; you can redistribute it and/or modify  |
7# | it under the terms of the GNU General Public License as published by  |
8# | the Free Software Foundation                                          |
9# |                                                                       |
10# | This program is distributed in the hope that it will be useful, but   |
11# | WITHOUT ANY WARRANTY; without even the implied warranty of            |
12# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
13# | General Public License for more details.                              |
14# |                                                                       |
15# | You should have received a copy of the GNU General Public License     |
16# | along with this program; if not, write to the Free Software           |
17# | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
18# | USA.                                                                  |
19# +-----------------------------------------------------------------------+
20package Uploader::GUI::wxLoginDlg;
21use strict;
22use Wx qw/
23             wxDefaultSize
24             wxDefaultPosition
25             wxID_CANCEL
26             wxID_OK
27             wxGREEN
28         /;
29use base qw/Wx::Dialog Class::Accessor::Fast/;
30use Wx::Event qw/
31                    EVT_UPDATE_UI
32                    EVT_BUTTON
33                /;
34
35__PACKAGE__->mk_accessors( 
36    qw/
37           btok
38           url
39           username
40           password
41           use_offline
42      / 
43);
44
45
46sub new {
47    my ($this, $params) = @_;
48    #on recupere le nom de la classe en fonction du type d'appel de la méthode.
49    my $class = ref($this) || $this;
50
51
52    my $self = $class->SUPER::new( undef, -1, $params->{title}, wxDefaultPosition, wxDefaultSize);
53    # load controls
54    &main::Login($self, 1);
55
56    $self->use_offline(
57        $params->{use_offline}
58    );
59   
60    $self->url(
61        $params->{site_url}
62    );
63
64    $self->username(
65        $params->{site_username}
66    );
67
68    $self->password(
69        $params->{site_password}
70    );
71
72    $self->_initEventHandlers();
73   
74    $self->btok( $self->FindWindow($main::ID_PWG_OK) );
75
76    $self->FindWindow($main::ID_PWG_URL)->SetValue(
77        $self->url->()
78    );
79   
80   
81    $self->FindWindow($main::ID_PWG_USERNAME)->SetValue(
82        $self->username->() 
83    );
84   
85    $self->FindWindow($main::ID_PWG_PASSWORD)->SetValue( 
86        $self->password->() 
87    );
88     
89    $self;   
90}
91
92
93sub _initEventHandlers {
94    my ( $self ) = @_;
95   
96    EVT_BUTTON( $self, $main::ID_PWG_OK, \&OnLoginOK );
97    EVT_BUTTON( $self, $main::ID_PWG_CANCEL, \&OnLoginCancel );
98    EVT_BUTTON( $self, $main::ID_PWG_OFFLINE, \&OnLoginOffline );
99   
100       
101}
102
103sub OnLoginOffline {
104    my ( $self, $event ) = @_;
105    $self->use_offline->(1);
106       
107    $self->EndModal(2);
108}
109
110
111sub OnLoginOK {
112    my ( $self, $event ) = @_;
113   
114    $self->url->(
115        $self->FindWindow($main::ID_PWG_URL)->GetValue   
116    );
117
118    $self->username->(
119        $self->FindWindow($main::ID_PWG_USERNAME)->GetValue
120    );
121   
122    $self->password->(
123        $self->FindWindow($main::ID_PWG_PASSWORD)->GetValue
124    );
125
126    $self->EndModal(1);
127}
128
129sub OnLoginCancel {
130    my ( $self, $event ) = @_;
131   
132   
133    $self->EndModal(0);
134 
135}
136
137
1381;
Note: See TracBrowser for help on using the repository browser.