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::wxFrameAUI; |
---|
21 | use strict; |
---|
22 | use Carp; |
---|
23 | use Wx; |
---|
24 | use Wx::DND; |
---|
25 | use Wx qw/ |
---|
26 | wxNullBitmap |
---|
27 | wxID_OK |
---|
28 | wxDEFAULT_FRAME_STYLE |
---|
29 | wxVERTICAL |
---|
30 | wxGROW |
---|
31 | wxBITMAP_TYPE_JPEG |
---|
32 | wxBITMAP_TYPE_GIF |
---|
33 | wxBITMAP_TYPE_PNG |
---|
34 | wxTB_FLAT |
---|
35 | wxSIZE |
---|
36 | wxWHITE |
---|
37 | wxBLACK |
---|
38 | wxID_CANCEL |
---|
39 | wxFD_OPEN |
---|
40 | wxFD_MULTIPLE |
---|
41 | wxLI_HORIZONTAL |
---|
42 | wxALIGN_CENTER_VERTICAL |
---|
43 | wxALL |
---|
44 | wxDefaultPosition |
---|
45 | wxDefaultSize |
---|
46 | wxTheApp |
---|
47 | wxIMAGE_LIST_NORMAL |
---|
48 | wxAUI_NB_TAB_MOVE |
---|
49 | wxAUI_NB_TAB_SPLIT |
---|
50 | wxNO_BORDER |
---|
51 | wxTE_MULTILINE |
---|
52 | wxTE_READONLY |
---|
53 | wxITEM_NORMAL |
---|
54 | wxCLIP_CHILDREN |
---|
55 | wxBORDER_NONE |
---|
56 | wxNullBitmap |
---|
57 | wxTR_MULTIPLE |
---|
58 | wxTR_EXTENDED |
---|
59 | wxTR_HIDE_ROOT |
---|
60 | wxTR_HAS_BUTTONS |
---|
61 | wxMAXIMIZE |
---|
62 | wxOK |
---|
63 | wxICON_EXCLAMATION |
---|
64 | wxICON_INFORMATION |
---|
65 | WXK_DELETE |
---|
66 | wxLANGUAGE_ABKHAZIAN |
---|
67 | wxLANGUAGE_AFAR |
---|
68 | wxLANGUAGE_AFRIKAANS |
---|
69 | wxLANGUAGE_ALBANIAN |
---|
70 | wxLANGUAGE_AMHARIC |
---|
71 | wxLANGUAGE_ARABIC |
---|
72 | wxLANGUAGE_ARABIC_ALGERIA |
---|
73 | wxLANGUAGE_ARABIC_BAHRAIN |
---|
74 | wxLANGUAGE_ARABIC_EGYPT |
---|
75 | wxLANGUAGE_ARABIC_IRAQ |
---|
76 | wxLANGUAGE_ARABIC_JORDAN |
---|
77 | wxLANGUAGE_ARABIC_KUWAIT |
---|
78 | wxLANGUAGE_ARABIC_LEBANON |
---|
79 | wxLANGUAGE_ARABIC_LIBYA |
---|
80 | wxLANGUAGE_ARABIC_MOROCCO |
---|
81 | wxLANGUAGE_ARABIC_OMAN |
---|
82 | wxLANGUAGE_ARABIC_QATAR |
---|
83 | wxLANGUAGE_ARABIC_SAUDI_ARABIA |
---|
84 | wxLANGUAGE_ARABIC_SUDAN |
---|
85 | wxLANGUAGE_ARABIC_SYRIA |
---|
86 | wxLANGUAGE_ARABIC_TUNISIA |
---|
87 | wxLANGUAGE_ARABIC_UAE |
---|
88 | wxLANGUAGE_ARABIC_YEMEN |
---|
89 | wxLANGUAGE_ARMENIAN |
---|
90 | wxLANGUAGE_ASSAMESE |
---|
91 | wxLANGUAGE_AYMARA |
---|
92 | wxLANGUAGE_AZERI |
---|
93 | wxLANGUAGE_AZERI_CYRILLIC |
---|
94 | wxLANGUAGE_AZERI_LATIN |
---|
95 | wxLANGUAGE_BASHKIR |
---|
96 | wxLANGUAGE_BASQUE |
---|
97 | wxLANGUAGE_BELARUSIAN |
---|
98 | wxLANGUAGE_BENGALI |
---|
99 | wxLANGUAGE_BHUTANI |
---|
100 | wxLANGUAGE_BIHARI |
---|
101 | wxLANGUAGE_BISLAMA |
---|
102 | wxLANGUAGE_BRETON |
---|
103 | wxLANGUAGE_BULGARIAN |
---|
104 | wxLANGUAGE_BURMESE |
---|
105 | wxLANGUAGE_CAMBODIAN |
---|
106 | wxLANGUAGE_CATALAN |
---|
107 | wxLANGUAGE_CHINESE |
---|
108 | wxLANGUAGE_CHINESE_SIMPLIFIED |
---|
109 | wxLANGUAGE_CHINESE_TRADITIONAL |
---|
110 | wxLANGUAGE_CHINESE_HONGKONG |
---|
111 | wxLANGUAGE_CHINESE_MACAU |
---|
112 | wxLANGUAGE_CHINESE_SINGAPORE |
---|
113 | wxLANGUAGE_CHINESE_TAIWAN |
---|
114 | wxLANGUAGE_CORSICAN |
---|
115 | wxLANGUAGE_CROATIAN |
---|
116 | wxLANGUAGE_CZECH |
---|
117 | wxLANGUAGE_DANISH |
---|
118 | wxLANGUAGE_DUTCH |
---|
119 | wxLANGUAGE_DUTCH_BELGIAN |
---|
120 | wxLANGUAGE_ENGLISH |
---|
121 | wxLANGUAGE_ENGLISH_UK |
---|
122 | wxLANGUAGE_ENGLISH_US |
---|
123 | wxLANGUAGE_ENGLISH_AUSTRALIA |
---|
124 | wxLANGUAGE_ENGLISH_BELIZE |
---|
125 | wxLANGUAGE_ENGLISH_BOTSWANA |
---|
126 | wxLANGUAGE_ENGLISH_CANADA |
---|
127 | wxLANGUAGE_ENGLISH_CARIBBEAN |
---|
128 | wxLANGUAGE_ENGLISH_DENMARK |
---|
129 | wxLANGUAGE_ENGLISH_EIRE |
---|
130 | wxLANGUAGE_ENGLISH_JAMAICA |
---|
131 | wxLANGUAGE_ENGLISH_NEW_ZEALAND |
---|
132 | wxLANGUAGE_ENGLISH_PHILIPPINES |
---|
133 | wxLANGUAGE_ENGLISH_SOUTH_AFRICA |
---|
134 | wxLANGUAGE_ENGLISH_TRINIDAD |
---|
135 | wxLANGUAGE_ENGLISH_ZIMBABWE |
---|
136 | wxLANGUAGE_ESPERANTO |
---|
137 | wxLANGUAGE_ESTONIAN |
---|
138 | wxLANGUAGE_FAEROESE |
---|
139 | wxLANGUAGE_FARSI |
---|
140 | wxLANGUAGE_FIJI |
---|
141 | wxLANGUAGE_FINNISH |
---|
142 | wxLANGUAGE_FRENCH |
---|
143 | wxLANGUAGE_FRENCH_BELGIAN |
---|
144 | wxLANGUAGE_FRENCH_CANADIAN |
---|
145 | wxLANGUAGE_FRENCH_LUXEMBOURG |
---|
146 | wxLANGUAGE_FRENCH_MONACO |
---|
147 | wxLANGUAGE_FRENCH_SWISS |
---|
148 | wxLANGUAGE_FRISIAN |
---|
149 | wxLANGUAGE_GALICIAN |
---|
150 | wxLANGUAGE_GEORGIAN |
---|
151 | wxLANGUAGE_GERMAN |
---|
152 | wxLANGUAGE_GERMAN_AUSTRIAN |
---|
153 | wxLANGUAGE_GERMAN_BELGIUM |
---|
154 | wxLANGUAGE_GERMAN_LIECHTENSTEIN |
---|
155 | wxLANGUAGE_GERMAN_LUXEMBOURG |
---|
156 | wxLANGUAGE_GERMAN_SWISS |
---|
157 | wxLANGUAGE_GREEK |
---|
158 | wxLANGUAGE_GREENLANDIC |
---|
159 | wxLANGUAGE_GUARANI |
---|
160 | wxLANGUAGE_GUJARATI |
---|
161 | wxLANGUAGE_HAUSA |
---|
162 | wxLANGUAGE_HEBREW |
---|
163 | wxLANGUAGE_HINDI |
---|
164 | wxLANGUAGE_HUNGARIAN |
---|
165 | wxLANGUAGE_ICELANDIC |
---|
166 | wxLANGUAGE_INDONESIAN |
---|
167 | wxLANGUAGE_INTERLINGUA |
---|
168 | wxLANGUAGE_INTERLINGUE |
---|
169 | wxLANGUAGE_INUKTITUT |
---|
170 | wxLANGUAGE_INUPIAK |
---|
171 | wxLANGUAGE_IRISH |
---|
172 | wxLANGUAGE_ITALIAN |
---|
173 | wxLANGUAGE_ITALIAN_SWISS |
---|
174 | wxLANGUAGE_JAPANESE |
---|
175 | wxLANGUAGE_JAVANESE |
---|
176 | wxLANGUAGE_KANNADA |
---|
177 | wxLANGUAGE_KASHMIRI |
---|
178 | wxLANGUAGE_KASHMIRI_INDIA |
---|
179 | wxLANGUAGE_KAZAKH |
---|
180 | wxLANGUAGE_KERNEWEK |
---|
181 | wxLANGUAGE_KINYARWANDA |
---|
182 | wxLANGUAGE_KIRGHIZ |
---|
183 | wxLANGUAGE_KIRUNDI |
---|
184 | wxLANGUAGE_KONKANI |
---|
185 | wxLANGUAGE_KOREAN |
---|
186 | wxLANGUAGE_KURDISH |
---|
187 | wxLANGUAGE_LAOTHIAN |
---|
188 | wxLANGUAGE_LATIN |
---|
189 | wxLANGUAGE_LATVIAN |
---|
190 | wxLANGUAGE_LINGALA |
---|
191 | wxLANGUAGE_LITHUANIAN |
---|
192 | wxLANGUAGE_MACEDONIAN |
---|
193 | wxLANGUAGE_MALAGASY |
---|
194 | wxLANGUAGE_MALAY |
---|
195 | wxLANGUAGE_MALAYALAM |
---|
196 | wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM |
---|
197 | wxLANGUAGE_MALAY_MALAYSIA |
---|
198 | wxLANGUAGE_MALTESE |
---|
199 | wxLANGUAGE_MANIPURI |
---|
200 | wxLANGUAGE_MAORI |
---|
201 | wxLANGUAGE_MARATHI |
---|
202 | wxLANGUAGE_MOLDAVIAN |
---|
203 | wxLANGUAGE_MONGOLIAN |
---|
204 | wxLANGUAGE_NAURU |
---|
205 | wxLANGUAGE_NEPALI |
---|
206 | wxLANGUAGE_NEPALI_INDIA |
---|
207 | wxLANGUAGE_NORWEGIAN_BOKMAL |
---|
208 | wxLANGUAGE_NORWEGIAN_NYNORSK |
---|
209 | wxLANGUAGE_OCCITAN |
---|
210 | wxLANGUAGE_ORIYA |
---|
211 | wxLANGUAGE_OROMO |
---|
212 | wxLANGUAGE_PASHTO |
---|
213 | wxLANGUAGE_POLISH |
---|
214 | wxLANGUAGE_PORTUGUESE |
---|
215 | wxLANGUAGE_PORTUGUESE_BRAZILIAN |
---|
216 | wxLANGUAGE_PUNJABI |
---|
217 | wxLANGUAGE_QUECHUA |
---|
218 | wxLANGUAGE_RHAETO_ROMANCE |
---|
219 | wxLANGUAGE_ROMANIAN |
---|
220 | wxLANGUAGE_RUSSIAN |
---|
221 | wxLANGUAGE_RUSSIAN_UKRAINE |
---|
222 | wxLANGUAGE_SAMI |
---|
223 | wxLANGUAGE_SAMOAN |
---|
224 | wxLANGUAGE_SANGHO |
---|
225 | wxLANGUAGE_SANSKRIT |
---|
226 | wxLANGUAGE_SCOTS_GAELIC |
---|
227 | wxLANGUAGE_SERBIAN |
---|
228 | wxLANGUAGE_SERBIAN_CYRILLIC |
---|
229 | wxLANGUAGE_SERBIAN_LATIN |
---|
230 | wxLANGUAGE_SERBO_CROATIAN |
---|
231 | wxLANGUAGE_SESOTHO |
---|
232 | wxLANGUAGE_SETSWANA |
---|
233 | wxLANGUAGE_SHONA |
---|
234 | wxLANGUAGE_SINDHI |
---|
235 | wxLANGUAGE_SINHALESE |
---|
236 | wxLANGUAGE_SISWATI |
---|
237 | wxLANGUAGE_SLOVAK |
---|
238 | wxLANGUAGE_SLOVENIAN |
---|
239 | wxLANGUAGE_SOMALI |
---|
240 | wxLANGUAGE_SPANISH |
---|
241 | wxLANGUAGE_SPANISH_ARGENTINA |
---|
242 | wxLANGUAGE_SPANISH_BOLIVIA |
---|
243 | wxLANGUAGE_SPANISH_CHILE |
---|
244 | wxLANGUAGE_SPANISH_COLOMBIA |
---|
245 | wxLANGUAGE_SPANISH_COSTA_RICA |
---|
246 | wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC |
---|
247 | wxLANGUAGE_SPANISH_ECUADOR |
---|
248 | wxLANGUAGE_SPANISH_EL_SALVADOR |
---|
249 | wxLANGUAGE_SPANISH_GUATEMALA |
---|
250 | wxLANGUAGE_SPANISH_HONDURAS |
---|
251 | wxLANGUAGE_SPANISH_MEXICAN |
---|
252 | wxLANGUAGE_SPANISH_MODERN |
---|
253 | wxLANGUAGE_SPANISH_NICARAGUA |
---|
254 | wxLANGUAGE_SPANISH_PANAMA |
---|
255 | wxLANGUAGE_SPANISH_PARAGUAY |
---|
256 | wxLANGUAGE_SPANISH_PERU |
---|
257 | wxLANGUAGE_SPANISH_PUERTO_RICO |
---|
258 | wxLANGUAGE_SPANISH_URUGUAY |
---|
259 | wxLANGUAGE_SPANISH_US |
---|
260 | wxLANGUAGE_SPANISH_VENEZUELA |
---|
261 | wxLANGUAGE_SUNDANESE |
---|
262 | wxLANGUAGE_SWAHILI |
---|
263 | wxLANGUAGE_SWEDISH |
---|
264 | wxLANGUAGE_SWEDISH_FINLAND |
---|
265 | wxLANGUAGE_TAGALOG |
---|
266 | wxLANGUAGE_TAJIK |
---|
267 | wxLANGUAGE_TAMIL |
---|
268 | wxLANGUAGE_TATAR |
---|
269 | wxLANGUAGE_TELUGU |
---|
270 | wxLANGUAGE_THAI |
---|
271 | wxLANGUAGE_TIBETAN |
---|
272 | wxLANGUAGE_TIGRINYA |
---|
273 | wxLANGUAGE_TONGA |
---|
274 | wxLANGUAGE_TSONGA |
---|
275 | wxLANGUAGE_TURKISH |
---|
276 | wxLANGUAGE_TURKMEN |
---|
277 | wxLANGUAGE_TWI |
---|
278 | wxLANGUAGE_UIGHUR |
---|
279 | wxLANGUAGE_UKRAINIAN |
---|
280 | wxLANGUAGE_URDU |
---|
281 | wxLANGUAGE_URDU_INDIA |
---|
282 | wxLANGUAGE_URDU_PAKISTAN |
---|
283 | wxLANGUAGE_UZBEK |
---|
284 | wxLANGUAGE_UZBEK_CYRILLIC |
---|
285 | wxLANGUAGE_UZBEK_LATIN |
---|
286 | wxLANGUAGE_VALENCIAN |
---|
287 | wxLANGUAGE_VIETNAMESE |
---|
288 | wxLANGUAGE_VOLAPUK |
---|
289 | wxLANGUAGE_WELSH |
---|
290 | wxLANGUAGE_WOLOF |
---|
291 | wxLANGUAGE_XHOSA |
---|
292 | wxLANGUAGE_YIDDISH |
---|
293 | wxLANGUAGE_YORUBA |
---|
294 | wxLANGUAGE_ZHUANG |
---|
295 | wxLANGUAGE_ZULU |
---|
296 | /; |
---|
297 | use base qw/Wx::Frame Class::Accessor::Fast/; |
---|
298 | use File::Spec; |
---|
299 | use Wx::Locale qw/:default/; |
---|
300 | use Encode qw/encode decode is_utf8/;; |
---|
301 | |
---|
302 | |
---|
303 | my @properties = |
---|
304 | qw/ |
---|
305 | progressdlg |
---|
306 | upload_progressdlg |
---|
307 | imageviewer |
---|
308 | tree |
---|
309 | tree_root |
---|
310 | treeimglist |
---|
311 | tree_item_default |
---|
312 | topsizer |
---|
313 | pwg |
---|
314 | manager |
---|
315 | logwnd |
---|
316 | oldlogwnd |
---|
317 | htmlhome |
---|
318 | notebook |
---|
319 | categories |
---|
320 | imagelist |
---|
321 | image_preview |
---|
322 | image_prop_piwigo |
---|
323 | image_prop_exif |
---|
324 | notebook_image_properties |
---|
325 | notebook_global_settings |
---|
326 | general_settings_panel |
---|
327 | resized_settings_panel |
---|
328 | thumbnail_settings_panel |
---|
329 | preview_settings_panel |
---|
330 | piwigo_properties |
---|
331 | exif_properties |
---|
332 | general_settings |
---|
333 | resized_settings |
---|
334 | thumbnail_settings |
---|
335 | preview_settings |
---|
336 | toolbar |
---|
337 | branding |
---|
338 | preview_w |
---|
339 | preview_h |
---|
340 | perspective |
---|
341 | /; |
---|
342 | __PACKAGE__->mk_accessors( @properties ); |
---|
343 | |
---|
344 | use Wx::Event |
---|
345 | qw/ |
---|
346 | EVT_MENU |
---|
347 | EVT_TREE_SEL_CHANGED |
---|
348 | EVT_CLOSE |
---|
349 | EVT_LIST_END_LABEL_EDIT |
---|
350 | EVT_LIST_ITEM_SELECTED |
---|
351 | EVT_LIST_ITEM_ACTIVATED |
---|
352 | EVT_TREE_ITEM_RIGHT_CLICK |
---|
353 | EVT_LIST_KEY_DOWN |
---|
354 | EVT_UPDATE_UI |
---|
355 | /; |
---|
356 | |
---|
357 | use Uploader::GUI::wxImageListCtrl; |
---|
358 | use Uploader::GUI::wxImageProcessingProgressDlg; |
---|
359 | use Wx::Html; |
---|
360 | use Uploader::GUI::wxHtmlWindow; |
---|
361 | use Data::Dumper; |
---|
362 | use Wx::AUI; |
---|
363 | use Storable; |
---|
364 | use Uploader::GUI::wxPropertyGridPanel; |
---|
365 | use Encode qw/encode decode is_utf8/; |
---|
366 | |
---|
367 | $|=1; |
---|
368 | |
---|
369 | my $ID_TREE_CTX_MENU = 20000 ; |
---|
370 | |
---|
371 | sub new { |
---|
372 | my( $class, $params ) = @_; |
---|
373 | my( $self ) = $class->SUPER::new( |
---|
374 | undef, |
---|
375 | -1, |
---|
376 | $params->{title}, |
---|
377 | [ $params->{x}, $params->{y} ], |
---|
378 | [ $params->{width}, $params->{height} ], |
---|
379 | wxDEFAULT_FRAME_STYLE|wxMAXIMIZE |
---|
380 | ); |
---|
381 | $self->preview_w( |
---|
382 | $params->{preview_w}||400 |
---|
383 | ); |
---|
384 | |
---|
385 | $self->preview_h( |
---|
386 | $params->{preview_h}||300 |
---|
387 | ); |
---|
388 | |
---|
389 | $self->perspective( |
---|
390 | $params->{perspective} |
---|
391 | ); |
---|
392 | |
---|
393 | $self->pwg( $params->{pwg} ); |
---|
394 | $self->imagelist( $params->{imagelist} ); |
---|
395 | |
---|
396 | # callback for GUI refresh : add thumbnail images to the imageviewer control |
---|
397 | $self->imagelist->SetNewFilesViewerRefreshCallback( |
---|
398 | sub { $self->SetNewFilesViewerRefresh(@_) } |
---|
399 | ); |
---|
400 | |
---|
401 | # callback for GUI refresh : progress dialog display of thumbnail image being created |
---|
402 | $self->imagelist->SetNewFilesProgressCallback( |
---|
403 | sub { $self->SetNewFilesProgress(@_) } |
---|
404 | ); |
---|
405 | |
---|
406 | $self->imagelist->SetNewFilesDisplayEndInfoCallback( |
---|
407 | sub { $self->SetNewFilesDisplayEndInfo(@_) } |
---|
408 | ); |
---|
409 | |
---|
410 | |
---|
411 | # callback for GUI refresh : remove thumbnail images from imageviewer control |
---|
412 | $self->imagelist->UploadImagesViewerCallback( |
---|
413 | sub { $self->UploadImagesViewerRefresh(@_) } |
---|
414 | ); |
---|
415 | |
---|
416 | |
---|
417 | |
---|
418 | # callback for GUI refresh : progress dialog display current uploaded image |
---|
419 | $self->imagelist->progress_thumbnail_refresh( |
---|
420 | sub { $self->UploadProgressThumbnailRefresh(@_) } |
---|
421 | ); |
---|
422 | |
---|
423 | $self->imagelist->progress_msg_refresh( |
---|
424 | sub { $self->UploadProgressMessageRefresh(@_) } |
---|
425 | ); |
---|
426 | |
---|
427 | |
---|
428 | $self->imagelist->progressbar_refresh( |
---|
429 | sub { $self->UploadProgressBarRefresh(@_) } |
---|
430 | ); |
---|
431 | |
---|
432 | $self->imagelist->progress_endinfo_refresh( |
---|
433 | sub { $self->UploadDisplayEndInfo(@_) } |
---|
434 | ); |
---|
435 | |
---|
436 | |
---|
437 | $self->imagelist->pwg( |
---|
438 | $self->pwg |
---|
439 | ); |
---|
440 | |
---|
441 | $self->imagelist->categories( |
---|
442 | [] |
---|
443 | ); |
---|
444 | |
---|
445 | |
---|
446 | $self->manager( Wx::AuiManager->new ); |
---|
447 | $self->manager->SetDockSizeConstraint(1, 1); |
---|
448 | $self->manager->SetManagedWindow( $self ); |
---|
449 | $self->_set_setting_properties; |
---|
450 | $self->_initFrame; |
---|
451 | $self->_InitEventHandlers; |
---|
452 | $self->_initImgTypes; |
---|
453 | |
---|
454 | $self; |
---|
455 | } |
---|
456 | |
---|
457 | |
---|
458 | sub _initImgTypes { |
---|
459 | my ( $self ) = @_; |
---|
460 | |
---|
461 | $self->{IMGTYPE} = { |
---|
462 | 'jpg' => wxBITMAP_TYPE_JPEG, |
---|
463 | 'gif' => wxBITMAP_TYPE_GIF, |
---|
464 | 'png' => wxBITMAP_TYPE_PNG, |
---|
465 | }; |
---|
466 | } |
---|
467 | |
---|
468 | |
---|
469 | sub GetWxBitmapType { |
---|
470 | my ( $self, $type ) = @_; |
---|
471 | |
---|
472 | $self->{IMGTYPE}->{$type}; |
---|
473 | } |
---|
474 | |
---|
475 | |
---|
476 | |
---|
477 | sub _set_setting_properties { |
---|
478 | my ( $self ) = @_; |
---|
479 | |
---|
480 | $self->piwigo_properties( |
---|
481 | [ |
---|
482 | { |
---|
483 | label => gettext("Photo caption :"), |
---|
484 | value => sub { $self->imagelist->current_image->site_name(@_) }, |
---|
485 | }, |
---|
486 | { |
---|
487 | label => gettext("Comment :"), |
---|
488 | value => sub { $self->imagelist->current_image->site_comment(@_) }, |
---|
489 | type => "LongText", |
---|
490 | }, |
---|
491 | { |
---|
492 | label => gettext("Author :"), |
---|
493 | value => sub { $self->imagelist->current_image->site_author(@_) }, |
---|
494 | }, |
---|
495 | { |
---|
496 | label => gettext("File name :"), |
---|
497 | value => sub { $self->imagelist->current_image->file(@_) }, |
---|
498 | readonly => 1, |
---|
499 | }, |
---|
500 | { |
---|
501 | label => gettext("Create date :"), |
---|
502 | value => sub { $self->imagelist->current_image->create_date(@_) }, |
---|
503 | readonly => 1, |
---|
504 | }, |
---|
505 | ] |
---|
506 | ); |
---|
507 | |
---|
508 | $self->exif_properties( |
---|
509 | [ |
---|
510 | { |
---|
511 | label => gettext("Create date :"), |
---|
512 | value => sub { $self->imagelist->current_image->create_date }, |
---|
513 | readonly => 1, |
---|
514 | }, |
---|
515 | { |
---|
516 | label => gettext("Model :"), |
---|
517 | value => sub { $self->imagelist->current_image->exif_tag('Model') }, |
---|
518 | readonly => 1, |
---|
519 | }, |
---|
520 | { |
---|
521 | label => gettext("Width :"), |
---|
522 | value => sub { $self->imagelist->current_image->exif_tag('ImageWidth') }, |
---|
523 | readonly => 1, |
---|
524 | }, |
---|
525 | { |
---|
526 | label => gettext("Height :"), |
---|
527 | value => sub { $self->imagelist->current_image->exif_tag('ImageHeight') }, |
---|
528 | readonly => 1, |
---|
529 | }, |
---|
530 | { |
---|
531 | label => gettext("Orientation :"), |
---|
532 | value => sub { $self->imagelist->current_image->exif_tag('Orientation') }, |
---|
533 | readonly => 1, |
---|
534 | }, |
---|
535 | { |
---|
536 | label => "ISO :", |
---|
537 | value => sub { $self->imagelist->current_image->exif_tag('ISO') }, |
---|
538 | readonly => 1, |
---|
539 | }, |
---|
540 | { |
---|
541 | label => gettext("Shutter speed :"), |
---|
542 | value => sub { $self->imagelist->current_image->exif_tag('ExposureTime') }, |
---|
543 | readonly => 1, |
---|
544 | }, |
---|
545 | { |
---|
546 | label => gettext("Aperture :"), |
---|
547 | value => sub { $self->imagelist->current_image->exif_tag('ApertureValue') }, |
---|
548 | readonly => 1, |
---|
549 | }, |
---|
550 | { |
---|
551 | label => gettext("Focal length :"), |
---|
552 | value => sub { $self->imagelist->current_image->exif_tag('FocalLength') }, |
---|
553 | readonly => 1, |
---|
554 | }, |
---|
555 | { |
---|
556 | label => gettext("Lens :"), |
---|
557 | value => sub { $self->imagelist->current_image->exif_tag('Lens') }, |
---|
558 | readonly => 1, |
---|
559 | }, |
---|
560 | ] |
---|
561 | ); |
---|
562 | |
---|
563 | $self->general_settings( |
---|
564 | [ |
---|
565 | { |
---|
566 | label => gettext("Default author :"), |
---|
567 | value => sub { $self->imagelist->author(@_) }, |
---|
568 | }, |
---|
569 | { |
---|
570 | label => gettext("Default photo caption :"), |
---|
571 | type => 'Choice', |
---|
572 | value => sub { $self->imagelist->default_photo_name(@_) }, |
---|
573 | choice => [ |
---|
574 | gettext('None'), |
---|
575 | gettext('File name'), |
---|
576 | gettext('File path and name'), |
---|
577 | gettext('Prefix'), |
---|
578 | gettext('Prefix + rank number'), |
---|
579 | gettext('Rank number + prefix'), |
---|
580 | gettext('Prefix + create date chrono'), |
---|
581 | gettext('Create date chrono + prefix'), |
---|
582 | ], |
---|
583 | }, |
---|
584 | { |
---|
585 | label => gettext("Photo caption prefix :"), |
---|
586 | value => sub { $self->imagelist->default_name_prefix(@_) }, |
---|
587 | }, |
---|
588 | { |
---|
589 | label => gettext("Resize site image :"), |
---|
590 | type => 'Bool', |
---|
591 | value => sub { $self->imagelist->create_resized(@_) }, |
---|
592 | }, |
---|
593 | { |
---|
594 | label => gettext("Auto rotate image :"), |
---|
595 | type => 'Bool', |
---|
596 | value => sub { $self->imagelist->auto_rotate(@_) }, |
---|
597 | }, |
---|
598 | { |
---|
599 | label => gettext("Upload high (original size) :"), |
---|
600 | type => 'Bool', |
---|
601 | value => sub { $self->imagelist->upload_high(@_) }, |
---|
602 | }, |
---|
603 | # { |
---|
604 | # label => gettext("Remove uploaded photo from selection :"), |
---|
605 | # type => 'Bool', |
---|
606 | # value => sub { $self->imagelist->remove_uploaded_from_selection(@_) }, |
---|
607 | # }, |
---|
608 | ] |
---|
609 | ); |
---|
610 | |
---|
611 | $self->resized_settings( |
---|
612 | [ |
---|
613 | { |
---|
614 | label => gettext("Site image width :"), |
---|
615 | type => 'Number', |
---|
616 | value => sub { $self->imagelist->resize_w(@_) }, |
---|
617 | }, |
---|
618 | { |
---|
619 | label => gettext("Site image height :"), |
---|
620 | type => 'Number', |
---|
621 | value => sub { $self->imagelist->resize_h(@_) }, |
---|
622 | }, |
---|
623 | { |
---|
624 | label => gettext("Site image jpeg quality :"), |
---|
625 | type => 'Number', |
---|
626 | value => sub { $self->imagelist->quality(@_) }, |
---|
627 | }, |
---|
628 | { |
---|
629 | label => gettext("Site image filter :"), |
---|
630 | type => 'Choice', |
---|
631 | value => sub { $self->imagelist->filter(@_) }, |
---|
632 | choice => [ qw/Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc/ ], |
---|
633 | }, |
---|
634 | { |
---|
635 | label => gettext("Site image blur :"), |
---|
636 | type => 'Number', |
---|
637 | value => sub { $self->imagelist->blur(@_) }, |
---|
638 | }, |
---|
639 | { |
---|
640 | label => gettext("Site image interlace :"), |
---|
641 | type => 'Choice', |
---|
642 | value => sub { $self->imagelist->interlace(@_) }, |
---|
643 | choice => [ qw/None Line Plane Partition JPEG GIF PNG/ ], |
---|
644 | }, |
---|
645 | ] |
---|
646 | ); |
---|
647 | |
---|
648 | $self->thumbnail_settings( |
---|
649 | [ |
---|
650 | { |
---|
651 | label => gettext("Site thumbnail size :"), |
---|
652 | type => 'Number', |
---|
653 | value => sub { $self->imagelist->thumb_size(@_) }, |
---|
654 | }, |
---|
655 | { |
---|
656 | label => gettext("Site thumbnail jpeg quality :"), |
---|
657 | type => 'Number', |
---|
658 | value => sub { $self->imagelist->th_quality(@_) }, |
---|
659 | }, |
---|
660 | { |
---|
661 | label => gettext("Photo selection thumbnail size :"), |
---|
662 | type => 'Number', |
---|
663 | value => sub { $self->imagelist->wx_thumb_size(@_) }, |
---|
664 | }, |
---|
665 | { |
---|
666 | label => gettext("Photo selection thumbnail jpeg quality :"), |
---|
667 | type => 'Number', |
---|
668 | value => sub { $self->imagelist->wx_quality(@_) }, |
---|
669 | }, |
---|
670 | ] |
---|
671 | ); |
---|
672 | |
---|
673 | $self->preview_settings( |
---|
674 | [ |
---|
675 | { |
---|
676 | label => gettext("Use exif preview when available :"), |
---|
677 | type => 'Bool', |
---|
678 | value => sub { $self->imagelist->use_exif_preview(@_) }, |
---|
679 | }, |
---|
680 | { |
---|
681 | label => gettext("Custom preview ratio :"), |
---|
682 | type => 'Number', |
---|
683 | value => sub { $self->imagelist->preview_ratio(@_) }, |
---|
684 | }, |
---|
685 | ] |
---|
686 | ); |
---|
687 | |
---|
688 | } |
---|
689 | |
---|
690 | sub _refreshFrame { |
---|
691 | my ( $self ) = @_; |
---|
692 | |
---|
693 | $self->_set_setting_properties; |
---|
694 | $self->_refresh_settings_panels_properties; |
---|
695 | map { |
---|
696 | $_->Refresh; |
---|
697 | } |
---|
698 | ( |
---|
699 | $self->image_prop_piwigo, |
---|
700 | $self->image_prop_exif, |
---|
701 | $self->general_settings_panel, |
---|
702 | $self->resized_settings_panel, |
---|
703 | $self->thumbnail_settings_panel, |
---|
704 | $self->preview_settings_panel, |
---|
705 | ); |
---|
706 | |
---|
707 | $self->manager->Update; |
---|
708 | } |
---|
709 | |
---|
710 | |
---|
711 | sub _destroy_settings_panels { |
---|
712 | my ( $self ) = @_; |
---|
713 | |
---|
714 | |
---|
715 | |
---|
716 | map { |
---|
717 | $self->manager->DetachPane( |
---|
718 | $_ |
---|
719 | ); |
---|
720 | $_->Show(0); |
---|
721 | $_->Destroy; |
---|
722 | }( |
---|
723 | $self->notebook_global_settings, |
---|
724 | $self->notebook_image_properties, |
---|
725 | ); |
---|
726 | } |
---|
727 | |
---|
728 | # |
---|
729 | sub _initFrame { |
---|
730 | my ( $self ) = @_; |
---|
731 | |
---|
732 | |
---|
733 | $self->init_panels; |
---|
734 | |
---|
735 | $self->imageviewer->Show(0); |
---|
736 | |
---|
737 | $self->init_aui; |
---|
738 | $self->init_dnd_targets; |
---|
739 | if( $self->imagelist->wx_thumb_imglist->GetImageCount){ |
---|
740 | printf("%s images\n", $self->imagelist->wx_thumb_imglist->GetImageCount); |
---|
741 | $self->ShowImageViewer; |
---|
742 | |
---|
743 | $self->imageviewer->Refresh( |
---|
744 | $self->imagelist->wx_thumb_imglist |
---|
745 | ); |
---|
746 | } |
---|
747 | |
---|
748 | } |
---|
749 | |
---|
750 | sub _refresh_settings_panels_properties { |
---|
751 | my ( $self ) = @_; |
---|
752 | |
---|
753 | $self->image_prop_piwigo->properties( |
---|
754 | $self->piwigo_properties |
---|
755 | ); |
---|
756 | |
---|
757 | $self->image_prop_exif->properties( |
---|
758 | $self->exif_properties |
---|
759 | ); |
---|
760 | |
---|
761 | |
---|
762 | $self->general_settings_panel->properties( |
---|
763 | $self->general_settings |
---|
764 | ); |
---|
765 | |
---|
766 | $self->resized_settings_panel->properties( |
---|
767 | $self->resized_settings |
---|
768 | ); |
---|
769 | |
---|
770 | $self->thumbnail_settings_panel->properties( |
---|
771 | $self->thumbnail_settings, |
---|
772 | ); |
---|
773 | |
---|
774 | $self->preview_settings_panel->properties( |
---|
775 | $self->preview_settings, |
---|
776 | ); |
---|
777 | |
---|
778 | } |
---|
779 | |
---|
780 | sub _init_settings_panels { |
---|
781 | my ( $self ) = @_; |
---|
782 | |
---|
783 | $self->image_prop_piwigo( |
---|
784 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
785 | { |
---|
786 | parentwnd => $self, |
---|
787 | properties => $self->piwigo_properties, |
---|
788 | frame_callbacks => [ |
---|
789 | sub { |
---|
790 | $self->imageviewer->Refresh(); |
---|
791 | }, |
---|
792 | ], |
---|
793 | } |
---|
794 | ) |
---|
795 | ); |
---|
796 | |
---|
797 | $self->image_prop_exif( |
---|
798 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
799 | { |
---|
800 | parentwnd => $self, |
---|
801 | frame_callbacks => [], |
---|
802 | properties => $self->exif_properties, |
---|
803 | } |
---|
804 | ) |
---|
805 | ); |
---|
806 | |
---|
807 | |
---|
808 | $self->general_settings_panel( |
---|
809 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
810 | { |
---|
811 | parentwnd => $self, |
---|
812 | properties => $self->general_settings, |
---|
813 | frame_callbacks => [], |
---|
814 | } |
---|
815 | ) |
---|
816 | ); |
---|
817 | |
---|
818 | $self->resized_settings_panel( |
---|
819 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
820 | { |
---|
821 | parentwnd => $self, |
---|
822 | properties => $self->resized_settings, |
---|
823 | frame_callbacks => [], |
---|
824 | |
---|
825 | } |
---|
826 | ) |
---|
827 | ); |
---|
828 | |
---|
829 | $self->thumbnail_settings_panel( |
---|
830 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
831 | { |
---|
832 | parentwnd => $self, |
---|
833 | properties => $self->thumbnail_settings, |
---|
834 | frame_callbacks => [], |
---|
835 | |
---|
836 | } |
---|
837 | ) |
---|
838 | ); |
---|
839 | $self->preview_settings_panel( |
---|
840 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
841 | { |
---|
842 | parentwnd => $self, |
---|
843 | properties => $self->preview_settings, |
---|
844 | frame_callbacks => [], |
---|
845 | |
---|
846 | } |
---|
847 | ) |
---|
848 | ); |
---|
849 | |
---|
850 | $self->general_settings_panel->Show(0); |
---|
851 | |
---|
852 | $self->image_preview( |
---|
853 | Wx::StaticBitmap->new( |
---|
854 | $self, |
---|
855 | -1, |
---|
856 | wxNullBitmap, |
---|
857 | wxDefaultPosition, |
---|
858 | [$self->preview_w, $self->preview_h] |
---|
859 | ) |
---|
860 | ); |
---|
861 | |
---|
862 | $self->image_prop_piwigo->Show(0); |
---|
863 | |
---|
864 | $self->image_prop_exif->Show(0); |
---|
865 | |
---|
866 | } |
---|
867 | |
---|
868 | sub init_panels { |
---|
869 | my ( $self ) = @_; |
---|
870 | |
---|
871 | $self->htmlhome( |
---|
872 | Uploader::GUI::wxHtmlWindow->new( |
---|
873 | $self, -1 |
---|
874 | ) |
---|
875 | ); |
---|
876 | |
---|
877 | $self->imageviewer( |
---|
878 | Uploader::GUI::wxImageListCtrl->new( |
---|
879 | { |
---|
880 | parentwnd => $self, |
---|
881 | imagelist => $self->imagelist, |
---|
882 | } |
---|
883 | ) |
---|
884 | ); |
---|
885 | |
---|
886 | $self->_init_settings_panels; |
---|
887 | } |
---|
888 | |
---|
889 | sub init_dnd_targets { |
---|
890 | my ( $self ) = @_; |
---|
891 | |
---|
892 | $self->imageviewer->SetDropTarget( |
---|
893 | DNDImageListDropTarget->new( |
---|
894 | $self->imageviewer |
---|
895 | ) |
---|
896 | ); |
---|
897 | $self->htmlhome->SetDropTarget( |
---|
898 | DNDImageListDropTarget->new( |
---|
899 | $self->imageviewer |
---|
900 | ) |
---|
901 | ); |
---|
902 | |
---|
903 | |
---|
904 | $self->tree->SetDropTarget( |
---|
905 | DNDCategoryTreeDropTarget->new( |
---|
906 | $self->tree |
---|
907 | ) |
---|
908 | ); |
---|
909 | |
---|
910 | } |
---|
911 | |
---|
912 | sub init_aui { |
---|
913 | my ( $self ) = @_; |
---|
914 | |
---|
915 | my $url = wxTheApp->site_url; |
---|
916 | |
---|
917 | $url = gettext("empty - work Offline") if wxTheApp->use_offline; |
---|
918 | |
---|
919 | $self->manager->AddPane |
---|
920 | ( $self->create_notebook_imagelist, Wx::AuiPaneInfo->new->Name( "ImageViewer" ) |
---|
921 | ->CenterPane->Resizable->CloseButton(0) ); |
---|
922 | |
---|
923 | $self->manager->AddPane |
---|
924 | ( $self->create_tree, Wx::AuiPaneInfo->new->Name( "categories" ) |
---|
925 | ->Right->Position( 0 )->Resizable->CloseButton(0) ); |
---|
926 | |
---|
927 | $self->manager->AddPane |
---|
928 | ( $self->image_preview, Wx::AuiPaneInfo->new->Name( "preview" ) |
---|
929 | ->Right->Position( 1 )->Resizable->CloseButton(0)->Floatable(0) ); |
---|
930 | |
---|
931 | |
---|
932 | $self->_init_aui_settings_panels; |
---|
933 | |
---|
934 | $self->toolbar( |
---|
935 | $self->create_toolbar |
---|
936 | ); |
---|
937 | |
---|
938 | $self->manager->AddPane |
---|
939 | ( $self->toolbar, Wx::AuiPaneInfo->new->Name( "tb1" ) |
---|
940 | ->ToolbarPane->Top->Row( 1 )->LeftDockable( 0 )->RightDockable( 0 ) ) if defined $self->toolbar; |
---|
941 | |
---|
942 | if( $self->perspective){ |
---|
943 | $self->manager->LoadPerspective($self->perspective); |
---|
944 | } |
---|
945 | |
---|
946 | $self->manager->GetPane("categories")->Caption( |
---|
947 | sprintf("%s - %s", sprintf("Piwigo %s", wxTheApp->branding->{categories}), $url ) |
---|
948 | ); |
---|
949 | |
---|
950 | $self->manager->GetPane("preview")->Caption(gettext("Preview")); |
---|
951 | $self->manager->GetPane("tb1")->Caption( gettext("Tools") ); |
---|
952 | $self->manager->GetPane("photo_properties")->Caption(gettext("Photo properties")); |
---|
953 | $self->manager->GetPane("global_settings")->Caption(gettext("Global settings")); |
---|
954 | |
---|
955 | |
---|
956 | $self->manager->Update; |
---|
957 | |
---|
958 | } |
---|
959 | |
---|
960 | sub _init_aui_settings_panels { |
---|
961 | my ( $self ) = @_; |
---|
962 | |
---|
963 | $self->manager->AddPane |
---|
964 | ( $self->create_notebook_image_properties, Wx::AuiPaneInfo->new->Name( "photo_properties" ) |
---|
965 | ->Floatable(1)->Resizable->CloseButton(1) ); |
---|
966 | |
---|
967 | $self->manager->AddPane |
---|
968 | ( $self->create_notebook_global_settings, Wx::AuiPaneInfo->new->Name( "global_settings" ) |
---|
969 | ->Floatable(1)->Resizable->CloseButton(1) ); |
---|
970 | |
---|
971 | $self->manager->GetPane("photo_properties")->Show(0); |
---|
972 | $self->manager->GetPane("global_settings")->Show(0); |
---|
973 | |
---|
974 | } |
---|
975 | |
---|
976 | sub OnPhotoProperties { |
---|
977 | my ( $self ) = @_; |
---|
978 | |
---|
979 | $self->manager->GetPane("photo_properties")->Float; |
---|
980 | $self->manager->GetPane("photo_properties")->Show(1); |
---|
981 | $self->manager->Update(); |
---|
982 | |
---|
983 | } |
---|
984 | |
---|
985 | sub OnGlobalSettings { |
---|
986 | my ( $self ) = @_; |
---|
987 | |
---|
988 | $self->toolbar->EnableTool(104, 0 ); |
---|
989 | $self->manager->GetPane("global_settings")->Float; |
---|
990 | $self->manager->GetPane("global_settings")->Show(1); |
---|
991 | $self->manager->Update(); |
---|
992 | } |
---|
993 | |
---|
994 | sub OnChooseLanguage { |
---|
995 | my ( $self ) = @_; |
---|
996 | |
---|
997 | my $languages = [ |
---|
998 | ['Dutch', wxLANGUAGE_DUTCH, ], |
---|
999 | ['English', wxLANGUAGE_ENGLISH, ], |
---|
1000 | ['French', wxLANGUAGE_FRENCH, ], |
---|
1001 | ['German', wxLANGUAGE_GERMAN, ], |
---|
1002 | ['Italian', wxLANGUAGE_ITALIAN, ], |
---|
1003 | ['Polish', wxLANGUAGE_POLISH, ], |
---|
1004 | ['Portuguese', wxLANGUAGE_PORTUGUESE, ], |
---|
1005 | ['Russian', wxLANGUAGE_RUSSIAN, ], |
---|
1006 | ['Spanish', wxLANGUAGE_SPANISH, ], |
---|
1007 | ]; |
---|
1008 | |
---|
1009 | my $dialog = new Wx::SingleChoiceDialog |
---|
1010 | ( undef, gettext( "Choose a language" ), gettext( "Choose a language" ), |
---|
1011 | [ map { Wx::GetTranslation( ${$_}[0] ) } @$languages ] ); |
---|
1012 | |
---|
1013 | if( $dialog->ShowModal() == wxID_OK ) { |
---|
1014 | wxTheApp->current_language( |
---|
1015 | $languages->[$dialog->GetSelection][1] |
---|
1016 | ); |
---|
1017 | wxTheApp->init_locale(); |
---|
1018 | $self->_refreshFrame; |
---|
1019 | } |
---|
1020 | |
---|
1021 | $dialog->Destroy; |
---|
1022 | |
---|
1023 | } |
---|
1024 | |
---|
1025 | |
---|
1026 | sub create_notebook_imagelist { |
---|
1027 | my( $self ) = @_; |
---|
1028 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [300, 450], |
---|
1029 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
1030 | my $pages = [ |
---|
1031 | [ |
---|
1032 | $self->htmlhome, |
---|
1033 | gettext("Photo selection"), |
---|
1034 | '../res/images.png', |
---|
1035 | wxBITMAP_TYPE_PNG, |
---|
1036 | ], |
---|
1037 | #[ |
---|
1038 | # $self->logwnd( $self->_create_textctrl( $book, undef, [450, 450] )), |
---|
1039 | # "Log", |
---|
1040 | # '../res/nb_log.png', |
---|
1041 | # wxBITMAP_TYPE_PNG, |
---|
1042 | #] |
---|
1043 | ]; |
---|
1044 | |
---|
1045 | $self->_populate_notebook( $book, $pages ); |
---|
1046 | |
---|
1047 | #$self->logwnd(Wx::LogTextCtrl->new( $self->logwnd )); |
---|
1048 | #$self->oldlogwnd( Wx::Log::SetActiveTarget( $self->logwnd ) ); |
---|
1049 | $self->notebook($book); |
---|
1050 | return $book; |
---|
1051 | } |
---|
1052 | |
---|
1053 | sub create_notebook_image_properties { |
---|
1054 | my( $self ) = @_; |
---|
1055 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [450, 450], |
---|
1056 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
1057 | my $pages = [ |
---|
1058 | [ |
---|
1059 | $self->image_prop_piwigo, |
---|
1060 | "Piwigo", |
---|
1061 | ], |
---|
1062 | [ |
---|
1063 | $self->image_prop_exif, |
---|
1064 | "Exif", |
---|
1065 | ], |
---|
1066 | ]; |
---|
1067 | |
---|
1068 | $self->_populate_notebook( $book, $pages ); |
---|
1069 | |
---|
1070 | $self->notebook_image_properties($book); |
---|
1071 | |
---|
1072 | return $book; |
---|
1073 | } |
---|
1074 | |
---|
1075 | sub create_notebook_global_settings { |
---|
1076 | my( $self ) = @_; |
---|
1077 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [450, 450], |
---|
1078 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
1079 | my $pages = [ |
---|
1080 | [ |
---|
1081 | $self->general_settings_panel, |
---|
1082 | gettext("General"), |
---|
1083 | ], |
---|
1084 | [ |
---|
1085 | $self->resized_settings_panel, |
---|
1086 | gettext("Resized"), |
---|
1087 | ], |
---|
1088 | [ |
---|
1089 | $self->thumbnail_settings_panel, |
---|
1090 | gettext("Thumbnail"), |
---|
1091 | ], |
---|
1092 | [ |
---|
1093 | $self->preview_settings_panel, |
---|
1094 | gettext("Preview"), |
---|
1095 | ], |
---|
1096 | ]; |
---|
1097 | |
---|
1098 | $self->_populate_notebook( $book, $pages ); |
---|
1099 | |
---|
1100 | $self->notebook_global_settings($book); |
---|
1101 | |
---|
1102 | return $book; |
---|
1103 | } |
---|
1104 | |
---|
1105 | |
---|
1106 | |
---|
1107 | |
---|
1108 | sub create_tree { |
---|
1109 | my ( $self ) = @_; |
---|
1110 | |
---|
1111 | my $images = [ |
---|
1112 | map { |
---|
1113 | Wx::Bitmap->new( $_, wxBITMAP_TYPE_PNG ) |
---|
1114 | |
---|
1115 | } |
---|
1116 | ( |
---|
1117 | '../res/tree_pwg.png', |
---|
1118 | '../res/tree_folder.png', |
---|
1119 | ) |
---|
1120 | ]; |
---|
1121 | |
---|
1122 | $self->treeimglist( Wx::ImageList->new( 16, 16, 1 ) ); |
---|
1123 | map { |
---|
1124 | $self->treeimglist->Add($_); |
---|
1125 | } |
---|
1126 | @$images; |
---|
1127 | |
---|
1128 | |
---|
1129 | $self->tree( |
---|
1130 | Wx::TreeCtrl->new( |
---|
1131 | $self, |
---|
1132 | -1, |
---|
1133 | wxDefaultPosition, |
---|
1134 | wxDefaultSize, |
---|
1135 | wxBORDER_NONE| |
---|
1136 | wxCLIP_CHILDREN| |
---|
1137 | # wxTR_MULTIPLE| |
---|
1138 | # wxTR_EXTENDED| |
---|
1139 | wxTR_HAS_BUTTONS |
---|
1140 | # wxTR_HIDE_ROOT |
---|
1141 | ) |
---|
1142 | ); |
---|
1143 | |
---|
1144 | $self->tree->SetImageList( $self->treeimglist ); |
---|
1145 | $self->populate_tree_categories if !wxTheApp->use_offline; |
---|
1146 | $self->tree ; |
---|
1147 | } |
---|
1148 | |
---|
1149 | |
---|
1150 | sub populate_tree_categories { |
---|
1151 | my ( $self ) = @_; |
---|
1152 | |
---|
1153 | $self->populate_tree( |
---|
1154 | $self->tree, |
---|
1155 | wxTheApp->pwg->categories, |
---|
1156 | ) if defined wxTheApp->pwg ; |
---|
1157 | |
---|
1158 | $self->tree->ExpandAll; |
---|
1159 | |
---|
1160 | } |
---|
1161 | |
---|
1162 | |
---|
1163 | # returns a valid itemData |
---|
1164 | sub itemData { Wx::TreeItemData->new( $_[0] ) } |
---|
1165 | |
---|
1166 | sub populate_tree { |
---|
1167 | my ( $self, $tree, $tree_items ) = @_; |
---|
1168 | my $root = shift @{$tree_items}; |
---|
1169 | $self->tree_root( |
---|
1170 | $tree->AddRoot( |
---|
1171 | $root->[0], |
---|
1172 | $root->[3], |
---|
1173 | $root->[4], |
---|
1174 | itemData( $root->[2] ) |
---|
1175 | ) |
---|
1176 | ); |
---|
1177 | |
---|
1178 | $self->populate_tree_helper( $tree, $self->tree_root, $tree_items ); |
---|
1179 | |
---|
1180 | $tree->Expand( $self->tree_root ); |
---|
1181 | } |
---|
1182 | |
---|
1183 | sub populate_tree_helper { |
---|
1184 | my ( $self, $tree, $parent_id, $tree_items ) = @_; |
---|
1185 | |
---|
1186 | my $id; |
---|
1187 | |
---|
1188 | map { |
---|
1189 | my $name = $_->[0]; |
---|
1190 | eval { |
---|
1191 | $name = is_utf8($name) ? decode('UTF-8', $name) : $name; |
---|
1192 | }; |
---|
1193 | if($@){ |
---|
1194 | $name = $_->[0]; |
---|
1195 | } |
---|
1196 | $id = $tree->AppendItem( |
---|
1197 | $parent_id, |
---|
1198 | $name, |
---|
1199 | defined($_->[3]) ? $_->[3] : 0, |
---|
1200 | defined($_->[4]) ? $_->[4] : 0, |
---|
1201 | itemData( $_->[2]) |
---|
1202 | ); |
---|
1203 | $self->tree_item_default($id) if ! defined $self->tree_item_default; |
---|
1204 | # current item has children |
---|
1205 | if( ref( $_->[1] ) eq 'ARRAY' ) { |
---|
1206 | $self->populate_tree_helper( $tree, $id, $_->[1] ); |
---|
1207 | } |
---|
1208 | } |
---|
1209 | @{$tree_items}; |
---|
1210 | |
---|
1211 | } |
---|
1212 | |
---|
1213 | |
---|
1214 | |
---|
1215 | |
---|
1216 | sub _populate_notebook { |
---|
1217 | my ( $self, $book, $pages, $position ) = @_; |
---|
1218 | |
---|
1219 | my $i = 0; |
---|
1220 | map { |
---|
1221 | my $icon = Wx::Icon->new(); |
---|
1222 | eval { $icon->LoadFile($_->[2], $_->[3]) ; } |
---|
1223 | if defined $_->[2]; |
---|
1224 | my $nb_icon = Wx::Bitmap->new( $icon ); |
---|
1225 | defined $position ? |
---|
1226 | $book->InsertPage($position, $_->[0], |
---|
1227 | $_->[1], 1, $nb_icon ) |
---|
1228 | : |
---|
1229 | $book->AddPage($_->[0], |
---|
1230 | $_->[1], 0, $nb_icon ); |
---|
1231 | |
---|
1232 | $i++; |
---|
1233 | } @$pages; |
---|
1234 | |
---|
1235 | } |
---|
1236 | |
---|
1237 | |
---|
1238 | |
---|
1239 | sub _InitEventHandlers { |
---|
1240 | my ( $self ) = @_ ; |
---|
1241 | |
---|
1242 | Wx::Event::EVT_MENU( $self, 101, \&OnAddImages ); |
---|
1243 | Wx::Event::EVT_MENU( $self, 102, \&OnRemoveImages ); |
---|
1244 | Wx::Event::EVT_MENU( $self, 103, \&OnUploadImages ); |
---|
1245 | Wx::Event::EVT_MENU( $self, 104, \&OnGlobalSettings ); |
---|
1246 | Wx::Event::EVT_MENU( $self, 105, \&OnChooseLanguage ); |
---|
1247 | EVT_TREE_SEL_CHANGED( $self, $self->tree, \&OnTreeSelChanged ); |
---|
1248 | EVT_TREE_ITEM_RIGHT_CLICK( $self->tree, $self->tree, \&OnTreeItemRightClick ); |
---|
1249 | EVT_LIST_END_LABEL_EDIT( $self, $self->imageviewer, \&OnImageViewerEndLabelEdit ); |
---|
1250 | EVT_LIST_ITEM_ACTIVATED( $self, $self->imageviewer, \&OnImageViewerItemActivated ); |
---|
1251 | EVT_LIST_ITEM_SELECTED($self, $self->imageviewer, \&OnImageViewerItemSelected) ; |
---|
1252 | EVT_LIST_KEY_DOWN($self, $self->imageviewer, \&OnImageViewerKeyDown) ; |
---|
1253 | EVT_CLOSE( $self, \&OnClose ); |
---|
1254 | Wx::Event::EVT_UPDATE_UI( $self, $self, \&OnUpdateUI ); |
---|
1255 | |
---|
1256 | |
---|
1257 | Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategories ); |
---|
1258 | Wx::Event::EVT_MENU( $self, 2+$ID_TREE_CTX_MENU, \&OnRefreshCategories ); |
---|
1259 | } |
---|
1260 | |
---|
1261 | { |
---|
1262 | my $prevdir; |
---|
1263 | my $prevfile; |
---|
1264 | |
---|
1265 | sub OnAddImages { |
---|
1266 | my( $self, $event ) = @_; |
---|
1267 | my $dialog = Wx::FileDialog->new |
---|
1268 | ( $self, gettext("Select photos for upload"), $prevfile, $prevdir, |
---|
1269 | sprintf("%s (*.jpg)|*.jpg|All(*.*)|*.*", gettext("JPEG files")), |
---|
1270 | wxFD_OPEN|wxFD_MULTIPLE ); |
---|
1271 | |
---|
1272 | my $file_paths = []; |
---|
1273 | if( $dialog->ShowModal != wxID_CANCEL ) { |
---|
1274 | @$file_paths = $dialog->GetPaths; |
---|
1275 | $self->SetNewFiles($file_paths) ; |
---|
1276 | } |
---|
1277 | $dialog->Destroy; |
---|
1278 | $event->Skip; |
---|
1279 | } |
---|
1280 | } |
---|
1281 | |
---|
1282 | sub OnUpdateUI { |
---|
1283 | my( $self, $event ) = @_; |
---|
1284 | |
---|
1285 | if( $self->manager ){ |
---|
1286 | if($self->manager->GetPane("global_settings")->IsShown){ |
---|
1287 | $self->toolbar->EnableTool(104, 0); |
---|
1288 | } |
---|
1289 | else{ |
---|
1290 | $self->toolbar->EnableTool(104, 1); |
---|
1291 | } |
---|
1292 | } |
---|
1293 | } |
---|
1294 | |
---|
1295 | sub OnRemoveImages { |
---|
1296 | my( $self, $event ) = @_; |
---|
1297 | |
---|
1298 | |
---|
1299 | $self->imagelist->RemoveImageSelection; |
---|
1300 | $self->imageviewer->Refresh; |
---|
1301 | } |
---|
1302 | |
---|
1303 | sub SetNewFiles { |
---|
1304 | my ( $self, $file_paths ) = @_; |
---|
1305 | |
---|
1306 | $self->ShowImageViewer(); |
---|
1307 | $self->progressdlg( |
---|
1308 | Uploader::GUI::wxImageProcessingProgressDlg->new( |
---|
1309 | { |
---|
1310 | title => gettext("Image processing progress information"), |
---|
1311 | bt_label => gettext("Cancel image processing"), |
---|
1312 | } |
---|
1313 | ) |
---|
1314 | ); |
---|
1315 | $self->progressdlg->Show(1); |
---|
1316 | Wx::Yield(); |
---|
1317 | |
---|
1318 | my $files = [ |
---|
1319 | map { |
---|
1320 | encode('iso-8859-1', $_) |
---|
1321 | }@$file_paths |
---|
1322 | ]; |
---|
1323 | |
---|
1324 | # last is first ! |
---|
1325 | if ( scalar @$files > 1 ){ |
---|
1326 | my $first = shift @$files; |
---|
1327 | push @$files, $first; |
---|
1328 | } |
---|
1329 | #print Dumper $files; |
---|
1330 | |
---|
1331 | $self->imagelist->SetNewFiles( |
---|
1332 | $files |
---|
1333 | ); |
---|
1334 | |
---|
1335 | |
---|
1336 | } |
---|
1337 | |
---|
1338 | sub OnTreeSelChanged { |
---|
1339 | my( $self, $event ) = @_; |
---|
1340 | |
---|
1341 | my @items = $self->tree->GetSelections; |
---|
1342 | |
---|
1343 | $self->imagelist->categories( |
---|
1344 | [ |
---|
1345 | map { |
---|
1346 | my $category = $self->tree->GetPlData( $_ ); |
---|
1347 | $category->{id} if $category != -1; |
---|
1348 | } |
---|
1349 | @items |
---|
1350 | ] |
---|
1351 | ); |
---|
1352 | } |
---|
1353 | |
---|
1354 | sub OnTreeItemRightClick { |
---|
1355 | my( $self, $event ) = @_; |
---|
1356 | |
---|
1357 | my $point = $event->GetPoint ; |
---|
1358 | my $ctx_mnu = Wx::Menu->new; |
---|
1359 | |
---|
1360 | map { |
---|
1361 | $ctx_mnu->Append( |
---|
1362 | @$_ |
---|
1363 | ); |
---|
1364 | } |
---|
1365 | ( |
---|
1366 | [ |
---|
1367 | 1+$ID_TREE_CTX_MENU, |
---|
1368 | wxTheApp->branding->{'Add new category'}, |
---|
1369 | sprintf( |
---|
1370 | "%s %s %s %s", |
---|
1371 | gettext("Add a new"), |
---|
1372 | wxTheApp->branding->{category}, |
---|
1373 | gettext("to the currently selected"), |
---|
1374 | wxTheApp->branding->{category}, |
---|
1375 | ) |
---|
1376 | ], |
---|
1377 | [ |
---|
1378 | 2+$ID_TREE_CTX_MENU, |
---|
1379 | "Refresh", |
---|
1380 | sprintf( |
---|
1381 | "Refresh %s list.", |
---|
1382 | wxTheApp->branding->{category}, |
---|
1383 | ) |
---|
1384 | ], |
---|
1385 | ); |
---|
1386 | $self->PopupMenu($ctx_mnu, $point); |
---|
1387 | |
---|
1388 | } |
---|
1389 | |
---|
1390 | sub OnAddCategories { |
---|
1391 | my ( $self, $event ) = @_; |
---|
1392 | |
---|
1393 | my $item = $self->tree->GetSelection; |
---|
1394 | |
---|
1395 | my $category = $self->tree->GetPlData($item); |
---|
1396 | my $category_id; |
---|
1397 | |
---|
1398 | $category_id = $category->{id} if 'HASH' eq ref($category) ; |
---|
1399 | |
---|
1400 | my $dialog = Wx::TextEntryDialog->new( |
---|
1401 | $self, |
---|
1402 | sprintf("Category name :", wxTheApp->branding->{Category}), |
---|
1403 | sprintf("Add new %s", wxTheApp->branding->{category}), |
---|
1404 | sprintf("New %s", wxTheApp->branding->{category}), |
---|
1405 | ); |
---|
1406 | |
---|
1407 | if( $dialog->ShowModal != wxID_CANCEL ) { |
---|
1408 | my $name = $dialog->GetValue; |
---|
1409 | my ( $status, $status_msg ) = $self->pwg->AddCategories( $name, $category_id); |
---|
1410 | $self->_refresh_tree_categories_helper; |
---|
1411 | } |
---|
1412 | $dialog->Destroy; |
---|
1413 | } |
---|
1414 | |
---|
1415 | sub OnRefreshCategories { |
---|
1416 | my ( $self, $event ) = @_; |
---|
1417 | |
---|
1418 | $self->_refresh_tree_categories_helper; |
---|
1419 | } |
---|
1420 | |
---|
1421 | sub _refresh_tree_categories_helper { |
---|
1422 | my ( $self ) = @_; |
---|
1423 | |
---|
1424 | my $busycursor = Wx::BusyCursor->new(); |
---|
1425 | $self->tree->CollapseAll; |
---|
1426 | $self->tree->DeleteAllItems; |
---|
1427 | $self->imagelist->categories([]); |
---|
1428 | $self->pwg->RefreshCategories(); |
---|
1429 | $self->populate_tree_categories; |
---|
1430 | } |
---|
1431 | |
---|
1432 | sub OnImageViewerEndLabelEdit { |
---|
1433 | my( $self, $event ) = @_; |
---|
1434 | |
---|
1435 | my $image = $self->imagelist->GetImage($event->GetIndex); |
---|
1436 | $image->site_name( |
---|
1437 | $event->GetLabel |
---|
1438 | ); |
---|
1439 | |
---|
1440 | $self->image_prop_piwigo->Refresh; |
---|
1441 | } |
---|
1442 | |
---|
1443 | sub OnImageViewerItemActivated { |
---|
1444 | my( $self, $event ) = @_; |
---|
1445 | |
---|
1446 | $self->OnPhotoProperties; |
---|
1447 | } |
---|
1448 | |
---|
1449 | |
---|
1450 | sub OnImageViewerItemSelected { |
---|
1451 | my( $self, $event ) = @_; |
---|
1452 | |
---|
1453 | my $indx = $event->GetIndex; |
---|
1454 | |
---|
1455 | # retrieve photo info for the last selected photo |
---|
1456 | $self->imagelist->SetCurrentImage($indx); |
---|
1457 | |
---|
1458 | $self->imagelist->image_selection( |
---|
1459 | $self->imageviewer->GetSelectedItems |
---|
1460 | ); |
---|
1461 | |
---|
1462 | $self->image_preview->SetBitmap( |
---|
1463 | wxNullBitmap |
---|
1464 | ); |
---|
1465 | $self->image_preview->Refresh; |
---|
1466 | |
---|
1467 | |
---|
1468 | $self->image_preview->SetBitmap( |
---|
1469 | Wx::Bitmap->new( |
---|
1470 | $self->imagelist->current_image->preview_file, |
---|
1471 | $self->GetWxBitmapType($self->imagelist->type), |
---|
1472 | ) |
---|
1473 | ); |
---|
1474 | |
---|
1475 | $self->image_preview->Refresh; |
---|
1476 | |
---|
1477 | $self->manager->Update; |
---|
1478 | |
---|
1479 | $self->image_prop_piwigo->Refresh; |
---|
1480 | $self->image_prop_exif->Refresh; |
---|
1481 | |
---|
1482 | } |
---|
1483 | |
---|
1484 | sub OnImageViewerKeyDown { |
---|
1485 | my( $self, $event ) = @_; |
---|
1486 | |
---|
1487 | if(WXK_DELETE == $event->GetKeyCode){ |
---|
1488 | $self->OnRemoveImages(); |
---|
1489 | } |
---|
1490 | } |
---|
1491 | |
---|
1492 | sub OnUploadImages { |
---|
1493 | my( $self, $event ) = @_; |
---|
1494 | |
---|
1495 | eval { |
---|
1496 | $self->ProcessImageSelection(); |
---|
1497 | }; |
---|
1498 | } |
---|
1499 | |
---|
1500 | # remove image from imagelist when uploaded |
---|
1501 | sub UploadImagesViewerRefresh { |
---|
1502 | my ( $self ) = @_; |
---|
1503 | |
---|
1504 | my $imagelist= $self->imagelist ; |
---|
1505 | |
---|
1506 | Wx::Yield(); |
---|
1507 | } |
---|
1508 | |
---|
1509 | sub UploadProgressMessageRefresh { |
---|
1510 | my ( $self, $msg ) = @_; |
---|
1511 | |
---|
1512 | $self->upload_progressdlg->processing( |
---|
1513 | $msg |
---|
1514 | ); |
---|
1515 | |
---|
1516 | Wx::Yield(); |
---|
1517 | } |
---|
1518 | |
---|
1519 | sub UploadProgressThumbnailRefresh { |
---|
1520 | my ( $self ) = @_; |
---|
1521 | |
---|
1522 | my $imagelist = $self->imagelist ; |
---|
1523 | |
---|
1524 | |
---|
1525 | $self->upload_progressdlg->image->SetBitmap(wxNullBitmap); |
---|
1526 | $self->upload_progressdlg->image->SetBitmap( |
---|
1527 | Wx::Bitmap->new( |
---|
1528 | $self->imagelist->current_image->wx_thumb_file, |
---|
1529 | $self->GetWxBitmapType($self->imagelist->type), |
---|
1530 | ) |
---|
1531 | ); |
---|
1532 | |
---|
1533 | Wx::Yield(); |
---|
1534 | } |
---|
1535 | |
---|
1536 | sub UploadProgressBarRefresh { |
---|
1537 | my ( $self, $ratio ) = @_; |
---|
1538 | |
---|
1539 | $ratio = $self->imagelist->count > 1 ? 1 : $ratio; |
---|
1540 | eval { |
---|
1541 | $self->upload_progressdlg->progress( |
---|
1542 | $ratio*$self->imagelist->count * ( 100/scalar @{$self->imagelist->image_selection} ) |
---|
1543 | ); |
---|
1544 | $self->upload_progressdlg->LogProgress(); |
---|
1545 | }; |
---|
1546 | croak gettext("Upload cancelled") if $@; |
---|
1547 | |
---|
1548 | Wx::Yield(); |
---|
1549 | } |
---|
1550 | |
---|
1551 | sub SetNewFilesDisplayEndInfo { |
---|
1552 | my ( $self, $msg ) = @_; |
---|
1553 | |
---|
1554 | $self->progressdlg->DisplayEndInfo($msg); |
---|
1555 | } |
---|
1556 | |
---|
1557 | sub UploadDisplayEndInfo { |
---|
1558 | my ( $self, $msg ) = @_; |
---|
1559 | |
---|
1560 | my $imagelist = $self->imagelist ; |
---|
1561 | |
---|
1562 | $self->upload_progressdlg->DisplayEndInfo($msg); |
---|
1563 | } |
---|
1564 | |
---|
1565 | sub ShowImageViewer { |
---|
1566 | my ( $self ) = @_; |
---|
1567 | |
---|
1568 | if(!$self->imageviewer->IsShown){ |
---|
1569 | my $imglistpage = [ |
---|
1570 | [ |
---|
1571 | $self->imageviewer, |
---|
1572 | gettext("Photo selection"), |
---|
1573 | '../res/images.png', |
---|
1574 | wxBITMAP_TYPE_PNG, |
---|
1575 | ], |
---|
1576 | ]; |
---|
1577 | $self->notebook->DeletePage(0); |
---|
1578 | |
---|
1579 | $self->imageviewer->Show(1); |
---|
1580 | $self->_populate_notebook($self->notebook, $imglistpage, 0); |
---|
1581 | # load imagelist with loading.jpg |
---|
1582 | } |
---|
1583 | |
---|
1584 | } |
---|
1585 | |
---|
1586 | |
---|
1587 | |
---|
1588 | |
---|
1589 | sub SetNewFilesViewerRefresh { |
---|
1590 | |
---|
1591 | my ( $self ) = @_; |
---|
1592 | |
---|
1593 | my $wximagelist = $self->imagelist->wx_thumb_imglist; |
---|
1594 | |
---|
1595 | my $indx = $wximagelist->Add( |
---|
1596 | Wx::Bitmap->new( |
---|
1597 | $self->imagelist->current_image->wx_thumb_file, |
---|
1598 | $self->GetWxBitmapType($self->imagelist->type), |
---|
1599 | ) |
---|
1600 | ) if defined $self->imagelist->current_image->wx_thumb_file; |
---|
1601 | print $self->imagelist->current_image->wx_thumb_file, " added with index ", $indx, "\n"; |
---|
1602 | $self->imageviewer->Refresh( |
---|
1603 | $wximagelist |
---|
1604 | ); |
---|
1605 | |
---|
1606 | Wx::Yield(); |
---|
1607 | } |
---|
1608 | |
---|
1609 | |
---|
1610 | |
---|
1611 | # prepare and upload image_selection |
---|
1612 | sub ProcessImageSelection { |
---|
1613 | my ( $self ) = @_; |
---|
1614 | |
---|
1615 | return if !scalar @{$self->imagelist->sums}; |
---|
1616 | |
---|
1617 | if( scalar @{$self->imagelist->categories} ){ |
---|
1618 | return if( !defined $self->imagelist->image_selection ); |
---|
1619 | return if( !scalar @{$self->imagelist->image_selection} ); |
---|
1620 | |
---|
1621 | $self->upload_progressdlg( |
---|
1622 | Uploader::GUI::wxImageProcessingProgressDlg->new( |
---|
1623 | { |
---|
1624 | title => gettext("Image upload progress information"), |
---|
1625 | bt_label => gettext("Cancel upload"), |
---|
1626 | } |
---|
1627 | ) |
---|
1628 | ); |
---|
1629 | # modeless dialog |
---|
1630 | $self->upload_progressdlg->Show(1); |
---|
1631 | Wx::Yield(); |
---|
1632 | eval { |
---|
1633 | $self->imagelist->UploadSelection; |
---|
1634 | }; |
---|
1635 | if($@){ |
---|
1636 | Wx::MessageBox( |
---|
1637 | sprintf( |
---|
1638 | gettext("Upload cancelled"), |
---|
1639 | ), |
---|
1640 | gettext("Piwigo upload information"), |
---|
1641 | wxOK | wxICON_INFORMATION, |
---|
1642 | ); |
---|
1643 | } |
---|
1644 | } |
---|
1645 | else { |
---|
1646 | Wx::MessageBox( |
---|
1647 | sprintf( |
---|
1648 | "%s %s", |
---|
1649 | gettext("Please select a valid target"), |
---|
1650 | wxTheApp->branding->{category} |
---|
1651 | ), |
---|
1652 | gettext("Piwigo upload error"), |
---|
1653 | wxOK | wxICON_EXCLAMATION, |
---|
1654 | ); |
---|
1655 | } |
---|
1656 | } |
---|
1657 | |
---|
1658 | |
---|
1659 | sub SetNewFilesProgress { |
---|
1660 | my ( $self ) = @_; |
---|
1661 | |
---|
1662 | my $imagelist = $self->imagelist; |
---|
1663 | |
---|
1664 | $self->progressdlg->processing( |
---|
1665 | sprintf( |
---|
1666 | $imagelist->progress_msg, |
---|
1667 | $imagelist->current_image->file, |
---|
1668 | ) |
---|
1669 | ); |
---|
1670 | |
---|
1671 | eval { |
---|
1672 | $self->progressdlg->image->SetSize([ $imagelist->wx_thumb_size, $imagelist->wx_thumb_size]); |
---|
1673 | $self->progressdlg->image->SetBitmap(wxNullBitmap); |
---|
1674 | $self->progressdlg->image->SetBitmap( |
---|
1675 | Wx::Bitmap->new( |
---|
1676 | $imagelist->current_image->wx_thumb_file, |
---|
1677 | $self->GetWxBitmapType( $imagelist->type ) |
---|
1678 | ) |
---|
1679 | ); |
---|
1680 | $self->progressdlg->progress( |
---|
1681 | $imagelist->count * ( 100/scalar @{$imagelist->new_files} ) |
---|
1682 | ); |
---|
1683 | $self->progressdlg->LogProgress(); |
---|
1684 | }; |
---|
1685 | Wx::Yield(); |
---|
1686 | } |
---|
1687 | |
---|
1688 | sub OnClose { |
---|
1689 | my $self = shift; |
---|
1690 | |
---|
1691 | |
---|
1692 | # Restaure previous log wnd |
---|
1693 | Wx::Log::SetActiveTarget( $self->oldlogwnd ); |
---|
1694 | |
---|
1695 | # allways store |
---|
1696 | |
---|
1697 | wxTheApp->StoreConnectionProperties; |
---|
1698 | |
---|
1699 | $self->imagelist->Store; |
---|
1700 | wxTheApp->login_dlg->Destroy; |
---|
1701 | |
---|
1702 | my $params = {}; |
---|
1703 | |
---|
1704 | ( $params->{'X'}, $params->{'Y'} ) = $self->GetPositionXY ; |
---|
1705 | ( $params->{'Width'}, $params->{'Height'} ) = $self->GetSizeWH ; |
---|
1706 | ( $params->{'PreviewWidth'}, $params->{'PreviewHeight'} ) = $self->image_preview->GetSizeWH ; |
---|
1707 | $params->{Perspective} = $self->manager->SavePerspective; |
---|
1708 | |
---|
1709 | |
---|
1710 | wxTheApp->SaveConfig( $params ); |
---|
1711 | |
---|
1712 | $self->Destroy; |
---|
1713 | } |
---|
1714 | |
---|
1715 | |
---|
1716 | sub create_toolbar { |
---|
1717 | my( $self ) = @_; |
---|
1718 | |
---|
1719 | my $tb = Wx::ToolBar->new( $self, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT ); |
---|
1720 | $tb->SetToolBitmapSize( wxSIZE( 32, 32 ) ); |
---|
1721 | map { |
---|
1722 | my $icon1 = Wx::Icon->new(); |
---|
1723 | eval { |
---|
1724 | $icon1->LoadFile($_->[2], $_->[3]); |
---|
1725 | }; |
---|
1726 | my $tb_icon1 = Wx::Bitmap->new( $icon1 ); |
---|
1727 | |
---|
1728 | my $icon2 = Wx::Icon->new(); |
---|
1729 | eval { |
---|
1730 | $icon2->LoadFile($_->[5], $_->[3]); |
---|
1731 | }; |
---|
1732 | my $tb_icon2 = Wx::Bitmap->new( $icon2 ); |
---|
1733 | |
---|
1734 | |
---|
1735 | $tb->AddTool( $_->[0], $_->[1], $tb_icon1, $tb_icon2, wxITEM_NORMAL, $_->[1] ); |
---|
1736 | $tb->EnableTool( $_->[0], $_->[4]); |
---|
1737 | } |
---|
1738 | ( |
---|
1739 | [ |
---|
1740 | 101, |
---|
1741 | gettext("Add photo to selection"), |
---|
1742 | '../res/tb_add.png', |
---|
1743 | wxBITMAP_TYPE_PNG, |
---|
1744 | 1, |
---|
1745 | '../res/tb_add.png', |
---|
1746 | gettext("Add photo to selection for resizing and uploading") |
---|
1747 | ], |
---|
1748 | [ |
---|
1749 | 102, |
---|
1750 | gettext("Remove photo from selection"), |
---|
1751 | '../res/tb_remove.png', |
---|
1752 | wxBITMAP_TYPE_PNG, |
---|
1753 | 1, |
---|
1754 | '../res/tb_remove.png', |
---|
1755 | gettext("Remove photo from selection. Files are not deleted ") |
---|
1756 | ], |
---|
1757 | [ |
---|
1758 | 103, |
---|
1759 | gettext("Upload to Piwigo"), |
---|
1760 | '../res/tb_upload.png', |
---|
1761 | wxBITMAP_TYPE_PNG, |
---|
1762 | wxTheApp->use_offline ? 0 : 1, |
---|
1763 | '../res/tb_upload.png', |
---|
1764 | gettext("Upload photos to Piwigo.") |
---|
1765 | ], |
---|
1766 | [ |
---|
1767 | 104, |
---|
1768 | gettext("Global settings"), |
---|
1769 | '../res/tb_settings.png', |
---|
1770 | wxBITMAP_TYPE_PNG, |
---|
1771 | 0, |
---|
1772 | '../res/tb_settings.png', |
---|
1773 | gettext("Change global settings.") |
---|
1774 | ], |
---|
1775 | [ |
---|
1776 | 105, |
---|
1777 | gettext("Language choice"), |
---|
1778 | '../res/tb_i18n.png', |
---|
1779 | wxBITMAP_TYPE_PNG, |
---|
1780 | 1, |
---|
1781 | '../res/tb_i18n.png', |
---|
1782 | gettext("Language choice") |
---|
1783 | ], |
---|
1784 | |
---|
1785 | ); |
---|
1786 | |
---|
1787 | if($@){ |
---|
1788 | undef $tb; |
---|
1789 | } |
---|
1790 | else{ |
---|
1791 | $tb->Realize; |
---|
1792 | } |
---|
1793 | |
---|
1794 | return $tb; |
---|
1795 | } |
---|
1796 | |
---|
1797 | |
---|
1798 | sub _create_textctrl { |
---|
1799 | my( $self, $parent, $text, $size ) = @_; |
---|
1800 | |
---|
1801 | return Wx::TextCtrl->new( $parent, -1, $text, [0, 0], $size, |
---|
1802 | wxNO_BORDER | wxTE_MULTILINE | wxTE_READONLY ); |
---|
1803 | } |
---|
1804 | |
---|
1805 | sub create_textctrl { |
---|
1806 | my( $self, $text, $size ) = @_; |
---|
1807 | |
---|
1808 | return $self->_create_textctrl( $self, $text, $size ); |
---|
1809 | } |
---|
1810 | |
---|
1811 | sub DESTROY { |
---|
1812 | my( $self ) = @_; |
---|
1813 | |
---|
1814 | $self->manager->UnInit; |
---|
1815 | } |
---|
1816 | |
---|
1817 | |
---|
1818 | |
---|
1819 | 1; |
---|
1820 | |
---|
1821 | |
---|
1822 | |
---|
1823 | |
---|
1824 | |
---|
1825 | package DNDImageListDropTarget; |
---|
1826 | |
---|
1827 | use base qw(Wx::FileDropTarget Class::Accessor::Fast); |
---|
1828 | |
---|
1829 | __PACKAGE__->mk_accessors( |
---|
1830 | qw/ |
---|
1831 | imageviewer |
---|
1832 | frame |
---|
1833 | / |
---|
1834 | ); |
---|
1835 | |
---|
1836 | sub new { |
---|
1837 | my $class = shift; |
---|
1838 | my $imageviewer = shift; |
---|
1839 | my $self = $class->SUPER::new( @_ ); |
---|
1840 | |
---|
1841 | $self->imageviewer($imageviewer); |
---|
1842 | $self->frame($imageviewer->GetParent); |
---|
1843 | return $self; |
---|
1844 | } |
---|
1845 | |
---|
1846 | sub OnDropFiles { |
---|
1847 | my( $self, $x, $y, $files ) = @_; |
---|
1848 | |
---|
1849 | $self->frame->SetNewFiles($files) ; |
---|
1850 | } |
---|
1851 | |
---|
1852 | |
---|
1853 | |
---|
1854 | |
---|
1855 | 1; |
---|
1856 | |
---|
1857 | |
---|
1858 | package DNDCategoryTreeDropTarget; |
---|
1859 | |
---|
1860 | use base qw(Wx::TextDropTarget Class::Accessor::Fast); |
---|
1861 | use Data::Dumper; |
---|
1862 | use Wx qw/ |
---|
1863 | wxDragNone |
---|
1864 | wxDragCopy |
---|
1865 | wxDragMove |
---|
1866 | /; |
---|
1867 | |
---|
1868 | __PACKAGE__->mk_accessors( |
---|
1869 | qw/ |
---|
1870 | tree |
---|
1871 | frame |
---|
1872 | / |
---|
1873 | ); |
---|
1874 | |
---|
1875 | sub new { |
---|
1876 | my ( $class, $tree ) = @_; |
---|
1877 | my $self = $class->SUPER::new(); |
---|
1878 | |
---|
1879 | $self->tree($tree); |
---|
1880 | $self->frame($tree->GetParent); |
---|
1881 | return $self; |
---|
1882 | } |
---|
1883 | |
---|
1884 | |
---|
1885 | |
---|
1886 | sub OnDropText { |
---|
1887 | my( $self, $x, $y, $textdata ) = @_; |
---|
1888 | |
---|
1889 | # must be $VAR1 because $textdata is the result of Data::Dumper |
---|
1890 | my $VAR1; |
---|
1891 | eval $textdata; |
---|
1892 | eval { |
---|
1893 | if(scalar @$VAR1){ |
---|
1894 | my @items; |
---|
1895 | if(scalar @items < 2) { |
---|
1896 | my ($dropItem, $flag) = $self->tree->HitTest([$x, $y]); |
---|
1897 | push @items, $dropItem; |
---|
1898 | } |
---|
1899 | else { |
---|
1900 | @items = $self->tree->GetSelections; |
---|
1901 | } |
---|
1902 | |
---|
1903 | # remove root item which is not a valid category |
---|
1904 | @items = grep { $self->tree->GetPlData( $_ ) != -1 } @items; |
---|
1905 | |
---|
1906 | $self->frame->imagelist->categories( |
---|
1907 | [ |
---|
1908 | map { |
---|
1909 | $self->tree->GetPlData( $_ )->{id}; |
---|
1910 | } |
---|
1911 | @items |
---|
1912 | ] |
---|
1913 | ); |
---|
1914 | |
---|
1915 | $self->frame->imagelist->image_selection($VAR1); |
---|
1916 | $self->frame->ProcessImageSelection ; |
---|
1917 | } |
---|
1918 | }; |
---|
1919 | } |
---|
1920 | |
---|
1921 | 1; |
---|