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::wxPhotoProperties; |
---|
21 | use strict; |
---|
22 | use Wx qw/ |
---|
23 | wxDefaultSize |
---|
24 | wxDefaultPosition |
---|
25 | wxTAB_TRAVERSAL |
---|
26 | wxID_CANCEL |
---|
27 | wxID_OK |
---|
28 | wxGREEN |
---|
29 | /; |
---|
30 | use base qw/Wx::Panel Uploader::GUI::DlgCommon/; |
---|
31 | use Wx::Event qw/ |
---|
32 | EVT_BUTTON |
---|
33 | EVT_CLOSE |
---|
34 | /; |
---|
35 | use Wx::Locale qw/:default/; |
---|
36 | use Carp; |
---|
37 | use Data::Dumper; |
---|
38 | |
---|
39 | sub new { |
---|
40 | my ($this, $params) = @_; |
---|
41 | #on recupere le nom de la classe en fonction du type d'appel de la méthode. |
---|
42 | my $class = ref($this) || $this; |
---|
43 | |
---|
44 | |
---|
45 | my $self = $class->SUPER::new( $params->{parentwnd}, -1, wxDefaultPosition, [-1, -1], wxTAB_TRAVERSAL ); |
---|
46 | # load controls |
---|
47 | &main::PhotoPropertiesCategoriesTags( $self, $params->{categories} ); |
---|
48 | |
---|
49 | $self->_initNotebook($params->{tags}); |
---|
50 | |
---|
51 | |
---|
52 | $self->properties( |
---|
53 | $params->{properties} |
---|
54 | ); |
---|
55 | |
---|
56 | $self->InitLabels(); |
---|
57 | $self->InitChoices(); |
---|
58 | $self->SetProperties(); |
---|
59 | $self->InitHandler(); |
---|
60 | $self->_initEventHandlers(); |
---|
61 | |
---|
62 | if($@){ |
---|
63 | Wx::LogMessage("Error during dialogbox initialization"); |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | $self; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | sub _initEventHandlers { |
---|
73 | my ( $self ) = @_; |
---|
74 | |
---|
75 | EVT_BUTTON( $self, $main::ID_REUPLOAD_OK, \&OnOK ); |
---|
76 | EVT_CLOSE( $self, \&OnClose ); |
---|
77 | |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | sub _initNotebook{ |
---|
82 | my ( $self, $tags ) = @_; |
---|
83 | |
---|
84 | my $nb = $self->FindWindow( |
---|
85 | $main::PHOTO_PROPERTIES_NB |
---|
86 | ); |
---|
87 | |
---|
88 | my( $page1 ) = Wx::Panel->new( $nb, -1 ); |
---|
89 | &main::photo_properties_caption_comments( $page1, 0 ); |
---|
90 | $nb->AddPage( $page1, "Photo informations" ); |
---|
91 | |
---|
92 | my( $page2 ) = Wx::Panel->new( $nb, -1 ); |
---|
93 | &main::photo_properties_tags( $page2, $tags ); |
---|
94 | $nb->AddPage( $page2, "Tags" ); |
---|
95 | |
---|
96 | $self->{notebook} = $nb; |
---|
97 | |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | sub OnOK { |
---|
102 | my ( $self, $event ) = @_; |
---|
103 | |
---|
104 | $self->_close; |
---|
105 | } |
---|
106 | |
---|
107 | sub OnClose { |
---|
108 | my ( $self, $event ) = @_; |
---|
109 | |
---|
110 | $self->_close; |
---|
111 | } |
---|
112 | |
---|
113 | sub _close { |
---|
114 | my ( $self ) = @_; |
---|
115 | |
---|
116 | $self->GetProperties(); |
---|
117 | |
---|
118 | $self->Destroy; |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | sub SetEnabled { |
---|
123 | my ( $self ) = @_; |
---|
124 | |
---|
125 | $self->{_properties_notebook}->Enable(1); |
---|
126 | } |
---|
127 | |
---|
128 | sub SetDisabled { |
---|
129 | my ( $self ) = @_; |
---|
130 | |
---|
131 | $self->{_properties_notebook}->Enable(0); |
---|
132 | } |
---|
133 | |
---|
134 | sub IsEnabled { |
---|
135 | my ( $self ) = @_; |
---|
136 | |
---|
137 | $self->{_properties_notebook}->IsEnabled; |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | sub SetMultiSelectionMode { |
---|
142 | my ( $self, $count ) = @_; |
---|
143 | |
---|
144 | $self->{_multi_selection_mode_panel}{_text1}->SetLabel( |
---|
145 | sprintf(gettext("You have selected a batch of %s photos"), $count ) |
---|
146 | ); |
---|
147 | |
---|
148 | $self->{_multi_selection_mode_panel}{_text2}->SetLabel( |
---|
149 | gettext("Changes apply to the whole batch") |
---|
150 | ); |
---|
151 | |
---|
152 | $self->{_multi_selection_mode_panel}->Show(1); |
---|
153 | $self->Layout; |
---|
154 | } |
---|
155 | |
---|
156 | |
---|
157 | sub SetSingleSelectionMode { |
---|
158 | my ( $self ) = @_; |
---|
159 | |
---|
160 | $self->{_multi_selection_mode_panel}->Show(0); |
---|
161 | $self->Layout; |
---|
162 | } |
---|
163 | 1; |
---|