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::wxExportProgressDlg; |
---|
21 | use strict; |
---|
22 | use Carp; |
---|
23 | use Wx qw/ |
---|
24 | wxDefaultSize |
---|
25 | wxDefaultPosition |
---|
26 | wxID_CANCEL |
---|
27 | wxID_OK |
---|
28 | wxGREEN |
---|
29 | /; |
---|
30 | use base qw/Wx::Dialog Class::Accessor::Fast/; |
---|
31 | use Wx::Event qw/ |
---|
32 | EVT_UPDATE_UI |
---|
33 | EVT_BUTTON |
---|
34 | /; |
---|
35 | |
---|
36 | __PACKAGE__->mk_accessors( |
---|
37 | qw/ |
---|
38 | btok |
---|
39 | gauge |
---|
40 | progress |
---|
41 | processing |
---|
42 | txtprocessing |
---|
43 | cancelled |
---|
44 | / |
---|
45 | ); |
---|
46 | |
---|
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 | &main::ProcessingProgress($self, 1); |
---|
57 | |
---|
58 | $self->_initEventHandlers(); |
---|
59 | |
---|
60 | $self->btok( $self->FindWindow($main::ID_PROGRESS_OK) ); |
---|
61 | $self->gauge( $self->FindWindow($main::ID_PROGRESS_GAUGE) ); |
---|
62 | $self->txtprocessing( $self->FindWindow($main::ID_PROGRESS_TXT) ); |
---|
63 | $self->gauge->SetForegroundColour(wxGREEN); |
---|
64 | |
---|
65 | $self; |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | sub _initEventHandlers { |
---|
70 | my ( $self ) = @_; |
---|
71 | |
---|
72 | EVT_BUTTON( $self, $main::ID_PROGRESS_OK, \&OnExportOK ); |
---|
73 | |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | # Update progress information |
---|
78 | sub LogProgress { |
---|
79 | my ( $self ) = @_; |
---|
80 | |
---|
81 | printf("$self cancelled %s \n", $self->cancelled); |
---|
82 | die if $self->cancelled; |
---|
83 | $self->txtprocessing->SetLabel( |
---|
84 | $text || $self->processing |
---|
85 | ); |
---|
86 | $self->gauge->SetValue( |
---|
87 | $value || $self->progress |
---|
88 | ); |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | # Close the dialog. cancel export |
---|
93 | sub OnExportOK { |
---|
94 | my ( $self, $event ) = @_; |
---|
95 | |
---|
96 | $self->cancelled(1); |
---|
97 | $self->Destroy; |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | 1; |
---|