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