Changeset 6538 for extensions
- Timestamp:
- Jun 16, 2010, 11:43:09 AM (14 years ago)
- Location:
- extensions/pLoader/trunk/src/Uploader
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/GUI/App.pm
r6522 r6538 62 62 my $transfer_progress_event : shared = Wx::NewEventType; 63 63 my $transfer_done_event : shared = Wx::NewEventType; 64 my $transfer_batch_end_event : shared = Wx::NewEventType; 64 65 my $resize_done_event : shared = Wx::NewEventType; 65 66 my $resize_progress_event : shared = Wx::NewEventType; 67 my $resize_batch_end_event : shared = Wx::NewEventType; 66 68 67 69 my $image_progress_event = Wx::NewEventType; … … 136 138 my @custom_events = qw/ 137 139 resize_start_event 140 batch_end_event 138 141 image_progress_event 139 142 /; … … 198 201 199 202 203 sub reset_add_rank { 204 my ( $self ) = @_; 205 206 $self->images->reset_add_rank; 207 } 208 209 200 210 sub cancel_all { 201 211 my ( $self ) = @_; 202 212 203 $self->resize_manager->cancel; 204 $self->transfer_manager->cancel; 213 $self->cancel_transfer if $self->cancel_resize; 205 214 } 206 215 … … 710 719 $self->resize_manager( 711 720 Uploader::ResizeManager->new({ 712 thumb_dir => $self->thumb_dir, 713 wx_thumb_dir => $self->wx_thumb_dir, 714 resized_dir => $self->resized_dir, 715 preferences => sub { $self->preferences(@_) }, 716 progress_event => $resize_progress_event, 717 done_event => $resize_done_event, 718 event_handler => $self, 721 thumb_dir => $self->thumb_dir, 722 wx_thumb_dir => $self->wx_thumb_dir, 723 resized_dir => $self->resized_dir, 724 preferences => sub { $self->preferences(@_) }, 725 progress_event => $resize_progress_event, 726 done_event => $resize_done_event, 727 batch_end_event => $resize_batch_end_event, 728 event_handler => $self, 719 729 }) 720 730 ); 721 731 732 $self->init_resize_batch_end_event_handler; 722 733 $self->init_resize_done_event_handler; 723 734 $self->init_resize_progress_event_handler; 735 } 736 737 738 sub init_resize_batch_end_event_handler { 739 my ( $self ) = @_; 740 741 Wx::Event::EVT_COMMAND( 742 $self, 743 -1, 744 $resize_batch_end_event, 745 sub { 746 my ( $handler, $event ) = @_; 747 my $msg : shared = shared_clone($event->GetData); 748 # add the batch end message to the queue 749 $self->transfer_manager->add_images([ $msg ]); 750 } 751 ); 752 724 753 } 725 754 … … 758 787 ); 759 788 789 } 790 791 792 sub on_batch_end { 793 my ( $self, $image ) = @_; 794 795 Wx::PostEvent( 796 $self->frame, 797 Wx::PlThreadEvent->new( 798 -1, 799 $self->batch_end_event, 800 $image 801 ) 802 ); 760 803 } 761 804 … … 1181 1224 $self->transfer_manager( 1182 1225 Uploader::TransferManager->new({ 1183 pwg => $self->pwg, 1184 progress_event => $transfer_progress_event, 1185 done_event => $transfer_done_event, 1186 event_handler => $self, 1226 pwg => $self->pwg, 1227 progress_event => $transfer_progress_event, 1228 done_event => $transfer_done_event, 1229 event_handler => $self, 1230 batch_end_event => $transfer_batch_end_event, 1187 1231 }) 1188 1232 ); 1189 1233 1190 1234 $self->image_progress_event( 1191 $image_progress_event 1192 ); 1193 1235 Wx::NewEventType 1236 ); 1237 1238 $self->batch_end_event( 1239 Wx::NewEventType 1240 ); 1241 1242 $self->init_transfer_batch_end_event_handler; 1194 1243 $self->init_transfer_done_event_handler; 1195 1244 $self->init_transfer_progress_event_handler; … … 1213 1262 1214 1263 1264 sub init_transfer_batch_end_event_handler { 1265 my ( $self ) = @_; 1266 1267 Wx::Event::EVT_COMMAND( 1268 $self, 1269 -1, 1270 $transfer_batch_end_event, 1271 sub { 1272 my ( $handler, $event ) = @_; 1273 my $data = $event->GetData; 1274 $handler->on_batch_end($data); 1275 } 1276 ); 1277 1278 } 1215 1279 1216 1280 … … 1259 1323 ); 1260 1324 1325 push @$images, { event => "BATCH_END" }; 1326 1261 1327 $self->resize_manager->add_images($images); 1262 1328 … … 1277 1343 my( $self ) = @_; 1278 1344 1279 # 1345 my $cancelled; 1346 1280 1347 if( $self->resize_manager->pending and wxYES == Wx::MessageBox( 1281 1348 sprintf( 1282 "Cancel %s pending job(s) ?",1349 "Cancel %s resize pending job(s) ?", 1283 1350 $self->resize_manager->pending, 1284 1351 ), … … 1286 1353 wxYES_NO|wxNO_DEFAULT| wxICON_QUESTION, ) 1287 1354 ){ 1355 $cancelled = 1; 1288 1356 $self->resize_manager->cancel; 1289 1357 } 1358 1359 $cancelled; 1360 } 1361 1362 1363 sub cancel_transfer { 1364 my( $self ) = @_; 1365 1366 my $cancelled = 1; 1367 if( $self->transfer_manager->pending ){ 1368 if( wxYES == Wx::MessageBox( 1369 sprintf( 1370 "Cancel %s transfer pending job(s) ?", 1371 $self->transfer_manager->pending, 1372 ), 1373 "pLoader job processing", 1374 wxYES_NO|wxNO_DEFAULT| wxICON_QUESTION, ) 1375 ) 1376 { 1377 $self->transfer_manager->cancel; 1378 } 1379 else{ 1380 $cancelled = 0; 1381 } 1382 } 1383 1384 $cancelled; 1290 1385 } 1291 1386 -
extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm
r6520 r6538 703 703 Uploader::GUI::ImageProgressDlg->new( 704 704 { 705 title => gettext("Image upload progress information"),705 title => gettext("Image upload progress information"), 706 706 progress_column => 2, 707 cancel_cbk => sub { wxTheApp->cancel_queues }, 707 cancel_cbk => sub { wxTheApp->cancel_all }, 708 clear_cbk => sub { wxTheApp->reset_add_rank }, 708 709 column_item_data => { 709 710 0 => sub { return undef }, … … 1053 1054 ); 1054 1055 1056 Wx::Event::EVT_COMMAND( 1057 $self, 1058 -1, 1059 wxTheApp->batch_end_event, 1060 sub { 1061 my ( $handler, $event ) = @_; 1062 my $data = $event->GetData; 1063 $handler->upload_progressdlg->batch_end($data); 1064 } 1065 ); 1066 1055 1067 } 1056 1068 -
extensions/pLoader/trunk/src/Uploader/GUI/ImageProgressDlg.pm
r6520 r6538 38 38 __PACKAGE__->mk_accessors( qw/ 39 39 cancel_cbk 40 clear_cbk 40 41 listctrl 41 42 columns 42 43 progress_column 44 btcancel 43 45 /); 44 46 use Carp; … … 76 78 ); 77 79 80 $self->clear_cbk( 81 $params->{clear_cbk} 82 ); 83 78 84 Uploader::GUI::Layout::ImageProgress::Init($self); 79 85 … … 89 95 ); 90 96 91 Wx::Event::EVT_BUTTON( $self, $main::ID_UPLOAD_CANCEL, \&on_cancel ); 97 Wx::Event::EVT_BUTTON( $self, $self->{_bt_cancel}->GetId, \&on_cancel ); 98 Wx::Event::EVT_BUTTON( $self, $self->{_bt_clear}->GetId, \&on_clear ); 92 99 Wx::Event::EVT_CLOSE( $self, \&on_close ); 93 100 … … 112 119 my ( $self, $images ) = @_; 113 120 114 $self->listctrl->add_progress_items($images); 121 # have to filter to remove fake images ( batch_end_events ) 122 $self->listctrl->add_progress_items( 123 [ 124 grep { $_->{image_id} } @$images 125 ] 126 ); 127 128 $self->{_bt_cancel}->Enable(1); 129 $self->{_bt_clear}->Enable(0); 115 130 } 116 131 … … 118 133 sub update_image_item { 119 134 my ( $self, $image ) = @_; 120 135 121 136 my $item = $image->{add_rank}; 122 137 $self->listctrl->replace_item_data($item, $image); … … 128 143 129 144 145 sub batch_end { 146 my ( $self, $image ) = @_; 147 148 $self->{_bt_cancel}->Enable(0); 149 $self->{_bt_clear}->Enable(1); 150 } 151 152 153 sub on_clear { 154 my( $self, $event ) = @_; 155 156 $self->listctrl->clear_progress_items; 157 $self->clear_cbk->(); 158 $event->Skip; 159 } 160 161 130 162 sub on_cancel { 131 163 my( $self, $event ) = @_; 132 164 133 $self->cancel_cbk->(); 165 if($self->cancel_cbk->()){ 166 $self->{_bt_cancel}->Enable(0); 167 $self->{_bt_clear}->Enable(1); 168 } 134 169 $event->Skip; 135 170 } -
extensions/pLoader/trunk/src/Uploader/GUI/Layout/ImageProgress.pm
r6494 r6538 16 16 use vars qw($ID_LINE); $ID_LINE = 10002; 17 17 use vars qw($ID_LISTCTRL); $ID_LISTCTRL = 10003; 18 use vars qw($ID_UPLOAD_CANCEL); $ID_UPLOAD_CANCEL = 10004;19 18 20 19 sub Init { … … 42 41 43 42 my( $item7 ) = Wx::BoxSizer->new( wxHORIZONTAL ); 43 my( $bt_clear ) = Wx::Button->new( 44 $panel, 45 -1, 46 gettext("Clear list"), 47 wxDefaultPosition, wxDefaultSize, 0 48 ); 49 $parent_wnd->{_bt_clear} = $bt_clear; 50 51 $item7->AddWindow( $bt_clear, 0, wxALIGN_CENTER|wxALL, 5 ); 52 44 53 my( $bt_cancel ) = Wx::Button->new( 45 54 $panel, 46 $main::ID_UPLOAD_CANCEL,55 -1, 47 56 gettext("Cancel upload"), 48 57 wxDefaultPosition, wxDefaultSize, 0 49 58 ); 59 $parent_wnd->{_bt_cancel} = $bt_cancel; 50 60 #$item7->AddButton( Wx::Button->new( $panel, wxID_OK, "" ) ); 51 61 $item7->AddWindow( $bt_cancel, 0, wxALIGN_CENTER|wxALL, 5 ); -
extensions/pLoader/trunk/src/Uploader/GUI/ListCtrlProgress.pm
r6520 r6538 31 31 32 32 $self->thumb_size(48); 33 33 $self->reset_all; 34 35 36 37 Wx::Event::EVT_PAINT( 38 $self, 39 sub { 40 my ( $self, $event ) = @_; 41 42 eval { $self->paint_progress_bars; }; 43 $event->Skip; 44 } 45 ); 46 47 48 $self; 49 } 50 51 52 sub reset_all { 53 my ( $self ) = @_; 54 55 delete $self->{_y_top}; 34 56 $self->progress_bars([]); 35 57 $self->item_data([]); … … 39 61 ) 40 62 ); 41 42 63 $self->wx_images([]); 43 64 $self->SetImageList( $self->wx_imagelist, wxIMAGE_LIST_SMALL ) ; 44 45 46 $self->wx_images([]);47 48 Wx::Event::EVT_PAINT(49 $self,50 sub {51 my ( $self, $event ) = @_;52 53 eval { $self->paint_progress_bars; };54 $event->Skip;55 }56 );57 58 59 $self;60 65 } 61 66 … … 112 117 } 113 118 119 114 120 sub add_progress_items { 115 121 my ( $self, $added_items ) = @_; 116 122 117 123 push @{$self->item_data}, @{$added_items}; 118 119 $self->SetItemCount(scalar @{$self->item_data}); 120 } 121 124 125 my $item_count = scalar @{$self->item_data}; 126 $self->SetItemCount($item_count); 127 } 128 129 130 sub clear_progress_items { 131 my ( $self ) = @_; 132 133 $self->{_y_top} = 100000; 134 $self->paint_progress_bars; 135 136 $self->reset_all; 137 $self->DeleteAllItems; 138 } 122 139 123 140 sub OnGetItemText { … … 188 205 189 206 207 208 190 209 sub paint_progress_bars { 191 210 my ( $self ) = @_; -
extensions/pLoader/trunk/src/Uploader/Images.pm
r6525 r6538 516 516 } 517 517 518 519 sub reset_add_rank { 520 my ( $self ) = @_; 521 522 $add_rank = 0; 523 } 518 524 1; -
extensions/pLoader/trunk/src/Uploader/ResizeWorker.pm
r6522 r6538 45 45 sub process_image { 46 46 my ( $self, $handler, $progress_event, $resize_done_event, $image ) = @_; 47 printf("process_image %s\n", join(', ', @_)); 47 48 48 $self->event_handler( 49 49 $handler … … 101 101 ); 102 102 } 103 104 103 105 104 106 -
extensions/pLoader/trunk/src/Uploader/ThreadManager.pm
r6522 r6538 15 15 done_event 16 16 event_handler 17 batch_end_event 17 18 /); 18 19 … … 61 62 } 62 63 } 64 elsif('BATCH_END' eq $data->{event}){ 65 $worker->post_image_event( 66 $self->batch_end_event, 67 $data, 68 ); 69 } 63 70 else{ 64 $worker->process_image( 71 $worker->process_image( 65 72 $handler, 66 73 $self->progress_event, -
extensions/pLoader/trunk/src/Uploader/TransferWorker.pm
r6525 r6538 163 163 sub update_image { 164 164 my ( $self, $image ) = @_; 165 print Dumper $image; 165 166 166 $self->log_image_progress($image, "updating", 0); 167 167
Note: See TracChangeset
for help on using the changeset viewer.