source: extensions/pLoader/trunk/src/Uploader/GUI/wxImageProcessingProgressDlg.pm @ 4469

Last change on this file since 4469 was 4279, checked in by ronosman, 14 years ago

Feature 1064 added : improve upload progress dialog box to display current operation and the rank of the photo being uploaded.

  • Property svn:eol-style set to LF
File size: 3.9 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::wxImageProcessingProgressDlg;
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           gauge
39           progress
40           processing
41           txtprocessing
42           processing_details
43           txtprocessing_details
44           image
45           cancelled
46           bt_close_label
47      / 
48);
49use Carp;
50
51sub new {
52    my ($this, $params) = @_;
53    #on recupere le nom de la classe en fonction du type d'appel de la méthode.
54    my $class = ref($this) || $this;
55
56
57    my $self = $class->SUPER::new( undef, -1, $params->{title}, wxDefaultPosition, wxDefaultSize);
58    # load controls
59    eval {
60      &main::ProcessingProgress($self, 1);
61
62    $self->_initEventHandlers();
63   
64    $self->btok( $self->FindWindow($main::ID_PROGRESS_OK) );
65    $self->gauge( $self->FindWindow($main::ID_PROGRESS_GAUGE) );
66    $self->txtprocessing( $self->FindWindow($main::ID_PROGRESS_TXT) );
67    $self->txtprocessing_details( $self->FindWindow($main::ID_PROGRESS_TXT2) );
68    $self->image( $self->FindWindow($main::ID_STATICBITMAP) );
69    $self->gauge->SetForegroundColour(wxGREEN);
70    };
71
72    $self->btok->SetLabel(
73        $params->{bt_label}||'Cancel'
74    );
75    $self->bt_close_label(
76        $params->{bt_close_label}||'Close'
77    );
78
79    if($@){
80        Wx::LogMessage("Error during dialogbox initialization");
81    }
82    $self;   
83}
84
85
86sub _initEventHandlers {
87    my ( $self ) = @_;
88   
89    EVT_BUTTON( $self, $main::ID_PROGRESS_OK, \&OnOK );
90   
91       
92}
93
94# Update progress information
95sub LogProgress {
96    my ( $self ) = @_;
97   
98    croak "Cancelled by user\n" if $self->cancelled;   
99   
100    $self->txtprocessing->SetLabel(
101        $self->processing
102    );
103    $self->txtprocessing_details->SetLabel(
104        $self->processing_details
105    );
106    $self->gauge->SetValue(
107        $self->progress
108    );
109}
110
111sub DisplayEndInfo {
112    my ( $self, $msg ) = @_;
113
114    $self->txtprocessing->SetLabel(
115        $msg
116    );
117    $self->image->Show(0);
118    $self->gauge->Show(0);
119    # for i18n
120    $self->btok->SetLabel(
121        $self->bt_close_label
122    );
123       
124    $self->txtprocessing_details->SetLabel("");
125}
126
127sub OnOK {
128    my ( $self, $event ) = @_;
129   
130    $self->cancelled(1);
131    $self->Destroy;
132 
133}
134
135
1361;
Note: See TracBrowser for help on using the repository browser.