Changeset 3284


Ignore:
Timestamp:
May 15, 2009, 8:41:14 AM (15 years ago)
Author:
ronosman
Message:

Feature 994 added : gui layout management. Use perspective to save/reload gui layout.

Location:
extras/pLoader/trunk/src/Uploader/GUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extras/pLoader/trunk/src/Uploader/GUI/wxApp.pm

    r3267 r3284  
    306306          use_offline
    307307          login_dlg
     308          branding
    308309      /
    309310);
     
    357358        $self->{site_url}
    358359    );
     360   
    359361
    360362    $self->site_username(
     
    527529        th_quality       => 90,
    528530        auto_rotate      => 1,
     531        remove_uploaded_from_selection => 1,
    529532        interlace        => 'Line',
    530533        create_resized   => 1,
     
    535538        userdata_dir     => $self->userdata_dir,
    536539        default_photo_name => gettext('File name'),
    537         default_name_prefix => 'Photo',
     540        default_name_prefix => gettext('Photo'),
    538541        upload_rejects   =>  [],
    539542        image_sums       => {},
     
    571574    $self->login_dlg->Show(0);
    572575
     576    $self->_init_branding;
     577
     578
    573579    $self->pwg(
    574580        # get these parameters from dialog or from file
     
    578584                site_username  => $self->site_username,
    579585                site_password  => $self->site_password,
     586                branding       => $self->branding,
    580587            }
    581588        )
     
    818825}
    819826
    820 
     827# some labels differ with branding ( piwigo.com or piwigo.org )
     828sub _init_branding {
     829    my ( $self ) =@_;
     830   
     831    if( $self->site_url =~ /\.piwigo\.com/ ){
     832        $self->branding(
     833            {
     834                category  => gettext("album"), 
     835                Category  => gettext("Album"), 
     836                categories => gettext("albums"),       
     837                Categories => gettext("Albums"),
     838                'Add new category' => gettext("Add new album"),
     839            }
     840        );
     841    }
     842    else{
     843        $self->branding(
     844            {
     845                categorie  => gettext("categorie"),     
     846                Categorie  => gettext("Categorie"),     
     847                categories => gettext("categories"),   
     848                Categories => gettext("Categories"),   
     849                'Add new category' => gettext("Add new category"),     
     850            }
     851        );
     852    }   
     853}
     854
     855sub SaveConfig {
     856    my ( $self, $params ) = @_;
     857
     858   my $config = Wx::ConfigBase::Get;
     859
     860   map {
     861       $config->WriteInt( $_, $params->{$_} )
     862   } keys %$params;
     863
     864   $config->Write( 'Perspective', $params->{Perspective} )
     865       
     866}
    821867
    822868
     
    830876    my $w = $config->ReadInt( "Width", 1024 );
    831877    my $h = $config->ReadInt( "height", 768 );
    832     my $sv = $config->ReadInt( "splitVertical", 150 );
    833     my $sh = $config->ReadInt( "splitHorizontal", 300 );
     878    my $prev_w = $config->ReadInt( "PreviewWidth", 400 );
     879    my $prev_h = $config->ReadInt( "PreviewHeight", 300 );
     880    my $perspective = $config->Read( "Perspective" );
     881   
     882    #printf("Config x %s, y %s, w %s, h %s, prev_w %s, prev_h %s\n", $x, $y, $w, $h, $prev_w, $prev_h);
    834883   
    835884    my $url = $self->site_url;
     
    848897            pwg       => $self->pwg,
    849898            imagelist => $self->imagelist,
     899            preview_w => $prev_w,
     900            preview_h => $prev_h,
     901            perspective => $perspective,
    850902        }
    851903    );
    852904       
    853         #printf("Config x %s, y %s, w %s, h %s\n", $x, $y, $w, $h);
    854         #$frame->SetSize( $x, $y, $w, $h );
     905    $frame->SetSize( $x, $y, $w, $h );
    855906    $frame->Show( 1 );
    856907    $self->SetTopWindow( $frame );
  • extras/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm

    r3269 r3284  
    335335          preview_settings
    336336          toolbar
     337          branding
     338          preview_w
     339          preview_h
     340          perspective
    337341      /;
    338342__PACKAGE__->mk_accessors( @properties );
     
    345349          EVT_LIST_END_LABEL_EDIT
    346350          EVT_LIST_ITEM_SELECTED
     351          EVT_LIST_ITEM_ACTIVATED
    347352          EVT_TREE_ITEM_RIGHT_CLICK
    348353          EVT_LIST_KEY_DOWN
     
    374379                                      wxDEFAULT_FRAME_STYLE|wxMAXIMIZE
    375380                                   );
     381    $self->preview_w(
     382        $params->{preview_w}||400
     383    );
     384
     385    $self->preview_h(
     386        $params->{preview_h}||300
     387    );
     388   
     389    $self->perspective(
     390        $params->{perspective}
     391    );
     392
    376393    $self->pwg( $params->{pwg} );
    377394    $self->imagelist( $params->{imagelist} );
     
    426443    );
    427444
     445
    428446    $self->manager( Wx::AuiManager->new );
     447    $self->manager->SetDockSizeConstraint(1, 1);
    429448    $self->manager->SetManagedWindow( $self );
    430449    $self->_set_setting_properties;
     
    436455}
    437456
     457
    438458sub _initImgTypes {
    439459    my ( $self ) = @_;
     
    461481        [
    462482            {
    463                 label => "Photo name :",
     483                label => gettext("Photo caption :"),
    464484                value => sub { $self->imagelist->current_image->site_name(@_) },
    465485            },
     
    548568            },
    549569            {
    550                 label     => gettext("Default photo name :"),
     570                label     => gettext("Default photo caption :"),
    551571                type      => 'Choice',
    552572                value   => sub { $self->imagelist->default_photo_name(@_) },
     
    563583            },
    564584            {
    565                 label     => gettext("Photo name  prefix :"),
     585                label     => gettext("Photo caption  prefix :"),
    566586                value   => sub { $self->imagelist->default_name_prefix(@_) },
    567587            },
     
    581601                value   => sub { $self->imagelist->upload_high(@_) },
    582602            },
     603#            {
     604#                label     => gettext("Remove uploaded photo from selection :"),
     605#                type      => 'Bool',
     606#                value  => sub { $self->imagelist->remove_uploaded_from_selection(@_) },
     607#            },
    583608        ]   
    584609    );
     
    822847        )   
    823848    );   
    824 
    825849   
    826850    $self->general_settings_panel->Show(0);
     
    830854            $self,
    831855            -1,
    832             wxNullBitmap
     856            wxNullBitmap,
     857            wxDefaultPosition,
     858            [$self->preview_w, $self->preview_h]
    833859        )
    834860    );
    835861
    836 
    837 
    838862    $self->image_prop_piwigo->Show(0);
    839 
    840        
    841863   
    842864    $self->image_prop_exif->Show(0);
     
    890912sub init_aui {
    891913    my ( $self ) = @_;
    892    
     914
    893915    my $url = wxTheApp->site_url;
    894916   
     
    901923    $self->manager->AddPane
    902924      ( $self->create_tree, Wx::AuiPaneInfo->new->Name( "categories" )->Caption(
    903           sprintf("%s - %s", gettext("Piwigo categories"), $url )
     925          sprintf("%s - %s", sprintf("Piwigo %s", wxTheApp->branding->{categories}), $url )
    904926      )
    905927        ->Right->Position( 0 )->Resizable->CloseButton(0) );
     
    920942        ->ToolbarPane->Top->Row( 1 )->LeftDockable( 0 )->RightDockable( 0 ) ) if defined $self->toolbar;
    921943
     944    if( $self->perspective){
     945        $self->manager->LoadPerspective($self->perspective);
     946    }
     947   
    922948    $self->manager->Update;
    923949
     
    929955    $self->manager->AddPane
    930956      ( $self->create_notebook_image_properties, Wx::AuiPaneInfo->new->Name( "photo_properties" )->Caption(gettext("Photo properties"))
    931         ->Right->Position( 1 )->Resizable->CloseButton(0) );
     957        ->Floatable(1)->Resizable->CloseButton(1) );
    932958
    933959    $self->manager->AddPane
    934960      ( $self->create_notebook_global_settings, Wx::AuiPaneInfo->new->Name( "global_settings" )->Caption(gettext("Global settings"))
    935         ->Right->Position( 2 )->Resizable->CloseButton(1) );
    936 
     961        ->Floatable(1)->Resizable->CloseButton(1) );
     962
     963    $self->manager->GetPane("photo_properties")->Show(0);
    937964    $self->manager->GetPane("global_settings")->Show(0);
    938965       
    939966}
    940967
     968sub OnPhotoProperties {
     969    my ( $self ) = @_;
     970
     971    $self->manager->GetPane("photo_properties")->Float;
     972    $self->manager->GetPane("photo_properties")->Show(1);
     973    $self->manager->Update();   
     974       
     975}
     976
    941977sub OnGlobalSettings {
    942978    my ( $self ) = @_;
    943979
    944980    $self->toolbar->EnableTool(104, 0 );
     981    $self->manager->GetPane("global_settings")->Float;
    945982    $self->manager->GetPane("global_settings")->Show(1);
    946983    $self->manager->Update();   
     
    11151152}
    11161153
    1117 #$tree_items is a list of anonymous arrays
    1118 # [ itemLabel, undef, rootInfo, ImageIndex, SelImageIndex ] for the root
    1119 
    1120 # [ itemLabel,
    1121 #       [ childItemLabel,
    1122 #           [...],
    1123 #           childItemdata,
    1124 #           childImageIndex,
    1125 #           childSelImageIndex
    1126 #       ],
    1127 #    Itemdata,
    1128 #    ImageIndex,
    1129 #    SelImageIndex
    1130 # ]
    11311154
    11321155# returns a valid itemData
     
    12171240    EVT_TREE_ITEM_RIGHT_CLICK( $self->tree, $self->tree, \&OnTreeItemRightClick );
    12181241    EVT_LIST_END_LABEL_EDIT( $self, $self->imageviewer, \&OnImageViewerEndLabelEdit );
     1242    EVT_LIST_ITEM_ACTIVATED( $self, $self->imageviewer, \&OnImageViewerItemActivated );
    12191243    EVT_LIST_ITEM_SELECTED($self, $self->imageviewer, \&OnImageViewerItemSelected) ;
    12201244    EVT_LIST_KEY_DOWN($self, $self->imageviewer, \&OnImageViewerKeyDown) ;
     
    12341258    my( $self, $event ) = @_;
    12351259    my $dialog = Wx::FileDialog->new
    1236       ( $self, "Select photos to send", $prevfile, $prevdir,
    1237         "JPEG files (*.jpg)|*.jpg|All(*.*)|*.*",
     1260      ( $self, gettext("Select photos for upload"), $prevfile, $prevdir,
     1261        sprintf("%s (*.jpg)|*.jpg|All(*.*)|*.*", gettext("JPEG files")),
    12381262        wxFD_OPEN|wxFD_MULTIPLE );
    12391263
     
    13321356    }
    13331357    (
    1334         [1+$ID_TREE_CTX_MENU, "Add new category","Add a new category to the current selected category."],
    1335         [2+$ID_TREE_CTX_MENU, "Refresh","Refresh category list."],
     1358        [
     1359            1+$ID_TREE_CTX_MENU,
     1360            wxTheApp->branding->{'Add new category'},
     1361            sprintf(
     1362                "%s %s %s %s",
     1363                gettext("Add a new"),
     1364                wxTheApp->branding->{category},
     1365                gettext("to the currently selected"),
     1366                wxTheApp->branding->{category},
     1367            )
     1368        ],
     1369        [
     1370            2+$ID_TREE_CTX_MENU,
     1371            "Refresh",
     1372            sprintf(
     1373                "Refresh %s list.",
     1374                wxTheApp->branding->{category},
     1375            )
     1376        ],
    13361377    );
    13371378    $self->PopupMenu($ctx_mnu, $point);
     
    13511392    my $dialog = Wx::TextEntryDialog->new(
    13521393        $self,
    1353         gettext("Category name :"),
    1354         gettext("Add new category"),
    1355         gettext("New category"),
     1394        sprintf("Category name :", wxTheApp->branding->{Category}),
     1395        sprintf("Add new %s", wxTheApp->branding->{category}),
     1396        sprintf("New %s", wxTheApp->branding->{category}),
    13561397    );
    13571398
     
    13901431       
    13911432    $self->image_prop_piwigo->Refresh;
     1433}
     1434
     1435sub OnImageViewerItemActivated {
     1436    my( $self, $event ) = @_;
     1437
     1438    $self->OnPhotoProperties;
    13921439}
    13931440
     
    15911638        Wx::MessageBox(
    15921639            sprintf(
    1593                 gettext("Please select a valid target category"),
     1640                "%s %s",
     1641                gettext("Please select a valid target"),
     1642                wxTheApp->branding->{category}
    15941643            ),
    15951644            gettext("Piwigo upload error"),
     
    16321681  my $self = shift;
    16331682
     1683
    16341684    # Restaure previous log wnd
    16351685    Wx::Log::SetActiveTarget( $self->oldlogwnd );
     
    16411691    $self->imagelist->Store;
    16421692    wxTheApp->login_dlg->Destroy;       
     1693
     1694    my $params = {};
     1695
     1696    ( $params->{'X'}, $params->{'Y'} ) = $self->GetPositionXY ;
     1697    ( $params->{'Width'}, $params->{'Height'} ) = $self->GetSizeWH ;
     1698    ( $params->{'PreviewWidth'}, $params->{'PreviewHeight'} ) = $self->image_preview->GetSizeWH ;
     1699    $params->{Perspective} = $self->manager->SavePerspective;
     1700   
     1701
     1702    wxTheApp->SaveConfig( $params );
     1703
    16431704    $self->Destroy;
    16441705}
Note: See TracChangeset for help on using the changeset viewer.