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