Index: /extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm	(revision 3471)
+++ /extensions/pLoader/trunk/src/Uploader/GUI/wxApp.pm	(revision 3472)
@@ -646,8 +646,9 @@
                 branding       => $self->branding,
                 chunk_size     => $self->chunk_size,
+                use_offline    => $self->use_offline,
             }
         )
     );
-    
+
     $rval;
 }
Index: /extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceGridPanel.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceGridPanel.pm	(revision 3472)
+++ /extensions/pLoader/trunk/src/Uploader/GUI/wxChoiceGridPanel.pm	(revision 3472)
@@ -0,0 +1,236 @@
+# +-----------------------------------------------------------------------+
+# | pLoader - a Perl photo uploader for Piwigo                            |
+# +-----------------------------------------------------------------------+
+# | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
+# +-----------------------------------------------------------------------+
+# | This program is free software; you can redistribute it and/or modify  |
+# | it under the terms of the GNU General Public License as published by  |
+# | the Free Software Foundation                                          |
+# |                                                                       |
+# | This program is distributed in the hope that it will be useful, but   |
+# | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+# | General Public License for more details.                              |
+# |                                                                       |
+# | You should have received a copy of the GNU General Public License     |
+# | along with this program; if not, write to the Free Software           |
+# | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+# | USA.                                                                  |
+# +-----------------------------------------------------------------------+
+package Uploader::GUI::wxChoiceGridPanel;
+use strict;
+use Wx qw/
+             wxDefaultSize
+             wxDefaultPosition
+         /;
+
+use base qw/Wx::Grid Uploader::Object2/;
+
+use Wx::Event qw/
+   EVT_GRID_CMD_CELL_CHANGE
+   EVT_GRID_CELL_LEFT_CLICK
+/;
+use Data::Dumper;
+
+__PACKAGE__->mk_accessors(     
+    qw/
+        frame_callbacks
+        renderer
+        editor
+        choices
+        selection
+        id_lookup
+        row_lookup
+      /
+);
+
+
+
+sub new {
+    my ($this, $params) = @_;
+    #on recupere le nom de la classe en fonction du type d'appel de la méthode.
+    my $class = ref($this) || $this;
+
+
+    my $self = $class->SUPER::new( $params->{parentwnd}, -1, wxDefaultPosition, wxDefaultSize );
+
+    $self->id_lookup(
+        {}
+    );
+
+    $self->row_lookup(
+        {}
+    );
+
+    $self->choices(
+        $params->{choices}
+    );
+
+    $self->selection(
+        $params->{selection}
+    );
+
+    
+    # a frame callback for each property
+    $self->frame_callbacks(
+        $params->{frame_callbacks}
+    );
+    
+    $self->Initialize;
+      
+    EVT_GRID_CMD_CELL_CHANGE( $self, $self, \&OnCellChanged );
+    EVT_GRID_CELL_LEFT_CLICK( $self, \&OnCellLeftClick );
+    $self;    
+}
+
+sub Initialize {
+    my ( $self ) = @_;	
+
+
+  $self->CreateGrid( scalar @{$self->choices}, 2 );
+  
+
+  $self->SetRowLabelSize(0);
+  $self->SetColLabelSize(0);
+  $self->SetColSize( 0, 200 );
+  $self->SetColSize( 1, 20 );
+  
+  $self->_init_choices;
+
+}
+
+sub Refresh {
+    my ( $self ) = @_;
+    
+    $self->ClearGrid;
+    $self->id_lookup({});
+    $self->row_lookup({});
+
+    my $row = 0;
+    map {
+    	$self->SetCellValue(
+    	    $row,
+    	    0,
+    	    $_->{name},
+    	) if defined $_;	
+
+        $self->id_lookup->{$row} = $_->{id};
+        $self->row_lookup->{$_->{id}} = $row;
+    	$row++;
+    }@{$self->choices};
+
+    $self->SetSelection;
+	
+}
+
+sub _init_choices {
+    my ( $self ) = @_;
+
+    my $row = 0;
+    #print Dumper $self->properties;
+    map {
+    	eval {
+    	    $self->SetReadOnly(
+    	        $row,
+    	        0,
+            );
+
+    	    $self->SetCellValue(
+    	        $row,
+    	        0,
+    	        $_->{name},
+    	    ) if defined $_;	
+
+    	    $self->SetCellEditor(
+    	        $row,
+    	        1,
+                &{
+                    sub { Wx::GridCellBoolEditor->new },
+                },    	    
+    	    );
+
+    	    $self->SetCellRenderer(
+    	        $row,
+    	        1,
+                &{
+                    sub { Wx::GridCellBoolRenderer->new }
+                },    	    
+    	    );
+
+    	};
+        $self->id_lookup->{$row} = $_->{id};
+        $self->row_lookup->{$_->{id}} = $row;
+    	$row++;
+    }@{$self->choices};
+
+
+}
+
+sub OnCellChanged {
+    my ( $self, $event ) = @_;
+
+    $self->selection->(
+        $self->GetSelection
+    );    
+}
+
+sub OnCellLeftClick {
+    my ( $self, $event ) = @_;
+
+    my ( $row, $col ) = ( $event->GetRow, $event->GetCol );
+    
+    # only col 0
+    if(!$event->GetCol){
+        $self->SetCellValue(
+            $event->GetRow,
+            1,
+            !$self->GetCellValue(
+                $event->GetRow,
+                1,
+            ),
+        );
+    }
+
+    $self->selection->(
+        $self->GetSelection
+    );    
+    $event->Skip;
+}
+
+sub SetSelection {
+    my ( $self ) = @_;
+
+    my $selection = $self->selection->()||[];
+
+    map {
+    	$self->SetCellValue(
+    	    $self->row_lookup->{$_},
+    	    1,
+    	    1,
+    	) if exists $self->row_lookup->{$_} ;	
+    }
+    @{$selection};	
+}
+
+
+
+sub GetSelection {
+    my ( $self ) = @_;
+
+    my $row = 0;
+    my $selection = [];
+    map {
+        my $selected = $self->GetCellValue(
+            $row,
+            1,
+        );
+            
+        if($selected){
+            push @$selection, $self->id_lookup->{$row};	
+        }
+    	$row++;
+    }@{$self->choices};
+    
+    $selection;	
+}
+1;
Index: /extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm	(revision 3471)
+++ /extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm	(revision 3472)
@@ -324,4 +324,5 @@
           image_prop_piwigo
           image_prop_exif
+          image_prop_tags
           notebook_image_properties
           notebook_global_settings
@@ -346,4 +347,6 @@
           imageviewer_select_multi
           frameLayout
+          piwigo_tags
+          image_tags
       /;
 __PACKAGE__->mk_accessors( @properties );
@@ -366,4 +369,5 @@
 use Uploader::GUI::wxImageListCtrl;
 use Uploader::GUI::wxImageProcessingProgressDlg;
+use Uploader::GUI::wxChoiceGridPanel;
 use Wx::Html;
 use Uploader::GUI::wxHtmlWindow;
@@ -576,4 +580,5 @@
         ]
     );   
+
 
     $self->general_settings(
@@ -711,5 +716,12 @@
         ]    
     );
-	
+
+    $self->image_tags(
+        sub { $self->imagelist->current_image->site_tags(@_) }
+    );
+
+    $self->piwigo_tags(
+        wxTheApp->pwg->tags||[]
+    );	
 }
 
@@ -725,4 +737,5 @@
         $self->image_prop_piwigo,
         $self->image_prop_exif,
+        $self->image_prop_tags,
         $self->general_settings_panel,
         $self->resized_settings_panel,
@@ -806,4 +819,5 @@
         $self->advanced_settings,
     );    
+
 	
 }
@@ -889,4 +903,15 @@
         )    
     );    
+
+    $self->image_prop_tags(
+        Uploader::GUI::wxChoiceGridPanel->new( 
+            { 
+                parentwnd    => $self,
+                choices      => $self->piwigo_tags,
+                selection    => $self->image_tags, 
+            }
+        )    
+    );    
+
     
     $self->general_settings_panel->Show(0);
@@ -952,10 +977,4 @@
         ) 
     );
-    #$self->htmlhome->SetDropTarget( 
-    #    DNDImageListDropTarget->new( 
-    #        $self->imageviewer 
-    #    ) 
-    #);
-
 
     $self->tree->SetDropTarget( 
@@ -1111,4 +1130,10 @@
 }
 
+sub OnDefaultPhotoNameChanged {
+    my ( $self ) = @_;
+    
+    Wx::LogMessage("New default_photo_name %s", $self->imagelist->default_photo_name);	
+}
+
 
 sub create_notebook_imagelist {
@@ -1139,4 +1164,8 @@
             $self->image_prop_piwigo, 
             "Piwigo",
+        ],
+        [
+            $self->image_prop_tags, 
+            "Tags",
         ],
         [
@@ -1746,4 +1775,5 @@
     $self->image_prop_piwigo->Refresh;
     $self->image_prop_exif->Refresh;
+    $self->image_prop_tags->Refresh;
 
 }
@@ -1869,19 +1899,6 @@
 
     if(!$self->imageviewer->IsShown){
-        #my $imglistpage = [
-        #    [
-        #        $self->imageviewer, 
-        #        gettext("Photo selection"),
-        #        '../res/images.png', 
-        #        wxBITMAP_TYPE_PNG,
-        #    ],
-        #];
-        #$self->notebook->DeletePage(0);
-    
         $self->imageviewer->Show(1);
-        #$self->_populate_notebook($self->notebook, $imglistpage, 0);
-        # load imagelist with loading.jpg
     }
-	
 }
 
Index: /extensions/pLoader/trunk/src/Uploader/ImageList.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 3471)
+++ /extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 3472)
@@ -143,51 +143,4 @@
 }
 
-sub _set_current_image_filepaths__ {
-    my ( $self ) = @_;
-
-    my ( $vol, $dir, $file ) = File::Spec->splitpath(
-        $self->current_image->file
-    );
-
-    my ( $filename, $ext ) = split /\./, $file ;
-    
-
-    $self->current_image->wx_thumb_file( 
-        File::Spec->catfile(
-            $self->wx_thumb_dir,
-            sprintf(
-                "%s.%s",
-                $filename,
-                $self->type,
-            )
-        )
-    );
-
-    $self->current_image->preview_file( 
-        File::Spec->catfile(
-            $self->preview_dir,
-            sprintf(
-                "%s.%s",
-                $filename,
-                $self->type,
-            )
-        )
-    );
-    $self->current_image->preview_file( 
-        encode('iso-8859-1', $self->current_image->preview_file)
-    );
-
-    $self->current_image->site_thumb_file( 
-        File::Spec->catfile(
-            $self->site_thumb_dir,
-            sprintf(
-                "%s.%s",
-                $filename,
-                $self->type,
-            )
-        )
-    );
-
-}
 
 sub _set_current_image_filepaths {
@@ -901,5 +854,4 @@
         my $site_name = $self->current_image->site_name;
     
-#        my ( $filename, $ext ) = split /\./, $file ;
         my $filename = $self->current_image->file_sum ;
 
@@ -1176,6 +1128,6 @@
     );
 
-    $self->pwg->tags(
-        #join(',', @{$self->current_image->site_tags})
+    $self->pwg->site_tags(
+        join(',', @{$self->current_image->site_tags})
     );
 	
Index: /extensions/pLoader/trunk/src/Uploader/PWG.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/PWG.pm	(revision 3471)
+++ /extensions/pLoader/trunk/src/Uploader/PWG.pm	(revision 3472)
@@ -38,4 +38,5 @@
            http_password
            branding
+           use_offline
       / 
 );
@@ -49,7 +50,9 @@
     # for web services    
     $self->SUPER::Init();
-    
-    $self->RefreshCategories;	
 
+    if(!$self->use_offline){
+        $self->RefreshCategories;	
+        $self->RefreshTags;
+    }
 }
 
@@ -64,4 +67,12 @@
 }
 
+sub RefreshTags {
+    my ( $self ) = @_;
+
+    $self->tags(
+        $self->GetTags
+    );
+}
+
 
 1;
Index: /extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm
===================================================================
--- /extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm	(revision 3471)
+++ /extensions/pLoader/trunk/src/Uploader/PWG/WebServices.pm	(revision 3472)
@@ -43,4 +43,5 @@
            qry_list_categories
            qry_add_categories
+           qry_list_tags
            items
            tags
@@ -50,4 +51,5 @@
            site_thumb_file
            site_image_name
+           site_tags
            rank
            site_author
@@ -105,4 +107,11 @@
     );
 
+    $self->qry_list_tags( sprintf
+        "%s/ws.php?format=json&method=%s",
+        $self->urlbase,
+        'pwg.tags.getAdminList',
+    );
+
+
     my $form = {
         method => 'pwg.session.login',
@@ -170,4 +179,34 @@
     $categories;	
 }
+
+sub GetTags {
+    my ( $self ) = @_;
+
+    my $result;
+    eval {
+        $result = $self->uagent->get(
+            $self->qry_list_tags
+        );
+    };
+
+    if($@){
+        printf("An error occured in query execution %s\n%s",
+            $self->qry_list_tags,
+            $@,
+        );	
+    }
+    my $hresult;
+    
+    eval {
+    	$hresult = from_json(
+            $result->content
+        );
+    };
+    
+    $hresult ||= {};
+
+    $hresult->{result}{tags};
+}
+
 
 sub UploadImage {
@@ -256,4 +295,5 @@
                 comment           => $self->site_comment,
                 date_creation     => $self->site_img_date_creation,
+                tag_ids           => $self->site_tags,
                 
             };
@@ -286,4 +326,5 @@
                 comment           => $self->site_comment,
                 date_creation     => $self->site_img_date_creation,
+                tag_ids           => $self->site_tags,
             };
         }
