Ignore:
Timestamp:
Mar 22, 2010, 5:16:48 PM (14 years ago)
Author:
ronosman
Message:

Feature 1530 added : add button is displayed in the categories list when it is empty.

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

Legend:

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

    r5184 r5261  
    2020package Uploader::GUI::Frame;
    2121use strict;
     22use Data::Dumper;
    2223use Carp;
    2324use Wx;
    2425use Wx::DND;
    2526use Wx qw/
    26              wxSP_3DBORDER
    27              wxSP_3D
    28              wxNO_FULL_REPAINT_ON_RESIZE
    2927             wxCLIP_CHILDREN
    3028             wxYES_NO
     
    3230             wxICON_QUESTION
    3331             wxITEM_NORMAL
    34              wxNullBitmap
    3532             wxID_OK
    3633             wxDEFAULT_FRAME_STYLE
     
    5047             wxFD_OPEN
    5148             wxFD_MULTIPLE
    52              wxLI_HORIZONTAL
    53              wxALIGN_CENTER_VERTICAL
    54              wxALIGN_CENTER_HORIZONTAL
    5549             wxALL
    5650             wxGROW
     
    5953             wxTheApp
    6054             wxIMAGE_LIST_NORMAL
    61              wxAUI_NB_TAB_MOVE
    62              wxAUI_NB_TAB_SPLIT
    6355             wxNO_BORDER
    6456             wxTE_MULTILINE
    6557             wxTE_READONLY
    6658             wxITEM_NORMAL
    67              wxCLIP_CHILDREN
    6859             wxBORDER_NONE
    6960             wxNullBitmap
     
    8172             wxVERTICAL
    8273             wxEXPAND
     74             wxSWISS
     75             wxNORMAL
     76             wxBOLD
     77             wxALIGN_CENTER
    8378         /;
    8479use base qw/Wx::Frame Class::Accessor::Fast/;
     
    755750    );
    756751
     752    $self->init_empty_category_msg;
     753    $self->set_empty_tree_panel_evt_paint;
     754    $self->show_pwg_categories_empty_msg;
    757755
    758756    $self->init_dnd_targets;
     
    960958
    961959    $self->tree->SetImageList( $self->treeimglist );
    962     $self->populate_tree_categories if !wxTheApp->use_offline;
     960    if(wxTheApp->use_offline){
     961        $self->tree->Enable(0);
     962    }
     963    else{
     964        $self->populate_tree_categories ;
     965    }
     966
    963967    $self->tree ;
     968}
     969
     970
     971sub set_empty_tree_panel_evt_paint{
     972    my ( $self ) = @_;
     973    Wx::Event::EVT_PAINT( $self->tree, sub {
     974            my ( $tree, $event ) = @_;
     975            if(exists $tree->{_empty_panel} and ! exists $tree->{_empty_panel}{_paint}){
     976                my ($w, $h) = $tree->GetSizeWH;
     977                my ($x, $y) = $tree->{_empty_panel}->GetPositionXY;
     978
     979                $tree->{_empty_panel}{x} = $x if !exists $tree->{_empty_panel}{x} ;
     980                $tree->{_empty_panel}{y} = $y if !exists $tree->{_empty_panel}{y};
     981                my ($wp, $hp) = $tree->{_empty_panel}->GetSizeWH;
     982                my $x_off = ($w-$wp)/2 > 0 ? ($w-$wp)/2 : 0;
     983                my $y_off = ($h-$hp)/2 > 0 ? ($h-$hp)/2 : 0;
     984                $tree->{_empty_panel}->Move(
     985                    [
     986                        $tree->{_empty_panel}{x}+$x_off,
     987                        $tree->{_empty_panel}{y}+$y_off
     988                    ]
     989                );
     990                $tree->{_empty_panel}{_paint} = 1;
     991            }
     992            $event->Skip;
     993        }
     994    ) if 1;
     995
     996}
     997
     998
     999sub init_empty_category_msg {
     1000
     1001    my ( $self ) = @_;
     1002    # add a panel
     1003    my $empty_panel = Wx::Panel->new($self->tree, -1, wxDefaultPosition, wxDefaultSize);
     1004    my( $item0 ) = Wx::BoxSizer->new( wxVERTICAL );
     1005   
     1006    my $fb = Wx::Font->new( 12, wxSWISS, wxNORMAL, wxBOLD );
     1007
     1008
     1009    my( $item1 ) = Wx::Button->new(
     1010        $empty_panel,
     1011        $main::CATEGORIES_ADD,
     1012        wxTheApp->branding->{'Add new category'},
     1013        wxDefaultPosition,
     1014        [-1,40],
     1015        0
     1016    );
     1017    my $btfont = Wx::Font->new(12, wxSWISS, wxNORMAL, wxNORMAL );
     1018    $item1->SetFont($btfont);
     1019    $item0->AddWindow( $item1, 0, wxALIGN_CENTER|wxALL, 5 );
     1020
     1021
     1022    $empty_panel->SetSizer( $item0 );
     1023    $item0->SetSizeHints( $empty_panel );
     1024
     1025    $self->tree->{_empty_panel} = $empty_panel;
     1026    $self->tree->{_empty_panel}->SetBackgroundColour(wxWHITE);
     1027
     1028    my ($wp, $hp) = $self->tree->{_empty_panel}->GetSizeWH;
     1029
     1030    $self->tree->SetMinSize( [20+$wp, -1 ]);
     1031
     1032}
     1033
     1034
     1035sub pwg_categories_are_empty {
     1036    my ( $self ) = @_;
     1037
     1038    scalar @{wxTheApp->pwg->categories} < 1 ? 1 : 0 ;
    9641039}
    9651040
     
    9721047        wxTheApp->pwg->categories,
    9731048    ) if defined wxTheApp->pwg ;
    974    
    975 
    976 }
     1049}
     1050
     1051
     1052sub show_pwg_categories_empty_msg {
     1053    my ( $self ) = @_;
     1054
     1055    if($self->pwg_categories_are_empty){
     1056        $self->tree->{_empty_panel}->Show(1);
     1057    }
     1058    else{
     1059        $self->tree->{_empty_panel}->Show(0);
     1060    }
     1061}
     1062
    9771063
    9781064
     
    11681254    Wx::Event::EVT_BUTTON( $self, $self->imageviewer->add_button->GetId, \&OnAddImages );
    11691255
     1256    Wx::Event::EVT_BUTTON( $self, $main::CATEGORIES_ADD, \&OnAddCategories );
     1257
    11701258    # only refresh when calling event is finished
    11711259    Wx::Event::EVT_IDLE(
     
    14401528
    14411529        if($success){
     1530            $self->tree->{_empty_panel}->Show(0);
    14421531            $self->_append_category($parent_item, $name, $content->{result}{id});
    14431532        }
    14441533    }
     1534
     1535
    14451536    $dialog->Destroy;
    14461537}
     
    14621553    $self->pwg->RefreshCategories();
    14631554    $self->populate_tree_categories;
     1555    $self->show_pwg_categories_empty_msg;
    14641556}
    14651557
     
    17981890    return if !scalar @{$self->imagelist->sums};
    17991891
    1800     if( scalar @{$self->imagelist->categories} ){
     1892    if( $self->destination_categories_are_empty ){
     1893        Wx::MessageBox(
     1894            sprintf(
     1895                "%s",
     1896                wxTheApp->branding->{'What is the destination category?'}
     1897            ),
     1898            gettext("Piwigo upload error"),
     1899            wxOK | wxICON_EXCLAMATION,
     1900        );
     1901
     1902    }
     1903    else {
    18011904        # all selected is implicit
    18021905        if(!scalar @{$self->imageviewer->GetSelectedItems}){
     
    18371940        }
    18381941    }
    1839     else {
    1840         Wx::MessageBox(
    1841             sprintf(
    1842                 "%s",
    1843                 wxTheApp->branding->{'What is the destination category?'}
    1844             ),
    1845             gettext("Piwigo upload error"),
    1846             wxOK | wxICON_EXCLAMATION,
    1847         );
    1848     }
     1942}
     1943
     1944
     1945sub destination_categories_are_empty {
     1946    my ( $self ) = @_;
     1947
     1948    !scalar @{$self->imagelist->categories};
    18491949}
    18501950
  • extensions/pLoader/trunk/src/Uploader/GUI/Layout/PhotoPropertiesCategoriesTags.pm

    r5184 r5261  
    111111use vars qw($PRIVACY_LEVEL); $PRIVACY_LEVEL = 10014;
    112112use vars qw($PHOTO_PROPERTIES_PRIVACY_LEVEL); $PHOTO_PROPERTIES_PRIVACY_LEVEL = 10015;
     113
    113114
    114115sub photo_properties_caption_comments {
     
    399400}
    400401
     402
     403use vars qw($CATEGORIES_ADD); $CATEGORIES_ADD = 10020;
     404
     405
    4014061;
    402407
Note: See TracChangeset for help on using the changeset viewer.