[2597] | 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; |
---|
[2696] | 22 | use Carp; |
---|
[2597] | 23 | use Wx; |
---|
| 24 | use Wx::DND; |
---|
| 25 | use Wx qw/ |
---|
[3372] | 26 | wxITEM_NORMAL |
---|
[3178] | 27 | wxNullBitmap |
---|
[3159] | 28 | wxID_OK |
---|
[2597] | 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 |
---|
[2618] | 62 | wxMAXIMIZE |
---|
[2661] | 63 | wxOK |
---|
[2696] | 64 | wxICON_EXCLAMATION |
---|
[2731] | 65 | wxICON_INFORMATION |
---|
| 66 | WXK_DELETE |
---|
[3159] | 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 |
---|
[2597] | 297 | /; |
---|
| 298 | use base qw/Wx::Frame Class::Accessor::Fast/; |
---|
| 299 | use File::Spec; |
---|
[3159] | 300 | use Wx::Locale qw/:default/; |
---|
[3227] | 301 | use Encode qw/encode decode is_utf8/;; |
---|
[2597] | 302 | |
---|
[3141] | 303 | |
---|
[2597] | 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 |
---|
[3178] | 322 | image_preview |
---|
| 323 | image_prop_piwigo |
---|
[2597] | 324 | image_prop_exif |
---|
| 325 | notebook_image_properties |
---|
[3159] | 326 | notebook_global_settings |
---|
[3178] | 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 |
---|
[3227] | 337 | toolbar |
---|
[3284] | 338 | branding |
---|
| 339 | preview_w |
---|
| 340 | preview_h |
---|
| 341 | perspective |
---|
[3362] | 342 | current_imageviewer_index |
---|
[3372] | 343 | imageviewer_mnu |
---|
| 344 | tree_mnu |
---|
[3374] | 345 | imageviewer_select_multi |
---|
[2597] | 346 | /; |
---|
| 347 | __PACKAGE__->mk_accessors( @properties ); |
---|
| 348 | |
---|
| 349 | use Wx::Event |
---|
| 350 | qw/ |
---|
| 351 | EVT_MENU |
---|
| 352 | EVT_TREE_SEL_CHANGED |
---|
| 353 | EVT_CLOSE |
---|
| 354 | EVT_LIST_END_LABEL_EDIT |
---|
[2661] | 355 | EVT_LIST_ITEM_SELECTED |
---|
[3284] | 356 | EVT_LIST_ITEM_ACTIVATED |
---|
[3365] | 357 | EVT_LIST_ITEM_RIGHT_CLICK |
---|
[2731] | 358 | EVT_TREE_ITEM_RIGHT_CLICK |
---|
[3227] | 359 | EVT_LIST_KEY_DOWN |
---|
| 360 | EVT_UPDATE_UI |
---|
[2597] | 361 | /; |
---|
| 362 | |
---|
| 363 | use Uploader::GUI::wxImageListCtrl; |
---|
[3357] | 364 | use Uploader::GUI::wxImagePreview; |
---|
[2597] | 365 | use Uploader::GUI::wxImageProcessingProgressDlg; |
---|
| 366 | use Wx::Html; |
---|
| 367 | use Uploader::GUI::wxHtmlWindow; |
---|
| 368 | use Data::Dumper; |
---|
| 369 | use Wx::AUI; |
---|
| 370 | use Storable; |
---|
[3178] | 371 | use Uploader::GUI::wxPropertyGridPanel; |
---|
[2661] | 372 | use Encode qw/encode decode is_utf8/; |
---|
[2597] | 373 | |
---|
| 374 | $|=1; |
---|
| 375 | |
---|
[2661] | 376 | my $ID_TREE_CTX_MENU = 20000 ; |
---|
[3365] | 377 | my $ID_IMAGEVIEWER_CTX_MENU = 20100 ; |
---|
[2661] | 378 | |
---|
[2597] | 379 | sub new { |
---|
| 380 | my( $class, $params ) = @_; |
---|
| 381 | my( $self ) = $class->SUPER::new( |
---|
| 382 | undef, |
---|
| 383 | -1, |
---|
| 384 | $params->{title}, |
---|
| 385 | [ $params->{x}, $params->{y} ], |
---|
| 386 | [ $params->{width}, $params->{height} ], |
---|
[3365] | 387 | wxDEFAULT_FRAME_STYLE |
---|
[2597] | 388 | ); |
---|
[3284] | 389 | $self->preview_w( |
---|
| 390 | $params->{preview_w}||400 |
---|
| 391 | ); |
---|
| 392 | |
---|
| 393 | $self->preview_h( |
---|
| 394 | $params->{preview_h}||300 |
---|
| 395 | ); |
---|
| 396 | |
---|
| 397 | $self->perspective( |
---|
| 398 | $params->{perspective} |
---|
| 399 | ); |
---|
[3362] | 400 | |
---|
| 401 | $self->current_imageviewer_index( |
---|
| 402 | $params->{imageviewer_index}||0 |
---|
| 403 | ); |
---|
[3284] | 404 | |
---|
[2597] | 405 | $self->pwg( $params->{pwg} ); |
---|
| 406 | $self->imagelist( $params->{imagelist} ); |
---|
| 407 | |
---|
| 408 | # callback for GUI refresh : add thumbnail images to the imageviewer control |
---|
| 409 | $self->imagelist->SetNewFilesViewerRefreshCallback( |
---|
| 410 | sub { $self->SetNewFilesViewerRefresh(@_) } |
---|
| 411 | ); |
---|
| 412 | |
---|
| 413 | # callback for GUI refresh : progress dialog display of thumbnail image being created |
---|
| 414 | $self->imagelist->SetNewFilesProgressCallback( |
---|
| 415 | sub { $self->SetNewFilesProgress(@_) } |
---|
| 416 | ); |
---|
| 417 | |
---|
[2696] | 418 | $self->imagelist->SetNewFilesDisplayEndInfoCallback( |
---|
| 419 | sub { $self->SetNewFilesDisplayEndInfo(@_) } |
---|
| 420 | ); |
---|
| 421 | |
---|
| 422 | |
---|
[2597] | 423 | # callback for GUI refresh : remove thumbnail images from imageviewer control |
---|
| 424 | $self->imagelist->UploadImagesViewerCallback( |
---|
| 425 | sub { $self->UploadImagesViewerRefresh(@_) } |
---|
| 426 | ); |
---|
| 427 | |
---|
[2696] | 428 | |
---|
| 429 | |
---|
[2728] | 430 | # callback for GUI refresh : progress dialog display current uploaded image |
---|
| 431 | $self->imagelist->progress_thumbnail_refresh( |
---|
| 432 | sub { $self->UploadProgressThumbnailRefresh(@_) } |
---|
[2597] | 433 | ); |
---|
[2728] | 434 | |
---|
| 435 | $self->imagelist->progress_msg_refresh( |
---|
| 436 | sub { $self->UploadProgressMessageRefresh(@_) } |
---|
| 437 | ); |
---|
| 438 | |
---|
| 439 | |
---|
| 440 | $self->imagelist->progressbar_refresh( |
---|
| 441 | sub { $self->UploadProgressBarRefresh(@_) } |
---|
| 442 | ); |
---|
[2696] | 443 | |
---|
[2728] | 444 | $self->imagelist->progress_endinfo_refresh( |
---|
[2696] | 445 | sub { $self->UploadDisplayEndInfo(@_) } |
---|
| 446 | ); |
---|
[2597] | 447 | |
---|
| 448 | |
---|
| 449 | $self->imagelist->pwg( |
---|
| 450 | $self->pwg |
---|
| 451 | ); |
---|
| 452 | |
---|
[2661] | 453 | $self->imagelist->categories( |
---|
| 454 | [] |
---|
| 455 | ); |
---|
| 456 | |
---|
[3284] | 457 | |
---|
[2597] | 458 | $self->manager( Wx::AuiManager->new ); |
---|
| 459 | $self->manager->SetManagedWindow( $self ); |
---|
[3178] | 460 | $self->_set_setting_properties; |
---|
[2597] | 461 | $self->_initFrame; |
---|
[3372] | 462 | $self->_initMenus; |
---|
| 463 | $self->_initEventHandlers; |
---|
[2597] | 464 | $self->_initImgTypes; |
---|
[3362] | 465 | |
---|
| 466 | |
---|
| 467 | $self->imageviewer->SelectItem( |
---|
| 468 | $self->current_imageviewer_index |
---|
| 469 | ) if $self->imageviewer->GetItemCount; |
---|
[2597] | 470 | |
---|
| 471 | $self; |
---|
| 472 | } |
---|
| 473 | |
---|
[3284] | 474 | |
---|
[2597] | 475 | sub _initImgTypes { |
---|
| 476 | my ( $self ) = @_; |
---|
| 477 | |
---|
| 478 | $self->{IMGTYPE} = { |
---|
| 479 | 'jpg' => wxBITMAP_TYPE_JPEG, |
---|
| 480 | 'gif' => wxBITMAP_TYPE_GIF, |
---|
| 481 | 'png' => wxBITMAP_TYPE_PNG, |
---|
| 482 | }; |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | |
---|
| 486 | sub GetWxBitmapType { |
---|
| 487 | my ( $self, $type ) = @_; |
---|
| 488 | |
---|
| 489 | $self->{IMGTYPE}->{$type}; |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | |
---|
[3159] | 493 | |
---|
[3178] | 494 | sub _set_setting_properties { |
---|
| 495 | my ( $self ) = @_; |
---|
| 496 | |
---|
| 497 | $self->piwigo_properties( |
---|
| 498 | [ |
---|
| 499 | { |
---|
[3284] | 500 | label => gettext("Photo caption :"), |
---|
[3178] | 501 | value => sub { $self->imagelist->current_image->site_name(@_) }, |
---|
| 502 | }, |
---|
| 503 | { |
---|
[3227] | 504 | label => gettext("Comment :"), |
---|
[3178] | 505 | value => sub { $self->imagelist->current_image->site_comment(@_) }, |
---|
| 506 | type => "LongText", |
---|
| 507 | }, |
---|
| 508 | { |
---|
[3227] | 509 | label => gettext("Author :"), |
---|
[3178] | 510 | value => sub { $self->imagelist->current_image->site_author(@_) }, |
---|
| 511 | }, |
---|
| 512 | { |
---|
[3227] | 513 | label => gettext("File name :"), |
---|
[3198] | 514 | value => sub { $self->imagelist->current_image->file(@_) }, |
---|
| 515 | readonly => 1, |
---|
| 516 | }, |
---|
| 517 | { |
---|
[3227] | 518 | label => gettext("Create date :"), |
---|
[3178] | 519 | value => sub { $self->imagelist->current_image->create_date(@_) }, |
---|
| 520 | readonly => 1, |
---|
| 521 | }, |
---|
| 522 | ] |
---|
| 523 | ); |
---|
| 524 | |
---|
| 525 | $self->exif_properties( |
---|
| 526 | [ |
---|
| 527 | { |
---|
| 528 | label => gettext("Create date :"), |
---|
| 529 | value => sub { $self->imagelist->current_image->create_date }, |
---|
| 530 | readonly => 1, |
---|
| 531 | }, |
---|
| 532 | { |
---|
| 533 | label => gettext("Model :"), |
---|
| 534 | value => sub { $self->imagelist->current_image->exif_tag('Model') }, |
---|
| 535 | readonly => 1, |
---|
| 536 | }, |
---|
| 537 | { |
---|
| 538 | label => gettext("Width :"), |
---|
| 539 | value => sub { $self->imagelist->current_image->exif_tag('ImageWidth') }, |
---|
| 540 | readonly => 1, |
---|
| 541 | }, |
---|
| 542 | { |
---|
| 543 | label => gettext("Height :"), |
---|
| 544 | value => sub { $self->imagelist->current_image->exif_tag('ImageHeight') }, |
---|
| 545 | readonly => 1, |
---|
| 546 | }, |
---|
| 547 | { |
---|
| 548 | label => gettext("Orientation :"), |
---|
| 549 | value => sub { $self->imagelist->current_image->exif_tag('Orientation') }, |
---|
| 550 | readonly => 1, |
---|
| 551 | }, |
---|
| 552 | { |
---|
| 553 | label => "ISO :", |
---|
| 554 | value => sub { $self->imagelist->current_image->exif_tag('ISO') }, |
---|
| 555 | readonly => 1, |
---|
| 556 | }, |
---|
| 557 | { |
---|
| 558 | label => gettext("Shutter speed :"), |
---|
| 559 | value => sub { $self->imagelist->current_image->exif_tag('ExposureTime') }, |
---|
| 560 | readonly => 1, |
---|
| 561 | }, |
---|
| 562 | { |
---|
| 563 | label => gettext("Aperture :"), |
---|
| 564 | value => sub { $self->imagelist->current_image->exif_tag('ApertureValue') }, |
---|
| 565 | readonly => 1, |
---|
| 566 | }, |
---|
| 567 | { |
---|
| 568 | label => gettext("Focal length :"), |
---|
| 569 | value => sub { $self->imagelist->current_image->exif_tag('FocalLength') }, |
---|
| 570 | readonly => 1, |
---|
| 571 | }, |
---|
| 572 | { |
---|
| 573 | label => gettext("Lens :"), |
---|
| 574 | value => sub { $self->imagelist->current_image->exif_tag('Lens') }, |
---|
| 575 | readonly => 1, |
---|
| 576 | }, |
---|
| 577 | ] |
---|
| 578 | ); |
---|
| 579 | |
---|
| 580 | $self->general_settings( |
---|
| 581 | [ |
---|
| 582 | { |
---|
| 583 | label => gettext("Default author :"), |
---|
| 584 | value => sub { $self->imagelist->author(@_) }, |
---|
| 585 | }, |
---|
| 586 | { |
---|
[3284] | 587 | label => gettext("Default photo caption :"), |
---|
[3267] | 588 | type => 'Choice', |
---|
| 589 | value => sub { $self->imagelist->default_photo_name(@_) }, |
---|
| 590 | choice => [ |
---|
| 591 | gettext('None'), |
---|
| 592 | gettext('File name'), |
---|
| 593 | gettext('File path and name'), |
---|
| 594 | gettext('Prefix'), |
---|
| 595 | gettext('Prefix + rank number'), |
---|
| 596 | gettext('Rank number + prefix'), |
---|
| 597 | gettext('Prefix + create date chrono'), |
---|
| 598 | gettext('Create date chrono + prefix'), |
---|
| 599 | ], |
---|
| 600 | }, |
---|
| 601 | { |
---|
[3284] | 602 | label => gettext("Photo caption prefix :"), |
---|
[3178] | 603 | value => sub { $self->imagelist->default_name_prefix(@_) }, |
---|
| 604 | }, |
---|
| 605 | { |
---|
| 606 | label => gettext("Resize site image :"), |
---|
| 607 | type => 'Bool', |
---|
| 608 | value => sub { $self->imagelist->create_resized(@_) }, |
---|
| 609 | }, |
---|
| 610 | { |
---|
| 611 | label => gettext("Auto rotate image :"), |
---|
| 612 | type => 'Bool', |
---|
| 613 | value => sub { $self->imagelist->auto_rotate(@_) }, |
---|
| 614 | }, |
---|
| 615 | { |
---|
| 616 | label => gettext("Upload high (original size) :"), |
---|
| 617 | type => 'Bool', |
---|
| 618 | value => sub { $self->imagelist->upload_high(@_) }, |
---|
| 619 | }, |
---|
[3387] | 620 | { |
---|
| 621 | label => gettext("Remove uploaded photo from selection :"), |
---|
| 622 | type => 'Bool', |
---|
| 623 | value => sub { $self->imagelist->remove_uploaded_from_selection(@_) }, |
---|
| 624 | }, |
---|
[3178] | 625 | ] |
---|
| 626 | ); |
---|
| 627 | |
---|
| 628 | $self->resized_settings( |
---|
| 629 | [ |
---|
| 630 | { |
---|
| 631 | label => gettext("Site image width :"), |
---|
| 632 | type => 'Number', |
---|
| 633 | value => sub { $self->imagelist->resize_w(@_) }, |
---|
| 634 | }, |
---|
| 635 | { |
---|
| 636 | label => gettext("Site image height :"), |
---|
| 637 | type => 'Number', |
---|
| 638 | value => sub { $self->imagelist->resize_h(@_) }, |
---|
| 639 | }, |
---|
| 640 | { |
---|
| 641 | label => gettext("Site image jpeg quality :"), |
---|
| 642 | type => 'Number', |
---|
| 643 | value => sub { $self->imagelist->quality(@_) }, |
---|
| 644 | }, |
---|
| 645 | { |
---|
| 646 | label => gettext("Site image filter :"), |
---|
| 647 | type => 'Choice', |
---|
| 648 | value => sub { $self->imagelist->filter(@_) }, |
---|
| 649 | choice => [ qw/Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc/ ], |
---|
| 650 | }, |
---|
| 651 | { |
---|
| 652 | label => gettext("Site image blur :"), |
---|
| 653 | type => 'Number', |
---|
| 654 | value => sub { $self->imagelist->blur(@_) }, |
---|
| 655 | }, |
---|
| 656 | { |
---|
| 657 | label => gettext("Site image interlace :"), |
---|
| 658 | type => 'Choice', |
---|
| 659 | value => sub { $self->imagelist->interlace(@_) }, |
---|
| 660 | choice => [ qw/None Line Plane Partition JPEG GIF PNG/ ], |
---|
| 661 | }, |
---|
| 662 | ] |
---|
| 663 | ); |
---|
| 664 | |
---|
| 665 | $self->thumbnail_settings( |
---|
| 666 | [ |
---|
| 667 | { |
---|
| 668 | label => gettext("Site thumbnail size :"), |
---|
| 669 | type => 'Number', |
---|
| 670 | value => sub { $self->imagelist->thumb_size(@_) }, |
---|
| 671 | }, |
---|
| 672 | { |
---|
| 673 | label => gettext("Site thumbnail jpeg quality :"), |
---|
| 674 | type => 'Number', |
---|
| 675 | value => sub { $self->imagelist->th_quality(@_) }, |
---|
| 676 | }, |
---|
| 677 | { |
---|
| 678 | label => gettext("Photo selection thumbnail size :"), |
---|
| 679 | type => 'Number', |
---|
| 680 | value => sub { $self->imagelist->wx_thumb_size(@_) }, |
---|
| 681 | }, |
---|
| 682 | { |
---|
| 683 | label => gettext("Photo selection thumbnail jpeg quality :"), |
---|
| 684 | type => 'Number', |
---|
| 685 | value => sub { $self->imagelist->wx_quality(@_) }, |
---|
| 686 | }, |
---|
| 687 | ] |
---|
| 688 | ); |
---|
| 689 | |
---|
| 690 | $self->preview_settings( |
---|
| 691 | [ |
---|
| 692 | { |
---|
| 693 | label => gettext("Use exif preview when available :"), |
---|
| 694 | type => 'Bool', |
---|
| 695 | value => sub { $self->imagelist->use_exif_preview(@_) }, |
---|
| 696 | }, |
---|
| 697 | { |
---|
| 698 | label => gettext("Custom preview ratio :"), |
---|
| 699 | type => 'Number', |
---|
| 700 | value => sub { $self->imagelist->preview_ratio(@_) }, |
---|
| 701 | }, |
---|
| 702 | ] |
---|
| 703 | ); |
---|
| 704 | |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | sub _refreshFrame { |
---|
| 708 | my ( $self ) = @_; |
---|
| 709 | |
---|
| 710 | $self->_set_setting_properties; |
---|
| 711 | $self->_refresh_settings_panels_properties; |
---|
| 712 | map { |
---|
| 713 | $_->Refresh; |
---|
| 714 | } |
---|
| 715 | ( |
---|
| 716 | $self->image_prop_piwigo, |
---|
| 717 | $self->image_prop_exif, |
---|
| 718 | $self->general_settings_panel, |
---|
| 719 | $self->resized_settings_panel, |
---|
| 720 | $self->thumbnail_settings_panel, |
---|
| 721 | $self->preview_settings_panel, |
---|
| 722 | ); |
---|
| 723 | |
---|
| 724 | $self->manager->Update; |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | |
---|
[3159] | 728 | sub _destroy_settings_panels { |
---|
| 729 | my ( $self ) = @_; |
---|
| 730 | |
---|
| 731 | |
---|
| 732 | |
---|
| 733 | map { |
---|
| 734 | $self->manager->DetachPane( |
---|
| 735 | $_ |
---|
| 736 | ); |
---|
| 737 | $_->Show(0); |
---|
| 738 | $_->Destroy; |
---|
| 739 | }( |
---|
| 740 | $self->notebook_global_settings, |
---|
| 741 | $self->notebook_image_properties, |
---|
| 742 | ); |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | # |
---|
[2597] | 746 | sub _initFrame { |
---|
| 747 | my ( $self ) = @_; |
---|
| 748 | |
---|
[3141] | 749 | |
---|
[3159] | 750 | $self->init_panels; |
---|
| 751 | |
---|
| 752 | $self->init_aui; |
---|
| 753 | $self->init_dnd_targets; |
---|
[3357] | 754 | |
---|
[3159] | 755 | if( $self->imagelist->wx_thumb_imglist->GetImageCount){ |
---|
[3269] | 756 | printf("%s images\n", $self->imagelist->wx_thumb_imglist->GetImageCount); |
---|
[3159] | 757 | $self->ShowImageViewer; |
---|
| 758 | |
---|
| 759 | $self->imageviewer->Refresh( |
---|
| 760 | $self->imagelist->wx_thumb_imglist |
---|
| 761 | ); |
---|
[3362] | 762 | |
---|
[3159] | 763 | } |
---|
| 764 | |
---|
| 765 | } |
---|
| 766 | |
---|
[3178] | 767 | sub _refresh_settings_panels_properties { |
---|
[3159] | 768 | my ( $self ) = @_; |
---|
| 769 | |
---|
[3178] | 770 | $self->image_prop_piwigo->properties( |
---|
| 771 | $self->piwigo_properties |
---|
| 772 | ); |
---|
[2597] | 773 | |
---|
[3178] | 774 | $self->image_prop_exif->properties( |
---|
| 775 | $self->exif_properties |
---|
| 776 | ); |
---|
[3159] | 777 | |
---|
[3178] | 778 | |
---|
| 779 | $self->general_settings_panel->properties( |
---|
| 780 | $self->general_settings |
---|
| 781 | ); |
---|
| 782 | |
---|
| 783 | $self->resized_settings_panel->properties( |
---|
| 784 | $self->resized_settings |
---|
| 785 | ); |
---|
| 786 | |
---|
| 787 | $self->thumbnail_settings_panel->properties( |
---|
| 788 | $self->thumbnail_settings, |
---|
| 789 | ); |
---|
| 790 | |
---|
| 791 | $self->preview_settings_panel->properties( |
---|
| 792 | $self->preview_settings, |
---|
| 793 | ); |
---|
| 794 | |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | sub _init_settings_panels { |
---|
| 798 | my ( $self ) = @_; |
---|
| 799 | |
---|
| 800 | $self->image_prop_piwigo( |
---|
| 801 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
[2597] | 802 | { |
---|
[3178] | 803 | parentwnd => $self, |
---|
| 804 | properties => $self->piwigo_properties, |
---|
| 805 | frame_callbacks => [ |
---|
[2661] | 806 | sub { |
---|
| 807 | $self->imageviewer->Refresh(); |
---|
| 808 | }, |
---|
[3178] | 809 | ], |
---|
[2597] | 810 | } |
---|
| 811 | ) |
---|
| 812 | ); |
---|
| 813 | |
---|
| 814 | $self->image_prop_exif( |
---|
[3178] | 815 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
[2597] | 816 | { |
---|
[3178] | 817 | parentwnd => $self, |
---|
| 818 | frame_callbacks => [], |
---|
| 819 | properties => $self->exif_properties, |
---|
[2597] | 820 | } |
---|
| 821 | ) |
---|
| 822 | ); |
---|
[3178] | 823 | |
---|
| 824 | |
---|
| 825 | $self->general_settings_panel( |
---|
| 826 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
| 827 | { |
---|
| 828 | parentwnd => $self, |
---|
| 829 | properties => $self->general_settings, |
---|
| 830 | frame_callbacks => [], |
---|
| 831 | } |
---|
| 832 | ) |
---|
| 833 | ); |
---|
| 834 | |
---|
| 835 | $self->resized_settings_panel( |
---|
| 836 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
| 837 | { |
---|
| 838 | parentwnd => $self, |
---|
| 839 | properties => $self->resized_settings, |
---|
| 840 | frame_callbacks => [], |
---|
| 841 | |
---|
| 842 | } |
---|
| 843 | ) |
---|
| 844 | ); |
---|
| 845 | |
---|
| 846 | $self->thumbnail_settings_panel( |
---|
| 847 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
| 848 | { |
---|
| 849 | parentwnd => $self, |
---|
| 850 | properties => $self->thumbnail_settings, |
---|
| 851 | frame_callbacks => [], |
---|
| 852 | |
---|
| 853 | } |
---|
| 854 | ) |
---|
| 855 | ); |
---|
| 856 | $self->preview_settings_panel( |
---|
| 857 | Uploader::GUI::wxPropertyGridPanel->new( |
---|
| 858 | { |
---|
| 859 | parentwnd => $self, |
---|
| 860 | properties => $self->preview_settings, |
---|
| 861 | frame_callbacks => [], |
---|
| 862 | |
---|
| 863 | } |
---|
| 864 | ) |
---|
| 865 | ); |
---|
[3159] | 866 | |
---|
[3178] | 867 | $self->general_settings_panel->Show(0); |
---|
| 868 | |
---|
| 869 | $self->image_preview( |
---|
[3357] | 870 | Uploader::GUI::wxImagePreview->new( |
---|
| 871 | $self, |
---|
| 872 | -1, |
---|
| 873 | wxNullBitmap, |
---|
| 874 | wxDefaultPosition, |
---|
| 875 | [$self->preview_w, $self->preview_h] |
---|
| 876 | ) |
---|
| 877 | ); |
---|
[3178] | 878 | |
---|
[3357] | 879 | |
---|
[3178] | 880 | $self->image_prop_piwigo->Show(0); |
---|
| 881 | |
---|
[3159] | 882 | $self->image_prop_exif->Show(0); |
---|
| 883 | |
---|
| 884 | } |
---|
[2597] | 885 | |
---|
[3159] | 886 | sub init_panels { |
---|
| 887 | my ( $self ) = @_; |
---|
[2597] | 888 | |
---|
[3357] | 889 | my $file = sprintf( |
---|
| 890 | "../locale/%s/gs.html", |
---|
| 891 | wxTheApp->locale->GetCanonicalName |
---|
| 892 | ); |
---|
| 893 | |
---|
[3159] | 894 | $self->htmlhome( |
---|
| 895 | Uploader::GUI::wxHtmlWindow->new( |
---|
[3357] | 896 | $self, -1, [-1, -1], [450, 450] |
---|
[3159] | 897 | ) |
---|
| 898 | ); |
---|
| 899 | |
---|
[3357] | 900 | $self->htmlhome->LoadPage($file) if -e $file ; |
---|
| 901 | |
---|
| 902 | $self->htmlhome->InitHrefCallbacks( |
---|
| 903 | { |
---|
| 904 | new_album => sub {$self->OnAddCategories(@_) }, |
---|
| 905 | add_photos => sub { $self->OnAddImages(@_) }, |
---|
| 906 | upload_photos => sub { $self->ProcessImageSelection(@_)}, |
---|
| 907 | } |
---|
| 908 | ); |
---|
| 909 | |
---|
[3159] | 910 | $self->imageviewer( |
---|
| 911 | Uploader::GUI::wxImageListCtrl->new( |
---|
| 912 | { |
---|
| 913 | parentwnd => $self, |
---|
| 914 | imagelist => $self->imagelist, |
---|
| 915 | } |
---|
| 916 | ) |
---|
| 917 | ); |
---|
| 918 | |
---|
| 919 | $self->_init_settings_panels; |
---|
| 920 | } |
---|
[2597] | 921 | |
---|
[3159] | 922 | sub init_dnd_targets { |
---|
| 923 | my ( $self ) = @_; |
---|
| 924 | |
---|
[2597] | 925 | $self->imageviewer->SetDropTarget( |
---|
| 926 | DNDImageListDropTarget->new( |
---|
| 927 | $self->imageviewer |
---|
| 928 | ) |
---|
| 929 | ); |
---|
[3357] | 930 | #$self->htmlhome->SetDropTarget( |
---|
| 931 | # DNDImageListDropTarget->new( |
---|
| 932 | # $self->imageviewer |
---|
| 933 | # ) |
---|
| 934 | #); |
---|
[2597] | 935 | |
---|
| 936 | |
---|
| 937 | $self->tree->SetDropTarget( |
---|
| 938 | DNDCategoryTreeDropTarget->new( |
---|
| 939 | $self->tree |
---|
| 940 | ) |
---|
| 941 | ); |
---|
[3159] | 942 | |
---|
| 943 | } |
---|
[2597] | 944 | |
---|
[3159] | 945 | sub init_aui { |
---|
[3227] | 946 | my ( $self ) = @_; |
---|
[3284] | 947 | |
---|
[3227] | 948 | my $url = wxTheApp->site_url; |
---|
| 949 | |
---|
| 950 | $url = gettext("empty - work Offline") if wxTheApp->use_offline; |
---|
[2597] | 951 | |
---|
| 952 | $self->manager->AddPane |
---|
[3159] | 953 | ( $self->create_notebook_imagelist, Wx::AuiPaneInfo->new->Name( "ImageViewer" ) |
---|
[3357] | 954 | ->CenterPane->Position(1)->Resizable->CloseButton(0) ); |
---|
[2597] | 955 | |
---|
| 956 | $self->manager->AddPane |
---|
[3287] | 957 | ( $self->create_tree, Wx::AuiPaneInfo->new->Name( "categories" ) |
---|
[3159] | 958 | ->Right->Position( 0 )->Resizable->CloseButton(0) ); |
---|
[2597] | 959 | |
---|
[3178] | 960 | |
---|
| 961 | |
---|
[3159] | 962 | $self->_init_aui_settings_panels; |
---|
[2597] | 963 | |
---|
[3227] | 964 | $self->toolbar( |
---|
| 965 | $self->create_toolbar |
---|
| 966 | ); |
---|
[2597] | 967 | |
---|
| 968 | $self->manager->AddPane |
---|
[3287] | 969 | ( $self->toolbar, Wx::AuiPaneInfo->new->Name( "tb1" ) |
---|
[3227] | 970 | ->ToolbarPane->Top->Row( 1 )->LeftDockable( 0 )->RightDockable( 0 ) ) if defined $self->toolbar; |
---|
[2597] | 971 | |
---|
[3362] | 972 | if($self->perspective){ |
---|
[3357] | 973 | $self->manager->LoadPerspective($self->perspective) if $self->perspective =~ /getting_started/; |
---|
[3284] | 974 | } |
---|
[3287] | 975 | |
---|
| 976 | $self->manager->GetPane("categories")->Caption( |
---|
| 977 | sprintf("%s - %s", sprintf("Piwigo %s", wxTheApp->branding->{categories}), $url ) |
---|
| 978 | ); |
---|
| 979 | |
---|
| 980 | $self->manager->GetPane("preview")->Caption(gettext("Preview")); |
---|
| 981 | $self->manager->GetPane("tb1")->Caption( gettext("Tools") ); |
---|
| 982 | $self->manager->GetPane("photo_properties")->Caption(gettext("Photo properties")); |
---|
| 983 | $self->manager->GetPane("global_settings")->Caption(gettext("Global settings")); |
---|
[3357] | 984 | $self->manager->GetPane("getting_started")->Caption(gettext("Getting started")); |
---|
[3287] | 985 | |
---|
[3284] | 986 | |
---|
[2597] | 987 | $self->manager->Update; |
---|
| 988 | |
---|
[3159] | 989 | } |
---|
[2597] | 990 | |
---|
[3159] | 991 | sub _init_aui_settings_panels { |
---|
| 992 | my ( $self ) = @_; |
---|
| 993 | |
---|
| 994 | $self->manager->AddPane |
---|
[3357] | 995 | ( $self->image_preview, Wx::AuiPaneInfo->new->Name( "preview" ) |
---|
[3383] | 996 | ->Floatable(1)->Fixed->CloseButton(1)); |
---|
[3357] | 997 | |
---|
| 998 | |
---|
| 999 | $self->manager->AddPane |
---|
| 1000 | ( $self->htmlhome, Wx::AuiPaneInfo->new->Name( "getting_started" ) |
---|
| 1001 | ->Floatable(1)->Resizable->CloseButton(1) ); |
---|
| 1002 | |
---|
| 1003 | |
---|
| 1004 | $self->manager->AddPane |
---|
[3287] | 1005 | ( $self->create_notebook_image_properties, Wx::AuiPaneInfo->new->Name( "photo_properties" ) |
---|
[3284] | 1006 | ->Floatable(1)->Resizable->CloseButton(1) ); |
---|
[3159] | 1007 | |
---|
| 1008 | $self->manager->AddPane |
---|
[3287] | 1009 | ( $self->create_notebook_global_settings, Wx::AuiPaneInfo->new->Name( "global_settings" ) |
---|
[3284] | 1010 | ->Floatable(1)->Resizable->CloseButton(1) ); |
---|
[3269] | 1011 | |
---|
[3357] | 1012 | $self->manager->GetPane("preview")->Show(0); |
---|
[3284] | 1013 | $self->manager->GetPane("photo_properties")->Show(0); |
---|
[3269] | 1014 | $self->manager->GetPane("global_settings")->Show(0); |
---|
[3357] | 1015 | $self->manager->GetPane("getting_started")->Float; |
---|
| 1016 | $self->manager->GetPane("getting_started")->Show(1); |
---|
[3159] | 1017 | |
---|
[2597] | 1018 | } |
---|
| 1019 | |
---|
[3284] | 1020 | sub OnPhotoProperties { |
---|
| 1021 | my ( $self ) = @_; |
---|
| 1022 | |
---|
| 1023 | $self->manager->GetPane("photo_properties")->Show(1); |
---|
| 1024 | $self->manager->Update(); |
---|
| 1025 | |
---|
| 1026 | } |
---|
| 1027 | |
---|
[3365] | 1028 | sub OnPreview { |
---|
| 1029 | my ( $self ) = @_; |
---|
| 1030 | |
---|
| 1031 | $self->manager->GetPane("preview")->Float->Show(1); |
---|
| 1032 | $self->manager->Update(); |
---|
| 1033 | |
---|
| 1034 | } |
---|
| 1035 | |
---|
[3357] | 1036 | sub OnGettingStarted { |
---|
| 1037 | my ( $self ) = @_; |
---|
| 1038 | |
---|
| 1039 | $self->toolbar->EnableTool(100, 0 ); |
---|
| 1040 | $self->manager->GetPane("getting_started")->Float->Show(1); |
---|
| 1041 | $self->manager->Update(); |
---|
| 1042 | |
---|
| 1043 | } |
---|
| 1044 | |
---|
[2597] | 1045 | sub OnGlobalSettings { |
---|
| 1046 | my ( $self ) = @_; |
---|
| 1047 | |
---|
[3227] | 1048 | $self->toolbar->EnableTool(104, 0 ); |
---|
[3357] | 1049 | $self->manager->GetPane("global_settings")->Float->Show(1); |
---|
[2597] | 1050 | $self->manager->Update(); |
---|
| 1051 | } |
---|
| 1052 | |
---|
[3159] | 1053 | sub OnChooseLanguage { |
---|
| 1054 | my ( $self ) = @_; |
---|
[2597] | 1055 | |
---|
[3159] | 1056 | my $languages = [ |
---|
| 1057 | ['Dutch', wxLANGUAGE_DUTCH, ], |
---|
| 1058 | ['English', wxLANGUAGE_ENGLISH, ], |
---|
| 1059 | ['French', wxLANGUAGE_FRENCH, ], |
---|
| 1060 | ['German', wxLANGUAGE_GERMAN, ], |
---|
| 1061 | ['Italian', wxLANGUAGE_ITALIAN, ], |
---|
| 1062 | ['Polish', wxLANGUAGE_POLISH, ], |
---|
| 1063 | ['Portuguese', wxLANGUAGE_PORTUGUESE, ], |
---|
| 1064 | ['Russian', wxLANGUAGE_RUSSIAN, ], |
---|
| 1065 | ['Spanish', wxLANGUAGE_SPANISH, ], |
---|
| 1066 | ]; |
---|
| 1067 | |
---|
| 1068 | my $dialog = new Wx::SingleChoiceDialog |
---|
| 1069 | ( undef, gettext( "Choose a language" ), gettext( "Choose a language" ), |
---|
| 1070 | [ map { Wx::GetTranslation( ${$_}[0] ) } @$languages ] ); |
---|
| 1071 | |
---|
| 1072 | if( $dialog->ShowModal() == wxID_OK ) { |
---|
| 1073 | wxTheApp->current_language( |
---|
| 1074 | $languages->[$dialog->GetSelection][1] |
---|
| 1075 | ); |
---|
| 1076 | wxTheApp->init_locale(); |
---|
| 1077 | $self->_refreshFrame; |
---|
| 1078 | } |
---|
| 1079 | |
---|
| 1080 | $dialog->Destroy; |
---|
| 1081 | |
---|
| 1082 | } |
---|
| 1083 | |
---|
| 1084 | |
---|
[2597] | 1085 | sub create_notebook_imagelist { |
---|
| 1086 | my( $self ) = @_; |
---|
| 1087 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [300, 450], |
---|
| 1088 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
| 1089 | |
---|
[3357] | 1090 | my $imglistpage = [ |
---|
| 1091 | [ |
---|
| 1092 | $self->imageviewer, |
---|
| 1093 | gettext("Photo selection"), |
---|
| 1094 | '../res/images.png', |
---|
| 1095 | wxBITMAP_TYPE_PNG, |
---|
| 1096 | ], |
---|
| 1097 | ]; |
---|
| 1098 | |
---|
[2597] | 1099 | $self->notebook($book); |
---|
[3357] | 1100 | $self->_populate_notebook($self->notebook, $imglistpage, 0); |
---|
[2597] | 1101 | return $book; |
---|
| 1102 | } |
---|
| 1103 | |
---|
| 1104 | sub create_notebook_image_properties { |
---|
| 1105 | my( $self ) = @_; |
---|
[2618] | 1106 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [450, 450], |
---|
[2597] | 1107 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
| 1108 | my $pages = [ |
---|
| 1109 | [ |
---|
[3178] | 1110 | $self->image_prop_piwigo, |
---|
[2597] | 1111 | "Piwigo", |
---|
| 1112 | ], |
---|
| 1113 | [ |
---|
| 1114 | $self->image_prop_exif, |
---|
| 1115 | "Exif", |
---|
| 1116 | ], |
---|
| 1117 | ]; |
---|
| 1118 | |
---|
| 1119 | $self->_populate_notebook( $book, $pages ); |
---|
| 1120 | |
---|
| 1121 | $self->notebook_image_properties($book); |
---|
| 1122 | |
---|
| 1123 | return $book; |
---|
| 1124 | } |
---|
| 1125 | |
---|
| 1126 | sub create_notebook_global_settings { |
---|
| 1127 | my( $self ) = @_; |
---|
[2618] | 1128 | my $book = Wx::AuiNotebook->new( $self, -1, [-1, -1], [450, 450], |
---|
[2597] | 1129 | wxBORDER_NONE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT); |
---|
| 1130 | my $pages = [ |
---|
| 1131 | [ |
---|
[3178] | 1132 | $self->general_settings_panel, |
---|
| 1133 | gettext("General"), |
---|
[2597] | 1134 | ], |
---|
[3178] | 1135 | [ |
---|
| 1136 | $self->resized_settings_panel, |
---|
| 1137 | gettext("Resized"), |
---|
| 1138 | ], |
---|
| 1139 | [ |
---|
| 1140 | $self->thumbnail_settings_panel, |
---|
| 1141 | gettext("Thumbnail"), |
---|
| 1142 | ], |
---|
| 1143 | [ |
---|
| 1144 | $self->preview_settings_panel, |
---|
| 1145 | gettext("Preview"), |
---|
| 1146 | ], |
---|
[2597] | 1147 | ]; |
---|
| 1148 | |
---|
| 1149 | $self->_populate_notebook( $book, $pages ); |
---|
| 1150 | |
---|
[3159] | 1151 | $self->notebook_global_settings($book); |
---|
[2597] | 1152 | |
---|
| 1153 | return $book; |
---|
| 1154 | } |
---|
| 1155 | |
---|
| 1156 | |
---|
| 1157 | |
---|
[3178] | 1158 | |
---|
[2597] | 1159 | sub create_tree { |
---|
| 1160 | my ( $self ) = @_; |
---|
| 1161 | |
---|
| 1162 | my $images = [ |
---|
| 1163 | map { |
---|
| 1164 | Wx::Bitmap->new( $_, wxBITMAP_TYPE_PNG ) |
---|
| 1165 | |
---|
| 1166 | } |
---|
| 1167 | ( |
---|
[2661] | 1168 | '../res/tree_pwg.png', |
---|
[2597] | 1169 | '../res/tree_folder.png', |
---|
| 1170 | ) |
---|
| 1171 | ]; |
---|
| 1172 | |
---|
| 1173 | $self->treeimglist( Wx::ImageList->new( 16, 16, 1 ) ); |
---|
| 1174 | map { |
---|
| 1175 | $self->treeimglist->Add($_); |
---|
| 1176 | } |
---|
| 1177 | @$images; |
---|
| 1178 | |
---|
| 1179 | |
---|
| 1180 | $self->tree( |
---|
| 1181 | Wx::TreeCtrl->new( |
---|
| 1182 | $self, |
---|
| 1183 | -1, |
---|
| 1184 | wxDefaultPosition, |
---|
| 1185 | wxDefaultSize, |
---|
| 1186 | wxBORDER_NONE| |
---|
| 1187 | wxCLIP_CHILDREN| |
---|
| 1188 | # wxTR_MULTIPLE| |
---|
| 1189 | # wxTR_EXTENDED| |
---|
[2661] | 1190 | wxTR_HAS_BUTTONS |
---|
| 1191 | # wxTR_HIDE_ROOT |
---|
[2597] | 1192 | ) |
---|
| 1193 | ); |
---|
| 1194 | |
---|
| 1195 | $self->tree->SetImageList( $self->treeimglist ); |
---|
[3227] | 1196 | $self->populate_tree_categories if !wxTheApp->use_offline; |
---|
[2661] | 1197 | $self->tree ; |
---|
| 1198 | } |
---|
[2597] | 1199 | |
---|
[2661] | 1200 | |
---|
| 1201 | sub populate_tree_categories { |
---|
| 1202 | my ( $self ) = @_; |
---|
| 1203 | |
---|
[2597] | 1204 | $self->populate_tree( |
---|
| 1205 | $self->tree, |
---|
| 1206 | wxTheApp->pwg->categories, |
---|
| 1207 | ) if defined wxTheApp->pwg ; |
---|
| 1208 | |
---|
[3383] | 1209 | #$self->tree->ExpandAll; |
---|
[2597] | 1210 | |
---|
| 1211 | } |
---|
| 1212 | |
---|
| 1213 | |
---|
| 1214 | # returns a valid itemData |
---|
| 1215 | sub itemData { Wx::TreeItemData->new( $_[0] ) } |
---|
| 1216 | |
---|
| 1217 | sub populate_tree { |
---|
| 1218 | my ( $self, $tree, $tree_items ) = @_; |
---|
| 1219 | my $root = shift @{$tree_items}; |
---|
[3387] | 1220 | |
---|
[2597] | 1221 | $self->tree_root( |
---|
| 1222 | $tree->AddRoot( |
---|
| 1223 | $root->[0], |
---|
| 1224 | $root->[3], |
---|
| 1225 | $root->[4], |
---|
| 1226 | itemData( $root->[2] ) |
---|
| 1227 | ) |
---|
| 1228 | ); |
---|
| 1229 | |
---|
| 1230 | $self->populate_tree_helper( $tree, $self->tree_root, $tree_items ); |
---|
[3387] | 1231 | |
---|
| 1232 | $tree->SelectItem( $self->tree_root ); |
---|
[2597] | 1233 | $tree->Expand( $self->tree_root ); |
---|
| 1234 | } |
---|
| 1235 | |
---|
| 1236 | sub populate_tree_helper { |
---|
| 1237 | my ( $self, $tree, $parent_id, $tree_items ) = @_; |
---|
| 1238 | |
---|
| 1239 | my $id; |
---|
| 1240 | |
---|
| 1241 | map { |
---|
[2661] | 1242 | my $name = $_->[0]; |
---|
[2698] | 1243 | eval { |
---|
| 1244 | $name = is_utf8($name) ? decode('UTF-8', $name) : $name; |
---|
| 1245 | }; |
---|
| 1246 | if($@){ |
---|
| 1247 | $name = $_->[0]; |
---|
| 1248 | } |
---|
[3383] | 1249 | |
---|
| 1250 | $id = $tree->AppendItem( |
---|
[2698] | 1251 | $parent_id, |
---|
| 1252 | $name, |
---|
| 1253 | defined($_->[3]) ? $_->[3] : 0, |
---|
| 1254 | defined($_->[4]) ? $_->[4] : 0, |
---|
| 1255 | itemData( $_->[2]) |
---|
| 1256 | ); |
---|
[2597] | 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(); |
---|
[2618] | 1276 | eval { $icon->LoadFile($_->[2], $_->[3]) ; } |
---|
| 1277 | if defined $_->[2]; |
---|
[2597] | 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 | |
---|
[3372] | 1292 | sub _initMenus { |
---|
| 1293 | my ( $self ) = @_ ; |
---|
[2597] | 1294 | |
---|
[3372] | 1295 | $self->_tree_mnu; |
---|
| 1296 | $self->_imageviewer_mnu; |
---|
| 1297 | } |
---|
| 1298 | |
---|
| 1299 | |
---|
| 1300 | sub _tree_mnu { |
---|
| 1301 | my ( $self ) = @_; |
---|
| 1302 | |
---|
| 1303 | my $ctx_mnu = Wx::Menu->new; |
---|
| 1304 | |
---|
| 1305 | map { |
---|
| 1306 | $ctx_mnu->Append( |
---|
| 1307 | @$_[0..2], wxITEM_NORMAL |
---|
| 1308 | )->SetBitmap(Wx::Bitmap->new($_->[3],wxBITMAP_TYPE_PNG)); |
---|
| 1309 | } |
---|
| 1310 | ( |
---|
| 1311 | # workaround : first item does not show bitmap |
---|
| 1312 | [ |
---|
| 1313 | 0, |
---|
| 1314 | "", |
---|
| 1315 | "", |
---|
| 1316 | '../res/mnu_folder_new.png', |
---|
| 1317 | ], |
---|
| 1318 | [ |
---|
| 1319 | 1+$ID_TREE_CTX_MENU, |
---|
| 1320 | wxTheApp->branding->{'Add new category'}, |
---|
| 1321 | sprintf( |
---|
| 1322 | "%s %s %s %s", |
---|
| 1323 | gettext("Add a new"), |
---|
| 1324 | wxTheApp->branding->{category}, |
---|
| 1325 | gettext("to the currently selected"), |
---|
| 1326 | wxTheApp->branding->{category}, |
---|
| 1327 | ), |
---|
| 1328 | '../res/mnu_folder_new.png', |
---|
| 1329 | ], |
---|
| 1330 | [ |
---|
| 1331 | 2+$ID_TREE_CTX_MENU, |
---|
[3384] | 1332 | gettext("Refresh"), |
---|
[3372] | 1333 | sprintf( |
---|
| 1334 | "Refresh %s list.", |
---|
| 1335 | wxTheApp->branding->{category}, |
---|
| 1336 | ), |
---|
| 1337 | '../res/mnu_refresh.png', |
---|
| 1338 | ], |
---|
[3384] | 1339 | [ |
---|
| 1340 | 3+$ID_TREE_CTX_MENU, |
---|
| 1341 | gettext("Expand all"), |
---|
| 1342 | sprintf( |
---|
| 1343 | "Expand %s list.", |
---|
| 1344 | wxTheApp->branding->{category}, |
---|
| 1345 | ), |
---|
| 1346 | '../res/mnu_expandall.png', |
---|
| 1347 | ], |
---|
| 1348 | [ |
---|
| 1349 | 4+$ID_TREE_CTX_MENU, |
---|
| 1350 | gettext("Collapse all"), |
---|
| 1351 | sprintf( |
---|
| 1352 | "Collapse %s list.", |
---|
| 1353 | wxTheApp->branding->{category}, |
---|
| 1354 | ), |
---|
| 1355 | '../res/mnu_collapseall.png', |
---|
| 1356 | ], |
---|
[3372] | 1357 | ); |
---|
| 1358 | |
---|
| 1359 | $ctx_mnu->Delete(0); |
---|
| 1360 | $self->tree_mnu( |
---|
| 1361 | $ctx_mnu |
---|
| 1362 | ); |
---|
| 1363 | } |
---|
| 1364 | |
---|
| 1365 | sub _imageviewer_mnu { |
---|
| 1366 | my ( $self ) = @_; |
---|
| 1367 | |
---|
| 1368 | my $ctx_mnu = Wx::Menu->new; |
---|
| 1369 | |
---|
| 1370 | map { |
---|
| 1371 | $ctx_mnu->Append( |
---|
| 1372 | @$_[0..2] |
---|
| 1373 | )->SetBitmap(Wx::Bitmap->new($_->[3],wxBITMAP_TYPE_PNG)); |
---|
| 1374 | } |
---|
| 1375 | ( |
---|
| 1376 | # workaround : first item does not show bitmap |
---|
| 1377 | [ |
---|
| 1378 | 0, |
---|
| 1379 | "", |
---|
| 1380 | "", |
---|
| 1381 | '../res/mnu_properties.png', |
---|
| 1382 | ], |
---|
| 1383 | [ |
---|
| 1384 | 1+$ID_IMAGEVIEWER_CTX_MENU, |
---|
| 1385 | gettext("Properties"), |
---|
| 1386 | gettext("Modify photo properties"), |
---|
| 1387 | '../res/mnu_properties.png', |
---|
| 1388 | ], |
---|
| 1389 | [ |
---|
| 1390 | 2+$ID_IMAGEVIEWER_CTX_MENU, |
---|
| 1391 | gettext("Preview"), |
---|
| 1392 | gettext("Display photo preview"), |
---|
| 1393 | '../res/mnu_preview.png', |
---|
| 1394 | ], |
---|
| 1395 | ); |
---|
| 1396 | |
---|
| 1397 | $ctx_mnu->Delete(0); |
---|
| 1398 | $self->imageviewer_mnu( |
---|
| 1399 | $ctx_mnu |
---|
| 1400 | ); |
---|
| 1401 | } |
---|
| 1402 | |
---|
| 1403 | sub _initEventHandlers { |
---|
[2597] | 1404 | my ( $self ) = @_ ; |
---|
| 1405 | |
---|
[3357] | 1406 | Wx::Event::EVT_MENU( $self, 100, \&OnGettingStarted ); |
---|
[2597] | 1407 | Wx::Event::EVT_MENU( $self, 101, \&OnAddImages ); |
---|
| 1408 | Wx::Event::EVT_MENU( $self, 102, \&OnRemoveImages ); |
---|
| 1409 | Wx::Event::EVT_MENU( $self, 103, \&OnUploadImages ); |
---|
| 1410 | Wx::Event::EVT_MENU( $self, 104, \&OnGlobalSettings ); |
---|
[3159] | 1411 | Wx::Event::EVT_MENU( $self, 105, \&OnChooseLanguage ); |
---|
[2597] | 1412 | EVT_TREE_SEL_CHANGED( $self, $self->tree, \&OnTreeSelChanged ); |
---|
[3372] | 1413 | EVT_TREE_ITEM_RIGHT_CLICK( $self, $self->tree, \&OnTreeItemRightClick ); |
---|
[3365] | 1414 | |
---|
[2597] | 1415 | EVT_LIST_END_LABEL_EDIT( $self, $self->imageviewer, \&OnImageViewerEndLabelEdit ); |
---|
[3284] | 1416 | EVT_LIST_ITEM_ACTIVATED( $self, $self->imageviewer, \&OnImageViewerItemActivated ); |
---|
[2597] | 1417 | EVT_LIST_ITEM_SELECTED($self, $self->imageviewer, \&OnImageViewerItemSelected) ; |
---|
[3365] | 1418 | EVT_LIST_ITEM_RIGHT_CLICK($self, $self->imageviewer, \&OnImageViewerItemRightClick) ; |
---|
| 1419 | |
---|
[2731] | 1420 | EVT_LIST_KEY_DOWN($self, $self->imageviewer, \&OnImageViewerKeyDown) ; |
---|
[3365] | 1421 | |
---|
[2597] | 1422 | EVT_CLOSE( $self, \&OnClose ); |
---|
[3227] | 1423 | Wx::Event::EVT_UPDATE_UI( $self, $self, \&OnUpdateUI ); |
---|
[2597] | 1424 | |
---|
[2661] | 1425 | |
---|
| 1426 | Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategories ); |
---|
| 1427 | Wx::Event::EVT_MENU( $self, 2+$ID_TREE_CTX_MENU, \&OnRefreshCategories ); |
---|
[3384] | 1428 | Wx::Event::EVT_MENU( $self, 3+$ID_TREE_CTX_MENU, \&OnExpandCategories ); |
---|
| 1429 | Wx::Event::EVT_MENU( $self, 4+$ID_TREE_CTX_MENU, \&OnCollapseCategories ); |
---|
| 1430 | |
---|
[3365] | 1431 | Wx::Event::EVT_MENU( $self, 1+$ID_IMAGEVIEWER_CTX_MENU, \&OnPhotoProperties ); |
---|
| 1432 | Wx::Event::EVT_MENU( $self, 2+$ID_IMAGEVIEWER_CTX_MENU, \&OnPreview ); |
---|
| 1433 | |
---|
| 1434 | |
---|
[2597] | 1435 | } |
---|
| 1436 | |
---|
| 1437 | { |
---|
| 1438 | my $prevdir; |
---|
| 1439 | my $prevfile; |
---|
| 1440 | |
---|
| 1441 | sub OnAddImages { |
---|
| 1442 | my( $self, $event ) = @_; |
---|
| 1443 | my $dialog = Wx::FileDialog->new |
---|
[3284] | 1444 | ( $self, gettext("Select photos for upload"), $prevfile, $prevdir, |
---|
| 1445 | sprintf("%s (*.jpg)|*.jpg|All(*.*)|*.*", gettext("JPEG files")), |
---|
[2597] | 1446 | wxFD_OPEN|wxFD_MULTIPLE ); |
---|
| 1447 | |
---|
| 1448 | my $file_paths = []; |
---|
| 1449 | if( $dialog->ShowModal != wxID_CANCEL ) { |
---|
| 1450 | @$file_paths = $dialog->GetPaths; |
---|
| 1451 | $self->SetNewFiles($file_paths) ; |
---|
| 1452 | } |
---|
| 1453 | $dialog->Destroy; |
---|
[3357] | 1454 | # $event->Skip; |
---|
[2597] | 1455 | } |
---|
| 1456 | } |
---|
| 1457 | |
---|
[3227] | 1458 | sub OnUpdateUI { |
---|
| 1459 | my( $self, $event ) = @_; |
---|
| 1460 | |
---|
| 1461 | if( $self->manager ){ |
---|
| 1462 | if($self->manager->GetPane("global_settings")->IsShown){ |
---|
| 1463 | $self->toolbar->EnableTool(104, 0); |
---|
| 1464 | } |
---|
| 1465 | else{ |
---|
| 1466 | $self->toolbar->EnableTool(104, 1); |
---|
| 1467 | } |
---|
[3387] | 1468 | |
---|
[3357] | 1469 | if($self->manager->GetPane("getting_started")->IsShown){ |
---|
| 1470 | $self->toolbar->EnableTool(100, 0); |
---|
| 1471 | } |
---|
| 1472 | else{ |
---|
| 1473 | $self->toolbar->EnableTool(100, 1); |
---|
| 1474 | } |
---|
[3227] | 1475 | } |
---|
[3372] | 1476 | |
---|
[3227] | 1477 | } |
---|
| 1478 | |
---|
[2597] | 1479 | sub OnRemoveImages { |
---|
| 1480 | my( $self, $event ) = @_; |
---|
| 1481 | |
---|
| 1482 | |
---|
| 1483 | $self->imagelist->RemoveImageSelection; |
---|
| 1484 | $self->imageviewer->Refresh; |
---|
[3372] | 1485 | |
---|
[3373] | 1486 | $self->image_preview->SetBitmap( |
---|
| 1487 | wxNullBitmap |
---|
| 1488 | ) if !$self->imageviewer->GetItemCount; |
---|
| 1489 | |
---|
[2597] | 1490 | } |
---|
| 1491 | |
---|
| 1492 | sub SetNewFiles { |
---|
| 1493 | my ( $self, $file_paths ) = @_; |
---|
| 1494 | |
---|
| 1495 | $self->ShowImageViewer(); |
---|
| 1496 | $self->progressdlg( |
---|
| 1497 | Uploader::GUI::wxImageProcessingProgressDlg->new( |
---|
| 1498 | { |
---|
[3287] | 1499 | title => gettext("Image processing progress information"), |
---|
| 1500 | bt_label => gettext("Cancel image processing"), |
---|
[2597] | 1501 | } |
---|
| 1502 | ) |
---|
| 1503 | ); |
---|
| 1504 | $self->progressdlg->Show(1); |
---|
| 1505 | Wx::Yield(); |
---|
[3227] | 1506 | |
---|
| 1507 | my $files = [ |
---|
| 1508 | map { |
---|
| 1509 | encode('iso-8859-1', $_) |
---|
| 1510 | }@$file_paths |
---|
| 1511 | ]; |
---|
[2597] | 1512 | |
---|
[3367] | 1513 | @$files = sort @$files; |
---|
| 1514 | |
---|
[2597] | 1515 | $self->imagelist->SetNewFiles( |
---|
[3227] | 1516 | $files |
---|
[2597] | 1517 | ); |
---|
| 1518 | |
---|
| 1519 | |
---|
| 1520 | } |
---|
| 1521 | |
---|
| 1522 | sub OnTreeSelChanged { |
---|
| 1523 | my( $self, $event ) = @_; |
---|
| 1524 | |
---|
| 1525 | my @items = $self->tree->GetSelections; |
---|
| 1526 | |
---|
| 1527 | $self->imagelist->categories( |
---|
| 1528 | [ |
---|
| 1529 | map { |
---|
| 1530 | my $category = $self->tree->GetPlData( $_ ); |
---|
| 1531 | $category->{id} if $category != -1; |
---|
| 1532 | } |
---|
| 1533 | @items |
---|
| 1534 | ] |
---|
| 1535 | ); |
---|
[2661] | 1536 | } |
---|
| 1537 | |
---|
| 1538 | sub OnTreeItemRightClick { |
---|
| 1539 | my( $self, $event ) = @_; |
---|
| 1540 | |
---|
[3365] | 1541 | |
---|
[3372] | 1542 | $self->PopupMenu($self->tree_mnu, wxDefaultPosition); |
---|
[2661] | 1543 | |
---|
[2597] | 1544 | } |
---|
| 1545 | |
---|
[3365] | 1546 | |
---|
| 1547 | sub OnImageViewerItemRightClick { |
---|
| 1548 | my( $self, $event ) = @_; |
---|
| 1549 | |
---|
| 1550 | |
---|
[3372] | 1551 | $self->PopupMenu($self->imageviewer_mnu, wxDefaultPosition); |
---|
[3365] | 1552 | |
---|
| 1553 | |
---|
| 1554 | } |
---|
| 1555 | |
---|
[3384] | 1556 | sub OnExpandCategories { |
---|
| 1557 | my ( $self, $event ) = @_; |
---|
| 1558 | |
---|
| 1559 | my $parent_item = $self->tree->GetSelection; |
---|
| 1560 | $self->tree->ExpandAllChildren($parent_item); |
---|
[3387] | 1561 | $self->tree->EnsureVisible($parent_item); |
---|
[3384] | 1562 | } |
---|
| 1563 | |
---|
| 1564 | sub OnCollapseCategories { |
---|
| 1565 | my ( $self, $event ) = @_; |
---|
| 1566 | |
---|
| 1567 | my $parent_item = $self->tree->GetSelection; |
---|
| 1568 | $self->tree->CollapseAllChildren($parent_item); |
---|
[3387] | 1569 | $self->tree->Expand($parent_item) if -1 == $self->tree->GetPlData($parent_item); |
---|
[3384] | 1570 | } |
---|
| 1571 | |
---|
[2661] | 1572 | sub OnAddCategories { |
---|
| 1573 | my ( $self, $event ) = @_; |
---|
| 1574 | |
---|
[3383] | 1575 | my $parent_item = $self->tree->GetSelection; |
---|
[2661] | 1576 | |
---|
[3383] | 1577 | my $category = $self->tree->GetPlData($parent_item); |
---|
[2661] | 1578 | my $category_id; |
---|
| 1579 | |
---|
| 1580 | $category_id = $category->{id} if 'HASH' eq ref($category) ; |
---|
| 1581 | |
---|
| 1582 | my $dialog = Wx::TextEntryDialog->new( |
---|
| 1583 | $self, |
---|
[3360] | 1584 | sprintf("%s name :", wxTheApp->branding->{Category}), |
---|
[3284] | 1585 | sprintf("Add new %s", wxTheApp->branding->{category}), |
---|
| 1586 | sprintf("New %s", wxTheApp->branding->{category}), |
---|
[2661] | 1587 | ); |
---|
| 1588 | |
---|
| 1589 | if( $dialog->ShowModal != wxID_CANCEL ) { |
---|
| 1590 | my $name = $dialog->GetValue; |
---|
[3383] | 1591 | my ( $success, $status_msg, $content ) = $self->pwg->AddCategories( $name, $category_id); |
---|
| 1592 | |
---|
| 1593 | if($success){ |
---|
[3387] | 1594 | $self->_append_category($parent_item, $name, $content->{result}{id}); |
---|
[3383] | 1595 | } |
---|
[2661] | 1596 | } |
---|
| 1597 | $dialog->Destroy; |
---|
| 1598 | } |
---|
| 1599 | |
---|
| 1600 | sub OnRefreshCategories { |
---|
| 1601 | my ( $self, $event ) = @_; |
---|
| 1602 | |
---|
[3383] | 1603 | $self->_refresh_all_categories_helper; |
---|
[2661] | 1604 | } |
---|
| 1605 | |
---|
[3383] | 1606 | |
---|
| 1607 | sub _refresh_all_categories_helper { |
---|
[2661] | 1608 | my ( $self ) = @_; |
---|
| 1609 | |
---|
| 1610 | my $busycursor = Wx::BusyCursor->new(); |
---|
| 1611 | $self->tree->CollapseAll; |
---|
| 1612 | $self->tree->DeleteAllItems; |
---|
| 1613 | $self->imagelist->categories([]); |
---|
| 1614 | $self->pwg->RefreshCategories(); |
---|
| 1615 | $self->populate_tree_categories; |
---|
| 1616 | } |
---|
| 1617 | |
---|
[3383] | 1618 | sub _append_category { |
---|
| 1619 | my ( $self, $parent_id, $name, $id ) = @_; |
---|
| 1620 | |
---|
| 1621 | $self->tree->SelectItem( |
---|
| 1622 | $self->tree->AppendItem( |
---|
| 1623 | $parent_id, |
---|
| 1624 | $name, |
---|
| 1625 | 1, |
---|
| 1626 | -1, |
---|
[3387] | 1627 | Wx::TreeItemData->new( { id => $id } ) |
---|
[3383] | 1628 | ) |
---|
| 1629 | ); |
---|
| 1630 | } |
---|
| 1631 | |
---|
[2597] | 1632 | sub OnImageViewerEndLabelEdit { |
---|
| 1633 | my( $self, $event ) = @_; |
---|
| 1634 | |
---|
[3227] | 1635 | my $image = $self->imagelist->GetImage($event->GetIndex); |
---|
[2597] | 1636 | $image->site_name( |
---|
| 1637 | $event->GetLabel |
---|
| 1638 | ); |
---|
| 1639 | |
---|
[3178] | 1640 | $self->image_prop_piwigo->Refresh; |
---|
[2597] | 1641 | } |
---|
| 1642 | |
---|
[3284] | 1643 | sub OnImageViewerItemActivated { |
---|
| 1644 | my( $self, $event ) = @_; |
---|
[3362] | 1645 | |
---|
| 1646 | $self->current_imageviewer_index( |
---|
| 1647 | $event->GetIndex |
---|
| 1648 | ); |
---|
[2597] | 1649 | |
---|
[3284] | 1650 | $self->OnPhotoProperties; |
---|
| 1651 | } |
---|
| 1652 | |
---|
| 1653 | |
---|
[2597] | 1654 | sub OnImageViewerItemSelected { |
---|
| 1655 | my( $self, $event ) = @_; |
---|
| 1656 | |
---|
| 1657 | my $indx = $event->GetIndex; |
---|
| 1658 | |
---|
[3362] | 1659 | $self->_on_imageviewer_item_selected($indx); |
---|
[3374] | 1660 | |
---|
[3362] | 1661 | $event->Skip; |
---|
| 1662 | } |
---|
| 1663 | |
---|
| 1664 | sub _on_imageviewer_item_selected { |
---|
| 1665 | my ( $self, $index ) = @_; |
---|
| 1666 | |
---|
| 1667 | $self->current_imageviewer_index($index); |
---|
| 1668 | $self->imagelist->SetCurrentImage($index); |
---|
[2597] | 1669 | |
---|
| 1670 | $self->imagelist->image_selection( |
---|
| 1671 | $self->imageviewer->GetSelectedItems |
---|
| 1672 | ); |
---|
| 1673 | |
---|
[3374] | 1674 | $self->_image_preview_refresh if @{$self->imagelist->image_selection} < 2; |
---|
| 1675 | |
---|
| 1676 | $self->manager->Update; |
---|
| 1677 | |
---|
| 1678 | $self->image_prop_piwigo->Refresh; |
---|
| 1679 | $self->image_prop_exif->Refresh; |
---|
| 1680 | |
---|
| 1681 | } |
---|
| 1682 | |
---|
| 1683 | sub _image_preview_refresh { |
---|
| 1684 | my ( $self ) = @_; |
---|
| 1685 | |
---|
[3178] | 1686 | $self->image_preview->SetBitmap( |
---|
| 1687 | wxNullBitmap |
---|
| 1688 | ); |
---|
[3357] | 1689 | |
---|
[3178] | 1690 | $self->image_preview->Refresh; |
---|
| 1691 | |
---|
[3362] | 1692 | my $bmp = Wx::Bitmap->new( |
---|
[3178] | 1693 | $self->imagelist->current_image->preview_file, |
---|
| 1694 | $self->GetWxBitmapType($self->imagelist->type), |
---|
[3357] | 1695 | ); |
---|
| 1696 | |
---|
| 1697 | |
---|
| 1698 | $self->image_preview->SetBitmap( |
---|
| 1699 | $bmp |
---|
[3178] | 1700 | ); |
---|
[3357] | 1701 | |
---|
| 1702 | my $size = [8+$bmp->GetWidth, 26+$bmp->GetHeight]; |
---|
| 1703 | $self->manager->GetPane("preview")->FloatingSize($size); |
---|
[3178] | 1704 | |
---|
| 1705 | $self->image_preview->Refresh; |
---|
[2597] | 1706 | } |
---|
| 1707 | |
---|
[2731] | 1708 | sub OnImageViewerKeyDown { |
---|
| 1709 | my( $self, $event ) = @_; |
---|
| 1710 | |
---|
| 1711 | if(WXK_DELETE == $event->GetKeyCode){ |
---|
| 1712 | $self->OnRemoveImages(); |
---|
[3372] | 1713 | |
---|
| 1714 | my $index = $self->current_imageviewer_index < $self->imageviewer->GetItemCount ? |
---|
[3374] | 1715 | $self->current_imageviewer_index : $self->imageviewer->GetItemCount -1 ; |
---|
[3371] | 1716 | $self->imageviewer->SelectItem( |
---|
[3372] | 1717 | $index |
---|
[3371] | 1718 | ); |
---|
[2731] | 1719 | } |
---|
[3374] | 1720 | |
---|
[2731] | 1721 | } |
---|
| 1722 | |
---|
[2597] | 1723 | sub OnUploadImages { |
---|
| 1724 | my( $self, $event ) = @_; |
---|
| 1725 | |
---|
[3227] | 1726 | eval { |
---|
[2696] | 1727 | $self->ProcessImageSelection(); |
---|
[3227] | 1728 | }; |
---|
[2597] | 1729 | } |
---|
| 1730 | |
---|
| 1731 | # remove image from imagelist when uploaded |
---|
| 1732 | sub UploadImagesViewerRefresh { |
---|
| 1733 | my ( $self ) = @_; |
---|
| 1734 | |
---|
[3387] | 1735 | $self->imageviewer->Refresh; |
---|
[2597] | 1736 | Wx::Yield(); |
---|
| 1737 | } |
---|
| 1738 | |
---|
[2728] | 1739 | sub UploadProgressMessageRefresh { |
---|
| 1740 | my ( $self, $msg ) = @_; |
---|
| 1741 | |
---|
| 1742 | $self->upload_progressdlg->processing( |
---|
| 1743 | $msg |
---|
| 1744 | ); |
---|
| 1745 | |
---|
| 1746 | Wx::Yield(); |
---|
| 1747 | } |
---|
| 1748 | |
---|
| 1749 | sub UploadProgressThumbnailRefresh { |
---|
[2597] | 1750 | my ( $self ) = @_; |
---|
[2728] | 1751 | |
---|
[2597] | 1752 | my $imagelist = $self->imagelist ; |
---|
| 1753 | |
---|
[2728] | 1754 | |
---|
| 1755 | $self->upload_progressdlg->image->SetBitmap(wxNullBitmap); |
---|
| 1756 | $self->upload_progressdlg->image->SetBitmap( |
---|
| 1757 | Wx::Bitmap->new( |
---|
| 1758 | $self->imagelist->current_image->wx_thumb_file, |
---|
| 1759 | $self->GetWxBitmapType($self->imagelist->type), |
---|
[2597] | 1760 | ) |
---|
| 1761 | ); |
---|
[2728] | 1762 | |
---|
| 1763 | Wx::Yield(); |
---|
| 1764 | } |
---|
| 1765 | |
---|
| 1766 | sub UploadProgressBarRefresh { |
---|
| 1767 | my ( $self, $ratio ) = @_; |
---|
| 1768 | |
---|
[3141] | 1769 | $ratio = $self->imagelist->count > 1 ? 1 : $ratio; |
---|
[2597] | 1770 | eval { |
---|
| 1771 | $self->upload_progressdlg->progress( |
---|
[2728] | 1772 | $ratio*$self->imagelist->count * ( 100/scalar @{$self->imagelist->image_selection} ) |
---|
[2597] | 1773 | ); |
---|
| 1774 | $self->upload_progressdlg->LogProgress(); |
---|
| 1775 | }; |
---|
[3159] | 1776 | croak gettext("Upload cancelled") if $@; |
---|
[2728] | 1777 | |
---|
[2597] | 1778 | Wx::Yield(); |
---|
| 1779 | } |
---|
| 1780 | |
---|
[2696] | 1781 | sub SetNewFilesDisplayEndInfo { |
---|
[2730] | 1782 | my ( $self, $msg ) = @_; |
---|
[2696] | 1783 | |
---|
[2730] | 1784 | $self->progressdlg->DisplayEndInfo($msg); |
---|
[2696] | 1785 | } |
---|
| 1786 | |
---|
| 1787 | sub UploadDisplayEndInfo { |
---|
[2728] | 1788 | my ( $self, $msg ) = @_; |
---|
[2696] | 1789 | |
---|
| 1790 | my $imagelist = $self->imagelist ; |
---|
| 1791 | |
---|
[2728] | 1792 | $self->upload_progressdlg->DisplayEndInfo($msg); |
---|
[2696] | 1793 | } |
---|
| 1794 | |
---|
[2597] | 1795 | sub ShowImageViewer { |
---|
| 1796 | my ( $self ) = @_; |
---|
| 1797 | |
---|
| 1798 | if(!$self->imageviewer->IsShown){ |
---|
[3357] | 1799 | #my $imglistpage = [ |
---|
| 1800 | # [ |
---|
| 1801 | # $self->imageviewer, |
---|
| 1802 | # gettext("Photo selection"), |
---|
| 1803 | # '../res/images.png', |
---|
| 1804 | # wxBITMAP_TYPE_PNG, |
---|
| 1805 | # ], |
---|
| 1806 | #]; |
---|
| 1807 | #$self->notebook->DeletePage(0); |
---|
[2597] | 1808 | |
---|
| 1809 | $self->imageviewer->Show(1); |
---|
[3357] | 1810 | #$self->_populate_notebook($self->notebook, $imglistpage, 0); |
---|
[2597] | 1811 | # load imagelist with loading.jpg |
---|
| 1812 | } |
---|
| 1813 | |
---|
| 1814 | } |
---|
| 1815 | |
---|
| 1816 | |
---|
[3357] | 1817 | sub ActivateImageViewer { |
---|
| 1818 | my ( $self ) = @_; |
---|
| 1819 | |
---|
| 1820 | } |
---|
[2597] | 1821 | |
---|
| 1822 | |
---|
| 1823 | sub SetNewFilesViewerRefresh { |
---|
| 1824 | |
---|
| 1825 | my ( $self ) = @_; |
---|
| 1826 | |
---|
| 1827 | my $wximagelist = $self->imagelist->wx_thumb_imglist; |
---|
| 1828 | |
---|
| 1829 | my $indx = $wximagelist->Add( |
---|
| 1830 | Wx::Bitmap->new( |
---|
| 1831 | $self->imagelist->current_image->wx_thumb_file, |
---|
| 1832 | $self->GetWxBitmapType($self->imagelist->type), |
---|
| 1833 | ) |
---|
| 1834 | ) if defined $self->imagelist->current_image->wx_thumb_file; |
---|
[3227] | 1835 | print $self->imagelist->current_image->wx_thumb_file, " added with index ", $indx, "\n"; |
---|
[2597] | 1836 | $self->imageviewer->Refresh( |
---|
| 1837 | $wximagelist |
---|
| 1838 | ); |
---|
| 1839 | |
---|
| 1840 | Wx::Yield(); |
---|
| 1841 | } |
---|
| 1842 | |
---|
| 1843 | |
---|
| 1844 | |
---|
| 1845 | # prepare and upload image_selection |
---|
| 1846 | sub ProcessImageSelection { |
---|
| 1847 | my ( $self ) = @_; |
---|
| 1848 | |
---|
[3227] | 1849 | return if !scalar @{$self->imagelist->sums}; |
---|
[2597] | 1850 | |
---|
| 1851 | if( scalar @{$self->imagelist->categories} ){ |
---|
[3359] | 1852 | # all selected is implicit |
---|
| 1853 | if(!scalar @{$self->imageviewer->GetSelectedItems}){ |
---|
| 1854 | |
---|
| 1855 | $self->imagelist->image_selection( |
---|
| 1856 | $self->imageviewer->GetAllItems |
---|
| 1857 | ); |
---|
| 1858 | } |
---|
[3357] | 1859 | |
---|
[2618] | 1860 | return if( !defined $self->imagelist->image_selection ); |
---|
| 1861 | return if( !scalar @{$self->imagelist->image_selection} ); |
---|
| 1862 | |
---|
[2597] | 1863 | $self->upload_progressdlg( |
---|
| 1864 | Uploader::GUI::wxImageProcessingProgressDlg->new( |
---|
| 1865 | { |
---|
[3227] | 1866 | title => gettext("Image upload progress information"), |
---|
[3159] | 1867 | bt_label => gettext("Cancel upload"), |
---|
[2597] | 1868 | } |
---|
| 1869 | ) |
---|
| 1870 | ); |
---|
[2696] | 1871 | # modeless dialog |
---|
[2597] | 1872 | $self->upload_progressdlg->Show(1); |
---|
| 1873 | Wx::Yield(); |
---|
[2696] | 1874 | eval { |
---|
| 1875 | $self->imagelist->UploadSelection; |
---|
| 1876 | }; |
---|
| 1877 | if($@){ |
---|
| 1878 | Wx::MessageBox( |
---|
| 1879 | sprintf( |
---|
[3159] | 1880 | gettext("Upload cancelled"), |
---|
[2696] | 1881 | ), |
---|
[3159] | 1882 | gettext("Piwigo upload information"), |
---|
[2696] | 1883 | wxOK | wxICON_INFORMATION, |
---|
| 1884 | ); |
---|
| 1885 | } |
---|
[2597] | 1886 | } |
---|
| 1887 | else { |
---|
[2661] | 1888 | Wx::MessageBox( |
---|
| 1889 | sprintf( |
---|
[3284] | 1890 | "%s %s", |
---|
| 1891 | gettext("Please select a valid target"), |
---|
| 1892 | wxTheApp->branding->{category} |
---|
[2661] | 1893 | ), |
---|
[3159] | 1894 | gettext("Piwigo upload error"), |
---|
[2661] | 1895 | wxOK | wxICON_EXCLAMATION, |
---|
| 1896 | ); |
---|
[2597] | 1897 | } |
---|
| 1898 | } |
---|
| 1899 | |
---|
| 1900 | |
---|
| 1901 | sub SetNewFilesProgress { |
---|
| 1902 | my ( $self ) = @_; |
---|
| 1903 | |
---|
| 1904 | my $imagelist = $self->imagelist; |
---|
| 1905 | |
---|
| 1906 | $self->progressdlg->processing( |
---|
| 1907 | sprintf( |
---|
| 1908 | $imagelist->progress_msg, |
---|
| 1909 | $imagelist->current_image->file, |
---|
| 1910 | ) |
---|
| 1911 | ); |
---|
| 1912 | |
---|
| 1913 | eval { |
---|
| 1914 | $self->progressdlg->image->SetSize([ $imagelist->wx_thumb_size, $imagelist->wx_thumb_size]); |
---|
| 1915 | $self->progressdlg->image->SetBitmap(wxNullBitmap); |
---|
| 1916 | $self->progressdlg->image->SetBitmap( |
---|
| 1917 | Wx::Bitmap->new( |
---|
| 1918 | $imagelist->current_image->wx_thumb_file, |
---|
| 1919 | $self->GetWxBitmapType( $imagelist->type ) |
---|
| 1920 | ) |
---|
| 1921 | ); |
---|
| 1922 | $self->progressdlg->progress( |
---|
| 1923 | $imagelist->count * ( 100/scalar @{$imagelist->new_files} ) |
---|
| 1924 | ); |
---|
| 1925 | $self->progressdlg->LogProgress(); |
---|
| 1926 | }; |
---|
| 1927 | Wx::Yield(); |
---|
| 1928 | } |
---|
| 1929 | |
---|
| 1930 | sub OnClose { |
---|
| 1931 | my $self = shift; |
---|
| 1932 | |
---|
[3284] | 1933 | |
---|
[2597] | 1934 | # Restaure previous log wnd |
---|
| 1935 | Wx::Log::SetActiveTarget( $self->oldlogwnd ); |
---|
| 1936 | |
---|
| 1937 | # allways store |
---|
[3227] | 1938 | |
---|
[2597] | 1939 | wxTheApp->StoreConnectionProperties; |
---|
| 1940 | |
---|
| 1941 | $self->imagelist->Store; |
---|
[3227] | 1942 | wxTheApp->login_dlg->Destroy; |
---|
[3284] | 1943 | |
---|
| 1944 | my $params = {}; |
---|
| 1945 | |
---|
| 1946 | ( $params->{'X'}, $params->{'Y'} ) = $self->GetPositionXY ; |
---|
| 1947 | ( $params->{'Width'}, $params->{'Height'} ) = $self->GetSizeWH ; |
---|
| 1948 | ( $params->{'PreviewWidth'}, $params->{'PreviewHeight'} ) = $self->image_preview->GetSizeWH ; |
---|
| 1949 | $params->{Perspective} = $self->manager->SavePerspective; |
---|
[3362] | 1950 | $params->{ImageviewerIndex} = $self->current_imageviewer_index; |
---|
[3284] | 1951 | |
---|
| 1952 | |
---|
| 1953 | wxTheApp->SaveConfig( $params ); |
---|
| 1954 | |
---|
[2597] | 1955 | $self->Destroy; |
---|
| 1956 | } |
---|
| 1957 | |
---|
| 1958 | |
---|
| 1959 | sub create_toolbar { |
---|
| 1960 | my( $self ) = @_; |
---|
| 1961 | |
---|
| 1962 | my $tb = Wx::ToolBar->new( $self, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT ); |
---|
| 1963 | $tb->SetToolBitmapSize( wxSIZE( 32, 32 ) ); |
---|
| 1964 | map { |
---|
| 1965 | my $icon1 = Wx::Icon->new(); |
---|
| 1966 | eval { |
---|
| 1967 | $icon1->LoadFile($_->[2], $_->[3]); |
---|
| 1968 | }; |
---|
| 1969 | my $tb_icon1 = Wx::Bitmap->new( $icon1 ); |
---|
| 1970 | |
---|
| 1971 | my $icon2 = Wx::Icon->new(); |
---|
| 1972 | eval { |
---|
| 1973 | $icon2->LoadFile($_->[5], $_->[3]); |
---|
| 1974 | }; |
---|
| 1975 | my $tb_icon2 = Wx::Bitmap->new( $icon2 ); |
---|
| 1976 | |
---|
| 1977 | |
---|
| 1978 | $tb->AddTool( $_->[0], $_->[1], $tb_icon1, $tb_icon2, wxITEM_NORMAL, $_->[1] ); |
---|
| 1979 | $tb->EnableTool( $_->[0], $_->[4]); |
---|
| 1980 | } |
---|
| 1981 | ( |
---|
| 1982 | [ |
---|
[3357] | 1983 | 100, |
---|
| 1984 | gettext("Getting started"), |
---|
| 1985 | '../res/tb_getting_started.png', |
---|
| 1986 | wxBITMAP_TYPE_PNG, |
---|
| 1987 | 1, |
---|
| 1988 | '../res/tb_getting_started.png', |
---|
| 1989 | gettext("Display getting started panel") |
---|
| 1990 | ], |
---|
| 1991 | [ |
---|
[3227] | 1992 | 101, |
---|
| 1993 | gettext("Add photo to selection"), |
---|
| 1994 | '../res/tb_add.png', |
---|
| 1995 | wxBITMAP_TYPE_PNG, |
---|
| 1996 | 1, |
---|
| 1997 | '../res/tb_add.png', |
---|
| 1998 | gettext("Add photo to selection for resizing and uploading") |
---|
[2597] | 1999 | ], |
---|
| 2000 | [ |
---|
[3227] | 2001 | 102, |
---|
| 2002 | gettext("Remove photo from selection"), |
---|
| 2003 | '../res/tb_remove.png', |
---|
| 2004 | wxBITMAP_TYPE_PNG, |
---|
| 2005 | 1, |
---|
| 2006 | '../res/tb_remove.png', |
---|
| 2007 | gettext("Remove photo from selection. Files are not deleted ") |
---|
[2597] | 2008 | ], |
---|
| 2009 | [ |
---|
[3227] | 2010 | 103, |
---|
| 2011 | gettext("Upload to Piwigo"), |
---|
| 2012 | '../res/tb_upload.png', |
---|
| 2013 | wxBITMAP_TYPE_PNG, |
---|
| 2014 | wxTheApp->use_offline ? 0 : 1, |
---|
| 2015 | '../res/tb_upload.png', |
---|
| 2016 | gettext("Upload photos to Piwigo.") |
---|
[2597] | 2017 | ], |
---|
| 2018 | [ |
---|
[3227] | 2019 | 104, |
---|
| 2020 | gettext("Global settings"), |
---|
| 2021 | '../res/tb_settings.png', |
---|
| 2022 | wxBITMAP_TYPE_PNG, |
---|
| 2023 | 0, |
---|
| 2024 | '../res/tb_settings.png', |
---|
| 2025 | gettext("Change global settings.") |
---|
[2597] | 2026 | ], |
---|
[3159] | 2027 | [ |
---|
[3227] | 2028 | 105, |
---|
| 2029 | gettext("Language choice"), |
---|
| 2030 | '../res/tb_i18n.png', |
---|
| 2031 | wxBITMAP_TYPE_PNG, |
---|
| 2032 | 1, |
---|
| 2033 | '../res/tb_i18n.png', |
---|
| 2034 | gettext("Language choice") |
---|
[3159] | 2035 | ], |
---|
[2597] | 2036 | |
---|
| 2037 | ); |
---|
| 2038 | |
---|
| 2039 | if($@){ |
---|
| 2040 | undef $tb; |
---|
| 2041 | } |
---|
| 2042 | else{ |
---|
| 2043 | $tb->Realize; |
---|
| 2044 | } |
---|
| 2045 | |
---|
| 2046 | return $tb; |
---|
| 2047 | } |
---|
| 2048 | |
---|
| 2049 | |
---|
| 2050 | sub _create_textctrl { |
---|
| 2051 | my( $self, $parent, $text, $size ) = @_; |
---|
| 2052 | |
---|
| 2053 | return Wx::TextCtrl->new( $parent, -1, $text, [0, 0], $size, |
---|
| 2054 | wxNO_BORDER | wxTE_MULTILINE | wxTE_READONLY ); |
---|
| 2055 | } |
---|
| 2056 | |
---|
| 2057 | sub create_textctrl { |
---|
| 2058 | my( $self, $text, $size ) = @_; |
---|
| 2059 | |
---|
| 2060 | return $self->_create_textctrl( $self, $text, $size ); |
---|
| 2061 | } |
---|
| 2062 | |
---|
| 2063 | sub DESTROY { |
---|
| 2064 | my( $self ) = @_; |
---|
| 2065 | |
---|
| 2066 | $self->manager->UnInit; |
---|
| 2067 | } |
---|
| 2068 | |
---|
| 2069 | |
---|
| 2070 | |
---|
| 2071 | 1; |
---|
| 2072 | |
---|
| 2073 | |
---|
| 2074 | |
---|
| 2075 | |
---|
| 2076 | |
---|
| 2077 | package DNDImageListDropTarget; |
---|
[3370] | 2078 | use Wx qw/wxTheApp/; |
---|
[2597] | 2079 | use base qw(Wx::FileDropTarget Class::Accessor::Fast); |
---|
| 2080 | |
---|
| 2081 | __PACKAGE__->mk_accessors( |
---|
| 2082 | qw/ |
---|
| 2083 | imageviewer |
---|
| 2084 | / |
---|
| 2085 | ); |
---|
| 2086 | |
---|
| 2087 | sub new { |
---|
| 2088 | my $class = shift; |
---|
| 2089 | my $imageviewer = shift; |
---|
| 2090 | my $self = $class->SUPER::new( @_ ); |
---|
| 2091 | |
---|
| 2092 | $self->imageviewer($imageviewer); |
---|
[3370] | 2093 | |
---|
[2597] | 2094 | return $self; |
---|
| 2095 | } |
---|
| 2096 | |
---|
| 2097 | sub OnDropFiles { |
---|
| 2098 | my( $self, $x, $y, $files ) = @_; |
---|
| 2099 | |
---|
[3370] | 2100 | wxTheApp->frame->SetNewFiles($files) ; |
---|
[2597] | 2101 | } |
---|
| 2102 | |
---|
[3227] | 2103 | |
---|
| 2104 | |
---|
| 2105 | |
---|
[2597] | 2106 | 1; |
---|
| 2107 | |
---|
| 2108 | |
---|
| 2109 | package DNDCategoryTreeDropTarget; |
---|
| 2110 | |
---|
| 2111 | use base qw(Wx::TextDropTarget Class::Accessor::Fast); |
---|
| 2112 | use Data::Dumper; |
---|
| 2113 | use Wx qw/ |
---|
| 2114 | wxDragNone |
---|
| 2115 | wxDragCopy |
---|
| 2116 | wxDragMove |
---|
| 2117 | /; |
---|
| 2118 | |
---|
| 2119 | __PACKAGE__->mk_accessors( |
---|
| 2120 | qw/ |
---|
| 2121 | tree |
---|
| 2122 | frame |
---|
| 2123 | / |
---|
| 2124 | ); |
---|
| 2125 | |
---|
| 2126 | sub new { |
---|
| 2127 | my ( $class, $tree ) = @_; |
---|
| 2128 | my $self = $class->SUPER::new(); |
---|
| 2129 | |
---|
| 2130 | $self->tree($tree); |
---|
| 2131 | $self->frame($tree->GetParent); |
---|
| 2132 | return $self; |
---|
| 2133 | } |
---|
| 2134 | |
---|
| 2135 | |
---|
| 2136 | |
---|
| 2137 | sub OnDropText { |
---|
| 2138 | my( $self, $x, $y, $textdata ) = @_; |
---|
| 2139 | |
---|
| 2140 | # must be $VAR1 because $textdata is the result of Data::Dumper |
---|
| 2141 | my $VAR1; |
---|
| 2142 | eval $textdata; |
---|
| 2143 | eval { |
---|
| 2144 | if(scalar @$VAR1){ |
---|
| 2145 | my @items; |
---|
| 2146 | if(scalar @items < 2) { |
---|
| 2147 | my ($dropItem, $flag) = $self->tree->HitTest([$x, $y]); |
---|
| 2148 | push @items, $dropItem; |
---|
| 2149 | } |
---|
| 2150 | else { |
---|
| 2151 | @items = $self->tree->GetSelections; |
---|
| 2152 | } |
---|
| 2153 | |
---|
[2661] | 2154 | # remove root item which is not a valid category |
---|
| 2155 | @items = grep { $self->tree->GetPlData( $_ ) != -1 } @items; |
---|
| 2156 | |
---|
[2597] | 2157 | $self->frame->imagelist->categories( |
---|
| 2158 | [ |
---|
| 2159 | map { |
---|
[2661] | 2160 | $self->tree->GetPlData( $_ )->{id}; |
---|
[2597] | 2161 | } |
---|
| 2162 | @items |
---|
| 2163 | ] |
---|
| 2164 | ); |
---|
[2661] | 2165 | |
---|
[2597] | 2166 | $self->frame->imagelist->image_selection($VAR1); |
---|
| 2167 | $self->frame->ProcessImageSelection ; |
---|
| 2168 | } |
---|
| 2169 | }; |
---|
| 2170 | } |
---|
| 2171 | |
---|
| 2172 | 1; |
---|