Changeset 5390 for extensions/pLoader/trunk/src
- Timestamp:
- Mar 26, 2010, 9:04:59 PM (15 years ago)
- Location:
- extensions/pLoader/trunk/src
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/GUI/DlgCommon.pm
r5184 r5390 50 50 Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnComboBoxText(@_) } ); 51 51 }, 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 }, 52 61 }; 53 62 54 63 map { 55 64 my $ctrl =$self->FindWindow($_); 65 56 66 if(defined $ctrl){ 57 67 $ctrl_handlers->{ ref $ctrl}->($ctrl) if exists $ctrl_handlers->{ ref $ctrl}; … … 257 267 }; 258 268 269 270 sub 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 259 290 my $clear_value = { 260 291 'Wx::TextCtrl' => sub { my ($ctrl) = @_; $ctrl->Clear}, 261 292 'Wx::CheckBox' => sub { my ($ctrl) = @_; $ctrl->SetValue(0)}, 262 293 'Wx::DatePickerCtrl' => sub { my ($ctrl) = @_; $ctrl->SetValue(Wx::DateTime->new->SetToCurrent)}, 294 'Uploader::GUI::wxCategoryTreeCtrl' => sub { my ( $ctrl ) = @_; 295 $ctrl->SelectItem($ctrl->GetRootItem); 296 }, 263 297 }; 264 298 -
extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm
r5261 r5390 101 101 categories 102 102 imagelist 103 image_preview 103 image_preview_dlg 104 104 image_prop_piwigo 105 image_prop_exif105 exif_dlg 106 106 image_prop_tags 107 global_settings_ panel107 global_settings_dlg 108 108 piwigo_property_list 109 109 exif_properties … … 119 119 image_tags 120 120 piwigo_photo_properties 121 dlg_piwigo_photo_properties121 piwigo_photo_properties_dlg 122 122 piwigo_photo_properties_tags 123 image_preview_ refresh123 image_preview_need_refresh 124 124 imageviewer_refresh 125 125 imageviewer_item_refresh 126 126 horizontal_splitter 127 destination_category_dlg 128 destination_categories 129 categories_treectrl 127 130 /; 128 131 __PACKAGE__->mk_accessors( @properties ); … … 137 140 use Uploader::GUI::wxImageProcessingProgressDlg; 138 141 use Uploader::GUI::wxChoiceFilteredPanel; 142 use Uploader::GUI::wxDestinationCategoryDlg; 143 use Uploader::GUI::wxCategoryTreeCtrl; 139 144 use utf8; 140 145 $|=1; … … 146 151 sub new { 147 152 my( $class, $params ) = @_; 153 148 154 my $self = $class->SUPER::new( 149 155 undef, … … 158 164 $self->pwg( $params->{pwg} ); 159 165 $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 197 sub init_gui_callbacks { 198 my ( $self ) = @_; 160 199 161 200 # callback for GUI refresh : add thumbnail images to the imageviewer control … … 249 288 sub { $self->UploadDisplayEndInfo(@_) } 250 289 ); 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 293 sub init_properties_dlg_bindings { 301 294 my ( $self ) = @_; 302 295 … … 665 658 } 666 659 660 sub 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 671 sub 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 667 750 sub _create_piwigo_tag { 668 751 my ( $self, $name ) = @_; … … 684 767 } 685 768 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_tags698 );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 empty724 $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_imglist763 );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 resize772 $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_h778 );779 my $new_size = $sizer_h->Fit(780 $self781 );782 $self->SetMinSize([600, 660]);783 $self->Center;784 }785 769 786 770 sub OnUpdateImageviewerEmpty { 787 771 my ( $self ) = @_; 788 772 789 $self-> dlg_piwigo_photo_properties->{_properties_notebook}->Enable(0);773 $self->piwigo_photo_properties_dlg->{_properties_notebook}->Enable(0); 790 774 $self->imageviewer->OnEmpty; 791 775 } … … 794 778 my ( $self ) = @_; 795 779 796 $self-> dlg_piwigo_photo_properties->{_properties_notebook}->Enable(1);780 $self->piwigo_photo_properties_dlg->{_properties_notebook}->Enable(1); 797 781 $self->imageviewer->OnNotEmpty; 798 782 } 799 783 800 784 801 sub _refresh_settings_panels_properties {785 sub init_dialogs { 802 786 my ( $self ) = @_; 803 787 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( 824 790 Uploader::GUI::wxPropertyListDlg->new( 825 791 { … … 830 796 ) 831 797 ); 832 $self-> image_prop_exif->Hide;833 834 $self->global_settings_ panel(798 $self->exif_dlg->Hide; 799 800 $self->global_settings_dlg( 835 801 Uploader::GUI::wxGlobalSettings->new( 836 802 { … … 841 807 ) 842 808 ); 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( 848 812 Uploader::GUI::wxImagePreview->new( 849 813 { … … 854 818 ); 855 819 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 } 865 857 866 858 … … 883 875 884 876 885 886 877 sub OnPhotoProperties { 887 878 my ( $self ) = @_; 888 879 889 $self->image_prop_exif->Show(1); 890 } 880 $self->exif_dlg->Show(1); 881 } 882 891 883 892 884 sub OnPreview { 893 885 my ( $self ) = @_; 894 886 895 $self->image_preview->Show(1); 896 897 898 887 $self->image_preview_dlg->Show(1); 899 888 } 900 889 … … 903 892 my ( $self ) = @_; 904 893 905 $self->global_settings_ panel->Show(1);894 $self->global_settings_dlg->Show(1); 906 895 } 907 896 … … 913 902 } 914 903 904 915 905 sub OnGeneralSettingsClose { 916 906 my ( $self, $event ) = @_; 917 907 918 $self->global_settings_panel->Hide; 919 } 908 $self->global_settings_dlg->Hide; 909 } 910 920 911 921 912 sub OnImageExifPropClose { … … 925 916 } 926 917 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 921 sub show_hide_pwg_categories_empty_msg { 922 my ( $self ) = @_; 923 942 924 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 933 sub init_menus { 1113 934 my ( $self ) = @_ ; 1114 935 … … 1221 1042 } 1222 1043 1223 sub _initEventHandlers {1044 sub init_event_handlers { 1224 1045 my ( $self ) = @_ ; 1225 1046 … … 1243 1064 Wx::Event::EVT_CLOSE( $self, \&OnClose ); 1244 1065 1245 Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategor ies);1066 Wx::Event::EVT_MENU( $self, 1+$ID_TREE_CTX_MENU, \&OnAddCategory ); 1246 1067 Wx::Event::EVT_MENU( $self, 2+$ID_TREE_CTX_MENU, \&OnRefreshCategories ); 1247 1068 Wx::Event::EVT_MENU( $self, 3+$ID_TREE_CTX_MENU, \&OnExpandCategories ); … … 1254 1075 Wx::Event::EVT_BUTTON( $self, $self->imageviewer->add_button->GetId, \&OnAddImages ); 1255 1076 1256 Wx::Event::EVT_BUTTON( $self, $main::CATEGORIES_ADD, \&OnAddCategories );1257 1077 1258 1078 # only refresh when calling event is finished … … 1262 1082 my ( $self, $event ) = @_; 1263 1083 1264 if ( $self->image_preview_ refresh and $self->image_preview->IsShown ){1084 if ( $self->image_preview_need_refresh and $self->image_preview_dlg->IsShown ){ 1265 1085 $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); 1268 1088 } 1269 1089 … … 1283 1103 } 1284 1104 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); 1287 1107 } 1288 1108 … … 1314 1134 } 1315 1135 1136 1316 1137 sub OnUpdateToolbar { 1317 1138 my( $self ) = @_; 1318 1139 1319 if($self->global_settings_ panel->IsShown){1140 if($self->global_settings_dlg->IsShown){ 1320 1141 $self->toolbar->EnableTool(104, 0); 1321 1142 } … … 1324 1145 } 1325 1146 1326 if($self->global_settings_ panel->IsShown){1147 if($self->global_settings_dlg->IsShown){ 1327 1148 $self->toolbar->EnableTool(104, 0); 1328 1149 } … … 1342 1163 1343 1164 if (!$self->imageviewer->GetItemCount){ 1344 $self->image_preview ->image(1165 $self->image_preview_dlg->image( 1345 1166 0 1346 1167 ); 1347 1168 # have to reset 1348 $self-> dlg_piwigo_photo_properties->ClearProperties;1169 $self->piwigo_photo_properties_dlg->ClearProperties; 1349 1170 $self->piwigo_photo_properties_tags->ClearAllSelection; 1350 1171 $self->imagelist->SetCurrentImage(-1); … … 1359 1180 } 1360 1181 1361 $self->image_preview ->Refresh;1362 $self-> image_prop_exif->Refresh;1182 $self->image_preview_dlg->Refresh; 1183 $self->exif_dlg->Refresh; 1363 1184 } 1364 1185 … … 1402 1223 } 1403 1224 1225 1404 1226 sub OnTreeSelChanged { 1405 1227 my( $self, $event ) = @_; 1406 1407 my @items = $self->tree->GetSelections;1408 1228 1409 1229 $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 1417 1231 ); 1418 1232 } … … 1506 1320 } 1507 1321 1508 sub OnAddCategor ies{1322 sub OnAddCategory { 1509 1323 my ( $self, $event ) = @_; 1510 1324 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 1538 1329 1539 1330 sub OnRefreshCategories { … … 1545 1336 1546 1337 sub _refresh_all_categories_helper { 1547 my ( $self ) = @_; 1338 my ( $self ) = @_; 1548 1339 1549 1340 my $busycursor = Wx::BusyCursor->new(); 1550 1341 $self->tree->CollapseAll; 1551 1342 $self->tree->DeleteAllItems; 1552 $self->imagelist->categories([]);1553 1343 $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 1571 1351 1572 1352 sub OnImageViewerEndLabelEdit { … … 1578 1358 ); 1579 1359 1580 $self-> dlg_piwigo_photo_properties->SetProperties;1360 $self->piwigo_photo_properties_dlg->SetProperties; 1581 1361 } 1582 1362 … … 1598 1378 my $indx = $event->GetIndex; 1599 1379 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; 1602 1382 $self->_on_imageviewer_item_selected($indx); 1603 1383 … … 1647 1427 # and when current event is processed 1648 1428 # 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; 1653 1433 $self->piwigo_photo_properties_tags->Refresh; 1654 1434 … … 1665 1445 1666 1446 1667 $self-> dlg_piwigo_photo_properties->{_multi_selection_mode_panel}{_text1}->SetLabel(1447 $self->piwigo_photo_properties_dlg->{_multi_selection_mode_panel}{_text1}->SetLabel( 1668 1448 sprintf(gettext("You have selected a batch of %s photos"), $self->imageviewer->GetSelectectItemsCount ) 1669 1449 ); 1670 1450 1671 $self-> dlg_piwigo_photo_properties->{_multi_selection_mode_panel}{_text2}->SetLabel(1451 $self->piwigo_photo_properties_dlg->{_multi_selection_mode_panel}{_text2}->SetLabel( 1672 1452 gettext("Changes apply to the whole batch") 1673 1453 ); 1674 1454 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; 1677 1457 } 1678 1458 … … 1680 1460 my( $self ) = @_; 1681 1461 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; 1684 1464 1685 1465 } … … 1708 1488 } 1709 1489 1710 $self->image_preview ->image_size(1490 $self->image_preview_dlg->image_size( 1711 1491 [$image->GetWidth, $image->GetHeight, ] 1712 1492 ); 1713 1493 1714 $self->image_preview ->image(1494 $self->image_preview_dlg->image( 1715 1495 $image 1716 1496 ); … … 1751 1531 1752 1532 if(!$self->imageviewer->GetItemCount){ 1753 $self->image_preview ->image(0);1533 $self->image_preview_dlg->image(0); 1754 1534 $self->OnUpdateImageviewerEmpty; 1755 1535 } … … 1763 1543 } 1764 1544 1765 $self->image_preview ->Refresh;1545 $self->image_preview_dlg->Refresh; 1766 1546 Wx::Yield(); 1767 1547 } … … 1850 1630 $self->imageviewer->Show(1); 1851 1631 } 1852 }1853 1854 1855 sub ActivateImageViewer {1856 my ( $self ) = @_;1857 1858 1632 } 1859 1633 … … 1883 1657 1884 1658 1659 sub GetWxBitmapType { 1660 my ( $self, $type ) = @_; 1661 1662 $self->{IMGTYPE}->{$type}; 1663 } 1664 1885 1665 1886 1666 # prepare and upload image_selection … … 1891 1671 1892 1672 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 { 1904 1676 # all selected is implicit 1905 1677 if(!scalar @{$self->imageviewer->GetSelectedItems}){ … … 1939 1711 ); 1940 1712 } 1941 }1713 #} 1942 1714 } 1943 1715 … … 2009 1781 2010 1782 #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; 2014 1787 2015 1788 $self->progressdlg->Destroy if defined $self->progressdlg; -
extensions/pLoader/trunk/src/Uploader/GUI/Layout/PhotoPropertiesCategoriesTags.pm
r5261 r5390 3 3 use Wx::DateTime; 4 4 use strict; 5 5 use Data::Dumper; 6 6 # Custom source 7 7 use Uploader::GUI::wxChoiceFilteredPanel; … … 26 26 27 27 sub PhotoPropertiesCategoriesTags { 28 my( $parent ) = @_; 28 my( $parent, $categories ) = @_; 29 30 29 31 my( $topsizer ) = Wx::BoxSizer->new( wxVERTICAL ); 30 32 … … 61 63 $topsizer->Add( $item1, 2, wxEXPAND|wxALL, 5 ); 62 64 63 my( $item3 ) = Wx::TreeCtrl->new( $parent, $main::PHOTO_PROPERTIES_CATEGORIES, wxDefaultPosition, [450,160], wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT );64 65 # 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 ); 66 75 67 76 my( $item4 ) = Wx::StaticLine->new( $parent, $main::ID_LINE, wxDefaultPosition, [20,-1], wxLI_HORIZONTAL ); … … 71 80 my $btfont = Wx::Font->new(16, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); 72 81 $item5->SetFont($btfont); 73 # $item5->SetForegroundColour( Wx::wxGREEN );74 82 $item5->SetForegroundColour( Wx::Colour->new(255, 51, 99) ); 75 83 $topsizer->AddWindow( $item5, 0, wxEXPAND|wxALL, 5 ); -
extensions/pLoader/trunk/src/Uploader/PWG.pm
r4779 r5390 53 53 54 54 if(!$self->use_offline){ 55 $self->RefreshCategories; 55 $self->RefreshCategories; 56 56 $self->RefreshTags; 57 57 } -
extensions/pLoader/trunk/src/ploader.pl
r4974 r5390 33 33 use Uploader::GUI::Layout::PhotoPropertiesCategoriesTags; 34 34 use Uploader::GUI::Layout::PhotoPropertiesExif; 35 use Uploader::GUI::Layout::DestinationCategory; 35 36 use JSON; 36 37 use Wx::Locale qw/:default/; … … 38 39 use File::HomeDir; 39 40 40 #$SIG{__DIE__} = \&OnDieHandler;41 $SIG{__DIE__} = \&OnDieHandler; 41 42 42 43 eval {
Note: See TracChangeset
for help on using the changeset viewer.