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