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