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