Changeset 4475


Ignore:
Timestamp:
Dec 12, 2009, 12:48:34 AM (14 years ago)
Author:
ronosman
Message:

Feature 1318 added : new photo properties panel with Piwigo metadata and tags.

Location:
extensions/pLoader/trunk
Files:
2 added
4 edited

Legend:

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

    r4469 r4475  
    1212);
    1313
     14sub InitHandler {
     15    my ( $self ) = @_;
     16
     17        # to connect the right event handler to each control
     18        my $ctrl_handlers = {
     19            'Wx::TextCtrl' => sub { my ( $ctrl ) = @_; Wx::Event::EVT_TEXT( $ctrl, $ctrl, sub { $self->OnTextCtrl(@_) } ); },
     20        };
     21       
     22        map {
     23        my $ctrl =$self->FindWindow($_);
     24        if(defined $ctrl){
     25                    $ctrl_handlers->{ ref $ctrl}->($ctrl) if exists $ctrl_handlers->{ ref $ctrl};
     26                }
     27    }
     28        keys %{$self->properties};
     29       
     30
     31}
     32
     33# what does happen when the text changes
     34sub OnTextCtrl {
     35    my ( $self, $ctrl, $event ) = @_;
     36       
     37        printf("OnTextCtrl %s, %s\n", $ctrl->GetId, $event->GetString);
     38    my $id = $ctrl->GetId;
     39    # change the property value
     40        $self->properties->{$id}->{value}->(
     41        $event->GetString
     42    ) if exists $self->properties->{$id}->{value};
     43
     44    # exec the callback
     45    $self->properties->{$id}->{frame_callback}->() if exists
     46        $self->properties->{$id}->{frame_callback};     
     47       
     48}
     49
     50my $change_value = {
     51    'Wx::TextCtrl' => sub { my ($ctrl, $value ) = @_; $ctrl->ChangeValue($value)},
     52    'Wx::CheckBox' => sub { my ($ctrl, $value ) = @_; $ctrl->SetValue($value)},
     53};     
    1454
    1555sub SetProperties {
     
    2060        #printf("ctrl %s : %s\n", $_, $ctrl);           
    2161        if(defined $ctrl){
    22                 # checkbox, static text
    23                 $ctrl->SetLabel(
    24            $self->properties->{$_}->{label}
    25                 ) if exists$self->properties->{$_}->{label};
    26 
    27         $ctrl->SetValue(
    28            $self->properties->{$_}->{value}->()
    29                 ) if exists$self->properties->{$_}->{value};
    30 
    31         # radiobox
    32         my $labels =$self->properties->{$_}->{labels};
    33                 $labels||=[];
    34                 for(my $i=0; $i < scalar @$labels ; $i++){
    35                     $ctrl->SetItemLabel($i, $labels->[$i]);
    36                 }
    37                 # only works for control with items
    38                 $ctrl->SetSelection(
    39                     $self->properties->{$_}->{selection}->()                   
    40                 ) if exists $self->properties->{$_}->{selection};
    41                
     62                # checkbox, static text
     63            $change_value->{ref $ctrl}->(
     64                        $ctrl,
     65                $self->properties->{$_}->{value}->()
     66                    ) if exists $self->properties->{$_}->{value};
     67                    # only works for control with items
     68                    $ctrl->SetSelection(
     69                        $self->properties->{$_}->{selection}->()                       
     70                    ) if exists $self->properties->{$_}->{selection};
    4271                }
    4372    }
    4473        keys %{$self->properties};
     74}
     75
     76sub InitLabels {
     77    my ( $self ) = @_;
     78       
     79        map {
     80        my $ctrl =$self->FindWindow($_);
     81        #printf("ctrl %s : %s\n", $_, $ctrl);           
     82        if(defined $ctrl){
     83                # checkbox, static text
     84                    $ctrl->SetLabel(
     85               $self->properties->{$_}->{label}
     86                    ) if exists $self->properties->{$_}->{label};
     87               
     88            # radiobox
     89            my $labels =$self->properties->{$_}->{labels};
     90                    $labels||=[];
     91                    for(my $i=0; $i < scalar @$labels ; $i++){
     92                        $ctrl->SetItemLabel($i, $labels->[$i]);
     93                    }
     94                }
     95    }
     96        keys %{$self->properties};
     97
    4598}
    4699
     
    66119        keys %{$self->properties};
    67120}
     121
    681221;
  • extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm

    r4094 r4475  
    6565
    6666
    67     my $self = $class->SUPER::new( $params->{parentwnd}, -1, wxDefaultPosition, wxDefaultSize );
     67    my $self = $class->SUPER::new( $params->{parentwnd}, $params->{id}||-1, wxDefaultPosition, wxDefaultSize );
    6868    $self->_init_panel;
    6969    $self->_init_properties($params);
    70 
     70printf("%s, %s\n", $self, $self->GetId);
    7171    $self->Refresh;
    7272
     
    8686       
    8787    $self->choices(
    88         $params->{choices}
     88        $params->{choices}|| sub { [] }
    8989    );
    9090
    9191    $self->selection(
    92         $params->{selection}
    93     );
    94 
    95     my $choices = $self->choices->() ||[];
     92        $params->{selection}|| sub{ [] }
     93    );
     94
     95    my $choices = $self->choices->();
    9696    $self->search_result(
    9797        []
     
    136136
    137137    $self->listchoices(
    138         Wx::CheckListBox->new( $self, -1, wxDefaultPosition, [320,300], [], 0 )
     138        Wx::CheckListBox->new( $self, -1, wxDefaultPosition, [320,200], [], 0 )
    139139    );
    140140    $vsizer->AddWindow( $self->listchoices, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
  • extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm

    r4468 r4475  
    127127          piwigo_tags
    128128          image_tags
     129                  piwigo_photo_properties
     130                  dlg_piwigo_photo_properties
     131                  piwigo_photo_properties_tags
    129132      /;
    130133__PACKAGE__->mk_accessors( @properties );
     
    156159use Storable;
    157160use Uploader::GUI::wxPropertyGridPanel;
     161use Uploader::GUI::wxPhotoProperties;
    158162use utf8;
    159163$|=1;
     
    323327sub _set_setting_properties {
    324328    my ( $self ) = @_;
    325        
     329
     330    $self->piwigo_photo_properties(
     331        {
     332                    $main::CAPTION => { label=>gettext("Photo caption :")},
     333                        $main::PHOTO_PROPERTIES_CAPTION => {
     334                                                               value => sub { $self->imagelist->current_image->site_name(@_) },
     335                                                                                                   frame_callback => sub { $self->imageviewer->Refresh() },
     336                                                           },
     337                    $main::COMMENT => { label=>gettext("Comment :")},
     338                        $main::PHOTO_PROPERTIES_COMMENT => {
     339                                                               value => sub { $self->imagelist->current_image->site_comment(@_) },
     340                                                           },
     341                    $main::AUTHOR => { label=>gettext("Author :")},
     342                        $main::PHOTO_PROPERTIES_AUTHOR => {
     343                                                               value => sub { $self->imagelist->current_image->site_author(@_) },
     344                                                           },
     345                    $main::TAGS => { label=>gettext("Tags :")},
     346                    $main::CREATE_DATE => { label=>gettext("Create date :")},
     347                        $main::PHOTO_PROPERTIES_CREATE_DATE => {
     348                                                               value => sub { $self->imagelist->current_image->create_date(@_) },
     349                                                           },
     350                    $main::PRIVACY_LEVEL => { label=>gettext("Privacy level :")},
     351                }
     352    ); 
    326353
    327354    $self->piwigo_properties(
     
    663690        $self->advanced_settings_panel,
    664691        $self->watermark_settings_panel,
     692                $self->piwigo_photo_properties_tags
    665693    );
    666694   
     
    710738sub _refresh_settings_panels_properties {
    711739    my ( $self ) = @_; 
     740
     741        $self->dlg_piwigo_photo_properties->properties(
     742        $self->piwigo_photo_properties
     743        );
    712744       
    713745    $self->image_prop_piwigo->properties(
     
    748780sub _init_settings_panels {
    749781    my ( $self ) = @_; 
    750 
    751782
    752783    $self->image_prop_piwigo(
     
    834865    );   
    835866
     867    $self->dlg_piwigo_photo_properties(
     868        Uploader::GUI::wxPhotoProperties->new(
     869                    {
     870                parentwnd       => $self,
     871                properties      => $self->piwigo_photo_properties,
     872                                tags            => {
     873                                                        id => $main::PHOTO_PROPERTIES_TAG,
     874                                        choices => $self->piwigo_tags,
     875                                        selection => $self->image_tags,
     876                                        creation_callback => sub { $self->_create_piwigo_tag(@_) },
     877                                                                   },
     878                        }
     879                )
     880    ); 
     881
     882        $self->piwigo_photo_properties_tags(
     883            $self->dlg_piwigo_photo_properties->FindWindow($main::PHOTO_PROPERTIES_TAG)
     884        );
     885
    836886   
    837887    $self->general_settings_panel->Show(0);
     
    845895    );
    846896
    847 
     897    $self->image_preview->Show(0);
    848898    $self->image_prop_piwigo->Show(0);
    849    
    850899    $self->image_prop_exif->Show(0);
    851900       
     
    916965        ->CenterPane->Resizable->CloseButton(0) );
    917966
     967        $self->manager->AddPane(
     968        $self->dlg_piwigo_photo_properties,
     969        Wx::AuiPaneInfo->new->Name( "piwigo_photo_properties" )
     970        ->Right->Position( 0 )->Resizable->CloseButton(0)
     971    );
    918972               
    919973    $self->manager->AddPane(
    920974        $self->create_tree,
    921975        Wx::AuiPaneInfo->new->Name( "categories" )
    922         ->Right->Position( 0 )->Resizable->CloseButton(0),
     976        ->Right->Position( 1 )->Resizable->CloseButton(0),
    923977    );
    924978
     
    9471001    }
    9481002    else {
    949         $self->manager->GetPane("categories")->MinSize(300,100);
     1003        $self->manager->GetPane("piwigo_photo_properties")->MinSize(600,350);
     1004        $self->manager->GetPane("categories")->MinSize(600,100);
    9501005
    9511006        $self->manager->GetPane("tb1")->Caption( gettext("Tools") );
     
    11691224    }
    11701225    @$images;
    1171 
    1172    
     1226   
    11731227    $self->tree(
    11741228        Wx::TreeCtrl->new(
     
    11851239
    11861240    $self->tree->SetImageList( $self->treeimglist );
    1187     $self->populate_tree_categories if !wxTheApp->use_offline;
     1241    $self->populate_tree_categories($self->tree) if !wxTheApp->use_offline;
    11881242    $self->tree ;
    11891243}
     
    11911245
    11921246sub populate_tree_categories {
    1193     my ( $self ) = @_;
     1247    my ( $self, $tree ) = @_;
    11941248
    11951249    $self->populate_tree(
    1196         $self->tree,
     1250        $tree,
    11971251        wxTheApp->pwg->categories,
    11981252    ) if defined wxTheApp->pwg ;
    11991253   
    1200     #$self->tree->ExpandAll;
    12011254
    12021255}
     
    17091762
    17101763    $event->Skip;
     1764
    17111765}
    17121766
     
    17261780        }
    17271781
     1782    $self->dlg_piwigo_photo_properties->SetProperties;
    17281783    $self->image_prop_piwigo->Refresh;
    17291784    $self->image_prop_exif->Refresh;
    17301785    $self->image_prop_tags->Refresh;
     1786        $self->piwigo_photo_properties_tags->Refresh;
    17311787
    17321788}
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageReuploadDlg.pm

    r4469 r4475  
    5151            $params->{properties}
    5252        );
    53 
     53        $self->InitLabels();
    5454        $self->SetProperties();
    5555        $self->_initEventHandlers();
     
    7070    EVT_BUTTON( $self, $main::ID_REUPLOAD_OK, \&OnOK );
    7171    EVT_CLOSE( $self, \&OnClose );
    72    
    73        
    7472}
    7573
Note: See TracChangeset for help on using the changeset viewer.