1 | # +-----------------------------------------------------------------------+ |
---|
2 | # | pLoader - a Perl photo uploader for Piwigo | |
---|
3 | # +-----------------------------------------------------------------------+ |
---|
4 | # | Copyright(C) 2008-2010 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 | wxDIALOG_NO_PARENT |
---|
29 | wxDEFAULT_DIALOG_STYLE |
---|
30 | |
---|
31 | wxMAXIMIZE_BOX |
---|
32 | wxMINIMIZE_BOX |
---|
33 | |
---|
34 | wxSTAY_ON_TOP |
---|
35 | /; |
---|
36 | use base qw/Wx::Dialog Class::Accessor::Fast/; |
---|
37 | use Wx::Event qw/ |
---|
38 | EVT_UPDATE_UI |
---|
39 | EVT_BUTTON |
---|
40 | /; |
---|
41 | |
---|
42 | __PACKAGE__->mk_accessors( |
---|
43 | qw/ |
---|
44 | btok |
---|
45 | gauge |
---|
46 | progress |
---|
47 | processing |
---|
48 | txtprocessing |
---|
49 | processing_details |
---|
50 | txtprocessing_details |
---|
51 | image |
---|
52 | cancelled |
---|
53 | bt_close_label |
---|
54 | stop_processing |
---|
55 | / |
---|
56 | ); |
---|
57 | use Carp; |
---|
58 | |
---|
59 | sub new { |
---|
60 | my ($this, $params) = @_; |
---|
61 | #on recupere le nom de la classe en fonction du type d'appel de la méthode. |
---|
62 | my $class = ref($this) || $this; |
---|
63 | |
---|
64 | |
---|
65 | my $self = $class->SUPER::new( |
---|
66 | undef, |
---|
67 | -1, |
---|
68 | $params->{title}, |
---|
69 | wxDefaultPosition, |
---|
70 | wxDefaultSize, |
---|
71 | wxDIALOG_NO_PARENT| |
---|
72 | wxDEFAULT_DIALOG_STYLE| |
---|
73 | wxMAXIMIZE_BOX| |
---|
74 | wxMINIMIZE_BOX| |
---|
75 | wxSTAY_ON_TOP |
---|
76 | |
---|
77 | ); |
---|
78 | # load controls |
---|
79 | eval { |
---|
80 | &main::ProcessingProgress($self, 1); |
---|
81 | |
---|
82 | $self->_initEventHandlers(); |
---|
83 | |
---|
84 | $self->btok( $self->FindWindow($main::ID_PROGRESS_OK) ); |
---|
85 | $self->gauge( $self->FindWindow($main::ID_PROGRESS_GAUGE) ); |
---|
86 | $self->txtprocessing( $self->FindWindow($main::ID_PROGRESS_TXT) ); |
---|
87 | $self->txtprocessing_details( $self->FindWindow($main::ID_PROGRESS_TXT2) ); |
---|
88 | $self->image( $self->FindWindow($main::ID_STATICBITMAP) ); |
---|
89 | $self->gauge->SetForegroundColour(wxGREEN); |
---|
90 | }; |
---|
91 | |
---|
92 | $self->btok->SetLabel( |
---|
93 | $params->{bt_label}||'Cancel' |
---|
94 | ); |
---|
95 | $self->bt_close_label( |
---|
96 | $params->{bt_close_label}||'Close' |
---|
97 | ); |
---|
98 | |
---|
99 | $self->stop_processing( |
---|
100 | $params->{stop_processing} |
---|
101 | ); |
---|
102 | |
---|
103 | if($@){ |
---|
104 | Wx::LogMessage("Error during dialogbox initialization"); |
---|
105 | } |
---|
106 | $self; |
---|
107 | } |
---|
108 | |
---|
109 | |
---|
110 | sub _initEventHandlers { |
---|
111 | my ( $self ) = @_; |
---|
112 | |
---|
113 | EVT_BUTTON( $self, $main::ID_PROGRESS_OK, \&OnOK ); |
---|
114 | |
---|
115 | |
---|
116 | } |
---|
117 | |
---|
118 | # Update progress information |
---|
119 | sub LogProgress { |
---|
120 | my ( $self ) = @_; |
---|
121 | |
---|
122 | croak "Cancelled by user\n" if $self->cancelled; |
---|
123 | |
---|
124 | $self->txtprocessing->SetLabel( |
---|
125 | $self->processing |
---|
126 | ); |
---|
127 | $self->txtprocessing_details->SetLabel( |
---|
128 | $self->processing_details |
---|
129 | ); |
---|
130 | $self->gauge->SetValue( |
---|
131 | $self->progress |
---|
132 | ); |
---|
133 | } |
---|
134 | |
---|
135 | sub DisplayEndInfo { |
---|
136 | my ( $self, $msg ) = @_; |
---|
137 | |
---|
138 | $self->txtprocessing->SetLabel( |
---|
139 | $msg |
---|
140 | ); |
---|
141 | $self->image->Show(0); |
---|
142 | $self->gauge->Show(0); |
---|
143 | # for i18n |
---|
144 | $self->btok->SetLabel( |
---|
145 | $self->bt_close_label |
---|
146 | ); |
---|
147 | |
---|
148 | $self->txtprocessing_details->SetLabel(""); |
---|
149 | } |
---|
150 | |
---|
151 | sub OnOK { |
---|
152 | my ( $self, $event ) = @_; |
---|
153 | |
---|
154 | $self->cancelled(1); |
---|
155 | $self->stop_processing->(); |
---|
156 | $self->Hide; |
---|
157 | |
---|
158 | } |
---|
159 | |
---|
160 | |
---|
161 | 1; |
---|