[2597] | 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 | # +-----------------------------------------------------------------------+ |
---|
| 20 | package Uploader::GUI::wxImageProcessingProgressDlg; |
---|
| 21 | use strict; |
---|
| 22 | use Wx qw/ |
---|
| 23 | wxDefaultSize |
---|
| 24 | wxDefaultPosition |
---|
| 25 | wxID_CANCEL |
---|
| 26 | wxID_OK |
---|
| 27 | wxGREEN |
---|
| 28 | /; |
---|
| 29 | use base qw/Wx::Dialog Class::Accessor::Fast/; |
---|
| 30 | use 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 |
---|
[4279] | 42 | processing_details |
---|
| 43 | txtprocessing_details |
---|
[2597] | 44 | image |
---|
[2728] | 45 | cancelled |
---|
[4279] | 46 | bt_close_label |
---|
[2597] | 47 | / |
---|
| 48 | ); |
---|
[2728] | 49 | use Carp; |
---|
[2597] | 50 | |
---|
| 51 | sub 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) ); |
---|
[4279] | 67 | $self->txtprocessing_details( $self->FindWindow($main::ID_PROGRESS_TXT2) ); |
---|
[2597] | 68 | $self->image( $self->FindWindow($main::ID_STATICBITMAP) ); |
---|
| 69 | $self->gauge->SetForegroundColour(wxGREEN); |
---|
| 70 | }; |
---|
| 71 | |
---|
[2728] | 72 | $self->btok->SetLabel( |
---|
| 73 | $params->{bt_label}||'Cancel' |
---|
| 74 | ); |
---|
[4279] | 75 | $self->bt_close_label( |
---|
| 76 | $params->{bt_close_label}||'Close' |
---|
| 77 | ); |
---|
[2728] | 78 | |
---|
[2597] | 79 | if($@){ |
---|
| 80 | Wx::LogMessage("Error during dialogbox initialization"); |
---|
| 81 | } |
---|
| 82 | $self; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | sub _initEventHandlers { |
---|
| 87 | my ( $self ) = @_; |
---|
| 88 | |
---|
[2728] | 89 | EVT_BUTTON( $self, $main::ID_PROGRESS_OK, \&OnOK ); |
---|
[2597] | 90 | |
---|
| 91 | |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | # Update progress information |
---|
| 95 | sub LogProgress { |
---|
[2728] | 96 | my ( $self ) = @_; |
---|
[2597] | 97 | |
---|
[2728] | 98 | croak "Cancelled by user\n" if $self->cancelled; |
---|
[2597] | 99 | |
---|
| 100 | $self->txtprocessing->SetLabel( |
---|
[2728] | 101 | $self->processing |
---|
[2597] | 102 | ); |
---|
[4279] | 103 | $self->txtprocessing_details->SetLabel( |
---|
| 104 | $self->processing_details |
---|
| 105 | ); |
---|
[2597] | 106 | $self->gauge->SetValue( |
---|
[4279] | 107 | $self->progress |
---|
[2597] | 108 | ); |
---|
| 109 | } |
---|
| 110 | |
---|
[2728] | 111 | sub DisplayEndInfo { |
---|
| 112 | my ( $self, $msg ) = @_; |
---|
[2597] | 113 | |
---|
[2728] | 114 | $self->txtprocessing->SetLabel( |
---|
| 115 | $msg |
---|
| 116 | ); |
---|
| 117 | $self->image->Show(0); |
---|
| 118 | $self->gauge->Show(0); |
---|
[4279] | 119 | # for i18n |
---|
[2728] | 120 | $self->btok->SetLabel( |
---|
[4279] | 121 | $self->bt_close_label |
---|
[2728] | 122 | ); |
---|
| 123 | |
---|
[4279] | 124 | $self->txtprocessing_details->SetLabel(""); |
---|
[2728] | 125 | } |
---|
| 126 | |
---|
| 127 | sub OnOK { |
---|
[2597] | 128 | my ( $self, $event ) = @_; |
---|
| 129 | |
---|
[2728] | 130 | $self->cancelled(1); |
---|
[2597] | 131 | $self->Destroy; |
---|
| 132 | |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | 1; |
---|