Ignore:
Timestamp:
Mar 26, 2010, 9:04:59 PM (15 years ago)
Author:
ronosman
Message:

Feature 1539 added : When uploading, display a dialog box with the categories list when no category is selected

Location:
extensions/pLoader/trunk/src
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm

    r5184 r5390  
    5050                              Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } );
    5151                          },
     52        'Uploader::GUI::wxCategoryTreeCtrl' => sub { my ( $ctrl ) = @_;
     53                                                   Wx::Event::EVT_TREE_SEL_CHANGED(
     54                                                       $ctrl,
     55                                                       $ctrl,
     56                                                       sub {
     57                                                           $self->OnCategoryTreeSelChanged(@_);
     58                                                       }
     59                                                   );
     60                                               },
    5261    };
    5362   
    5463    map {
    5564        my $ctrl =$self->FindWindow($_);
     65
    5666        if(defined $ctrl){
    5767            $ctrl_handlers->{ ref $ctrl}->($ctrl) if exists $ctrl_handlers->{ ref $ctrl};
     
    257267};
    258268
     269
     270sub OnCategoryTreeSelChanged {
     271    my ( $self, $ctrl, $event ) = @_;
     272
     273    my $id = $ctrl->GetId;
     274
     275    # change the property value.
     276    $self->properties->{$id}->{id_selection}->(
     277        $event->GetEventObject->GetSelectionsIds
     278    ) if exists $self->properties->{$id}->{id_selection};
     279
     280    #printf("OnCategoryTreeSelChanged %s\n", Dumper $self->properties->{$id}->{id_selection}->());
     281
     282    # exec the callback
     283    $self->properties->{$id}->{frame_callback}->($self, $ctrl, $event) if exists
     284        $self->properties->{$id}->{frame_callback};   
     285   
     286    $event->Skip;
     287}
     288
     289
    259290my $clear_value = {
    260291    'Wx::TextCtrl' => sub { my ($ctrl) = @_; $ctrl->Clear},
    261292    'Wx::CheckBox' => sub { my ($ctrl) = @_; $ctrl->SetValue(0)},
    262293    'Wx::DatePickerCtrl' => sub { my ($ctrl) = @_; $ctrl->SetValue(Wx::DateTime->new->SetToCurrent)},
     294    'Uploader::GUI::wxCategoryTreeCtrl' => sub { my ( $ctrl ) = @_;
     295                                               $ctrl->SelectItem($ctrl->GetRootItem);
     296                                           },
    263297};   
    264298
  • extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm

    r5261 r5390  
    101101          categories
    102102          imagelist
    103           image_preview
     103          image_preview_dlg
    104104          image_prop_piwigo
    105           image_prop_exif
     105          exif_dlg
    106106          image_prop_tags
    107           global_settings_panel
     107          global_settings_dlg
    108108          piwigo_property_list
    109109          exif_properties
     
    119119          image_tags
    120120          piwigo_photo_properties
    121           dlg_piwigo_photo_properties
     121          piwigo_photo_properties_dlg
    122122          piwigo_photo_properties_tags
    123           image_preview_refresh
     123          image_preview_need_refresh
    124124          imageviewer_refresh
    125125          imageviewer_item_refresh
    126126          horizontal_splitter
     127          destination_category_dlg
     128          destination_categories
     129          categories_treectrl
    127130      /;
    128131__PACKAGE__->mk_accessors( @properties );
     
    137140use Uploader::GUI::wxImageProcessingProgressDlg;
    138141use Uploader::GUI::wxChoiceFilteredPanel;
     142use Uploader::GUI::wxDestinationCategoryDlg;
     143use Uploader::GUI::wxCategoryTreeCtrl;
    139144use utf8;
    140145$|=1;
     
    146151sub new {
    147152    my( $class, $params ) = @_;
     153
    148154    my $self  = $class->SUPER::new(
    149155        undef,
     
    158164    $self->pwg( $params->{pwg} );
    159165    $self->imagelist( $params->{imagelist} );
     166
     167
     168    $self->imagelist->pwg(
     169        $self->pwg
     170    );
     171
     172    $self->imagelist->categories(
     173        []
     174    );
     175
     176
     177    $self->init_gui_callbacks;
     178    $self->init_properties_dlg_bindings;
     179    $self->init_frame;
     180    $self->init_menus;
     181    $self->init_event_handlers;
     182    $self->init_image_types;   
     183
     184    $self->imageviewer->SelectItem(
     185        $self->current_imageviewer_index
     186    ) if $self->imageviewer->GetItemCount;
     187   
     188    # if file in command line parameters, try to load
     189    my $files = wxTheApp->argv;
     190    $self->SetNewFiles($files) if scalar @$files;
     191
     192    $self->Show;
     193    $self;
     194}
     195
     196
     197sub init_gui_callbacks {
     198    my ( $self ) = @_;
    160199
    161200    # callback for GUI refresh : add thumbnail images to the imageviewer control
     
    249288        sub { $self->UploadDisplayEndInfo(@_) }
    250289    );
    251 
    252 
    253     $self->imagelist->pwg(
    254         $self->pwg
    255     );
    256 
    257     $self->imagelist->categories(
    258         []
    259     );
    260 
    261 
    262     $self->_set_setting_properties;
    263     $self->_initFrame;
    264     $self->_initMenus;
    265     $self->_initEventHandlers;
    266     $self->_initImgTypes;   
    267 
    268     $self->imageviewer->SelectItem(
    269         $self->current_imageviewer_index
    270     ) if $self->imageviewer->GetItemCount;
    271    
    272     # if file in command line parameters, try to load
    273     my $files = wxTheApp->argv;
    274     $self->SetNewFiles($files) if scalar @$files;
    275 
    276     $self->Show;
    277     $self;
    278 }
    279 
    280 
    281 sub _initImgTypes {
    282     my ( $self ) = @_;
    283 
    284     $self->{IMGTYPE} = {
    285         'jpg' => wxBITMAP_TYPE_JPEG,
    286         'gif' => wxBITMAP_TYPE_GIF,
    287         'png' => wxBITMAP_TYPE_PNG,
    288     };
    289 }
    290 
    291 
    292 sub GetWxBitmapType {
    293     my ( $self, $type ) = @_;
    294    
    295     $self->{IMGTYPE}->{$type};
    296 }
    297 
    298 
    299 
    300 sub _set_setting_properties {
     290}
     291
     292
     293sub init_properties_dlg_bindings {
    301294    my ( $self ) = @_;
    302295
     
    665658}
    666659
     660sub init_image_types {
     661    my ( $self ) = @_;
     662
     663    $self->{IMGTYPE} = {
     664        'jpg' => wxBITMAP_TYPE_JPEG,
     665        'gif' => wxBITMAP_TYPE_GIF,
     666        'png' => wxBITMAP_TYPE_PNG,
     667    };
     668}
     669
     670
     671sub init_frame {
     672    my ( $self ) = @_;
     673   
     674    $self->create_toolbar;
     675
     676    my $sizer_h = Wx::BoxSizer->new( wxHORIZONTAL );
     677   
     678
     679
     680    $self->imageviewer(
     681        Uploader::GUI::wxImageListCtrl->new(
     682            {
     683                parentwnd => $self,
     684                imagelist => $self->imagelist,
     685                image_size => $self->imagelist->wx_thumb_size,
     686                columns => $self->piwigo_property_list,
     687            }
     688        )
     689    );
     690
     691
     692    $self->piwigo_photo_properties_dlg (
     693        Uploader::GUI::wxPhotoProperties->new(
     694            {
     695                parentwnd  => $self,
     696                categories => [ @{$self->pwg->categories}],
     697                properties => $self->piwigo_photo_properties,
     698                tags       =>
     699                {
     700                    id => $main::PHOTO_PROPERTIES_TAG,
     701                    choices => $self->piwigo_tags,
     702                    selection => $self->image_tags,
     703                    creation_callback => sub { $self->_create_piwigo_tag(@_) },
     704               },
     705            }
     706        )
     707    );
     708
     709    $self->piwigo_photo_properties_tags(
     710        $self->piwigo_photo_properties_dlg->FindWindow($main::PHOTO_PROPERTIES_TAG)
     711    );
     712
     713    $self->tree(
     714        $self->piwigo_photo_properties_dlg->FindWindow($main::PHOTO_PROPERTIES_CATEGORIES)
     715    );
     716
     717    $self->init_dnd_targets;
     718    $self->init_dialogs;
     719    $self->show_hide_pwg_categories_empty_msg;
     720
     721    if( $self->imagelist->wx_thumb_imglist->GetImageCount){
     722        $self->ShowImageViewer;
     723       
     724        $self->imageviewer->Refresh(
     725            $self->imagelist->wx_thumb_imglist
     726        );
     727       
     728        $self->OnUpdateImageviewerNotEmpty;
     729    }
     730    else{
     731        $self->OnUpdateImageviewerEmpty;
     732    }
     733
     734    # the imageviewer has a stretch factor of 1 : expands its size on frame resize
     735    $sizer_h->Add( $self->imageviewer, 1, wxEXPAND|wxALL, 2 );
     736    $sizer_h->Add( $self->piwigo_photo_properties_dlg, 0, wxEXPAND|wxALL, 2 );
     737
     738
     739    $self->SetSizer(
     740        $sizer_h
     741    );
     742    my $new_size = $sizer_h->Fit(
     743        $self
     744    );
     745    $self->SetMinSize([600, 660]);
     746    $self->Center;
     747}
     748
     749
    667750sub _create_piwigo_tag {
    668751    my ( $self, $name ) = @_;
     
    684767}
    685768
    686 sub _refreshFrame {
    687     my ( $self ) = @_;
    688    
    689     eval { $self->_set_setting_properties; };
    690     $self->_refresh_settings_panels_properties;
    691     map {
    692         $_->Refresh;
    693     }
    694     (
    695         $self->image_prop_exif,
    696         $self->global_settings_panel,
    697         $self->piwigo_photo_properties_tags
    698     );
    699    
    700 }
    701 
    702 #
    703 sub _initFrame {
    704     my ( $self ) = @_;
    705    
    706     $self->create_toolbar;
    707 
    708     my $sizer_h = Wx::BoxSizer->new( wxHORIZONTAL );
    709    
    710 
    711 
    712     $self->imageviewer(
    713         Uploader::GUI::wxImageListCtrl->new(
    714             {
    715                 parentwnd => $self,
    716                 imagelist => $self->imagelist,
    717                 image_size => $self->imagelist->wx_thumb_size,
    718                 columns => $self->piwigo_property_list,
    719             }
    720         )
    721     );
    722 
    723     # message displayed in the image listctrl when empty
    724     $self->imageviewer->InitEmptyMsg;
    725 
    726     $self->init_panels;
    727 
    728     $self->dlg_piwigo_photo_properties (
    729         Uploader::GUI::wxPhotoProperties->new(
    730             {
    731                 parentwnd       => $self,
    732                 properties      => $self->piwigo_photo_properties,
    733                 tags            =>
    734                 {
    735                     id => $main::PHOTO_PROPERTIES_TAG,
    736                     choices => $self->piwigo_tags,
    737                     selection => $self->image_tags,
    738                     creation_callback => sub { $self->_create_piwigo_tag(@_) },
    739                },
    740             }
    741         )
    742     );
    743 
    744     $self->piwigo_photo_properties_tags(
    745         $self->dlg_piwigo_photo_properties->FindWindow($main::PHOTO_PROPERTIES_TAG)
    746     );
    747 
    748     $self->create_tree(
    749         $self->dlg_piwigo_photo_properties->FindWindow($main::PHOTO_PROPERTIES_CATEGORIES)
    750     );
    751 
    752     $self->init_empty_category_msg;
    753     $self->set_empty_tree_panel_evt_paint;
    754     $self->show_pwg_categories_empty_msg;
    755 
    756     $self->init_dnd_targets;
    757 
    758     if( $self->imagelist->wx_thumb_imglist->GetImageCount){
    759         $self->ShowImageViewer;
    760        
    761         $self->imageviewer->Refresh(
    762             $self->imagelist->wx_thumb_imglist
    763         );
    764        
    765         $self->OnUpdateImageviewerNotEmpty;
    766     }
    767     else{
    768         $self->OnUpdateImageviewerEmpty;
    769     }
    770 
    771     # the imageviewer has a stretch factor of 1 : expands its size on frame resize
    772     $sizer_h->Add( $self->imageviewer, 1, wxEXPAND|wxALL, 2 );
    773     $sizer_h->Add( $self->dlg_piwigo_photo_properties, 0, wxEXPAND|wxALL, 2 );
    774 
    775 
    776     $self->SetSizer(
    777         $sizer_h
    778     );
    779     my $new_size = $sizer_h->Fit(
    780         $self
    781     );
    782     $self->SetMinSize([600, 660]);
    783     $self->Center;
    784 }
    785769
    786770sub OnUpdateImageviewerEmpty {
    787771    my ( $self ) = @_;
    788772
    789     $self->dlg_piwigo_photo_properties->{_properties_notebook}->Enable(0);
     773    $self->piwigo_photo_properties_dlg->{_properties_notebook}->Enable(0);
    790774    $self->imageviewer->OnEmpty;
    791775}
     
    794778    my ( $self ) = @_;
    795779
    796     $self->dlg_piwigo_photo_properties->{_properties_notebook}->Enable(1);
     780    $self->piwigo_photo_properties_dlg->{_properties_notebook}->Enable(1);
    797781    $self->imageviewer->OnNotEmpty;
    798782}
    799783
    800784
    801 sub _refresh_settings_panels_properties {
     785sub init_dialogs {
    802786    my ( $self ) = @_;   
    803787
    804     $self->dlg_piwigo_photo_properties->properties(
    805         $self->piwigo_photo_properties
    806     );
    807 
    808    
    809     $self->image_prop_exif->properties(
    810         $self->exif_properties
    811     );
    812 
    813     $self->global_settings_panel->properties(
    814         $self->global_settings
    815     );   
    816 
    817 }
    818 
    819 sub _init_settings_panels {
    820     my ( $self ) = @_;   
    821 
    822 
    823     $self->image_prop_exif(
     788
     789    $self->exif_dlg(
    824790        Uploader::GUI::wxPropertyListDlg->new(
    825791            {
     
    830796        )
    831797    );
    832     $self->image_prop_exif->Hide;
    833 
    834     $self->global_settings_panel(
     798    $self->exif_dlg->Hide;
     799
     800    $self->global_settings_dlg(
    835801        Uploader::GUI::wxGlobalSettings->new(
    836802            {
     
    841807        )
    842808    );
    843     $self->global_settings_panel->Hide;
    844 
    845 
    846 
    847     $self->image_preview(
     809    $self->global_settings_dlg->Hide;
     810
     811    $self->image_preview_dlg(
    848812        Uploader::GUI::wxImagePreview->new(
    849813            {
     
    854818    );
    855819
    856 }
    857 
    858 sub init_panels {
    859     my ( $self ) = @_;
    860    
    861     $self->_init_settings_panels;   
    862 }
    863 
    864 # HTML code for getting started dialog box
     820    $self->destination_category_dlg(
     821        Uploader::GUI::wxDestinationCategoryDlg->new(
     822            {
     823                parentwnd    => $self,
     824                caption      => gettext("Upload to Piwigo"),
     825                categories   => [@{$self->pwg->categories}],
     826                properties   => {
     827                                    $main::CHOOSE_DESTINATION => { label => wxTheApp->branding->{'What is the destination category?'} },
     828                                    $main::DESTINATION_CATEGORIES_OK => { label=>gettext("Upload to Piwigo")},
     829                                    $main::DESTINATION_CATEGORIES_CANCEL => { label=>gettext("Cancel")},
     830                                    $main::DESTINATION_CATEGORIES => {
     831                                        id_selection => sub { $self->imagelist->categories(@_) },
     832                                        frame_callback => sub {
     833                                            my ( $dlg, $ctrl, $evt ) = @_;
     834                                            $dlg->FindWindow($main::DESTINATION_CATEGORIES_OK)->Enable(scalar @{$self->imagelist->categories});
     835                                        },
     836                                    },
     837                                },
     838                frame_callback => sub { $self->OnRefreshCategories },
     839            }
     840        )
     841    );
     842
     843    $self->destination_category_dlg->Hide;
     844
     845    $self->destination_categories(
     846        $self->destination_category_dlg->FindWindow($main::DESTINATION_CATEGORIES)
     847    );
     848
     849    $self->categories_treectrl(
     850        [
     851            $self->destination_categories,
     852            $self->tree,
     853        ]
     854    );
     855
     856}
    865857
    866858
     
    883875
    884876
    885 
    886877sub OnPhotoProperties {
    887878    my ( $self ) = @_;
    888879
    889     $self->image_prop_exif->Show(1);
    890 }
     880    $self->exif_dlg->Show(1);
     881}
     882
    891883
    892884sub OnPreview {
    893885    my ( $self ) = @_;
    894886
    895     $self->image_preview->Show(1);
    896 
    897 
    898 
     887    $self->image_preview_dlg->Show(1);
    899888}
    900889
     
    903892    my ( $self ) = @_;
    904893
    905     $self->global_settings_panel->Show(1);
     894    $self->global_settings_dlg->Show(1);
    906895}
    907896
     
    913902}
    914903
     904
    915905sub OnGeneralSettingsClose {
    916906    my ( $self, $event ) = @_;
    917907
    918     $self->global_settings_panel->Hide;
    919 }
     908    $self->global_settings_dlg->Hide;
     909}
     910
    920911
    921912sub OnImageExifPropClose {
     
    925916}
    926917
    927 sub create_tree {
    928     my ( $self, $tree ) = @_;
    929 
    930     my $images = [
    931         map {
    932             Wx::Bitmap->new( $_, wxBITMAP_TYPE_PNG )
    933            
    934         }
    935         (
    936           wxTheApp->resource_path('tree_pwg.png'),
    937           wxTheApp->resource_path('tree_folder.png'),
    938         )   
    939     ];
    940 
    941     $self->treeimglist( Wx::ImageList->new( 16, 16, 1 ) );
     918
     919
     920
     921sub show_hide_pwg_categories_empty_msg {
     922    my ( $self ) = @_;
     923
    942924    map {
    943         $self->treeimglist->Add($_);
    944     }
    945     @$images;
    946    
    947     $self->tree(
    948         $tree || Wx::TreeCtrl->new(
    949            $self->horizontal_splitter,
    950            -1,
    951            wxDefaultPosition,
    952            wxDefaultSize,
    953            wxCLIP_CHILDREN|
    954            wxTR_HAS_BUTTONS|
    955            wxTR_EDIT_LABELS
    956         )
    957     );
    958 
    959     $self->tree->SetImageList( $self->treeimglist );
    960     if(wxTheApp->use_offline){
    961         $self->tree->Enable(0);
    962     }
    963     else{
    964         $self->populate_tree_categories ;
    965     }
    966 
    967     $self->tree ;
    968 }
    969 
    970 
    971 sub set_empty_tree_panel_evt_paint{
    972     my ( $self ) = @_;
    973     Wx::Event::EVT_PAINT( $self->tree, sub {
    974             my ( $tree, $event ) = @_;
    975             if(exists $tree->{_empty_panel} and ! exists $tree->{_empty_panel}{_paint}){
    976                 my ($w, $h) = $tree->GetSizeWH;
    977                 my ($x, $y) = $tree->{_empty_panel}->GetPositionXY;
    978 
    979                 $tree->{_empty_panel}{x} = $x if !exists $tree->{_empty_panel}{x} ;
    980                 $tree->{_empty_panel}{y} = $y if !exists $tree->{_empty_panel}{y};
    981                 my ($wp, $hp) = $tree->{_empty_panel}->GetSizeWH;
    982                 my $x_off = ($w-$wp)/2 > 0 ? ($w-$wp)/2 : 0;
    983                 my $y_off = ($h-$hp)/2 > 0 ? ($h-$hp)/2 : 0;
    984                 $tree->{_empty_panel}->Move(
    985                     [
    986                         $tree->{_empty_panel}{x}+$x_off,
    987                         $tree->{_empty_panel}{y}+$y_off
    988                     ]
    989                 );
    990                 $tree->{_empty_panel}{_paint} = 1;
    991             }
    992             $event->Skip;
    993         }
    994     ) if 1;
    995 
    996 }
    997 
    998 
    999 sub init_empty_category_msg {
    1000 
    1001     my ( $self ) = @_;
    1002     # add a panel
    1003     my $empty_panel = Wx::Panel->new($self->tree, -1, wxDefaultPosition, wxDefaultSize);
    1004     my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
    1005    
    1006     my $fb = Wx::Font->new( 12, wxSWISS, wxNORMAL, wxBOLD );
    1007 
    1008 
    1009     my( $item1 ) = Wx::Button->new(
    1010         $empty_panel,
    1011         $main::CATEGORIES_ADD,
    1012         wxTheApp->branding->{'Add new category'},
    1013         wxDefaultPosition,
    1014         [-1,40],
    1015         0
    1016     );
    1017     my $btfont = Wx::Font->new(12, wxSWISS, wxNORMAL, wxNORMAL );
    1018     $item1->SetFont($btfont);
    1019     $item0->AddWindow( $item1, 0, wxALIGN_CENTER|wxALL, 5 );
    1020 
    1021 
    1022     $empty_panel->SetSizer( $item0 );
    1023     $item0->SetSizeHints( $empty_panel );
    1024 
    1025     $self->tree->{_empty_panel} = $empty_panel;
    1026     $self->tree->{_empty_panel}->SetBackgroundColour(wxWHITE);
    1027 
    1028     my ($wp, $hp) = $self->tree->{_empty_panel}->GetSizeWH;
    1029 
    1030     $self->tree->SetMinSize( [20+$wp, -1 ]);
    1031 
    1032 }
    1033 
    1034 
    1035 sub pwg_categories_are_empty {
    1036     my ( $self ) = @_;
    1037 
    1038     scalar @{wxTheApp->pwg->categories} < 1 ? 1 : 0 ;
    1039 }
    1040 
    1041 
    1042 sub populate_tree_categories {
    1043     my ( $self ) = @_;
    1044 
    1045     $self->populate_tree(
    1046         $self->tree,
    1047         wxTheApp->pwg->categories,
    1048     ) if defined wxTheApp->pwg ;
    1049 }
    1050 
    1051 
    1052 sub show_pwg_categories_empty_msg {
    1053     my ( $self ) = @_;
    1054 
    1055     if($self->pwg_categories_are_empty){
    1056         $self->tree->{_empty_panel}->Show(1);
    1057     }
    1058     else{
    1059         $self->tree->{_empty_panel}->Show(0);
    1060     }
    1061 }
    1062 
    1063 
    1064 
    1065 # returns a valid itemData
    1066 sub itemData { Wx::TreeItemData->new( $_[0] ) }
    1067 
    1068 sub populate_tree {
    1069     my ( $self, $tree, $tree_items ) = @_;
    1070     my $root = shift @{$tree_items};
    1071 
    1072     $self->tree_root(
    1073         $tree->AddRoot(
    1074             $root->[0],
    1075             $root->[3],
    1076             $root->[4],
    1077             itemData( $root->[2] )
    1078         )
    1079     );
    1080 
    1081   $self->populate_tree_helper( $tree, $self->tree_root, $tree_items );
    1082  
    1083   $tree->SelectItem( $self->tree_root );
    1084   $tree->Expand( $self->tree_root );
    1085 }
    1086 
    1087 sub populate_tree_helper {
    1088   my ( $self, $tree, $parent_id, $tree_items ) = @_;
    1089 
    1090   my $id;
    1091 
    1092   map {
    1093       my $name = $_->[0];
    1094 
    1095       $id = $tree->AppendItem(
    1096                                    $parent_id,
    1097                                    $name,
    1098                                    defined($_->[3]) ? $_->[3] : 0,
    1099                                    defined($_->[4]) ? $_->[4] : 0,
    1100                                    itemData( $_->[2])
    1101                               );
    1102       $self->tree_item_default($id) if ! defined $self->tree_item_default;
    1103       # current item has children
    1104       if( ref( $_->[1] ) eq 'ARRAY' ) {
    1105           $self->populate_tree_helper( $tree, $id, $_->[1] );
    1106       }
    1107   }
    1108   @{$tree_items};
    1109 
    1110 }
    1111 
    1112 sub _initMenus {
     925        $_->GetCount > 1 ?
     926            $_->HideEmptyMsg :
     927            $_->ShowEmptyMsg;
     928    }@{$self->categories_treectrl};
     929
     930}
     931
     932
     933sub init_menus {
    1113934    my ( $self ) = @_ ;
    1114935
     
    12211042}
    12221043
    1223 sub _initEventHandlers {
     1044sub init_event_handlers {
    12241045    my ( $self ) = @_ ;
    12251046   
     
    12431064    Wx::Event::EVT_CLOSE( $self, \&OnClose );
    12441065
    1245     Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategories );
     1066    Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategory );
    12461067    Wx::Event::EVT_MENU( $self, 2+$ID_TREE_CTX_MENU, \&OnRefreshCategories );
    12471068    Wx::Event::EVT_MENU( $self, 3+$ID_TREE_CTX_MENU, \&OnExpandCategories );
     
    12541075    Wx::Event::EVT_BUTTON( $self, $self->imageviewer->add_button->GetId, \&OnAddImages );
    12551076
    1256     Wx::Event::EVT_BUTTON( $self, $main::CATEGORIES_ADD, \&OnAddCategories );
    12571077
    12581078    # only refresh when calling event is finished
     
    12621082            my ( $self, $event ) = @_;
    12631083
    1264             if ( $self->image_preview_refresh and $self->image_preview->IsShown ){
     1084            if ( $self->image_preview_need_refresh and $self->image_preview_dlg->IsShown ){
    12651085                $self->set_preview_image;
    1266                 $self->image_preview->Refresh;
    1267                 $self->image_preview_refresh(0);
     1086                $self->image_preview_dlg->Refresh;
     1087                $self->image_preview_need_refresh(0);
    12681088            }
    12691089
     
    12831103            }
    12841104
    1285             if(!scalar @{$self->imageviewer->GetSelectedItems} and $self->dlg_piwigo_photo_properties->{_properties_notebook}->IsEnabled){
    1286                 $self->dlg_piwigo_photo_properties->{_properties_notebook}->Enable(0);
     1105            if(!scalar @{$self->imageviewer->GetSelectedItems} and $self->piwigo_photo_properties_dlg->{_properties_notebook}->IsEnabled){
     1106                $self->piwigo_photo_properties_dlg->{_properties_notebook}->Enable(0);
    12871107            }
    12881108
     
    13141134}
    13151135
     1136
    13161137sub OnUpdateToolbar {
    13171138    my( $self ) = @_;
    13181139   
    1319     if($self->global_settings_panel->IsShown){
     1140    if($self->global_settings_dlg->IsShown){
    13201141        $self->toolbar->EnableTool(104, 0);
    13211142    }
     
    13241145    }
    13251146
    1326     if($self->global_settings_panel->IsShown){
     1147    if($self->global_settings_dlg->IsShown){
    13271148        $self->toolbar->EnableTool(104, 0);
    13281149    }
     
    13421163
    13431164    if (!$self->imageviewer->GetItemCount){
    1344         $self->image_preview->image(
     1165        $self->image_preview_dlg->image(
    13451166            0
    13461167        );
    13471168        # have to reset
    1348         $self->dlg_piwigo_photo_properties->ClearProperties;
     1169        $self->piwigo_photo_properties_dlg->ClearProperties;
    13491170        $self->piwigo_photo_properties_tags->ClearAllSelection;
    13501171        $self->imagelist->SetCurrentImage(-1);
     
    13591180    }
    13601181
    1361     $self->image_preview->Refresh;
    1362     $self->image_prop_exif->Refresh;
     1182    $self->image_preview_dlg->Refresh;
     1183    $self->exif_dlg->Refresh;
    13631184}
    13641185
     
    14021223}
    14031224
     1225
    14041226sub OnTreeSelChanged {
    14051227    my( $self, $event ) = @_;
    1406  
    1407     my @items = $self->tree->GetSelections;
    14081228
    14091229    $self->imagelist->categories(
    1410         [
    1411             map {
    1412                 my $category = $self->tree->GetPlData( $_ );
    1413                 $category->{id} if $category != -1;
    1414             }
    1415             @items
    1416         ]
     1230        $event->GetEventObject->GetSelectionsIds
    14171231    );
    14181232}
     
    15061320}
    15071321
    1508 sub OnAddCategories {
     1322sub OnAddCategory {
    15091323    my ( $self, $event ) = @_;
    15101324
    1511     my $parent_item = $self->tree->GetSelection;
    1512 
    1513     my $category = $self->tree->GetPlData($parent_item);
    1514     my $category_id;
    1515    
    1516     $category_id = $category->{id} if 'HASH' eq ref($category) ;
    1517 
    1518     my $dialog = Wx::TextEntryDialog->new(
    1519         $self,
    1520         wxTheApp->branding->{'Category name'},
    1521         wxTheApp->branding->{'Add new category'},
    1522         wxTheApp->branding->{'New category'},
    1523     );
    1524 
    1525     if( $dialog->ShowModal != wxID_CANCEL ) {
    1526         my $name = $dialog->GetValue;
    1527         my ( $success, $status_msg, $content ) = $self->pwg->AddCategories( $name, $category_id);
    1528 
    1529         if($success){
    1530             $self->tree->{_empty_panel}->Show(0);
    1531             $self->_append_category($parent_item, $name, $content->{result}{id});
    1532         }
    1533     }
    1534 
    1535 
    1536     $dialog->Destroy;
    1537 }
     1325    $self->tree->AddCategory;
     1326
     1327}
     1328
    15381329
    15391330sub OnRefreshCategories {
     
    15451336
    15461337sub _refresh_all_categories_helper {
    1547     my ( $self ) = @_;   
     1338    my ( $self ) = @_;
    15481339
    15491340    my $busycursor = Wx::BusyCursor->new();
    15501341    $self->tree->CollapseAll;
    15511342    $self->tree->DeleteAllItems;
    1552     $self->imagelist->categories([]);
    15531343    $self->pwg->RefreshCategories();
    1554     $self->populate_tree_categories;
    1555     $self->show_pwg_categories_empty_msg;
    1556 }
    1557 
    1558 sub _append_category {
    1559     my ( $self, $parent_id, $name, $id ) = @_;
    1560 
    1561     $self->tree->SelectItem(
    1562         $self->tree->AppendItem(
    1563             $parent_id,
    1564             $name,
    1565             1,
    1566             -1,
    1567             Wx::TreeItemData->new( { id => $id } )
    1568         )
    1569     );
    1570 }
     1344    $self->tree->categories(
     1345        $self->pwg->categories
     1346    );
     1347    $self->tree->Populate;
     1348    $self->show_hide_pwg_categories_empty_msg;
     1349}
     1350
    15711351
    15721352sub OnImageViewerEndLabelEdit {
     
    15781358    );
    15791359       
    1580     $self->dlg_piwigo_photo_properties->SetProperties;
     1360    $self->piwigo_photo_properties_dlg->SetProperties;
    15811361}
    15821362
     
    15981378    my $indx = $event->GetIndex;
    15991379
    1600     $self->dlg_piwigo_photo_properties->{_properties_notebook}->Enable(1)
    1601         if !$self->dlg_piwigo_photo_properties->{_properties_notebook}->IsEnabled;
     1380    $self->piwigo_photo_properties_dlg->{_properties_notebook}->Enable(1)
     1381        if !$self->piwigo_photo_properties_dlg->{_properties_notebook}->IsEnabled;
    16021382    $self->_on_imageviewer_item_selected($indx);
    16031383
     
    16471427    # and when current event is processed
    16481428    # see call to EVT_IDLE
    1649     $self->image_preview_refresh(1);
    1650 
    1651     $self->dlg_piwigo_photo_properties->SetProperties if defined $self->dlg_piwigo_photo_properties;
    1652     $self->image_prop_exif->Refresh;
     1429    $self->image_preview_need_refresh(1);
     1430
     1431    $self->piwigo_photo_properties_dlg->SetProperties if defined $self->piwigo_photo_properties_dlg;
     1432    $self->exif_dlg->Refresh;
    16531433    $self->piwigo_photo_properties_tags->Refresh;
    16541434
     
    16651445
    16661446
    1667     $self->dlg_piwigo_photo_properties->{_multi_selection_mode_panel}{_text1}->SetLabel(
     1447    $self->piwigo_photo_properties_dlg->{_multi_selection_mode_panel}{_text1}->SetLabel(
    16681448        sprintf(gettext("You have selected a batch of %s photos"), $self->imageviewer->GetSelectectItemsCount )
    16691449    );
    16701450
    1671     $self->dlg_piwigo_photo_properties->{_multi_selection_mode_panel}{_text2}->SetLabel(
     1451    $self->piwigo_photo_properties_dlg->{_multi_selection_mode_panel}{_text2}->SetLabel(
    16721452        gettext("Changes apply to the whole batch")
    16731453    );
    16741454
    1675     $self->dlg_piwigo_photo_properties->{_multi_selection_mode_panel}->Show(1);
    1676     $self->dlg_piwigo_photo_properties->Layout;
     1455    $self->piwigo_photo_properties_dlg->{_multi_selection_mode_panel}->Show(1);
     1456    $self->piwigo_photo_properties_dlg->Layout;
    16771457}
    16781458
     
    16801460    my( $self ) = @_;
    16811461
    1682     $self->dlg_piwigo_photo_properties->{_multi_selection_mode_panel}->Show(0);
    1683     $self->dlg_piwigo_photo_properties->Layout;
     1462    $self->piwigo_photo_properties_dlg->{_multi_selection_mode_panel}->Show(0);
     1463    $self->piwigo_photo_properties_dlg->Layout;
    16841464
    16851465}
     
    17081488    }
    17091489
    1710     $self->image_preview->image_size(
     1490    $self->image_preview_dlg->image_size(
    17111491        [$image->GetWidth, $image->GetHeight, ]
    17121492    );       
    17131493
    1714     $self->image_preview->image(
     1494    $self->image_preview_dlg->image(
    17151495        $image
    17161496    );       
     
    17511531
    17521532    if(!$self->imageviewer->GetItemCount){
    1753         $self->image_preview->image(0);
     1533        $self->image_preview_dlg->image(0);
    17541534        $self->OnUpdateImageviewerEmpty;
    17551535    }
     
    17631543    }
    17641544
    1765     $self->image_preview->Refresh;
     1545    $self->image_preview_dlg->Refresh;
    17661546    Wx::Yield();
    17671547}
     
    18501630        $self->imageviewer->Show(1);
    18511631    }
    1852 }
    1853 
    1854 
    1855 sub ActivateImageViewer {
    1856     my ( $self ) = @_;   
    1857    
    18581632}
    18591633
     
    18831657
    18841658
     1659sub GetWxBitmapType {
     1660    my ( $self, $type ) = @_;
     1661   
     1662    $self->{IMGTYPE}->{$type};
     1663}
     1664
    18851665
    18861666# prepare and upload image_selection
     
    18911671
    18921672    if( $self->destination_categories_are_empty ){
    1893         Wx::MessageBox(
    1894             sprintf(
    1895                 "%s",
    1896                 wxTheApp->branding->{'What is the destination category?'}
    1897             ),
    1898             gettext("Piwigo upload error"),
    1899             wxOK | wxICON_EXCLAMATION,
    1900         );
    1901 
    1902     }
    1903     else {
     1673        return unless $self->destination_category_dlg->ShowModal != wxID_CANCEL;
     1674    }
     1675#    else {
    19041676        # all selected is implicit
    19051677        if(!scalar @{$self->imageviewer->GetSelectedItems}){
     
    19391711            );
    19401712        }
    1941     }
     1713    #}
    19421714}
    19431715
     
    20091781
    20101782    #destroy hidden dialogs
    2011     $self->global_settings_panel->Destroy;
    2012     $self->image_preview->Destroy;
    2013     $self->image_prop_exif->Destroy;
     1783    $self->global_settings_dlg->Destroy;
     1784    $self->image_preview_dlg->Destroy;
     1785    $self->exif_dlg->Destroy;
     1786    $self->destination_category_dlg->Destroy;
    20141787
    20151788    $self->progressdlg->Destroy if defined $self->progressdlg;
  • extensions/pLoader/trunk/src/Uploader/GUI/Layout/PhotoPropertiesCategoriesTags.pm

    r5261 r5390  
    33use Wx::DateTime;
    44use strict;
    5 
     5use Data::Dumper;
    66# Custom source
    77use Uploader::GUI::wxChoiceFilteredPanel;
     
    2626
    2727sub PhotoPropertiesCategoriesTags {
    28     my( $parent ) = @_;
     28    my( $parent, $categories ) = @_;
     29
     30
    2931    my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL );
    3032
     
    6163    $topsizer->Add( $item1, 2, wxEXPAND|wxALL, 5 );
    6264
    63     my( $item3 ) = Wx::TreeCtrl->new( $parent, $main::PHOTO_PROPERTIES_CATEGORIES, wxDefaultPosition, [450,160], wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT );
    6465    # the notebook has adaptive size : stretch factor 1, wxEXPAND
    65     $topsizer->AddWindow( $item3, 1, wxEXPAND|wxALL, 5 );
     66    my ( $tree_categories ) = Uploader::GUI::wxCategoryTreeCtrl->new(
     67        {
     68            parentwnd  => $parent,
     69            id         => $main::PHOTO_PROPERTIES_CATEGORIES,
     70            categories => $categories,
     71        }
     72    );
     73    $tree_categories->Populate;
     74    $topsizer->AddWindow( $tree_categories, 1, wxEXPAND|wxALL, 5 );
    6675
    6776    my( $item4 ) = Wx::StaticLine->new( $parent, $main::ID_LINE, wxDefaultPosition, [20,-1], wxLI_HORIZONTAL );
     
    7180    my $btfont = Wx::Font->new(16, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
    7281    $item5->SetFont($btfont);
    73 #    $item5->SetForegroundColour( Wx::wxGREEN );
    7482    $item5->SetForegroundColour( Wx::Colour->new(255, 51, 99) );
    7583    $topsizer->AddWindow( $item5, 0, wxEXPAND|wxALL, 5 );
  • extensions/pLoader/trunk/src/Uploader/PWG.pm

    r4779 r5390  
    5353
    5454    if(!$self->use_offline){
    55         $self->RefreshCategories;       
     55        $self->RefreshCategories;
    5656        $self->RefreshTags;
    5757    }
  • extensions/pLoader/trunk/src/ploader.pl

    r4974 r5390  
    3333use Uploader::GUI::Layout::PhotoPropertiesCategoriesTags;
    3434use Uploader::GUI::Layout::PhotoPropertiesExif;
     35use Uploader::GUI::Layout::DestinationCategory;
    3536use JSON;
    3637use Wx::Locale qw/:default/;
     
    3839use File::HomeDir;
    3940
    40 #$SIG{__DIE__} = \&OnDieHandler;
     41$SIG{__DIE__} = \&OnDieHandler;
    4142
    4243eval {
Note: See TracChangeset for help on using the changeset viewer.