Changeset 5104 for extensions/pLoader


Ignore:
Timestamp:
Mar 11, 2010, 6:15:33 PM (14 years ago)
Author:
ronosman
Message:

Feature 1496 added : display a message in the photo selection when it is empty.

Location:
extensions/pLoader/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/locale/fr_FR/pLoader.po

    r5103 r5104  
    658658msgid "Changes apply to the whole batch"
    659659msgstr "Les modifications s'appliquent à toutes les photos de la sélection"
     660
     661msgid "Drag photos here to get started"
     662msgstr "Glissez-déposez vos photos ici pour démarrer"
     663
     664msgid "Or click"
     665msgstr "Ou cliquez sur"
     666
     667msgid "to choose files on your computer"
     668msgstr "pour choisir des fichiers de votre ordinateur"
  • extensions/pLoader/trunk/src/Uploader/GUI/Frame.pm

    r5103 r5104  
    4343             wxBITMAP_TYPE_ANY
    4444             wxTB_FLAT
     45             wxTB_TEXT
    4546             wxSIZE
    4647             wxWHITE
     
    7980             wxHORIZONTAL
    8081             wxVERTICAL
     82             wxEXPAND
    8183         /;
    8284use base qw/Wx::Frame Class::Accessor::Fast/;
     
    101103          logwnd
    102104          oldlogwnd
    103           getting_started
    104105          categories
    105106          imagelist
     
    728729    );
    729730
     731    # message displayed in the image listctrl when empty
     732    $self->imageviewer->InitEmptyMsg;
    730733
    731734    $self->init_panels;
     
    765768        );
    766769       
     770        $self->OnUpdateImageviewerNotEmpty;
     771    }
     772    else{
     773        $self->OnUpdateImageviewerEmpty;
    767774    }
    768775
    769776    # the imageviewer has a stretch factor of 1 : expands its size on frame resize
    770     $sizer_h->AddWindow( $self->imageviewer, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL||wxSHAPED, 2 );
    771     $sizer_h->AddWindow( $self->dlg_piwigo_photo_properties, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxALL||wxSHAPED, 2 );
     777    $sizer_h->Add( $self->imageviewer, 1, wxEXPAND|wxALL, 2 );
     778    $sizer_h->Add( $self->dlg_piwigo_photo_properties, 0, wxEXPAND|wxALL, 2 );
     779
     780
    772781    $self->SetSizer(
    773782        $sizer_h
    774783    );
    775 
    776     $sizer_h->SetSizeHints(
     784    my $new_size = $sizer_h->Fit(
    777785        $self
    778786    );
    779 
    780 
    781 
    782 }
     787    $self->SetMinSize([600, 500]);
     788    $self->Center;
     789}
     790
     791sub OnUpdateImageviewerEmpty {
     792    my ( $self ) = @_;
     793
     794    $self->dlg_piwigo_photo_properties->Enable(0);
     795    $self->imageviewer->OnEmpty;
     796}
     797
     798sub OnUpdateImageviewerNotEmpty {
     799    my ( $self ) = @_;
     800
     801    $self->dlg_piwigo_photo_properties->Enable(1);
     802    $self->imageviewer->OnNotEmpty;
     803}
     804
    783805
    784806sub _refresh_settings_panels_properties {
     
    842864    my ( $self ) = @_;
    843865   
    844     $self->getting_started(
    845         Uploader::GUI::wxHtmlWindow->new(
    846             {   
    847                 html => $self->_gs_html(
    848                     {
    849                         label   => gettext("Click links below to start using pLoader."),
    850                         lnk1    => gettext("Add a new album."),
    851                         lnk2    => gettext("Add photos to the selection."),
    852                         lnk3    => gettext("Upload the photo selection into your album."),
    853                     }
    854                 ),
    855                 caption => gettext("Getting started"),
    856                 size => [450, 350],
    857             }
    858         )
    859     );
    860    
    861    
    862     $self->getting_started->InitHrefCallbacks(
    863         {
    864             new_album => sub {$self->OnAddCategories(@_) },
    865             add_photos => sub { $self->OnAddImages(@_) },
    866             upload_photos => sub { $self->ProcessImageSelection(@_)},   
    867         }
    868     );
    869     $self->getting_started->Hide;
    870    
    871866    $self->_init_settings_panels;   
    872867}
    873868
    874869# HTML code for getting started dialog box
    875 sub _gs_html {
    876     my ( $self, $params ) = @_;
    877 
    878 
    879    my $logo = File::Spec->catfile(wxTheApp->root_dir, wxTheApp->resource_dir, 'piwigo_logo.PNG');
    880 
    881 
    882     my $html = '<html>';
    883     $html .= '<body text="#E15918" link="#E15918">';
    884     $html .= '<font size=5 face="verdana, arial">';
    885     $html .= '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>';
    886     $html .= sprintf("<img src=\"%s\" /><br /><br />", $logo);
    887     $html .= $params->{label};
    888     $html .= "<br /><br /><br />";
    889     $html .= '1. <a href="new_album">';
    890     $html .= $params->{lnk1};
    891     $html .= '</a><br /><br />';
    892     $html .= '2. <a href="add_photos">';
    893     $html .= $params->{lnk2};
    894     $html .= '</a><br /><br />';
    895     $html .= '3. <a href="upload_photos">';
    896     $html .= $params->{lnk3};
    897     $html .= '</a><br /><br />';
    898 
    899     $html .= '</font></body></html>';
    900 
    901     $html;
    902 }
    903870
    904871
     
    937904}
    938905
    939 sub OnGettingStarted {
    940     my ( $self ) = @_;
    941 
    942     $self->getting_started->Show(1);
    943 }
    944906
    945907sub OnGlobalSettings {
     
    12101172    my ( $self ) = @_ ;
    12111173   
    1212     Wx::Event::EVT_MENU( $self, 100, \&OnGettingStarted );
    12131174    Wx::Event::EVT_MENU( $self, 101, \&OnAddImages );
    12141175    Wx::Event::EVT_MENU( $self, 102, \&OnRemoveImages );
     
    12401201
    12411202    Wx::Event::EVT_BUTTON( $self, $main::PHOTO_PROPERTIES_UPLOAD, \&OnUploadImages );
     1203    Wx::Event::EVT_BUTTON( $self, $self->imageviewer->add_button->GetId, \&OnAddImages );
    12421204
    12431205}
     
    12981260        $self->piwigo_photo_properties_tags->ClearAllSelection;
    12991261        $self->imagelist->SetCurrentImage(-1);
    1300     }
     1262        $self->OnUpdateImageviewerEmpty;
     1263    }
     1264    else{
     1265        $self->OnUpdateImageviewerNotEmpty;
     1266    }
     1267
    13011268    if(!$self->multi_selection_mode){
    13021269        $self->OnUpdateSingleSelectionModeUI;
     
    16871654    $self->imageviewer->Refresh;
    16881655
    1689     $self->image_preview->image(
    1690         0
    1691     ) if !$self->imageviewer->GetItemCount;
    1692 
     1656    if(!$self->imageviewer->GetItemCount){
     1657        $self->image_preview->image(0);
     1658        $self->OnUpdateImageviewerEmpty;
     1659    }
    16931660    # reset previous selection
    16941661    $self->imagelist->image_selection(
     
    18081775        $wximagelist
    18091776    );
     1777
     1778    $self->OnUpdateImageviewerNotEmpty if $self->imageviewer->GetItemCount;
    18101779
    18111780    Wx::Yield();
     
    19341903    $self->image_preview->Destroy;
    19351904    $self->image_prop_exif->Destroy;
    1936     $self->getting_started->Destroy;
    19371905
    19381906    $self->progressdlg->Destroy if defined $self->progressdlg;
     
    19661934    }
    19671935    (
    1968         [
    1969             100,
    1970             gettext("Getting started"),
    1971             wxTheApp->resource_path('tb_getting_started.png'),
    1972             wxBITMAP_TYPE_PNG,
    1973             1,
    1974             wxTheApp->resource_path('tb_getting_started.png'),
    1975             gettext("Display getting started panel")
    1976         ],
    19771936        [
    19781937            101,
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageListCtrl.pm

    r5041 r5104  
    2323use Wx::DND;
    2424use POSIX qw(ceil floor);
     25use Wx::Locale qw/:default/;
    2526use Wx qw/
    2627             wxDefaultPosition
     
    4748             wxIMAGE_LIST_SMALL
    4849             wxTheApp
     50             wxVERTICAL
     51             wxALIGN_CENTER
     52             wxHORIZONTAL
     53             wxALIGN_CENTER_VERTICAL
     54             wxALIGN_CENTER_HORIZONTAL
     55             wxALL
     56             wxGROW
     57             wxWHITE
     58             wxSWISS
     59             wxNORMAL
     60             wxBOLD
     61             wxBITMAP_TYPE_PNG
    4962         /;
    5063use Wx::Event qw/
     
    8396        -1,
    8497        wxDefaultPosition,
    85         [ 180, -1],
     98        [ -1, -1],
    8699    );
    87100   
     
    110123
    111124    $self->prevItemCount(-1);
     125
    112126
    113127    EVT_LIST_BEGIN_DRAG( $self, $self, \&OnBeginDrag);
     
    135149                $self->Refresh;
    136150                $self->change_display_mode(0);
    137         }
    138         $event->Skip;
    139         }
    140     );
     151            }
     152            $event->Skip;
     153        }
     154    );
     155
     156    # manages empty panel position
     157    Wx::Event::EVT_PAINT( $self, sub {
     158            my ( $self, $event ) = @_;
     159            if(exists $self->{_empty_panel}){
     160                my ($w, $h) = $self->GetSizeWH;
     161                my ($x, $y) = $self->GetPositionXY;
     162                my ($wp, $hp) = $self->{_empty_panel}->GetSizeWH;
     163                my $x_off = ($w-$wp)/3 > 0 ? ($w-$wp)/3 : 0;
     164                my $y_off = ($h-$hp)/3 > 0 ? ($h-$hp)/3 : 0;
     165                $self->{_empty_panel}->Move(
     166                    [ $x+$x_off, $y+$y_off ]
     167                );
     168            }
     169            $event->Skip;
     170        }
     171    );
     172
    141173   
    142174    $self->initialize(
     
    353385}
    354386
     387sub OnEmpty {
     388    my ( $self ) = @_;
     389
     390    $self->_OnEmptyLayout;
     391
     392}
     393
     394sub OnNotEmpty {
     395    my ( $self ) = @_;
     396
     397    $self->{_empty_panel}->Show(0) if exists $self->{_empty_panel};
     398}
     399
     400sub _OnEmptyLayout {
     401
     402    my( $self ) = @_;
     403    $self->{_empty_panel}->Show(1);
     404
     405}
     406
     407sub add_button {
     408    my ( $self ) = @_;
     409
     410    $self->{_add_bt};
     411}
     412
     413sub InitEmptyMsg {
     414
     415    my ( $self ) = @_;
     416    # add a panel
     417    my $empty_panel = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize);
     418    my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     419   
     420    my $fb = Wx::Font->new( 12, wxSWISS, wxNORMAL, wxBOLD );
     421    my $fn = Wx::Font->new( 12, wxSWISS, wxNORMAL, wxNORMAL );
     422
     423    my( $item1 ) = Wx::StaticText->new( $empty_panel, -1, gettext("Drag photos here to get started"), wxDefaultPosition, wxDefaultSize, 0 );
     424    $item1->SetFont($fb);
     425    $item0->AddWindow( $item1, 0, wxALIGN_CENTER|wxALL, 5 );
     426
     427    my( $item2 ) = Wx::BoxSizer->new( wxHORIZONTAL );
     428   
     429    my( $item3 ) = Wx::StaticText->new( $empty_panel, -1, gettext("Or click"), wxDefaultPosition, wxDefaultSize, 0 );
     430    $item3->SetFont($fn);
     431    $item2->AddWindow( $item3, 0, wxALIGN_CENTER|wxALL, 5 );
     432
     433    my $icon1 = Wx::Icon->new();
     434    eval {
     435        $icon1->LoadFile(
     436            wxTheApp->resource_path('tb_add.png'),
     437            wxBITMAP_TYPE_PNG
     438        );
     439    };
     440    my $bmp = Wx::Bitmap->new( $icon1 );
     441
     442    my( $item4 ) = Wx::BitmapButton->new( $empty_panel, -1, $bmp, wxDefaultPosition, wxDefaultSize );
     443    $item2->AddWindow( $item4, 0, wxALIGN_CENTER|wxALL, 5 );
     444
     445    my( $item5 ) = Wx::StaticText->new( $empty_panel, -1, gettext("to choose files on your computer"), wxDefaultPosition, wxDefaultSize, 0 );
     446    $item5->SetFont($fn);
     447    $item2->AddWindow( $item5, 0, wxALIGN_CENTER|wxALL, 5 );
     448
     449    $item0->Add( $item2, 0, wxALIGN_CENTER|wxALL, 0 );
     450
     451    $empty_panel->SetSizer( $item0 );
     452    $item0->SetSizeHints( $empty_panel );
     453
     454    $self->{_empty_panel} = $empty_panel;
     455    $self->{_add_bt} = $item4;
     456    $self->{_empty_panel}->SetBackgroundColour(wxWHITE);
     457
     458    my ($wp, $hp) = $self->{_empty_panel}->GetSizeWH;
     459
     460    $self->SetMinSize( [20+$wp, -1 ]);
     461
     462}
     463
     464
     465
    3554661;
    356467
Note: See TracChangeset for help on using the changeset viewer.