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 | /; |
---|
338 | __PACKAGE__->mk_accessors( @properties ); |
---|
339 | |
---|
340 | use Wx::Event |
---|
341 | qw/ |
---|
342 | EVT_MENU |
---|
343 | EVT_TREE_SEL_CHANGED |
---|
344 | EVT_CLOSE |
---|
345 | EVT_LIST_END_LABEL_EDIT |
---|
346 | EVT_LIST_ITEM_SELECTED |
---|
347 | EVT_TREE_ITEM_RIGHT_CLICK |
---|
348 | EVT_LIST_KEY_DOWN |
---|
349 | EVT_UPDATE_UI |
---|
350 | /; |
---|
351 | |
---|
352 | use Uploader::GUI::wxImageListCtrl; |
---|
353 | use Uploader::GUI::wxImageProcessingProgressDlg; |
---|
354 | use Wx::Html; |
---|
355 | use Uploader::GUI::wxHtmlWindow; |
---|
356 | use Data::Dumper; |
---|
357 | use Wx::AUI; |
---|
358 | use Storable; |
---|
359 | use Uploader::GUI::wxPropertyGridPanel; |
---|
360 | use Encode qw/encode decode is_utf8/; |
---|
361 | |
---|
362 | $|=1; |
---|
363 | |
---|
364 | my $ID_TREE_CTX_MENU = 20000 ; |
---|
365 | |
---|
366 | sub new { |
---|
367 | my( $class, $params ) = @_; |
---|
368 | my( $self ) = $class->SUPER::new( |
---|
369 | undef, |
---|
370 | -1, |
---|
371 | $params->{title}, |
---|
372 | [ $params->{x}, $params->{y} ], |
---|
373 | [ $params->{width}, $params->{height} ], |
---|
374 | wxDEFAULT_FRAME_STYLE|wxMAXIMIZE |
---|
375 | ); |
---|
376 | $self->pwg( $params->{pwg} ); |
---|
377 | $self->imagelist( $params->{imagelist} ); |
---|
378 | |
---|
379 | # callback for GUI refresh : add thumbnail images to the imageviewer control |
---|
380 | $self->imagelist->SetNewFilesViewerRefreshCallback( |
---|
381 | sub { $self->SetNewFilesViewerRefresh(@_) } |
---|
382 | ); |
---|
383 | |
---|
384 | # callback for GUI refresh : progress dialog display of thumbnail image being created |
---|
385 | $self->imagelist->SetNewFilesProgressCallback( |
---|
386 | sub { $self->SetNewFilesProgress(@_) } |
---|
387 | ); |
---|
388 | |
---|
389 | $self->imagelist->SetNewFilesDisplayEndInfoCallback( |
---|
390 | sub { $self->SetNewFilesDisplayEndInfo(@_) } |
---|
391 | ); |
---|
392 | |
---|
393 | |
---|
394 | # callback for GUI refresh : remove thumbnail images from imageviewer control |
---|
395 | $self->imagelist->UploadImagesViewerCallback( |
---|
396 | sub { $self->UploadImagesViewerRefresh(@_) } |
---|
397 | ); |
---|
398 | |
---|
399 | |
---|
400 | |
---|
401 | # callback for GUI refresh : progress dialog display current uploaded image |
---|
402 | $self->imagelist->progress_thumbnail_refresh( |
---|
403 | sub { $self->UploadProgressThumbnailRefresh(@_) } |
---|
404 | ); |
---|
405 | |
---|
406 | $self->imagelist->progress_msg_refresh( |
---|
407 | sub { $self->UploadProgressMessageRefresh(@_) } |
---|
408 | ); |
---|
409 | |
---|
410 | |
---|
411 | $self->imagelist->progressbar_refresh( |
---|
412 | sub { $self->UploadProgressBarRefresh(@_) } |
---|
413 | ); |
---|
414 | |
---|
415 | $self->imagelist->progress_endinfo_refresh( |
---|
416 | sub { $self->UploadDisplayEndInfo(@_) } |
---|
417 | ); |
---|
418 | |
---|
419 | |
---|
420 | $self->imagelist->pwg( |
---|
421 | $self->pwg |
---|
422 | ); |
---|
423 | |
---|
424 | $self->imagelist->categories( |
---|
425 | [] |
---|
426 | ); |
---|
427 | |
---|
428 | $self->manager( Wx::AuiManager->new ); |
---|
429 | $self->manager->SetManagedWindow( $self ); |
---|
430 | $self->_set_setting_properties; |
---|
431 | $self->_initFrame; |
---|
432 | $self->_InitEventHandlers; |
---|
433 | $self->_initImgTypes; |
---|
434 | |
---|
435 | $self; |
---|
436 | } |
---|
437 | |
---|
438 | sub _initImgTypes { |
---|
439 | my ( $self ) = @_; |
---|
440 | |
---|
441 | $self->{IMGTYPE} = { |
---|
442 | 'jpg' => wxBITMAP_TYPE_JPEG, |
---|
443 | 'gif' => wxBITMAP_TYPE_GIF, |
---|
444 | 'png' => wxBITMAP_TYPE_PNG, |
---|
445 | }; |
---|
446 | } |
---|
447 | |
---|
448 | |
---|
449 | sub GetWxBitmapType { |
---|
450 | my ( $self, $type ) = @_; |
---|
451 | |
---|
452 | $self->{IMGTYPE}->{$type}; |
---|
453 | } |
---|
454 | |
---|
455 | |
---|
456 | |
---|
457 | sub _set_setting_properties { |
---|
458 | my ( $self ) = @_; |
---|
459 | |
---|
460 | $self->piwigo_properties( |
---|
461 | [ |
---|
462 | { |
---|
463 | label => "Photo name :", |
---|
464 | value => sub { $self->imagelist->current_image->site_name(@_) }, |
---|
465 | }, |
---|
466 | { |
---|
467 | label => gettext("Comment :"), |
---|
468 | value => sub { $self->imagelist->current_image->site_comment(@_) }, |
---|
469 | type => "LongText", |
---|
470 | }, |
---|
471 | { |
---|
472 | label => gettext("Author :"), |
---|
473 | value => sub { $self->imagelist->current_image->site_author(@_) }, |
---|
474 | }, |
---|
475 | { |
---|
476 | label => gettext("File name :"), |
---|
477 | value => sub { $self->imagelist->current_image->file(@_) }, |
---|
478 | readonly => 1, |
---|
479 | }, |
---|
480 | { |
---|
481 | label => gettext("Create date :"), |
---|
482 | value => sub { $self->imagelist->current_image->create_date(@_) }, |
---|
483 | readonly => 1, |
---|
484 | }, |
---|
485 | ] |
---|
486 | ); |
---|
487 | |
---|
488 | $self->exif_properties( |
---|
489 | [ |
---|
490 | { |
---|
491 | label => gettext("Create date :"), |
---|
492 | value => sub { $self->imagelist->current_image->create_date }, |
---|
493 | readonly => 1, |
---|
494 | }, |
---|
495 | { |
---|
496 | label => gettext("Model :"), |
---|
497 | value => sub { $self->imagelist->current_image->exif_tag('Model') }, |
---|
498 | readonly => 1, |
---|
499 | }, |
---|
500 | { |
---|
501 | label => gettext("Width :"), |
---|
502 | value => sub { $self->imagelist->current_image->exif_tag('ImageWidth') }, |
---|
503 | readonly => 1, |
---|
504 | }, |
---|
505 | { |
---|
506 | label => gettext("Height :"), |
---|
507 | value => sub { $self->imagelist->current_image->exif_tag('ImageHeight') }, |
---|
508 | readonly => 1, |
---|
509 | }, |
---|
510 | { |
---|
511 | label => gettext("Orientation :"), |
---|
512 | value => sub { $self->imagelist->current_image->exif_tag('Orientation') }, |
---|
513 | readonly => 1, |
---|
514 | }, |
---|
515 | { |
---|
516 | label => "ISO :", |
---|
517 | value => sub { $self->imagelist->current_image->exif_tag('ISO') }, |
---|
518 | readonly => 1, |
---|
519 | }, |
---|
520 | { |
---|
521 | label => gettext("Shutter speed :"), |
---|
522 | value => sub { $self->imagelist->current_image->exif_tag('ExposureTime') }, |
---|
523 | readonly => 1, |
---|
524 | }, |
---|
525 | { |
---|
526 | label => gettext("Aperture :"), |
---|
527 | value => sub { $self->imagelist->current_image->exif_tag('ApertureValue') }, |
---|
528 | readonly => 1, |
---|
529 | }, |
---|
530 | { |
---|
531 | label => gettext("Focal length :"), |
---|
532 | value => sub { $self->imagelist->current_image->exif_tag('FocalLength') }, |
---|
533 | readonly => 1, |
---|
534 | }, |
---|
535 | { |
---|
536 | label => gettext("Lens :"), |
---|
537 | value => sub { $self->imagelist->current_image->exif_tag('Lens') }, |
---|
538 | readonly => 1, |
---|
539 | }, |
---|
540 | ] |
---|
541 | ); |
---|
542 | |
---|
543 | $self->general_settings( |
---|
544 | [ |
---|
545 | { |
---|
546 | label => gettext("Default author :"), |
---|
547 | value => sub { $self->imagelist->author(@_) }, |
---|
548 | }, |
---|
549 | { |
---|
550 | label => gettext("Default photo name :"), |
---|
551 | type => 'Choice', |
---|
552 | value => sub { $self->imagelist->default_photo_name(@_) }, |
---|
553 | choice => [ |
---|
554 | gettext('None'), |
---|
555 | gettext('File name'), |
---|
556 | gettext('File path and name'), |
---|
557 | gettext('Prefix'), |
---|
558 | gettext('Prefix + rank number'), |
---|
559 | gettext('Rank number + prefix'), |
---|
560 | gettext('Prefix + create date chrono'), |
---|
561 | gettext('Create date chrono + prefix'), |
---|
562 | ], |
---|
563 | }, |
---|
564 | { |
---|
565 | label => gettext("Photo name prefix :"), |
---|
566 | value => sub { $self->imagelist->default_name_prefix(@_) }, |
---|
567 | }, |
---|
568 | { |
---|
569 | label => gettext("Resize site image :"), |
---|
570 | type => 'Bool', |
---|
571 | value => sub { $self->imagelist->create_resized(@_) }, |
---|
572 | }, |
---|
573 | { |
---|
574 | label => gettext("Auto rotate image :"), |
---|
575 | type => 'Bool', |
---|
576 | value => sub { $self->imagelist->auto_rotate(@_) }, |
---|
577 | }, |
---|
578 | { |
---|
579 | label => gettext("Upload high (original size) :"), |
---|
580 | type => 'Bool', |
---|
581 | value => sub { $self->imagelist->upload_high(@_) }, |
---|
582 | }, |
---|
583 | ] |
---|
584 | ); |
---|
585 | |
---|
586 | $self->resized_settings( |
---|
587 | [ |
---|
588 | { |
---|
589 | label => gettext("Site image width :"), |
---|
590 | type => 'Number', |
---|
591 | value => sub { $self->imagelist->resize_w(@_) }, |
---|
592 | }, |
---|
593 | { |
---|
594 | label => gettext("Site image height :"), |
---|
595 | type => 'Number', |
---|
596 | value => sub { $self->imagelist->resize_h(@_) }, |
---|
597 | }, |
---|
598 | { |
---|
599 | label => gettext("Site image jpeg quality :"), |
---|
600 | type => 'Number', |
---|
601 | value => sub { $self->imagelist->quality(@_) }, |
---|
602 | }, |
---|
603 | { |
---|
604 | label => gettext("Site image filter :"), |
---|
605 | type => 'Choice', |
---|
606 | value => sub { $self->imagelist->filter(@_) }, |
---|
607 | choice => [ qw/Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc/ ], |
---|
608 | }, |
---|
609 | { |
---|
610 | label => gettext("Site image blur :"), |
---|
611 | type => 'Number', |
---|
612 | value => sub { $self->imagelist->blur(@_) }, |
---|
613 | }, |
---|
614 | { |
---|
615 | label => gettext("Site image interlace :"), |
---|
616 | type => 'Choice', |
---|
617 | value => sub { $self->imagelist->interlace(@_) }, |
---|
618 | choice => [ qw/None Line Plane Partition JPEG GIF PNG/ ], |
---|
619 | }, |
---|
620 | ] |
---|
621 | ); |
---|
622 | |
---|
623 | $self->thumbnail_settings( |
---|
624 | [ |
---|
625 | { |
---|
626 | label => gettext("Site thumbnail size :"), |
---|
627 | type => 'Number', |
---|
628 | value => sub { $self->imagelist->thumb_size(@_) }, |
---|
629 | }, |
---|
630 | { |
---|
631 | label => gettext("Site thumbnail jpeg quality :"), |
---|
632 | type => 'Number', |
---|
633 | value => sub { $self->imagelist->th_quality(@_) }, |
---|
634 | }, |
---|
635 | { |
---|
636 | label => gettext("Photo selection thumbnail size :"), |
---|
637 | type => 'Number', |
---|
638 | value => sub { $self->imagelist->wx_thumb_size(@_) }, |
---|
639 | }, |
---|
640 | { |
---|
641 | label => gettext("Photo selection thumbnail jpeg quality :"), |
---|
642 | type => 'Number', |
---|
643 | value => sub { $self->imagelist->wx_quality(@_) }, |
---|
644 | }, |
---|
645 | ] |
---|
646 | ); |
---|
647 | |
---|
648 | $self->preview_settings( |
---|
649 | [ |
---|
650 | { |
---|
651 | label => gettext("Use exif preview when available :"), |
---|
652 | type => 'Bool', |
---|
653 | value => sub { $self->imagelist->use_exif_preview(@_) }, |
---|
654 | }, |
---|
655 | { |
---|
656 | label => gettext("Custom preview ratio :"), |
---|
657 | type => 'Number', |
---|
658 | value => sub { $self->imagelist->preview_ratio(@_) }, |
---|
659 | }, |
---|
660 | ] |
---|
661 | ); |
---|
662 | |
---|
663 | } |
---|
664 | |
---|
665 | sub _refreshFrame { |
---|
666 | my ( $self ) = @_; |
---|
667 | |
---|
668 | $self->_set_setting_properties; |
---|
669 | $self->_refresh_settings_panels_properties; |
---|
670 | map { |
---|
671 | $_->Refresh; |
---|
672 | } |
---|
673 | ( |
---|
674 | $self->image_prop_piwigo, |
---|
675 | $self->image_prop_exif, |
---|
676 | $self->general_settings_panel, |
---|
677 | $self->resized_settings_panel, |
---|
678 | $self->thumbnail_settings_panel, |
---|
679 | $self->preview_settings_panel, |
---|
680 | ); |
---|
681 | |
---|
682 | $self->manager->Update; |
---|
683 | } |
---|
684 | |
---|
685 | |
---|
686 | sub _destroy_settings_panels { |
---|
687 | my ( $self ) = @_; |
---|
688 | |
---|
689 | |
---|
690 | |
---|
691 | map { |
---|
692 | $self->manager->DetachPane( |
---|
693 | $_ |
---|
694 | ); |
---|
695 | $_->Show(0); |
---|
696 | $_->Destroy; |
---|
697 | }( |
---|
698 | $self->notebook_global_settings, |
---|
699 | $self->notebook_image_properties, |
---|
700 | ); |
---|
701 | } |
---|
702 | |
---|
703 | # |
---|
704 | sub _initFrame { |
---|
705 | my ( $self ) = @_; |
---|
706 | |
---|
707 | |
---|
708 | $self->init_panels; |
---|
709 | |
---|
710 | $self->imageviewer->Show(0); |
---|
711 | |
---|
712 | $self->init_aui; |
---|
713 | $self->init_dnd_targets; |
---|
714 | if( $self->imagelist->wx_thumb_imglist->GetImageCount){ |
---|
715 | printf("%s images\n", $self->imagelist->wx_thumb_imglist->GetImageCount); |
---|
716 | $self->ShowImageViewer; |
---|
717 | |
---|
718 | $self->imageviewer->Refresh( |
---|
719 | $self->imagelist->wx_thumb_imglist |
---|
720 | ); |
---|
721 | } |
---|
722 | |
---|
723 | } |
---|
724 | |
---|
725 | sub _refresh_settings_panels_properties { |
---|
726 | my ( $self ) = @_; |
---|
727 | |
---|
728 | $self->image_prop_piwigo->properties( |
---|
729 | $self->piwigo_properties |
---|
730 | ); |
---|
731 | |
---|
732 | $self->image_prop_exif->properties( |
---|
733 | $self->exif_properties |
---|
734 | ); |
---|
735 | |
---|
736 | |
---|
737 | $self->general_settings_panel->properties( |
---|
738 | $self->general_settings |
---|
739 | ); |
---|
740 | |
---|
741 | $self->resized_settings_panel->properties( |
---|
742 | $self->resized_settings |
---|
743 | ); |
---|
744 | |
---|
745 | $self->thumbnail_settings_panel->properties( |
---|
746 | $self->thumbnail_settings, |
---|
747 | ); |
---|
748 | |
---|
749 | $self->preview_settings_panel->properties( |
---|
750 | $self->preview_settings, |
---|
751 | ); |
---|
752 | |
---|
753 | } |
---|
754 | |
---|
755 | sub _init_settings_panels { |
---|
756 | my ( $self ) = @_; |
---|
757 | |
---|
758 | $self->image_prop_piwigo( |
---|
759 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
760 | { |
---|
761 | parentwnd => $self, |
---|
762 | properties => $self->piwigo_properties, |
---|
763 | frame_callbacks => [ |
---|
764 | sub { |
---|
765 | $self->imageviewer->Refresh(); |
---|
766 | }, |
---|
767 | ], |
---|
768 | } |
---|
769 | ) |
---|
770 | ); |
---|
771 | |
---|
772 | $self->image_prop_exif( |
---|
773 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
774 | { |
---|
775 | parentwnd => $self, |
---|
776 | frame_callbacks => [], |
---|
777 | properties => $self->exif_properties, |
---|
778 | } |
---|
779 | ) |
---|
780 | ); |
---|
781 | |
---|
782 | |
---|
783 | $self->general_settings_panel( |
---|
784 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
785 | { |
---|
786 | parentwnd => $self, |
---|
787 | properties => $self->general_settings, |
---|
788 | frame_callbacks => [], |
---|
789 | } |
---|
790 | ) |
---|
791 | ); |
---|
792 | |
---|
793 | $self->resized_settings_panel( |
---|
794 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
795 | { |
---|
796 | parentwnd => $self, |
---|
797 | properties => $self->resized_settings, |
---|
798 | frame_callbacks => [], |
---|
799 | |
---|
800 | } |
---|
801 | ) |
---|
802 | ); |
---|
803 | |
---|
804 | $self->thumbnail_settings_panel( |
---|
805 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
806 | { |
---|
807 | parentwnd => $self, |
---|
808 | properties => $self->thumbnail_settings, |
---|
809 | frame_callbacks => [], |
---|
810 | |
---|
811 | } |
---|
812 | ) |
---|
813 | ); |
---|
814 | $self->preview_settings_panel( |
---|
815 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
816 | { |
---|
817 | parentwnd => $self, |
---|
818 | properties => $self->preview_settings, |
---|
819 | frame_callbacks => [], |
---|
820 | |
---|
821 | } |
---|
822 | ) |
---|
823 | ); |
---|
824 | |
---|
825 | |
---|
826 | $self->general_settings_panel->Show(0); |
---|
827 | |
---|
828 | $self->image_preview( |
---|
829 | Wx::StaticBitmap->new( |
---|
830 | $self, |
---|
831 | -1, |
---|
832 | wxNullBitmap |
---|
833 | ) |
---|
834 | ); |
---|
835 | |
---|
836 | |
---|
837 | |
---|
838 | $self->image_prop_piwigo->Show(0); |
---|
839 | |
---|
840 | |
---|
841 | |
---|
842 | $self->image_prop_exif->Show(0); |
---|
843 | |
---|
844 | } |
---|
845 | |
---|
846 | sub init_panels { |
---|
847 | my ( $self ) = @_; |
---|
848 | |
---|
849 | $self->htmlhome( |
---|
850 | Uploader::GUI::wxHtmlWindow->new( |
---|
851 | $self, -1 |
---|
852 | ) |
---|
853 | ); |
---|
854 | |
---|
855 | $self->imageviewer( |
---|
856 | Uploader::GUI::wxImageListCtrl->new( |
---|
857 | { |
---|
858 | parentwnd => $self, |
---|
859 | imagelist => $self->imagelist, |
---|
860 | } |
---|
861 | ) |
---|
862 | ); |
---|
863 | |
---|
864 | $self->_init_settings_panels; |
---|
865 | } |
---|
866 | |
---|
867 | sub init_dnd_targets { |
---|
868 | my ( $self ) = @_; |
---|
869 | |
---|
870 | $self->imageviewer->SetDropTarget( |
---|
871 | DNDImageListDropTarget->new( |
---|
872 | $self->imageviewer |
---|
873 | ) |
---|
874 | ); |
---|
875 | $self->htmlhome->SetDropTarget( |
---|
876 | DNDImageListDropTarget->new( |
---|
877 | $self->imageviewer |
---|
878 | ) |
---|
879 | ); |
---|
880 | |
---|
881 | |
---|
882 | $self->tree->SetDropTarget( |
---|
883 | DNDCategoryTreeDropTarget->new( |
---|
884 | $self->tree |
---|
885 | ) |
---|
886 | ); |
---|
887 | |
---|
888 | } |
---|
889 | |
---|
890 | sub init_aui { |
---|
891 | my ( $self ) = @_; |
---|
892 | |
---|
893 | my $url = wxTheApp->site_url; |
---|
894 | |
---|
895 | $url = gettext("empty - work Offline") if wxTheApp->use_offline; |
---|
896 | |
---|
897 | $self->manager->AddPane |
---|
898 | ( $self->create_notebook_imagelist, Wx::AuiPaneInfo->new->Name( "ImageViewer" ) |
---|
899 | ->CenterPane->Resizable->CloseButton(0) ); |
---|
900 | |
---|
901 | $self->manager->AddPane |
---|
902 | ( $self->create_tree, Wx::AuiPaneInfo->new->Name( "categories" )->Caption( |
---|
903 | sprintf("%s - %s", gettext("Piwigo categories"), $url ) |
---|
904 | ) |
---|
905 | ->Right->Position( 0 )->Resizable->CloseButton(0) ); |
---|
906 | |
---|
907 | $self->manager->AddPane |
---|
908 | ( $self->image_preview, Wx::AuiPaneInfo->new->Name( "preview" )->Caption(gettext("Photo preview")) |
---|
909 | ->Right->Position( 1 )->Resizable->CloseButton(0)->Floatable(0) ); |
---|
910 | |
---|
911 | |
---|
912 | $self->_init_aui_settings_panels; |
---|
913 | |
---|
914 | $self->toolbar( |
---|
915 | $self->create_toolbar |
---|
916 | ); |
---|
917 | |
---|
918 | $self->manager->AddPane |
---|
919 | ( $self->toolbar, Wx::AuiPaneInfo->new->Name( "tb1" )->Caption( gettext("Tools") ) |
---|
920 | ->ToolbarPane->Top->Row( 1 )->LeftDockable( 0 )->RightDockable( 0 ) ) if defined $self->toolbar; |
---|
921 | |
---|
922 | $self->manager->Update; |
---|
923 | |
---|
924 | } |
---|
925 | |
---|
926 | sub _init_aui_settings_panels { |
---|
927 | my ( $self ) = @_; |
---|
928 | |
---|
929 | $self->manager->AddPane |
---|
930 | ( $self->create_notebook_image_properties, Wx::AuiPaneInfo->new->Name( "photo_properties" )->Caption(gettext("Photo properties")) |
---|
931 | ->Right->Position( 1 )->Resizable->CloseButton(0) ); |
---|
932 | |
---|
933 | $self->manager->AddPane |
---|
934 | ( $self->create_notebook_global_settings, Wx::AuiPaneInfo->new->Name( "global_settings" )->Caption(gettext("Global settings")) |
---|
935 | ->Right->Position( 2 )->Resizable->CloseButton(1) ); |
---|
936 | |
---|
937 | $self->manager->GetPane("global_settings")->Show(0); |
---|
938 | |
---|
939 | } |
---|
940 | |
---|
941 | sub OnGlobalSettings { |
---|
942 | my ( $self ) = @_; |
---|
943 | |
---|
944 | $self->toolbar->EnableTool(104, 0 ); |
---|
945 | $self->manager->GetPane("global_settings")->Show(1); |
---|
946 | $self->manager->Update(); |
---|
947 | } |
---|
948 | |
---|
949 | sub OnChooseLanguage { |
---|
950 | my ( $self ) = @_; |
---|
951 | |
---|
952 | my $languages = [ |
---|
953 | ['Dutch', wxLANGUAGE_DUTCH, ], |
---|
954 | ['English', wxLANGUAGE_ENGLISH, ], |
---|
955 | ['French', wxLANGUAGE_FRENCH, ], |
---|
956 | ['German', wxLANGUAGE_GERMAN, ], |
---|
957 | ['Italian', wxLANGUAGE_ITALIAN, ], |
---|
958 | ['Polish', wxLANGUAGE_POLISH, ], |
---|
959 | ['Portuguese', wxLANGUAGE_PORTUGUESE, ], |
---|
960 | ['Russian', wxLANGUAGE_RUSSIAN, ], |
---|
961 | ['Spanish', wxLANGUAGE_SPANISH, ], |
---|
962 | ]; |
---|
963 | |
---|
964 | my $dialog = new Wx::SingleChoiceDialog |
---|
965 | ( undef, gettext( "Choose a language" ), gettext( "Choose a language" ), |
---|
966 | [ map { Wx::GetTranslation( ${$_}[0] ) } @$languages ] ); |
---|
967 | |
---|
968 | if( $dialog->ShowModal() == wxID_OK ) { |
---|
969 | wxTheApp->current_language( |
---|
970 | $languages->[$dialog->GetSelection][1] |
---|
971 | ); |
---|
972 | wxTheApp->init_locale(); |
---|
973 | $self->_refreshFrame; |
---|
974 | } |
---|
975 | |
---|
976 | $dialog->Destroy; |
---|
977 | |
---|
978 | } |
---|
979 | |
---|
980 | |
---|
981 | sub create_notebook_imagelist { |
---|
982 | my( $self ) = @_; |
---|
983 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [300, 450], |
---|
984 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
985 | my $pages = [ |
---|
986 | [ |
---|
987 | $self->htmlhome, |
---|
988 | gettext("Photo selection"), |
---|
989 | '../res/images.png', |
---|
990 | wxBITMAP_TYPE_PNG, |
---|
991 | ], |
---|
992 | #[ |
---|
993 | # $self->logwnd( $self->_create_textctrl( $book, undef, [450, 450] )), |
---|
994 | # "Log", |
---|
995 | # '../res/nb_log.png', |
---|
996 | # wxBITMAP_TYPE_PNG, |
---|
997 | #] |
---|
998 | ]; |
---|
999 | |
---|
1000 | $self->_populate_notebook( $book, $pages ); |
---|
1001 | |
---|
1002 | #$self->logwnd(Wx::LogTextCtrl->new( $self->logwnd )); |
---|
1003 | #$self->oldlogwnd( Wx::Log::SetActiveTarget( $self->logwnd ) ); |
---|
1004 | $self->notebook($book); |
---|
1005 | return $book; |
---|
1006 | } |
---|
1007 | |
---|
1008 | sub create_notebook_image_properties { |
---|
1009 | my( $self ) = @_; |
---|
1010 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [450, 450], |
---|
1011 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
1012 | my $pages = [ |
---|
1013 | [ |
---|
1014 | $self->image_prop_piwigo, |
---|
1015 | "Piwigo", |
---|
1016 | ], |
---|
1017 | [ |
---|
1018 | $self->image_prop_exif, |
---|
1019 | "Exif", |
---|
1020 | ], |
---|
1021 | ]; |
---|
1022 | |
---|
1023 | $self->_populate_notebook( $book, $pages ); |
---|
1024 | |
---|
1025 | $self->notebook_image_properties($book); |
---|
1026 | |
---|
1027 | return $book; |
---|
1028 | } |
---|
1029 | |
---|
1030 | sub create_notebook_global_settings { |
---|
1031 | my( $self ) = @_; |
---|
1032 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [450, 450], |
---|
1033 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
1034 | my $pages = [ |
---|
1035 | [ |
---|
1036 | $self->general_settings_panel, |
---|
1037 | gettext("General"), |
---|
1038 | ], |
---|
1039 | [ |
---|
1040 | $self->resized_settings_panel, |
---|
1041 | gettext("Resized"), |
---|
1042 | ], |
---|
1043 | [ |
---|
1044 | $self->thumbnail_settings_panel, |
---|
1045 | gettext("Thumbnail"), |
---|
1046 | ], |
---|
1047 | [ |
---|
1048 | $self->preview_settings_panel, |
---|
1049 | gettext("Preview"), |
---|
1050 | ], |
---|
1051 | ]; |
---|
1052 | |
---|
1053 | $self->_populate_notebook( $book, $pages ); |
---|
1054 | |
---|
1055 | $self->notebook_global_settings($book); |
---|
1056 | |
---|
1057 | return $book; |
---|
1058 | } |
---|
1059 | |
---|
1060 | |
---|
1061 | |
---|
1062 | |
---|
1063 | sub create_tree { |
---|
1064 | my ( $self ) = @_; |
---|
1065 | |
---|
1066 | my $images = [ |
---|
1067 | map { |
---|
1068 | Wx::Bitmap->new( $_, wxBITMAP_TYPE_PNG ) |
---|
1069 | |
---|
1070 | } |
---|
1071 | ( |
---|
1072 | '../res/tree_pwg.png', |
---|
1073 | '../res/tree_folder.png', |
---|
1074 | ) |
---|
1075 | ]; |
---|
1076 | |
---|
1077 | $self->treeimglist( Wx::ImageList->new( 16, 16, 1 ) ); |
---|
1078 | map { |
---|
1079 | $self->treeimglist->Add($_); |
---|
1080 | } |
---|
1081 | @$images; |
---|
1082 | |
---|
1083 | |
---|
1084 | $self->tree( |
---|
1085 | Wx::TreeCtrl->new( |
---|
1086 | $self, |
---|
1087 | -1, |
---|
1088 | wxDefaultPosition, |
---|
1089 | wxDefaultSize, |
---|
1090 | wxBORDER_NONE| |
---|
1091 | wxCLIP_CHILDREN| |
---|
1092 | # wxTR_MULTIPLE| |
---|
1093 | # wxTR_EXTENDED| |
---|
1094 | wxTR_HAS_BUTTONS |
---|
1095 | # wxTR_HIDE_ROOT |
---|
1096 | ) |
---|
1097 | ); |
---|
1098 | |
---|
1099 | $self->tree->SetImageList( $self->treeimglist ); |
---|
1100 | $self->populate_tree_categories if !wxTheApp->use_offline; |
---|
1101 | $self->tree ; |
---|
1102 | } |
---|
1103 | |
---|
1104 | |
---|
1105 | sub populate_tree_categories { |
---|
1106 | my ( $self ) = @_; |
---|
1107 | |
---|
1108 | $self->populate_tree( |
---|
1109 | $self->tree, |
---|
1110 | wxTheApp->pwg->categories, |
---|
1111 | ) if defined wxTheApp->pwg ; |
---|
1112 | |
---|
1113 | $self->tree->ExpandAll; |
---|
1114 | |
---|
1115 | } |
---|
1116 | |
---|
1117 | #$tree_items is a list of anonymous arrays |
---|
1118 | # [ itemLabel, undef, rootInfo, ImageIndex, SelImageIndex ] for the root |
---|
1119 | |
---|
1120 | # [ itemLabel, |
---|
1121 | # [ childItemLabel, |
---|
1122 | # [...], |
---|
1123 | # childItemdata, |
---|
1124 | # childImageIndex, |
---|
1125 | # childSelImageIndex |
---|
1126 | # ], |
---|
1127 | # Itemdata, |
---|
1128 | # ImageIndex, |
---|
1129 | # SelImageIndex |
---|
1130 | # ] |
---|
1131 | |
---|
1132 | # returns a valid itemData |
---|
1133 | sub itemData { Wx::TreeItemData->new( $_[0] ) } |
---|
1134 | |
---|
1135 | sub populate_tree { |
---|
1136 | my ( $self, $tree, $tree_items ) = @_; |
---|
1137 | my $root = shift @{$tree_items}; |
---|
1138 | $self->tree_root( |
---|
1139 | $tree->AddRoot( |
---|
1140 | $root->[0], |
---|
1141 | $root->[3], |
---|
1142 | $root->[4], |
---|
1143 | itemData( $root->[2] ) |
---|
1144 | ) |
---|
1145 | ); |
---|
1146 | |
---|
1147 | $self->populate_tree_helper( $tree, $self->tree_root, $tree_items ); |
---|
1148 | |
---|
1149 | $tree->Expand( $self->tree_root ); |
---|
1150 | } |
---|
1151 | |
---|
1152 | sub populate_tree_helper { |
---|
1153 | my ( $self, $tree, $parent_id, $tree_items ) = @_; |
---|
1154 | |
---|
1155 | my $id; |
---|
1156 | |
---|
1157 | map { |
---|
1158 | my $name = $_->[0]; |
---|
1159 | eval { |
---|
1160 | $name = is_utf8($name) ? decode('UTF-8', $name) : $name; |
---|
1161 | }; |
---|
1162 | if($@){ |
---|
1163 | $name = $_->[0]; |
---|
1164 | } |
---|
1165 | $id = $tree->AppendItem( |
---|
1166 | $parent_id, |
---|
1167 | $name, |
---|
1168 | defined($_->[3]) ? $_->[3] : 0, |
---|
1169 | defined($_->[4]) ? $_->[4] : 0, |
---|
1170 | itemData( $_->[2]) |
---|
1171 | ); |
---|
1172 | $self->tree_item_default($id) if ! defined $self->tree_item_default; |
---|
1173 | # current item has children |
---|
1174 | if( ref( $_->[1] ) eq 'ARRAY' ) { |
---|
1175 | $self->populate_tree_helper( $tree, $id, $_->[1] ); |
---|
1176 | } |
---|
1177 | } |
---|
1178 | @{$tree_items}; |
---|
1179 | |
---|
1180 | } |
---|
1181 | |
---|
1182 | |
---|
1183 | |
---|
1184 | |
---|
1185 | sub _populate_notebook { |
---|
1186 | my ( $self, $book, $pages, $position ) = @_; |
---|
1187 | |
---|
1188 | my $i = 0; |
---|
1189 | map { |
---|
1190 | my $icon = Wx::Icon->new(); |
---|
1191 | eval { $icon->LoadFile($_->[2], $_->[3]) ; } |
---|
1192 | if defined $_->[2]; |
---|
1193 | my $nb_icon = Wx::Bitmap->new( $icon ); |
---|
1194 | defined $position ? |
---|
1195 | $book->InsertPage($position, $_->[0], |
---|
1196 | $_->[1], 1, $nb_icon ) |
---|
1197 | : |
---|
1198 | $book->AddPage($_->[0], |
---|
1199 | $_->[1], 0, $nb_icon ); |
---|
1200 | |
---|
1201 | $i++; |
---|
1202 | } @$pages; |
---|
1203 | |
---|
1204 | } |
---|
1205 | |
---|
1206 | |
---|
1207 | |
---|
1208 | sub _InitEventHandlers { |
---|
1209 | my ( $self ) = @_ ; |
---|
1210 | |
---|
1211 | Wx::Event::EVT_MENU( $self, 101, \&OnAddImages ); |
---|
1212 | Wx::Event::EVT_MENU( $self, 102, \&OnRemoveImages ); |
---|
1213 | Wx::Event::EVT_MENU( $self, 103, \&OnUploadImages ); |
---|
1214 | Wx::Event::EVT_MENU( $self, 104, \&OnGlobalSettings ); |
---|
1215 | Wx::Event::EVT_MENU( $self, 105, \&OnChooseLanguage ); |
---|
1216 | EVT_TREE_SEL_CHANGED( $self, $self->tree, \&OnTreeSelChanged ); |
---|
1217 | EVT_TREE_ITEM_RIGHT_CLICK( $self->tree, $self->tree, \&OnTreeItemRightClick ); |
---|
1218 | EVT_LIST_END_LABEL_EDIT( $self, $self->imageviewer, \&OnImageViewerEndLabelEdit ); |
---|
1219 | EVT_LIST_ITEM_SELECTED($self, $self->imageviewer, \&OnImageViewerItemSelected) ; |
---|
1220 | EVT_LIST_KEY_DOWN($self, $self->imageviewer, \&OnImageViewerKeyDown) ; |
---|
1221 | EVT_CLOSE( $self, \&OnClose ); |
---|
1222 | Wx::Event::EVT_UPDATE_UI( $self, $self, \&OnUpdateUI ); |
---|
1223 | |
---|
1224 | |
---|
1225 | Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategories ); |
---|
1226 | Wx::Event::EVT_MENU( $self, 2+$ID_TREE_CTX_MENU, \&OnRefreshCategories ); |
---|
1227 | } |
---|
1228 | |
---|
1229 | { |
---|
1230 | my $prevdir; |
---|
1231 | my $prevfile; |
---|
1232 | |
---|
1233 | sub OnAddImages { |
---|
1234 | my( $self, $event ) = @_; |
---|
1235 | my $dialog = Wx::FileDialog->new |
---|
1236 | ( $self, "Select photos to send", $prevfile, $prevdir, |
---|
1237 | "JPEG files (*.jpg)|*.jpg|All(*.*)|*.*", |
---|
1238 | wxFD_OPEN|wxFD_MULTIPLE ); |
---|
1239 | |
---|
1240 | my $file_paths = []; |
---|
1241 | if( $dialog->ShowModal != wxID_CANCEL ) { |
---|
1242 | @$file_paths = $dialog->GetPaths; |
---|
1243 | $self->SetNewFiles($file_paths) ; |
---|
1244 | } |
---|
1245 | $dialog->Destroy; |
---|
1246 | $event->Skip; |
---|
1247 | } |
---|
1248 | } |
---|
1249 | |
---|
1250 | sub OnUpdateUI { |
---|
1251 | my( $self, $event ) = @_; |
---|
1252 | |
---|
1253 | if( $self->manager ){ |
---|
1254 | if($self->manager->GetPane("global_settings")->IsShown){ |
---|
1255 | $self->toolbar->EnableTool(104, 0); |
---|
1256 | } |
---|
1257 | else{ |
---|
1258 | $self->toolbar->EnableTool(104, 1); |
---|
1259 | } |
---|
1260 | } |
---|
1261 | } |
---|
1262 | |
---|
1263 | sub OnRemoveImages { |
---|
1264 | my( $self, $event ) = @_; |
---|
1265 | |
---|
1266 | |
---|
1267 | $self->imagelist->RemoveImageSelection; |
---|
1268 | $self->imageviewer->Refresh; |
---|
1269 | } |
---|
1270 | |
---|
1271 | sub SetNewFiles { |
---|
1272 | my ( $self, $file_paths ) = @_; |
---|
1273 | |
---|
1274 | $self->ShowImageViewer(); |
---|
1275 | $self->progressdlg( |
---|
1276 | Uploader::GUI::wxImageProcessingProgressDlg->new( |
---|
1277 | { |
---|
1278 | title => "Image processing progress information", |
---|
1279 | bt_label => "Cancel image processing", |
---|
1280 | } |
---|
1281 | ) |
---|
1282 | ); |
---|
1283 | $self->progressdlg->Show(1); |
---|
1284 | Wx::Yield(); |
---|
1285 | |
---|
1286 | my $files = [ |
---|
1287 | map { |
---|
1288 | encode('iso-8859-1', $_) |
---|
1289 | }@$file_paths |
---|
1290 | ]; |
---|
1291 | |
---|
1292 | # last is first ! |
---|
1293 | if ( scalar @$files > 1 ){ |
---|
1294 | my $first = shift @$files; |
---|
1295 | push @$files, $first; |
---|
1296 | } |
---|
1297 | #print Dumper $files; |
---|
1298 | |
---|
1299 | $self->imagelist->SetNewFiles( |
---|
1300 | $files |
---|
1301 | ); |
---|
1302 | |
---|
1303 | |
---|
1304 | } |
---|
1305 | |
---|
1306 | sub OnTreeSelChanged { |
---|
1307 | my( $self, $event ) = @_; |
---|
1308 | |
---|
1309 | my @items = $self->tree->GetSelections; |
---|
1310 | |
---|
1311 | $self->imagelist->categories( |
---|
1312 | [ |
---|
1313 | map { |
---|
1314 | my $category = $self->tree->GetPlData( $_ ); |
---|
1315 | $category->{id} if $category != -1; |
---|
1316 | } |
---|
1317 | @items |
---|
1318 | ] |
---|
1319 | ); |
---|
1320 | } |
---|
1321 | |
---|
1322 | sub OnTreeItemRightClick { |
---|
1323 | my( $self, $event ) = @_; |
---|
1324 | |
---|
1325 | my $point = $event->GetPoint ; |
---|
1326 | my $ctx_mnu = Wx::Menu->new; |
---|
1327 | |
---|
1328 | map { |
---|
1329 | $ctx_mnu->Append( |
---|
1330 | @$_ |
---|
1331 | ); |
---|
1332 | } |
---|
1333 | ( |
---|
1334 | [1+$ID_TREE_CTX_MENU, "Add new category","Add a new category to the current selected category."], |
---|
1335 | [2+$ID_TREE_CTX_MENU, "Refresh","Refresh category list."], |
---|
1336 | ); |
---|
1337 | $self->PopupMenu($ctx_mnu, $point); |
---|
1338 | |
---|
1339 | } |
---|
1340 | |
---|
1341 | sub OnAddCategories { |
---|
1342 | my ( $self, $event ) = @_; |
---|
1343 | |
---|
1344 | my $item = $self->tree->GetSelection; |
---|
1345 | |
---|
1346 | my $category = $self->tree->GetPlData($item); |
---|
1347 | my $category_id; |
---|
1348 | |
---|
1349 | $category_id = $category->{id} if 'HASH' eq ref($category) ; |
---|
1350 | |
---|
1351 | my $dialog = Wx::TextEntryDialog->new( |
---|
1352 | $self, |
---|
1353 | gettext("Category name :"), |
---|
1354 | gettext("Add new category"), |
---|
1355 | gettext("New category"), |
---|
1356 | ); |
---|
1357 | |
---|
1358 | if( $dialog->ShowModal != wxID_CANCEL ) { |
---|
1359 | my $name = $dialog->GetValue; |
---|
1360 | my ( $status, $status_msg ) = $self->pwg->AddCategories( $name, $category_id); |
---|
1361 | $self->_refresh_tree_categories_helper; |
---|
1362 | } |
---|
1363 | $dialog->Destroy; |
---|
1364 | } |
---|
1365 | |
---|
1366 | sub OnRefreshCategories { |
---|
1367 | my ( $self, $event ) = @_; |
---|
1368 | |
---|
1369 | $self->_refresh_tree_categories_helper; |
---|
1370 | } |
---|
1371 | |
---|
1372 | sub _refresh_tree_categories_helper { |
---|
1373 | my ( $self ) = @_; |
---|
1374 | |
---|
1375 | my $busycursor = Wx::BusyCursor->new(); |
---|
1376 | $self->tree->CollapseAll; |
---|
1377 | $self->tree->DeleteAllItems; |
---|
1378 | $self->imagelist->categories([]); |
---|
1379 | $self->pwg->RefreshCategories(); |
---|
1380 | $self->populate_tree_categories; |
---|
1381 | } |
---|
1382 | |
---|
1383 | sub OnImageViewerEndLabelEdit { |
---|
1384 | my( $self, $event ) = @_; |
---|
1385 | |
---|
1386 | my $image = $self->imagelist->GetImage($event->GetIndex); |
---|
1387 | $image->site_name( |
---|
1388 | $event->GetLabel |
---|
1389 | ); |
---|
1390 | |
---|
1391 | $self->image_prop_piwigo->Refresh; |
---|
1392 | } |
---|
1393 | |
---|
1394 | |
---|
1395 | sub OnImageViewerItemSelected { |
---|
1396 | my( $self, $event ) = @_; |
---|
1397 | |
---|
1398 | my $indx = $event->GetIndex; |
---|
1399 | |
---|
1400 | # retrieve photo info for the last selected photo |
---|
1401 | $self->imagelist->SetCurrentImage($indx); |
---|
1402 | |
---|
1403 | $self->imagelist->image_selection( |
---|
1404 | $self->imageviewer->GetSelectedItems |
---|
1405 | ); |
---|
1406 | |
---|
1407 | $self->image_preview->SetBitmap( |
---|
1408 | wxNullBitmap |
---|
1409 | ); |
---|
1410 | $self->image_preview->Refresh; |
---|
1411 | |
---|
1412 | |
---|
1413 | $self->image_preview->SetBitmap( |
---|
1414 | Wx::Bitmap->new( |
---|
1415 | $self->imagelist->current_image->preview_file, |
---|
1416 | $self->GetWxBitmapType($self->imagelist->type), |
---|
1417 | ) |
---|
1418 | ); |
---|
1419 | |
---|
1420 | $self->image_preview->Refresh; |
---|
1421 | |
---|
1422 | $self->manager->Update; |
---|
1423 | |
---|
1424 | $self->image_prop_piwigo->Refresh; |
---|
1425 | $self->image_prop_exif->Refresh; |
---|
1426 | |
---|
1427 | } |
---|
1428 | |
---|
1429 | sub OnImageViewerKeyDown { |
---|
1430 | my( $self, $event ) = @_; |
---|
1431 | |
---|
1432 | if(WXK_DELETE == $event->GetKeyCode){ |
---|
1433 | $self->OnRemoveImages(); |
---|
1434 | } |
---|
1435 | } |
---|
1436 | |
---|
1437 | sub OnUploadImages { |
---|
1438 | my( $self, $event ) = @_; |
---|
1439 | |
---|
1440 | eval { |
---|
1441 | $self->ProcessImageSelection(); |
---|
1442 | }; |
---|
1443 | } |
---|
1444 | |
---|
1445 | # remove image from imagelist when uploaded |
---|
1446 | sub UploadImagesViewerRefresh { |
---|
1447 | my ( $self ) = @_; |
---|
1448 | |
---|
1449 | my $imagelist= $self->imagelist ; |
---|
1450 | |
---|
1451 | Wx::Yield(); |
---|
1452 | } |
---|
1453 | |
---|
1454 | sub UploadProgressMessageRefresh { |
---|
1455 | my ( $self, $msg ) = @_; |
---|
1456 | |
---|
1457 | $self->upload_progressdlg->processing( |
---|
1458 | $msg |
---|
1459 | ); |
---|
1460 | |
---|
1461 | Wx::Yield(); |
---|
1462 | } |
---|
1463 | |
---|
1464 | sub UploadProgressThumbnailRefresh { |
---|
1465 | my ( $self ) = @_; |
---|
1466 | |
---|
1467 | my $imagelist = $self->imagelist ; |
---|
1468 | |
---|
1469 | |
---|
1470 | $self->upload_progressdlg->image->SetBitmap(wxNullBitmap); |
---|
1471 | $self->upload_progressdlg->image->SetBitmap( |
---|
1472 | Wx::Bitmap->new( |
---|
1473 | $self->imagelist->current_image->wx_thumb_file, |
---|
1474 | $self->GetWxBitmapType($self->imagelist->type), |
---|
1475 | ) |
---|
1476 | ); |
---|
1477 | |
---|
1478 | Wx::Yield(); |
---|
1479 | } |
---|
1480 | |
---|
1481 | sub UploadProgressBarRefresh { |
---|
1482 | my ( $self, $ratio ) = @_; |
---|
1483 | |
---|
1484 | $ratio = $self->imagelist->count > 1 ? 1 : $ratio; |
---|
1485 | eval { |
---|
1486 | $self->upload_progressdlg->progress( |
---|
1487 | $ratio*$self->imagelist->count * ( 100/scalar @{$self->imagelist->image_selection} ) |
---|
1488 | ); |
---|
1489 | $self->upload_progressdlg->LogProgress(); |
---|
1490 | }; |
---|
1491 | croak gettext("Upload cancelled") if $@; |
---|
1492 | |
---|
1493 | Wx::Yield(); |
---|
1494 | } |
---|
1495 | |
---|
1496 | sub SetNewFilesDisplayEndInfo { |
---|
1497 | my ( $self, $msg ) = @_; |
---|
1498 | |
---|
1499 | $self->progressdlg->DisplayEndInfo($msg); |
---|
1500 | } |
---|
1501 | |
---|
1502 | sub UploadDisplayEndInfo { |
---|
1503 | my ( $self, $msg ) = @_; |
---|
1504 | |
---|
1505 | my $imagelist = $self->imagelist ; |
---|
1506 | |
---|
1507 | $self->upload_progressdlg->DisplayEndInfo($msg); |
---|
1508 | } |
---|
1509 | |
---|
1510 | sub ShowImageViewer { |
---|
1511 | my ( $self ) = @_; |
---|
1512 | |
---|
1513 | if(!$self->imageviewer->IsShown){ |
---|
1514 | my $imglistpage = [ |
---|
1515 | [ |
---|
1516 | $self->imageviewer, |
---|
1517 | gettext("Photo selection"), |
---|
1518 | '../res/images.png', |
---|
1519 | wxBITMAP_TYPE_PNG, |
---|
1520 | ], |
---|
1521 | ]; |
---|
1522 | $self->notebook->DeletePage(0); |
---|
1523 | |
---|
1524 | $self->imageviewer->Show(1); |
---|
1525 | $self->_populate_notebook($self->notebook, $imglistpage, 0); |
---|
1526 | # load imagelist with loading.jpg |
---|
1527 | } |
---|
1528 | |
---|
1529 | } |
---|
1530 | |
---|
1531 | |
---|
1532 | |
---|
1533 | |
---|
1534 | sub SetNewFilesViewerRefresh { |
---|
1535 | |
---|
1536 | my ( $self ) = @_; |
---|
1537 | |
---|
1538 | my $wximagelist = $self->imagelist->wx_thumb_imglist; |
---|
1539 | |
---|
1540 | my $indx = $wximagelist->Add( |
---|
1541 | Wx::Bitmap->new( |
---|
1542 | $self->imagelist->current_image->wx_thumb_file, |
---|
1543 | $self->GetWxBitmapType($self->imagelist->type), |
---|
1544 | ) |
---|
1545 | ) if defined $self->imagelist->current_image->wx_thumb_file; |
---|
1546 | print $self->imagelist->current_image->wx_thumb_file, " added with index ", $indx, "\n"; |
---|
1547 | $self->imageviewer->Refresh( |
---|
1548 | $wximagelist |
---|
1549 | ); |
---|
1550 | |
---|
1551 | Wx::Yield(); |
---|
1552 | } |
---|
1553 | |
---|
1554 | |
---|
1555 | |
---|
1556 | # prepare and upload image_selection |
---|
1557 | sub ProcessImageSelection { |
---|
1558 | my ( $self ) = @_; |
---|
1559 | |
---|
1560 | return if !scalar @{$self->imagelist->sums}; |
---|
1561 | |
---|
1562 | if( scalar @{$self->imagelist->categories} ){ |
---|
1563 | return if( !defined $self->imagelist->image_selection ); |
---|
1564 | return if( !scalar @{$self->imagelist->image_selection} ); |
---|
1565 | |
---|
1566 | $self->upload_progressdlg( |
---|
1567 | Uploader::GUI::wxImageProcessingProgressDlg->new( |
---|
1568 | { |
---|
1569 | title => gettext("Image upload progress information"), |
---|
1570 | bt_label => gettext("Cancel upload"), |
---|
1571 | } |
---|
1572 | ) |
---|
1573 | ); |
---|
1574 | # modeless dialog |
---|
1575 | $self->upload_progressdlg->Show(1); |
---|
1576 | Wx::Yield(); |
---|
1577 | eval { |
---|
1578 | $self->imagelist->UploadSelection; |
---|
1579 | }; |
---|
1580 | if($@){ |
---|
1581 | Wx::MessageBox( |
---|
1582 | sprintf( |
---|
1583 | gettext("Upload cancelled"), |
---|
1584 | ), |
---|
1585 | gettext("Piwigo upload information"), |
---|
1586 | wxOK | wxICON_INFORMATION, |
---|
1587 | ); |
---|
1588 | } |
---|
1589 | } |
---|
1590 | else { |
---|
1591 | Wx::MessageBox( |
---|
1592 | sprintf( |
---|
1593 | gettext("Please select a valid target category"), |
---|
1594 | ), |
---|
1595 | gettext("Piwigo upload error"), |
---|
1596 | wxOK | wxICON_EXCLAMATION, |
---|
1597 | ); |
---|
1598 | } |
---|
1599 | } |
---|
1600 | |
---|
1601 | |
---|
1602 | sub SetNewFilesProgress { |
---|
1603 | my ( $self ) = @_; |
---|
1604 | |
---|
1605 | my $imagelist = $self->imagelist; |
---|
1606 | |
---|
1607 | $self->progressdlg->processing( |
---|
1608 | sprintf( |
---|
1609 | $imagelist->progress_msg, |
---|
1610 | $imagelist->current_image->file, |
---|
1611 | ) |
---|
1612 | ); |
---|
1613 | |
---|
1614 | eval { |
---|
1615 | $self->progressdlg->image->SetSize([ $imagelist->wx_thumb_size, $imagelist->wx_thumb_size]); |
---|
1616 | $self->progressdlg->image->SetBitmap(wxNullBitmap); |
---|
1617 | $self->progressdlg->image->SetBitmap( |
---|
1618 | Wx::Bitmap->new( |
---|
1619 | $imagelist->current_image->wx_thumb_file, |
---|
1620 | $self->GetWxBitmapType( $imagelist->type ) |
---|
1621 | ) |
---|
1622 | ); |
---|
1623 | $self->progressdlg->progress( |
---|
1624 | $imagelist->count * ( 100/scalar @{$imagelist->new_files} ) |
---|
1625 | ); |
---|
1626 | $self->progressdlg->LogProgress(); |
---|
1627 | }; |
---|
1628 | Wx::Yield(); |
---|
1629 | } |
---|
1630 | |
---|
1631 | sub OnClose { |
---|
1632 | my $self = shift; |
---|
1633 | |
---|
1634 | # Restaure previous log wnd |
---|
1635 | Wx::Log::SetActiveTarget( $self->oldlogwnd ); |
---|
1636 | |
---|
1637 | # allways store |
---|
1638 | |
---|
1639 | wxTheApp->StoreConnectionProperties; |
---|
1640 | |
---|
1641 | $self->imagelist->Store; |
---|
1642 | wxTheApp->login_dlg->Destroy; |
---|
1643 | $self->Destroy; |
---|
1644 | } |
---|
1645 | |
---|
1646 | |
---|
1647 | sub create_toolbar { |
---|
1648 | my( $self ) = @_; |
---|
1649 | |
---|
1650 | my $tb = Wx::ToolBar->new( $self, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT ); |
---|
1651 | $tb->SetToolBitmapSize( wxSIZE( 32, 32 ) ); |
---|
1652 | map { |
---|
1653 | my $icon1 = Wx::Icon->new(); |
---|
1654 | eval { |
---|
1655 | $icon1->LoadFile($_->[2], $_->[3]); |
---|
1656 | }; |
---|
1657 | my $tb_icon1 = Wx::Bitmap->new( $icon1 ); |
---|
1658 | |
---|
1659 | my $icon2 = Wx::Icon->new(); |
---|
1660 | eval { |
---|
1661 | $icon2->LoadFile($_->[5], $_->[3]); |
---|
1662 | }; |
---|
1663 | my $tb_icon2 = Wx::Bitmap->new( $icon2 ); |
---|
1664 | |
---|
1665 | |
---|
1666 | $tb->AddTool( $_->[0], $_->[1], $tb_icon1, $tb_icon2, wxITEM_NORMAL, $_->[1] ); |
---|
1667 | $tb->EnableTool( $_->[0], $_->[4]); |
---|
1668 | } |
---|
1669 | ( |
---|
1670 | [ |
---|
1671 | 101, |
---|
1672 | gettext("Add photo to selection"), |
---|
1673 | '../res/tb_add.png', |
---|
1674 | wxBITMAP_TYPE_PNG, |
---|
1675 | 1, |
---|
1676 | '../res/tb_add.png', |
---|
1677 | gettext("Add photo to selection for resizing and uploading") |
---|
1678 | ], |
---|
1679 | [ |
---|
1680 | 102, |
---|
1681 | gettext("Remove photo from selection"), |
---|
1682 | '../res/tb_remove.png', |
---|
1683 | wxBITMAP_TYPE_PNG, |
---|
1684 | 1, |
---|
1685 | '../res/tb_remove.png', |
---|
1686 | gettext("Remove photo from selection. Files are not deleted ") |
---|
1687 | ], |
---|
1688 | [ |
---|
1689 | 103, |
---|
1690 | gettext("Upload to Piwigo"), |
---|
1691 | '../res/tb_upload.png', |
---|
1692 | wxBITMAP_TYPE_PNG, |
---|
1693 | wxTheApp->use_offline ? 0 : 1, |
---|
1694 | '../res/tb_upload.png', |
---|
1695 | gettext("Upload photos to Piwigo.") |
---|
1696 | ], |
---|
1697 | [ |
---|
1698 | 104, |
---|
1699 | gettext("Global settings"), |
---|
1700 | '../res/tb_settings.png', |
---|
1701 | wxBITMAP_TYPE_PNG, |
---|
1702 | 0, |
---|
1703 | '../res/tb_settings.png', |
---|
1704 | gettext("Change global settings.") |
---|
1705 | ], |
---|
1706 | [ |
---|
1707 | 105, |
---|
1708 | gettext("Language choice"), |
---|
1709 | '../res/tb_i18n.png', |
---|
1710 | wxBITMAP_TYPE_PNG, |
---|
1711 | 1, |
---|
1712 | '../res/tb_i18n.png', |
---|
1713 | gettext("Language choice") |
---|
1714 | ], |
---|
1715 | |
---|
1716 | ); |
---|
1717 | |
---|
1718 | if($@){ |
---|
1719 | undef $tb; |
---|
1720 | } |
---|
1721 | else{ |
---|
1722 | $tb->Realize; |
---|
1723 | } |
---|
1724 | |
---|
1725 | return $tb; |
---|
1726 | } |
---|
1727 | |
---|
1728 | |
---|
1729 | sub _create_textctrl { |
---|
1730 | my( $self, $parent, $text, $size ) = @_; |
---|
1731 | |
---|
1732 | return Wx::TextCtrl->new( $parent, -1, $text, [0, 0], $size, |
---|
1733 | wxNO_BORDER | wxTE_MULTILINE | wxTE_READONLY ); |
---|
1734 | } |
---|
1735 | |
---|
1736 | sub create_textctrl { |
---|
1737 | my( $self, $text, $size ) = @_; |
---|
1738 | |
---|
1739 | return $self->_create_textctrl( $self, $text, $size ); |
---|
1740 | } |
---|
1741 | |
---|
1742 | sub DESTROY { |
---|
1743 | my( $self ) = @_; |
---|
1744 | |
---|
1745 | $self->manager->UnInit; |
---|
1746 | } |
---|
1747 | |
---|
1748 | |
---|
1749 | |
---|
1750 | 1; |
---|
1751 | |
---|
1752 | |
---|
1753 | |
---|
1754 | |
---|
1755 | |
---|
1756 | package DNDImageListDropTarget; |
---|
1757 | |
---|
1758 | use base qw(Wx::FileDropTarget Class::Accessor::Fast); |
---|
1759 | |
---|
1760 | __PACKAGE__->mk_accessors( |
---|
1761 | qw/ |
---|
1762 | imageviewer |
---|
1763 | frame |
---|
1764 | / |
---|
1765 | ); |
---|
1766 | |
---|
1767 | sub new { |
---|
1768 | my $class = shift; |
---|
1769 | my $imageviewer = shift; |
---|
1770 | my $self = $class->SUPER::new( @_ ); |
---|
1771 | |
---|
1772 | $self->imageviewer($imageviewer); |
---|
1773 | $self->frame($imageviewer->GetParent); |
---|
1774 | return $self; |
---|
1775 | } |
---|
1776 | |
---|
1777 | sub OnDropFiles { |
---|
1778 | my( $self, $x, $y, $files ) = @_; |
---|
1779 | |
---|
1780 | $self->frame->SetNewFiles($files) ; |
---|
1781 | } |
---|
1782 | |
---|
1783 | |
---|
1784 | |
---|
1785 | |
---|
1786 | 1; |
---|
1787 | |
---|
1788 | |
---|
1789 | package DNDCategoryTreeDropTarget; |
---|
1790 | |
---|
1791 | use base qw(Wx::TextDropTarget Class::Accessor::Fast); |
---|
1792 | use Data::Dumper; |
---|
1793 | use Wx qw/ |
---|
1794 | wxDragNone |
---|
1795 | wxDragCopy |
---|
1796 | wxDragMove |
---|
1797 | /; |
---|
1798 | |
---|
1799 | __PACKAGE__->mk_accessors( |
---|
1800 | qw/ |
---|
1801 | tree |
---|
1802 | frame |
---|
1803 | / |
---|
1804 | ); |
---|
1805 | |
---|
1806 | sub new { |
---|
1807 | my ( $class, $tree ) = @_; |
---|
1808 | my $self = $class->SUPER::new(); |
---|
1809 | |
---|
1810 | $self->tree($tree); |
---|
1811 | $self->frame($tree->GetParent); |
---|
1812 | return $self; |
---|
1813 | } |
---|
1814 | |
---|
1815 | |
---|
1816 | |
---|
1817 | sub OnDropText { |
---|
1818 | my( $self, $x, $y, $textdata ) = @_; |
---|
1819 | |
---|
1820 | # must be $VAR1 because $textdata is the result of Data::Dumper |
---|
1821 | my $VAR1; |
---|
1822 | eval $textdata; |
---|
1823 | eval { |
---|
1824 | if(scalar @$VAR1){ |
---|
1825 | my @items; |
---|
1826 | if(scalar @items < 2) { |
---|
1827 | my ($dropItem, $flag) = $self->tree->HitTest([$x, $y]); |
---|
1828 | push @items, $dropItem; |
---|
1829 | } |
---|
1830 | else { |
---|
1831 | @items = $self->tree->GetSelections; |
---|
1832 | } |
---|
1833 | |
---|
1834 | # remove root item which is not a valid category |
---|
1835 | @items = grep { $self->tree->GetPlData( $_ ) != -1 } @items; |
---|
1836 | |
---|
1837 | $self->frame->imagelist->categories( |
---|
1838 | [ |
---|
1839 | map { |
---|
1840 | $self->tree->GetPlData( $_ )->{id}; |
---|
1841 | } |
---|
1842 | @items |
---|
1843 | ] |
---|
1844 | ); |
---|
1845 | |
---|
1846 | $self->frame->imagelist->image_selection($VAR1); |
---|
1847 | $self->frame->ProcessImageSelection ; |
---|
1848 | } |
---|
1849 | }; |
---|
1850 | } |
---|
1851 | |
---|
1852 | 1; |
---|