Changeset 2661 for extras/pLoader/trunk
- Timestamp:
- Oct 5, 2008, 12:31:42 AM (16 years ago)
- Location:
- extras/pLoader/trunk
- Files:
-
- 1 added
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
extras/pLoader/trunk/build/build_pLoader.bat
r2597 r2661 1 wxpar.bat @par_options.txt --icon=..\res\favicon.ico -output=pLoader.exe ..\src\pLoader.pl1 wxpar.bat @par_options.txt --gui --icon=..\res\favicon.ico -output=pLoader.exe ..\src\pLoader.pl -
extras/pLoader/trunk/res/global_settings_wdr.pl
r2618 r2661 24 24 use vars qw($ID_GLOBAL_RESIZED_W); $ID_GLOBAL_RESIZED_W = 10004; 25 25 use vars qw($ID_GLOBAL_RESIZED_H); $ID_GLOBAL_RESIZED_H = 10005; 26 use vars qw($ID_GLOBAL_OK); $ID_GLOBAL_OK = 10006;27 use vars qw($ID_GLOBAL_CANCEL); $ID_GLOBAL_CANCEL = 10007;28 26 29 27 sub GlobalSettings { … … 62 60 $item1->AddWindow( $item11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); 63 61 64 $item1->AddSpace( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );65 66 my( $item12 ) = Wx::BoxSizer->new( wxHORIZONTAL );67 68 my( $item13 ) = Wx::Button->new( $_[0], $main::ID_GLOBAL_OK, "Save", wxDefaultPosition, wxDefaultSize, 0 );69 $item13->SetDefault();70 $item12->AddWindow( $item13, 0, wxALIGN_CENTER|wxALL, 5 );71 72 my( $item14 ) = Wx::Button->new( $_[0], $main::ID_GLOBAL_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize, 0 );73 $item12->AddWindow( $item14, 0, wxALIGN_CENTER|wxALL, 5 );74 75 $item1->Add( $item12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );76 77 62 $item0->Add( $item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); 78 63 -
extras/pLoader/trunk/res/photo_properties_wdr.pl
r2618 r2661 23 23 use vars qw($ID_PHOTO_COMMENT); $ID_PHOTO_COMMENT = 10003; 24 24 use vars qw($ID_PHOTO_CREATE_DATE); $ID_PHOTO_CREATE_DATE = 10004; 25 use vars qw($ID_PHOTO_OK); $ID_PHOTO_OK = 10005;26 use vars qw($ID_PHOTO_CANCEL); $ID_PHOTO_CANCEL = 10006;27 25 28 26 sub PhotoProperties { … … 55 53 $item1->AddWindow( $item9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); 56 54 57 $item1->AddSpace( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );58 59 my( $item10 ) = Wx::BoxSizer->new( wxHORIZONTAL );60 61 my( $item11 ) = Wx::Button->new( $_[0], $main::ID_PHOTO_OK, "Save", wxDefaultPosition, wxDefaultSize, 0 );62 $item11->SetDefault();63 $item10->AddWindow( $item11, 0, wxALIGN_CENTER|wxALL, 5 );64 65 my( $item12 ) = Wx::Button->new( $_[0], $main::ID_PHOTO_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize, 0 );66 $item10->AddWindow( $item12, 0, wxALIGN_CENTER|wxALL, 5 );67 68 $item1->Add( $item10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );69 70 55 $item0->Add( $item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); 71 56 -
extras/pLoader/trunk/src/Uploader/GUI/wxApp.pm
r2618 r2661 27 27 wxBITMAP_TYPE_PNG 28 28 wxBITMAP_TYPE_JPEG 29 wxIMAGE_QUALITY_NORMAL 30 wxIMAGE_QUALITY_HIGH 29 31 wxSPLASH_CENTRE_ON_SCREEN 30 32 wxSPLASH_TIMEOUT … … 168 170 eval { 169 171 $stored_imagelist = retrieve $self->storable_file; 170 $stored_imagelist->{images_h} = {};171 172 }; 172 173 if($@){ 174 Wx::LogMessage( 175 "An error has occured. Can not read %s\n%s", 176 $self->storable_file, 177 $@ 178 ); 173 179 $stored_imagelist = $self->_default_imagelist_params ; 174 180 } … … 183 189 ) 184 190 ); 191 192 $self->imagelist->ResizeCallback( 193 sub { $self->ResizeImage(@_) } 194 ); 185 195 } 186 196 … … 191 201 my $params = { 192 202 thumb_size => 120, 193 site_thumb_dir 203 site_thumb_dir => $self->thumb_dir, 194 204 wx_thumb_size => 120, 195 205 wx_thumb_dir => $self->wx_thumb_dir, … … 198 208 resize_w => 800, 199 209 resize_h => 600, 200 site_resized_dir 210 site_resized_dir => $self->resized_dir, 201 211 type => 'jpg', 202 212 filter => 'Lanczos', 203 blur => 1,204 quality => 90,213 blur => 0.9, 214 quality => 100, 205 215 prefix => 'TN', 206 216 count => 0, 207 217 storable_file => $self->storable_file, 208 218 images => [], 209 images_h => {},210 219 userdata_dir => $self->userdata_dir, 211 220 default_name_prefix => 'Photo', 212 221 upload_rejects => [], 222 ResizeCallback => sub { $self->ResizeImage(@_) }, 213 223 }; 214 224 … … 254 264 ) 255 265 ); 256 printf( 257 "conf file %s\n", 258 $self->conf_file 259 ); 266 260 267 261 268 … … 326 333 } 327 334 335 336 sub ResizeImage { 337 my ( $self, $image_file, $image_file_out, $type, $ratio, $width, $height, $quality ) = @_; 338 339 340 my $image = Wx::Image->new( 341 $image_file, 342 $self->GetWxBitmapType($type), 343 0 344 ); 345 346 my $w; 347 my $h; 348 349 my $img_w = $image->GetWidth; 350 my $img_h = $image->GetHeight; 351 352 # use a ratio ( 25% default ) if defined 353 # default ratio is used for preview. 354 if($ratio){ 355 $w = $ratio*$img_w/100 ; 356 $h = $ratio*$img_h/100 ; 357 } 358 # use specified width and height 359 else{ 360 # portrait 361 if( $img_w < $img_h ){ 362 $w = $height; 363 } 364 else{ 365 $w = $width; 366 } 367 # to respect aspect ratio 368 $h = sprintf( 369 "%.0f", 370 ($w*$img_h)/$img_w 371 ); 372 } 373 374 $image->Rescale( 375 $w, 376 $h, 377 wxIMAGE_QUALITY_HIGH 378 ); 379 380 $quality ||= 90; 381 382 $image->SetOption( 383 "quality", 384 $quality 385 ); 386 387 if(!$image->SaveFile( 388 $image_file_out, 389 $self->GetWxBitmapType($type), 390 )){ 391 Wx::LogMessage( 392 "An error has occured. Can not save file %s", 393 $image_file_out, 394 ) 395 }; 396 } 328 397 329 398 sub _init_frame { … … 363 432 width => $w, 364 433 height => $h, 365 title => "pLoader - Piwigo uploader - [$url]" ,434 title => "pLoader - Piwigo uploader 1.0 RC2 - [$url]" , 366 435 pwg => $self->pwg, 367 436 imagelist => $self->imagelist, -
extras/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
r2618 r2661 57 57 wxTR_HAS_BUTTONS 58 58 wxMAXIMIZE 59 wxOK 60 wxICON_EXCLAMATION 59 61 /; 60 62 use base qw/Wx::Frame Class::Accessor::Fast/; … … 90 92 EVT_MENU 91 93 EVT_TREE_SEL_CHANGED 92 EVT_UPDATE_UI93 94 EVT_CLOSE 94 95 EVT_LIST_END_LABEL_EDIT 95 EVT_LIST_ITEM_SELECTED 96 EVT_LIST_ITEM_SELECTED 97 EVT_TREE_ITEM_RIGHT_CLICK 96 98 /; 97 99 … … 106 108 use Uploader::GUI::wxPhotoExifPanel; 107 109 use Uploader::GUI::wxGlobalSettingsPanel; 110 use Encode qw/encode decode is_utf8/; 108 111 109 112 $|=1; 113 114 my $ID_TREE_CTX_MENU = 20000 ; 110 115 111 116 sub new { … … 147 152 ); 148 153 154 $self->imagelist->categories( 155 [] 156 ); 157 149 158 $self->manager( Wx::AuiManager->new ); 150 159 $self->manager->SetManagedWindow( $self ); … … 203 212 parentwnd => $self, 204 213 accessors => { 205 name => [ 206 sub { $self->imagelist->current_image->site_name(@_) }, 207 $main::ID_PHOTO_NAME 208 ], 209 date_created => [ 210 sub { $self->imagelist->current_image->create_date(@_) }, 211 $main::ID_PHOTO_CREATE_DATE 212 ], 213 comment => [ 214 sub { $self->imagelist->current_image->site_comment(@_) }, 215 $main::ID_PHOTO_COMMENT 216 ], 217 author => [ 218 sub { $self->imagelist->current_image->site_author(@_) }, 219 $main::ID_PHOTO_AUTHOR 220 ], 214 $main::ID_PHOTO_NAME => 215 sub { $self->imagelist->current_image->site_name(@_) }, 216 217 $main::ID_PHOTO_CREATE_DATE => 218 sub { $self->imagelist->current_image->create_date(@_) }, 219 220 $main::ID_PHOTO_COMMENT => 221 sub { $self->imagelist->current_image->site_comment(@_) }, 222 223 $main::ID_PHOTO_AUTHOR => 224 sub { $self->imagelist->current_image->site_author(@_) }, 221 225 }, 222 frame_callback => sub { 223 $self->imageviewer->Refresh(); 224 }, 226 frame_callbacks => { 227 $main::ID_PHOTO_NAME => 228 sub { 229 $self->imageviewer->Refresh(); 230 }, 231 }, 225 232 } 226 233 ) … … 231 238 { 232 239 parentwnd => $self, 240 frame_callback => sub { 241 $self->imageviewer->Refresh(); 242 }, 233 243 accessors => { 234 create_date => [ 235 sub { $self->imagelist->current_image->create_date }, 236 $main::ID_EXIF_CREATE_DATE 237 ], 238 model => [ 239 sub { $self->imagelist->current_image->exif_tag('Model') }, 240 $main::ID_EXIF_MODEL 241 ], 242 width => [ 243 sub { $self->imagelist->current_image->exif_tag('ImageWidth') }, 244 $main::ID_EXIF_WIDTH 245 ], 246 height => [ 247 sub { $self->imagelist->current_image->exif_tag('ImageHeight') }, 248 $main::ID_EXIF_HEIGHT 249 ], 250 orientation => [ 251 sub { $self->imagelist->current_image->exif_tag('Orientation') }, 252 $main::ID_EXIF_ORIENTATION 253 ], 254 iso => [ 255 sub { $self->imagelist->current_image->exif_tag('ISO') }, 256 $main::ID_EXIF_ISO 257 ], 258 shutter_speed => [ 259 sub { $self->imagelist->current_image->exif_tag('ShutterSpeedValue') }, 260 $main::ID_EXIF_SHUTTER_SPEED 261 ], 262 aperture => [ 263 sub { $self->imagelist->current_image->exif_tag('ApertureValue') }, 264 $main::ID_EXIF_APERTURE 265 ], 266 focal_length => [ 267 sub { $self->imagelist->current_image->exif_tag('FocalLength') }, 268 $main::ID_EXIF_FOCAL_LENGTH 269 ], 270 lens => [ 271 sub { $self->imagelist->current_image->exif_tag('Lens') }, 272 $main::ID_EXIF_LENS 273 ], 244 $main::ID_EXIF_CREATE_DATE => 245 sub { $self->imagelist->current_image->create_date }, 246 $main::ID_EXIF_MODEL => 247 sub { $self->imagelist->current_image->exif_tag('Model') }, 248 $main::ID_EXIF_WIDTH => 249 sub { $self->imagelist->current_image->exif_tag('ImageWidth') }, 250 $main::ID_EXIF_HEIGHT => 251 sub { $self->imagelist->current_image->exif_tag('ImageHeight') }, 252 $main::ID_EXIF_ORIENTATION => 253 sub { $self->imagelist->current_image->exif_tag('Orientation') }, 254 $main::ID_EXIF_ISO => 255 sub { $self->imagelist->current_image->exif_tag('ISO') }, 256 $main::ID_EXIF_SHUTTER_SPEED => 257 sub { $self->imagelist->current_image->exif_tag('ExposureTime') }, 258 $main::ID_EXIF_APERTURE => 259 sub { $self->imagelist->current_image->exif_tag('ApertureValue') }, 260 $main::ID_EXIF_FOCAL_LENGTH => 261 sub { $self->imagelist->current_image->exif_tag('FocalLength') }, 262 $main::ID_EXIF_LENS => 263 sub { $self->imagelist->current_image->exif_tag('Lens') }, 274 264 }, 275 265 } … … 341 331 my ( $self ) = @_; 342 332 343 $self->global_settings_panel( 344 $self->create_global_settings_panel() 345 ); 346 347 $self->manager->AddPane 348 ( $self->create_notebook_global_settings, Wx::AuiPaneInfo->new->Name( "global_settings" ) 349 ->Right->Position( 2 )->Resizable->CloseButton(1) ); 350 333 $self->manager->GetPane("global_settings")->Show(1); 351 334 $self->manager->Update(); 352 353 335 } 354 336 … … 428 410 parentwnd => $self, 429 411 accessors => { 430 default_name_prefix => 431 [ 432 sub { $self->imagelist->default_name_prefix(@_) }, 433 $main::ID_GLOBAL_NAME_PREFIX 434 ], 435 author => [ 436 sub { $self->imagelist->author(@_) }, 437 $main::ID_GLOBAL_AUTHOR 438 ], 439 thumb_size => [ 440 sub { $self->imagelist->thumb_size(@_) }, 441 $main::ID_GLOBAL_THUMB_SIZE 442 ], 443 resize_w => [ 444 sub { $self->imagelist->resize_w(@_) }, 445 $main::ID_GLOBAL_RESIZED_W 446 ], 447 resize_h => [ 448 sub { $self->imagelist->resize_h(@_) }, 449 $main::ID_GLOBAL_RESIZED_H 450 ], 412 $main::ID_GLOBAL_NAME_PREFIX => 413 sub { $self->imagelist->default_name_prefix(@_) }, 414 $main::ID_GLOBAL_AUTHOR => 415 sub { $self->imagelist->author(@_) }, 416 $main::ID_GLOBAL_THUMB_SIZE => 417 sub { $self->imagelist->thumb_size(@_) }, 418 $main::ID_GLOBAL_RESIZED_W => 419 sub { $self->imagelist->resize_w(@_) }, 420 $main::ID_GLOBAL_RESIZED_H => 421 sub { $self->imagelist->resize_h(@_) }, 451 422 }, 452 frame_callback => sub { 453 Wx::LogMessage("Author %s", $self->imagelist->author); 454 }, 423 frame_callbacks => { 424 }, 455 425 } 456 426 ); … … 466 436 } 467 437 ( 438 '../res/tree_pwg.png', 468 439 '../res/tree_folder.png', 469 440 ) … … 487 458 # wxTR_MULTIPLE| 488 459 # wxTR_EXTENDED| 489 wxTR_HAS_BUTTONS |490 wxTR_HIDE_ROOT460 wxTR_HAS_BUTTONS 461 # wxTR_HIDE_ROOT 491 462 ) 492 463 ); 493 464 494 465 $self->tree->SetImageList( $self->treeimglist ); 466 $self->populate_tree_categories; 467 $self->tree ; 468 } 469 470 471 sub populate_tree_categories { 472 my ( $self ) = @_; 495 473 496 474 $self->populate_tree( … … 499 477 ) if defined wxTheApp->pwg ; 500 478 501 $self->tree->SelectItem( $self->tree_item_default, 1) if defined $self->tree_item_default;502 503 my $category = $self->tree->GetPlData(504 $self->tree_item_default505 ) if defined $self->tree_item_default;;506 507 $self->imagelist->categories(508 []509 );510 511 $self->imagelist->categories(512 [ $category->{id} ]513 ) if $category != -1;514 515 479 $self->tree->ExpandAll; 516 $self->tree ; 517 } 518 480 481 } 519 482 520 483 #$tree_items is a list of anonymous arrays … … 559 522 560 523 map { 524 my $name = $_->[0]; 561 525 $id = $tree->AppendItem( 562 526 $parent_id, 563 $_->[0], 564 0, 565 0, 566 #defined($_->[3]) ? $_->[3] : 0, 567 #defined($_->[4]) ? $_->[4] : 0, 527 is_utf8($name) ? decode('UTF-8', $name) : $name, 528 defined($_->[3]) ? $_->[3] : 0, 529 defined($_->[4]) ? $_->[4] : 0, 568 530 itemData( $_->[2]) 569 531 ); … … 575 537 } 576 538 @{$tree_items}; 539 577 540 578 541 } … … 612 575 Wx::Event::EVT_MENU( $self, 104, \&OnGlobalSettings ); 613 576 EVT_TREE_SEL_CHANGED( $self, $self->tree, \&OnTreeSelChanged ); 577 EVT_TREE_ITEM_RIGHT_CLICK( $self->tree, $self->tree, \&OnTreeItemRightClick ); 614 578 EVT_LIST_END_LABEL_EDIT( $self, $self->imageviewer, \&OnImageViewerEndLabelEdit ); 615 579 EVT_LIST_ITEM_SELECTED($self, $self->imageviewer, \&OnImageViewerItemSelected) ; 616 580 EVT_CLOSE( $self, \&OnClose ); 617 581 582 583 Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategories ); 584 Wx::Event::EVT_MENU( $self, 2+$ID_TREE_CTX_MENU, \&OnRefreshCategories ); 618 585 } 619 586 … … 682 649 ] 683 650 ); 684 651 } 652 653 sub OnTreeItemRightClick { 654 my( $self, $event ) = @_; 655 656 my $point = $event->GetPoint ; 657 my $ctx_mnu = Wx::Menu->new; 658 659 map { 660 $ctx_mnu->Append( 661 @$_ 662 ); 663 } 664 ( 665 [1+$ID_TREE_CTX_MENU, "Add new category","Add a new category to the current selected category."], 666 [2+$ID_TREE_CTX_MENU, "Refresh","Refresh category list."], 667 ); 668 $self->PopupMenu($ctx_mnu, $point); 669 670 } 671 672 sub OnAddCategories { 673 my ( $self, $event ) = @_; 674 675 my $item = $self->tree->GetSelection; 676 677 my $category = $self->tree->GetPlData($item); 678 my $category_id; 679 680 $category_id = $category->{id} if 'HASH' eq ref($category) ; 681 682 my $dialog = Wx::TextEntryDialog->new( 683 $self, 684 "Category name :", 685 "Add new category", 686 "New category" 687 ); 688 689 if( $dialog->ShowModal != wxID_CANCEL ) { 690 my $name = $dialog->GetValue; 691 my ( $status, $status_msg ) = $self->pwg->AddCategories( $name, $category_id); 692 $self->_refresh_tree_categories_helper; 693 } 694 $dialog->Destroy; 695 } 696 697 sub OnRefreshCategories { 698 my ( $self, $event ) = @_; 699 700 $self->_refresh_tree_categories_helper; 701 } 702 703 sub _refresh_tree_categories_helper { 704 my ( $self ) = @_; 705 706 my $busycursor = Wx::BusyCursor->new(); 707 $self->tree->CollapseAll; 708 $self->tree->DeleteAllItems; 709 $self->imagelist->categories([]); 710 $self->pwg->RefreshCategories(); 711 $self->populate_tree_categories; 685 712 } 686 713 … … 814 841 815 842 return if !scalar @{$self->imagelist->images}; 816 817 843 818 844 if( scalar @{$self->imagelist->categories} ){ … … 832 858 } 833 859 else { 834 Wx::LogMessage("Please select a category"); 860 Wx::MessageBox( 861 sprintf( 862 "Please select a valid target category", 863 ), 864 "Piwigo upload error", 865 wxOK | wxICON_EXCLAMATION, 866 ); 835 867 } 836 868 } … … 1032 1064 } 1033 1065 1066 # remove root item which is not a valid category 1067 @items = grep { $self->tree->GetPlData( $_ ) != -1 } @items; 1068 1034 1069 $self->frame->imagelist->categories( 1035 1070 [ 1036 1071 map { 1037 my $category = $self->tree->GetPlData( $_ ); 1038 $category->{id} if $category != -1; 1072 $self->tree->GetPlData( $_ )->{id}; 1039 1073 } 1040 1074 @items 1041 1075 ] 1042 1076 ); 1077 1043 1078 $self->frame->imagelist->image_selection($VAR1); 1044 1079 $self->frame->ProcessImageSelection ; -
extras/pLoader/trunk/src/Uploader/GUI/wxGlobalSettingsPanel.pm
r2597 r2661 32 32 33 33 use Wx::Event qw/ 34 EVT_ BUTTON34 EVT_TEXT 35 35 /; 36 36 … … 55 55 56 56 57 $self-> InitAccessors( $params->{accessors} );58 $self->frame_callback (59 $params->{frame_callback }57 $self->accessors( $params->{accessors} ); 58 $self->frame_callbacks( 59 $params->{frame_callbacks} 60 60 ); 61 61 … … 90 90 my ( $self ) = @_; 91 91 92 EVT_BUTTON( $self, $main::ID_GLOBAL_OK, \&OnOK ); 93 EVT_BUTTON( $self, $main::ID_GLOBAL_CANCEL, \&OnCancel ); 92 map { 93 my $ctrl = $self->FindWindow($_); 94 EVT_TEXT($self, $ctrl, sub { OnTextChanged(@_) }); 95 } 96 keys %{$self->accessors}; 97 98 } 99 100 sub OnTextChanged { 101 my ( $self, $event ) = @_; 94 102 95 103 my $control_id = $event->GetId ; 104 105 $self->accessors->{$control_id}->( 106 $event->GetString 107 ); 108 109 110 my $frame_callback = $self->frame_callbacks->{$control_id}; 111 112 eval{ 113 $frame_callback->() if defined $frame_callback; 114 }; 96 115 } 97 116 98 117 99 118 100 sub OnOK {101 my ( $self, $event ) = @_;102 103 104 $self->GetControlValues();105 $self->frame_callback->();106 }107 108 sub OnCancel {109 my ( $self, $event ) = @_;110 111 # reset previous values112 113 }114 115 116 119 1; -
extras/pLoader/trunk/src/Uploader/GUI/wxPhotoExifPanel.pm
r2597 r2661 35 35 /; 36 36 37 #__PACKAGE__->mk_accessors(38 # qw/39 # btok40 # name41 # description42 # date_created43 # /44 #);45 37 46 38 __PACKAGE__->mk_accessors( … … 60 52 61 53 62 $self-> InitAccessors( $params->{accessors} );54 $self->accessors( $params->{accessors} ); 63 55 64 56 # load controls -
extras/pLoader/trunk/src/Uploader/GUI/wxPhotoPropertiesPanel.pm
r2597 r2661 31 31 32 32 use Wx::Event qw/ 33 EVT_ BUTTON33 EVT_TEXT 34 34 /; 35 35 36 36 37 __PACKAGE__->mk_accessors(38 qw/39 accessors40 frame_callback41 /42 );43 37 44 38 … … 54 48 55 49 56 $self-> InitAccessors( $params->{accessors} );57 $self->frame_callback (58 $params->{frame_callback }50 $self->accessors( $params->{accessors} ); 51 $self->frame_callbacks( 52 $params->{frame_callbacks} 59 53 ); 60 54 61 55 # load controls 62 56 &main::PhotoProperties($self, 1); 63 57 64 58 65 59 $self->_initEventHandlers(); … … 74 68 my ( $self ) = @_; 75 69 76 EVT_BUTTON( $self, $main::ID_PHOTO_OK, \&OnOK ); 77 EVT_BUTTON( $self, $main::ID_PHOTO_CANCEL, \&OnCancel ); 78 79 70 71 map { 72 my $ctrl = $self->FindWindow($_); 73 EVT_TEXT($self, $ctrl, sub { OnTextChanged(@_) }); 74 } 75 keys %{$self->accessors}; 80 76 } 81 77 82 78 83 79 84 sub On OK{80 sub OnTextChanged { 85 81 my ( $self, $event ) = @_; 86 82 83 my $control_id = $event->GetId ; 84 85 $self->accessors->{$control_id}->( 86 $event->GetString 87 ); 88 89 my $frame_callback = $self->frame_callbacks->{$control_id}; 87 90 88 $self->GetControlValues(); 89 $self->frame_callback->(); 90 } 91 92 sub OnCancel { 93 my ( $self, $event ) = @_; 94 95 # reset previous values 96 91 eval{ 92 $frame_callback->(); 93 }; 97 94 } 98 95 99 96 97 100 98 1; -
extras/pLoader/trunk/src/Uploader/ImageList.pm
r2618 r2661 48 48 current_image 49 49 images 50 images_h51 50 image_selection 52 51 exif_metadata … … 58 57 userdata_dir 59 58 progress_msg 59 last_error_msg 60 60 default_name_prefix 61 61 SetNewFilesViewerRefreshCallback … … 63 63 UploadImagesViewerCallback 64 64 UploadImagesProgressCallback 65 ResizeCallback 65 66 upload_rejects 66 67 pwg … … 75 76 76 77 77 78 sub _write_images_from_exif { 79 my ( $self, $info ) = @_; 78 # save exif preview image if available 79 # otherwise create a preview image 80 sub _write_preview_image { 81 my ( $self, $imagedata ) = @_; 80 82 81 83 82 84 # If PreviewImage is available, we use it 83 if(defined $i nfo->{PreviewImage}) {85 if(defined $imagedata ) { 84 86 eval { 85 87 open PREVIEW_FILE, ">", $self->current_image->preview_file ; 86 88 binmode PREVIEW_FILE; 87 print PREVIEW_FILE $ {$info->{PreviewImage}};89 print PREVIEW_FILE $$imagedata; 88 90 close PREVIEW_FILE; 89 91 }; 90 warn $@if $@;92 $self->last_error_msg($@) if $@; 91 93 } 92 else {93 # create a preview file94 $self->CreateGUIPreview();95 }96 # use the preview image to create a gui display thumbnail97 $self->CreateGUIThumbnail();98 94 99 95 } … … 131 127 ); 132 128 133 $self->current_image->site_resized_file(134 File::Spec->catfile(135 $self->site_resized_dir,136 sprintf(137 "%s_%sx%s.%s",138 $filename,139 $self->resize_w,140 $self->resize_h,141 $self->type,142 )143 )144 );145 129 146 130 $self->current_image->site_thumb_file( … … 166 150 } 167 151 152 168 153 sub SetNewFiles { 169 154 my ( $self, $files ) = @_; 170 155 171 156 $self->new_files( $files ); 172 157 … … 174 159 my $i = scalar @{$self->images}; 175 160 map { 176 $self->progress_msg("Creating thumbnail and preview for %s"); 177 178 # Only add new images 179 if(! exists $self->images_h->{$_} ){ 180 # exif metadata 181 my $info = ImageInfo( $_ ); 182 $self->_add_image($_, $info, $i); 183 $self->SetCurrentImage($i); 184 $self->_set_current_image_filepaths(); 185 $self->_write_images_from_exif($info ); 161 # read exif metadata 162 my $info; 163 164 165 eval { 166 $info = ImageInfo( $_ ); 167 }; 168 169 $info = {} if($@); 170 171 $self->_add_image($_, $info, $i); 172 $self->SetCurrentImage($i); 173 $self->_set_current_image_filepaths(); 174 175 176 # an exif preview is available. we use it 177 if(defined $info->{PreviewImage}){ 178 $self->_write_preview_image( $info->{PreviewImage} ); 179 } 180 # have to create a preview file 181 else { 182 eval { 183 if(!$self->CreateGUIPreview()){ 184 # use method provided by the caller 185 # source, target, type, ratio 186 $self->ResizeCallback->( 187 $self->current_image->file, 188 $self->current_image->preview_file, 189 $self->type, 190 $self->preview_ratio, 191 undef, 192 undef, 193 $self->quality, 194 ); 195 } 196 };# create a preview file 197 } 198 # Now, we should have a valid preview image. 199 # try to thumbnail it 200 eval { 201 # use the preview image to create a gui display thumbnail 202 $self->CreateGUIThumbnail(); 203 }; 204 # ok 205 if(!$@){ 206 $self->progress_msg("Thumbnail and preview created for %s"); 186 207 $i++; 187 208 $self->count($i); 188 189 $self->SetNewFilesProgressCallback->(); 190 $self->SetNewFilesViewerRefreshCallback->(); 191 } 209 } 210 else { 211 $self->progress_msg("An error has occured when processing %s\n$@"); 212 # remove from list 213 splice @{$self->images}, $i, 1; 214 } 215 216 $self->SetNewFilesProgressCallback->(); 217 $self->SetNewFilesViewerRefreshCallback->(); 192 218 193 219 } … … 204 230 my $image = Uploader::Image->new( 205 231 { 206 file=> $_,207 site_name=> sprintf(208 209 210 211 212 213 214 215 216 232 file => $_, 233 site_name => sprintf( 234 "%s %s", 235 $self->default_name_prefix, 236 $i, 237 ), 238 site_author => $self->author, 239 exif_metadata => $self->_select_exif_data($info), 240 add_rank => $i, 241 site_categories => [], 242 site_tags => [], 217 243 } 218 244 ); … … 221 247 $self->images->[$i] = $image ; 222 248 223 # to retrieve data by image file name224 $self->images_h->{$file} = $image ;225 249 } 226 250 … … 236 260 map { 237 261 my $image = $self->images->[$_]->file; 238 delete $self->images_h->{$image};239 262 splice @{$self->images}, $_, 1 ; 240 263 $self->wx_thumb_imglist->Remove($_); … … 252 275 253 276 return 1 if( -e $self->current_image->wx_thumb_file ); 277 my $rval = 0; 254 278 255 279 my $image = new Image::Magick; … … 263 287 $self->current_image->preview_file 264 288 ); 265 warn "$status" if $status ; 289 warn "$status" if $status; 290 return $rval if $status; 266 291 267 292 $status = $image->Thumbnail( 268 293 geometry=>sprintf("%s%s>", $size*$size, '@') 269 294 ); 270 warn "$status" if $status ; 295 warn "$status" if $status; 296 return $rval if $status; 271 297 272 298 $status = $image->Set(background=>"white"); … … 294 320 ) 295 321 ); 322 warn "$status" if $status; 323 return $rval if $status; 296 324 297 325 undef $image; 326 327 $rval = 1; 328 329 return $rval; 298 330 } 299 331 … … 303 335 304 336 return 1 if( -e $self->current_image->preview_file ); 305 306 my $image = new Image::Magick; 337 338 my $rval = 1; 339 340 my $image = Image::Magick->new(); 307 341 308 342 my $ratio = $self->preview_ratio; 309 343 310 my $status = $image->ReadImage( 344 345 my $status = $image->Read( 311 346 $self->current_image->file 312 347 ); 313 warn "$status" if $status ; 348 warn "$status ", $self->current_image->file, "\n" if $status ; 349 return 0 if $status; 314 350 315 351 $status = $image->Thumbnail( … … 321 357 ); 322 358 warn "$status" if $status ; 359 return 0 if $status; 323 360 324 361 … … 333 370 334 371 335 $ image->Write(372 $status = $image->Write( 336 373 sprintf( 337 374 "%s:%s", … … 340 377 ) 341 378 ); 379 warn "$status" if $status ; 380 return 0 if $status; 342 381 343 382 undef $image; 344 383 384 return $rval; 345 385 } 346 386 … … 349 389 my ( $self ) = @_; 350 390 351 return 1 if( -e $self->current_image->site_resized_file ); 391 my $rval = 1 ; 392 return $rval if( -e $self->current_image->site_resized_file ); 393 352 394 353 395 my $image = new Image::Magick; … … 357 399 ); 358 400 warn "$status" if $status ; 401 return 0 if $status; 359 402 360 403 my $w = $image->Get('width'); … … 377 420 ); 378 421 warn "$status" if $status ; 422 return 0 if $status; 379 423 380 424 $status = $image->Set(Gravity=>"Center"); … … 391 435 ) 392 436 ); 437 warn "$status" if $status ; 438 return 0 if $status; 393 439 394 440 undef $image; 395 441 442 443 $rval = 0 if $status; 444 445 return $rval; 396 446 } 397 447 … … 400 450 401 451 return 1 if( -e $self->current_image->site_thumb_file ); 452 453 my $rval = 1; 402 454 403 455 my $image = new Image::Magick; … … 438 490 undef $image; 439 491 492 493 $rval = 0 if $status; 494 495 return $rval; 440 496 } 441 497 … … 456 512 DateTimeOriginal 457 513 ISO 458 ShutterSpeedValue514 ExposureTime 459 515 ApertureValue 460 516 FocalLength … … 515 571 my ( $self ) = @_; 516 572 573 my $progress_msg; 517 574 my $progress_callback = $self->UploadImagesProgressCallback; 518 575 my $viewer_callback = $self->UploadImagesViewerCallback ; … … 529 586 $self->images->[$_] 530 587 ); 588 589 my ( $vol, $dir, $file ) = File::Spec->splitpath( 590 $self->current_image->file 591 ); 592 593 my ( $filename, $ext ) = split /\./, $file ; 594 595 # is defined lately to make sure we have the last global properties ( resize_w, resize_h ) 596 $self->current_image->site_resized_file( 597 File::Spec->catfile( 598 $self->site_resized_dir, 599 sprintf( 600 "%s_%sx%s.%s", 601 $filename, 602 $self->resize_w, 603 $self->resize_h, 604 $self->type, 605 ) 606 ) 607 ); 531 608 532 609 … … 536 613 # update upload progress dialog 537 614 $progress_callback->(); 538 $self->CreateResized(); 539 540 615 eval { 616 if(!$self->CreateResized()){ 617 printf("CreateResized failed %s. Use ResizeCallback\n", $@); 618 # use method provided by the caller 619 # source, target, type, ratio, width, $height 620 $self->ResizeCallback->( 621 $self->current_image->file, 622 $self->current_image->site_resized_file, 623 $self->type, 624 undef, 625 $self->resize_w, 626 $self->resize_h, 627 $self->quality, 628 ); 629 } 630 }; 631 if($@){ 632 $progress_msg = "An error has occured %s - %s\n$@"; 633 } 634 else{ 635 $progress_msg = "Preparing thumbnail for %s - %s"; 636 } 637 541 638 $self->progress_msg( 542 "Preparing thumbnail for %s - %s"639 $progress_msg 543 640 ); 544 641 # update upload progress dialog 545 642 $progress_callback->(); 546 $self->CreateThumbnail(); 547 548 549 550 $self->progress_msg( 551 "Uploading %s - %s" 552 ); 643 eval { 644 $self->CreateThumbnail(); 645 }; 646 if($@){ 647 $self->progress_msg( 648 "An error has occured %s - %s\n$@" 649 ); 650 } 651 else{ 652 $self->progress_msg( 653 "Uploading %s - %s" 654 ); 655 } 553 656 # update upload progress dialog 554 657 $progress_callback->() ; 555 556 $self->_prepare_upload ();658 659 $self->_prepare_upload_properties(); 557 660 my ( $status, $status_msg ) = $self->pwg->UploadImage(); 558 661 … … 563 666 } else { 564 667 $self->progress_msg( 565 "An error occured.\n%s : %s upload is cancelled."668 "An error has occured.\n%s : %s upload is cancelled.\n$status_msg" 566 669 ); 567 670 push @{$self->upload_rejects}, $self->current_image ; … … 579 682 } 580 683 581 sub _prepare_upload {684 sub _prepare_upload_properties { 582 685 my ( $self ) = @_; 583 686 -
extras/pLoader/trunk/src/Uploader/Object2.pm
r2597 r2661 26 26 /; 27 27 28 # $param is a hash with : 29 # key : member name 30 sub InitAccessors { 31 my ( $self, $accessors ) = @_; 32 33 $accessors ||= {}; 34 35 36 37 # create member accessors 38 __PACKAGE__->mk_accessors( 39 keys %$accessors 40 ); 41 42 43 # member accessors initialization 44 # accessor_name => [ sub {}, control_id ] 45 map { 46 $self->$_( 47 $accessors->{$_}->[0] 48 ); 49 } 50 keys %$accessors; 51 52 $self->accessors( 53 $accessors 54 ); 55 56 return $self; 57 } 28 __PACKAGE__->mk_accessors( 29 qw/ 30 accessors 31 frame_callbacks 32 / 33 ); 58 34 59 35 60 36 37 38 39 40 # Set control values with accessor 61 41 sub SetControlValues { 62 42 my ( $self ) = @_; … … 66 46 # accessor_name => [ sub {}, control_id ] 67 47 map { 68 my ( $accessor, $control_id) = @{$accessors->{$_}}; 69 48 my $control_id = $_; 70 49 my $ctrl = $self->FindWindow($control_id) ; 71 50 51 my $accessor = $accessors->{$control_id}; 72 52 eval { 73 $ctrl-> SetValue(53 $ctrl->ChangeValue( 74 54 $accessor->() 75 55 ); … … 88 68 } 89 69 70 # Get values from controls. Set callback accessors with these values 90 71 sub GetControlValues { 91 72 my ( $self ) = @_; 92 73 93 74 my $accessors = $self->accessors; 94 75 95 76 # accessor_name => [ sub {}, control_id ] 96 77 map { … … 115 96 116 97 98 sub GetControlValue { 99 my( $self, $control_id ) = @_; 100 101 my $value; 102 eval { 103 my $ctrl = $self->FindWindow( 104 $control_id 105 ); 106 107 $value = $ctrl->GetValue; 108 109 $self->accessors->{$control_id}->( 110 $value 111 ); 112 }; 113 114 return $value; 115 } 116 117 118 119 120 121 117 122 1; -
extras/pLoader/trunk/src/Uploader/PWG.pm
r2597 r2661 45 45 46 46 # for web services 47 $self->SUPER::Init(); 47 $self->SUPER::Init(); 48 49 $self->RefreshCategories; 50 51 } 52 53 sub RefreshCategories { 54 my ( $self ) = @_; 48 55 49 56 $self->categories( … … 55 62 56 63 57 58 59 64 1; -
extras/pLoader/trunk/src/Uploader/PWG/Categories.pm
r2597 r2661 20 20 package Uploader::PWG::Categories; 21 21 use strict; 22 use Data::Dumper; 22 23 use base qw/ 23 24 Uploader::Object … … 53 54 sort { $b <=> $a } 54 55 keys %$records; 55 56 56 57 return [ 57 58 [ 58 ' All',59 'Categories', 59 60 undef, 60 61 -1, 61 -1,62 0, 62 63 -1, 63 64 64 65 ], 65 values %$records,66 sort { $a->[6] <=> $b->[6] } values %$records, 66 67 ]; 67 68 } … … 112 113 undef, 113 114 $category, 114 -1,115 1, 115 116 -1, 116 117 $parent, -
extras/pLoader/trunk/src/Uploader/PWG/WebServices.pm
r2618 r2661 43 43 password 44 44 qry_list_categories 45 qry_add_ images45 qry_add_categories 46 46 items 47 47 tags … … 160 160 161 161 162 printf( 163 "UploadImage %s\n", 164 $self->imagefile 165 ); 162 166 my $file_content = encode_base64( 163 167 read_file( … … 190 194 thumbnail_content => $thumbnail_content, 191 195 categories => $self->categories, 192 name => encode('UTF-8', $self->imagename),196 name => $self->imagename, 193 197 rank => $self->rank, 194 198 author => $self->author, … … 206 210 } 207 211 208 212 213 sub AddCategories{ 214 my ( $self, $name, $parentid ) = @_; 215 216 my $form = { 217 method => 'pwg.categories.add', 218 name => $name, 219 parent => $parentid, 220 221 }; 222 223 my $result = $self->uagent->post( 224 $self->urlbase.'/ws.php?format=json', 225 $form 226 ); 227 228 return ( $result->is_success, $result->status_line ); 229 230 } 209 231 1; 210 232 -
extras/pLoader/trunk/src/ploader.pl
r2597 r2661 11 11 # | WITHOUT ANY WARRANTY; without even the implied warranty of | 12 12 # | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 # | General Public License for more details. |13 # | General Public License for more details. i | 14 14 # | | 15 15 # | You should have received a copy of the GNU General Public License |
Note: See TracChangeset
for help on using the changeset viewer.