Index: /extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm	(revision 5446)
+++ /extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm	(revision 5447)
@@ -139,5 +139,4 @@
 use Uploader::GUI::wxImageReuploadDlg;
 use Uploader::GUI::wxImageProcessingProgressDlg;
-use Uploader::GUI::wxChoiceFilteredPanel;
 use Uploader::GUI::wxDestinationCategoryDlg;
 use Uploader::GUI::wxCategoryTreeCtrl;
@@ -1431,5 +1430,5 @@
     $self->piwigo_photo_properties_dlg->SetProperties if defined $self->piwigo_photo_properties_dlg;
     $self->exif_dlg->Refresh;
-    $self->piwigo_photo_properties_tags->Refresh;
+    $self->piwigo_photo_properties_tags->RefreshChoices;
 
 }
Index: /extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm	(revision 5446)
+++ /extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceFilteredPanel.pm	(revision 5447)
@@ -47,5 +47,5 @@
         id_from_name
         search
-        listchoices
+        choices_list
         btn_show
         show_method
@@ -57,4 +57,5 @@
         autocomplete_to
         autocomplete_set_selection
+        current_show_mode
       /
 );
@@ -66,13 +67,198 @@
     my $class = ref($this) || $this;
 
-
     my $self = $class->SUPER::new( $params->{parentwnd}, $params->{id}||-1, wxDefaultPosition, wxDefaultSize );
-    $self->_init_panel;
-    $self->_init_properties($params);
-
-    $self->Refresh;
-
-    Wx::Event::EVT_CHECKLISTBOX( $self, $self->listchoices, \&OnCheck );
-    Wx::Event::EVT_LISTBOX( $self, $self->listchoices, \&OnSelected );
+
+    $self->init_panel;
+    $self->init_properties($params);
+    $self->init_event_handlers;
+
+    $self;
+}
+
+
+sub init_panel {
+    my ( $self ) = @_;    
+
+    my( $vsizer ) = Wx::BoxSizer->new( wxVERTICAL );
+    
+    $self->search(
+        Wx::SearchCtrl->new( $self, -1, "", wxDefaultPosition, [-1,-1],wxTE_PROCESS_ENTER )
+    );
+
+    $self->search->ShowCancelButton( 1 );
+    $vsizer->Add( $self->search, 0, wxEXPAND|wxALL, 2 );
+
+    $self->choices_list(
+        Wx::CheckListBox->new( $self, -1, wxDefaultPosition, [-1,-1], [], 0 )
+    );
+    $vsizer->Add( $self->choices_list, 1, wxEXPAND|wxALL, 2 );
+
+    $self->btn_show(
+        Wx::RadioBox->new( $self, -1, sprintf("%s :", gettext("Show")), wxDefaultPosition, [-1, -1], 
+            [gettext("All"),gettext("Selection")] , 1, wxRA_SPECIFY_ROWS )
+    );
+    $vsizer->Add( $self->btn_show, 0, wxEXPAND|wxALL, 2 );
+
+    $self->SetSizer( $vsizer );
+    $vsizer->Fit( $self );
+}
+
+
+sub init_properties {
+    my ( $self, $params ) = @_;    
+    
+    $self->choices(
+        $params->{choices}|| sub { [] }
+    );
+
+    $self->selection(
+        $params->{selection}|| sub{ [] }
+    );
+
+    $self->search_result(
+        []
+    );
+    
+    $self->is_selected({});
+    
+    $self->creation_callback(
+        $params->{creation_callback}
+    ) if 'CODE' eq ref($params->{creation_callback});
+
+    $self->show_method(
+        {
+            gettext("All") => sub { $self->show_all(@_) },
+            gettext("Selection") => sub { $self->show_selected(@_) },
+        }
+    );
+}
+
+
+sub RefreshChoices {
+    my ( $self ) = @_;
+
+    $self->refresh_lookups(
+        $self->choices->()
+    );
+    $self->refresh_is_selected;
+    my $show_mode = $self->current_show_mode||gettext("All");
+    $self->show_method->{$show_mode}->();
+}
+
+
+sub refresh_lookups {
+    my ( $self, $choices ) = @_;
+
+    $self->id_lookup({});
+    $self->row_lookup({});
+    $self->id_from_name({});
+
+    my $row = 0;
+    #print Dumper $self->properties;
+    map {
+        $self->id_lookup->{$row} = $_->{id};
+        $self->row_lookup->{$_->{id}} = $row;
+        $self->id_from_name->{$_->{name}} = $_->{id};
+        $row++;    
+    }@{$choices};
+
+}
+
+
+sub refresh_is_selected {
+    my ( $self ) = @_;
+
+    my $selection = $self->selection->();
+    $self->is_selected({});
+
+    map {
+        $self->is_selected->{$_} = 1;
+    } @$selection;
+
+}
+
+
+sub show_all {
+    my ( $self ) = @_;
+
+    my $choices = $self->choices->();
+    $self->current_show_mode(
+        gettext("All")
+    );
+    $self->refresh_choices_list(
+        $self->choices->()
+    );
+}
+
+
+sub show_selected {
+    my ( $self ) = @_;    
+
+    $self->current_show_mode(
+        gettext("Selection")
+    );
+
+    $self->refresh_choices_list(
+        $self->get_selected_choices()
+    );
+}
+
+
+sub refresh_choices_list {
+    my ( $self, $choices ) = @_;
+
+    $self->choices_list->Freeze;
+    $self->choices_list->Clear;
+
+    #print Dumper $self->properties;
+    my $i=0;
+    map {
+        $self->choices_list->Append(
+            $_->{name},
+        );
+        $self->choices_list->Check(
+            $i,
+            $self->is_selected->{$_->{id}}
+        );
+        $i++;
+    }@{$choices};
+    $self->choices_list->Thaw;
+}
+
+
+sub get_selected_choices {
+    my ( $self ) = @_;
+
+    my $choices = $self->choices->()||[];
+    # each choice item is { id => $id,  name => $name, url_nam => $url_name }
+    my $selected = [
+        grep { $self->is_selected->{$_->{id}} } @$choices
+    ];
+
+
+    $selected;
+}
+
+
+sub ClearAllSelection {
+    my ( $self ) = @_;
+
+    my $row = 0;
+    
+    my $choices = $self->choices->();
+    $self->choices_list->Freeze;
+    map {
+        $self->choices_list->Check($row, 0) ;    
+        $row++;
+    }@$choices;
+    $self->choices_list->Thaw;
+}
+
+
+sub init_event_handlers {
+    my ( $self ) = @_;
+
+    Wx::Event::EVT_CHECKLISTBOX( $self, $self->choices_list, \&OnCheck );
+    Wx::Event::EVT_LISTBOX( $self, $self->choices_list, \&OnSelected );
     Wx::Event::EVT_SEARCHCTRL_SEARCH_BTN( $self, $self->search, \&OnSearch );
     Wx::Event::EVT_SEARCHCTRL_CANCEL_BTN( $self, $self->search, \&OnCancel );
@@ -93,192 +279,80 @@
         }
     );
-
-    $self;
-}
-
-sub _init_properties {
-    my ( $self, $params ) = @_;    
-    
-    $self->choices(
-        $params->{choices}|| sub { [] }
-    );
-
-    $self->selection(
-        $params->{selection}|| sub{ [] }
-    );
-
-    my $choices = $self->choices->();
-    $self->search_result(
-        []
-    );
-    
-    
-    
-    $self->is_selected({});
-    
-    $self->creation_callback(
-        $params->{creation_callback}
-    ) if 'CODE' eq ref($params->{creation_callback});
-
-    $self->show_method(
-        {
-            gettext("All") => sub { $self->_show_all(@_) },
-            gettext("Selected") => sub { $self->_show_selected(@_) },
-            gettext("Not selected") => sub { $self->_show_notselected(@_) },
-        }
-    );
-}
-
-sub _init_panel {
-    my ( $self ) = @_;    
-
-    my( $vsizer ) = Wx::BoxSizer->new( wxVERTICAL );
-    
-    $self->search(
-        Wx::SearchCtrl->new( $self, -1, "", wxDefaultPosition, [-1,-1],wxTE_PROCESS_ENTER )
-    );
-
-    $self->search->ShowCancelButton( 1 );
-
-    $vsizer->AddWindow( $self->search, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 2 );
-
-    $self->btn_show(
-        Wx::RadioBox->new( $self, -1, sprintf("%s :", gettext("Show")), wxDefaultPosition, [-1, -1], 
-            [gettext("All"),gettext("Selected"),gettext("Not selected")] , 1, wxRA_SPECIFY_ROWS )
-    );
-    $vsizer->AddWindow( $self->btn_show, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 2 );
-
-
-    $self->listchoices(
-        Wx::CheckListBox->new( $self, -1, wxDefaultPosition, [-1,-1], [], 0 )
-    );
-    $vsizer->AddWindow( $self->listchoices, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 2 );
-
-    $self->SetSizer( $vsizer );
-    $vsizer->SetSizeHints( $self );
-         
-}
-
-sub _init_choices {
-    my ( $self, $choices ) = @_;
-
-    $self->listchoices->Freeze;
-    $self->listchoices->Clear;
-    $self->id_lookup({});
-    $self->row_lookup({});
-    $self->id_from_name({});
-    $self->is_selected({});
-
-    my $row = 0;
-    #print Dumper $self->properties;
-    map {
-        $self->listchoices->Append(
-            $_->{name},
-        );
-        $self->id_lookup->{$row} = $_->{id};
-        $self->row_lookup->{$_->{id}} = $row;
-        $self->id_from_name->{$_->{name}} = $_->{id};
-        $row++;    
-    }@{$choices};
-    $self->listchoices->Thaw;
-
-}
-
-sub Refresh {
-    my ( $self, $choices, $selected ) = @_;
-
-    
-
-    if (!defined $choices){
-        $self->btn_show->SetStringSelection(gettext("All"));
-        $choices = $self->choices->();
-    }
-
-    $self->_init_choices($choices);
-    $self->SetSelection($selected);
-    
-}
-
-sub ClearAllSelection {
-    my ( $self ) = @_;
-
-    my $row = 0;
-    
-    my $choices = $self->choices->();
-    $self->listchoices->Freeze;
-    map {
-        $self->listchoices->Check($row, 0) ;    
-        $row++;
-    }@$choices;
-    $self->listchoices->Thaw;
-}
-
-sub SetSelection {
-    my ( $self, $selected ) = @_;
-
-    my $selection = $self->selection->()||[];
-
-    push @$selection, $self->id_from_name->{$selected} if defined $selected;
-
-    $self->listchoices->Freeze;
-    map {
-        $self->listchoices->Check(
-            $self->row_lookup->{$_},
-            exists $self->row_lookup->{$_},
-        ) if defined $self->row_lookup->{$_};
-        $self->is_selected->{$_} = 1;    
-    }
-    @{$selection};    
-    $self->listchoices->Thaw;
-}
-
-sub GetSelection {
-    my ( $self ) = @_;
-
-    my $row = 0;
-    my $selection = [];
-    
-    my $choices = $self->choices->();
-    map {
-           
-        my $id = $self->id_lookup->{$row};
-        $self->is_selected->{$id} = $self->listchoices->IsChecked($row) ;    
-        $row++;
-    }@$choices;
-
-    [
-        grep { $self->is_selected->{$_} } keys %{$self->is_selected}
-    ];    
-}
-
-sub OnCheck {
-    my ( $self ) = @_;
-    
-    $self->selection->(
-        $self->GetSelection
-    );    
-}
+}
+
 
 sub OnSelected {
     my ( $self, $event ) = @_;
 
+    my $list = $event->GetEventObject;
     my $row = $event->GetInt;
-    $self->listchoices->Check(
+
+    $list->Check(
         $row,
-        !$self->listchoices->IsChecked($row)    
-    );
-
-    $self->OnCheck;
-
-    $event->Skip;    
-}
+        !$list->IsChecked($row)    
+    );
+
+    $self->OnCheck($event);
+
+}
+
+
+sub OnCheck {
+    my ( $self, $event ) = @_;
+
+    my $list = $event->GetEventObject;
+    my $indx = $event->GetInt;
+    my $item = $list->GetString($indx);
+    if($list->IsChecked($indx)){
+       $self->add_to_selection($item);
+    }
+    else{
+        $self->remove_from_selection($item);
+    }
+    
+}
+
+
+sub add_to_selection {
+    my ( $self, $item ) = @_;
+
+    return if !defined $item;
+
+    my $id = $self->id_from_name->{$item};
+    return if !defined $id;
+
+    $self->is_selected->{$id} = 1;
+    my $selection = $self->selection->();
+
+    $self->selection->(
+        [
+            $id,
+            @$selection
+        ]
+    );
+}
+
+
+sub remove_from_selection {
+    my ( $self, $item ) = @_;
+
+    my $id = $self->id_from_name->{$item};
+    my $selection = $self->selection->();
+    $self->selection->(
+        [
+            grep { $_ ne $id } @$selection
+        ]
+    );
+    $self->refresh_is_selected;
+}
+
 
 sub OnShow {
     my( $self, $event ) = @_;
 
-    my $show = $event->GetString();
-    
-    $self->show_method->{$show}->();                               
-}
+    my $show_mode = $event->GetString();
+    $self->show_method->{$show_mode}->();
+}
+
 
 sub OnSearchEnter {
@@ -286,5 +360,5 @@
 
     my $searched = $self->search->GetValue;
-    $searched =~ s/\s+$//;
+    eval { $searched =~ s/\s+$//; };
     $searched = $searched eq "" ? undef : $searched ;
 
@@ -299,10 +373,10 @@
             );
     
-            $self->_refresh_selected_searched($searched);
+            $self->refresh_selected_searched($searched);
             $cleanup = 1;
         }
     
         if( 1 == scalar @{$self->search_result}){
-            $self->_refresh_selected_searched($searched);
+            $self->refresh_selected_searched($searched);
             $cleanup = 1;
         }
@@ -319,11 +393,13 @@
 }
 
-sub _refresh_selected_searched {
+sub refresh_selected_searched {
     my ( $self, $searched ) = @_;        
 
-    $self->Refresh;
-    $self->SetSelection($searched);
-    $self->_show_selected;
-    $self->btn_show->SetStringSelection(gettext("Selected"));
+    $self->refresh_lookups(
+        $self->choices->()
+    );
+    $self->add_to_selection($searched);
+    $self->show_selected;
+    $self->btn_show->SetStringSelection(gettext("Selection"));
 }
 
@@ -336,10 +412,10 @@
 
     $self->search_result(
-        $self->_filter_choices(
+        $self->search_in_choices(
             $searched
         )
     );
 
-    $self->Refresh(
+    $self->refresh_choices_list(
         $self->search_result
     );
@@ -367,8 +443,20 @@
 }
 
+
+sub search_in_choices {
+    my ( $self, $searched ) = @_;
+    
+    my $choices = $self->choices->()||[];
+    
+    [
+       grep { $_->{name} =~ /\b$searched/i} @$choices
+    ];
+}
+
+
 sub OnCancel {
     my( $self, $event ) = @_;
 
-    $self->Refresh(
+    $self->init_choices_list(
         $self->choices->()
     );
@@ -378,55 +466,3 @@
 
 
-sub _filter_choices {
-    my ( $self, $searched ) = @_;
-    
-    my $choices = $self->choices->()||[];
-    [
-       grep { $_->{name} =~ /$searched/i} @$choices
-    ]
-}
-
-sub _show_notselected {
-    my ( $self ) = @_;    
-
-    $self->Refresh(
-        $self->_filter_notselected()
-    );
-}
-
-sub _show_selected {
-    my ( $self ) = @_;    
-
-    $self->Refresh(
-        $self->_filter_selected()
-    );
-}
-
-sub _show_all {
-    my ( $self ) = @_;    
-
-    $self->Refresh(
-        $self->choices->()
-    );
-}
-
-sub _filter_selected {
-    my ( $self ) = @_;
-
-    my $choices = $self->choices->()||[];
-    [
-        grep { $self->is_selected->{$_->{id}} } @$choices
-    ]    
-}
-
-sub _filter_notselected {
-    my ( $self ) = @_;
-
-    my $choices = $self->choices->()||[];
-    [
-        grep { !$self->is_selected->{$_->{id}} } @$choices
-    ]    
-}
-
-
 1;
