Changeset 4632


Ignore:
Timestamp:
Jan 8, 2010, 4:41:15 PM (14 years ago)
Author:
ronosman
Message:

Feature 1369 added : no longer use relative path to access resource and locale directories.

Location:
extensions/pLoader/trunk/src
Files:
4 edited

Legend:

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

    r4616 r4632  
    113113          privacy_level
    114114          user_defined_properties
     115          bin_dir
     116          resource_dir
     117          locale_dir
    115118      /
    116119);
     
    124127}
    125128
     129# not very clean but :
     130# at that moment, object is not yet instanciated
     131# only way : class variable
     132my $bin_dir;
     133my $resource_dir;
     134my $locale_dir;
     135sub new {
     136    my ( $self, $params ) = @_;
     137
     138    $bin_dir = $params->{bin_dir}||'.';
     139    $locale_dir = $params->{locale_dir}||'.';
     140    $resource_dir = $params->{resource_dir}||'.';
     141
     142    $self->SUPER::new();
     143}
    126144
    127145sub OnInit {
    128146    my( $self ) = @_;
    129    
     147
     148    $self->bin_dir(
     149        $bin_dir
     150    );
     151
     152    $self->locale_dir(
     153        $locale_dir
     154    );
     155
     156    $self->resource_dir(
     157        $resource_dir
     158    );
     159
    130160    $self->version(
    131161        '2.0.7b'
     
    178208    }
    179209    else {
    180         $self->_readParams( 'pLoader.ini' ) unless defined $conf ;
    181     }
    182 
    183     $self->_read_default_user_properties( 'properties.ini' ) ;
     210        $self->_readParams( $self->bin_path('pLoader.ini') ) unless defined $conf ;
     211    }
     212
     213    $self->_read_default_user_properties( $self->bin_path('properties.ini') ) ;
    184214
    185215    $self->site_url(
     
    233263}
    234264
     265
     266# helper method to get the full path for a resource
     267sub resource_path{
     268    my ( $self, $file ) = @_;
     269
     270    File::Spec->catfile($self->bin_dir, '..', $self->resource_dir, $file);
     271}
     272
     273sub bin_path{
     274    my ( $self, $file ) = @_;
     275
     276    File::Spec->catfile($self->bin_dir, $file);
     277}
     278
     279sub locale_path{
     280    my ( $self, $file ) = @_;
     281
     282    File::Spec->catfile($self->bin_dir, '..', $self->locale_dir, $file);
     283}
     284
     285sub locale_catalog_path{
     286    my ( $self, $file ) = @_;
     287
     288    File::Spec->catfile($self->bin_dir, '..', $self->locale_dir, $self->locale->GetCanonicalName, $file);
     289}
     290
    235291sub _set_stored_layout {
    236292    my ( $self ) = @_;
     
    360416                            if(Wx::Locale::IsAvailable($_->[1])){
    361417                            my $locale = Wx::Locale->new($_->[1]);
    362                             $locale->AddCatalogLookupPathPrefix('../locale');
     418                            $locale->AddCatalogLookupPathPrefix(
     419                        File::Spec->catfile($self->bin_dir, '..', $self->locale_dir)
     420                    );
    363421                            $_ if $locale->AddCatalog('pLoader');
    364422                                }
     
    407465        $self->current_language
    408466    );
    409     $locale->AddCatalogLookupPathPrefix( '../locale');
     467    $locale->AddCatalogLookupPathPrefix(
     468        File::Spec->catfile($self->bin_dir, '..', $self->locale_dir)
     469    );
    410470    if(!$locale->AddCatalog( 'pLoader.mo' )){
    411471        Wx::LogMessage gettext("Cannot find translation catalog files for %s. Use default language"), $locale->GetCanonicalName();
     
    592652
    593653    my $icon = Wx::Icon->new();
    594     $icon->LoadFile('../res/favicon.ico', wxBITMAP_TYPE_ICO);
     654    $icon->LoadFile(
     655        File::Spec->catfile($self->bin_dir, '..', 'res', 'favicon.ico'),
     656        wxBITMAP_TYPE_ICO
     657    );
    595658    $self->login_dlg->SetIcon($icon);   
    596659
     
    934997
    935998    my $icon = Wx::Icon->new();
    936     $icon->LoadFile('../res/favicon.ico', wxBITMAP_TYPE_ICO);
     999    $icon->LoadFile(
     1000        File::Spec->catfile(
     1001            $self->bin_dir, '..', 'res', 'favicon.ico'
     1002        ),
     1003        wxBITMAP_TYPE_ICO
     1004    );
    9371005    $self->frame->SetIcon($icon);       
    9381006}
  • extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm

    r4616 r4632  
    814814    my ( $self ) = @_;   
    815815
    816     my $file = sprintf(
    817         "../locale/%s/gs.html",
    818         wxTheApp->locale->GetCanonicalName
    819     );
     816    my $file = wxTheApp->locale_catalog_path('gs.html');
    820817
    821818    $self->htmlhome(
     
    10481045        }
    10491046        (
    1050           '../res/tree_pwg.png',
    1051           '../res/tree_folder.png',
     1047          wxTheApp->resource_path('tree_pwg.png'),
     1048          wxTheApp->resource_path('tree_folder.png'),
    10521049        )   
    10531050    ];
     
    11861183            "",
    11871184            "",
    1188             '../res/mnu_folder_new.png',
     1185            wxTheApp->resource_path('mnu_folder_new.png'),
    11891186        ],
    11901187        [
     
    11981195                wxTheApp->branding->{category},
    11991196            ),
    1200             '../res/mnu_folder_new.png',
     1197            wxTheApp->resource_path('mnu_folder_new.png'),
    12011198        ],
    12021199        [
     
    12071204                wxTheApp->branding->{category},
    12081205            ),
    1209             '../res/mnu_refresh.png',
     1206            wxTheApp->resource_path('mnu_refresh.png'),
    12101207        ],
    12111208        [
     
    12161213                wxTheApp->branding->{category},
    12171214            ),
    1218             '../res/mnu_expandall.png',
     1215            wxTheApp->resource_path('mnu_expandall.png'),
    12191216        ],
    12201217        [
     
    12251222                wxTheApp->branding->{category},
    12261223            ),
    1227             '../res/mnu_collapseall.png',
     1224            wxTheApp->resource_path('mnu_collapseall.png'),
    12281225        ],
    12291226    );
     
    12511248            "",
    12521249            "",
    1253             '../res/mnu_properties.png',
     1250            wxTheApp->resource_path('mnu_properties.png'),
    12541251        ],
    12551252        [
     
    12571254            gettext("Properties"),
    12581255            gettext("Modify photo properties"),
    1259             '../res/mnu_properties.png',
     1256            wxTheApp->resource_path('mnu_properties.png'),
    12601257        ],
    12611258        [
     
    12631260            gettext("Preview"),
    12641261            gettext("Display photo preview"),
    1265             '../res/mnu_preview.png',
     1262            wxTheApp->resource_path('mnu_preview.png'),
    12661263        ],
    12671264    );
     
    19571954            100,
    19581955            gettext("Getting started"),
    1959             '../res/tb_getting_started.png',
     1956            wxTheApp->resource_path('tb_getting_started.png'),
    19601957            wxBITMAP_TYPE_PNG,
    19611958            1,
    1962             '../res/tb_getting_started.png',
     1959            wxTheApp->resource_path('tb_getting_started.png'),
    19631960            gettext("Display getting started panel")
    19641961        ],
     
    19661963            101,
    19671964            gettext("Add photo to selection"),
    1968             '../res/tb_add.png',
     1965            wxTheApp->resource_path('tb_add.png'),
    19691966            wxBITMAP_TYPE_PNG,
    19701967            1,
    1971             '../res/tb_add.png',
     1968            wxTheApp->resource_path('tb_add.png'),
    19721969            gettext("Add photo to selection for resizing and uploading")
    19731970        ],
     
    19751972            102,
    19761973            gettext("Remove photo from selection"),
    1977             '../res/tb_remove.png',
     1974            wxTheApp->resource_path('tb_remove.png'),
    19781975            wxBITMAP_TYPE_PNG,
    19791976            1,
    1980             '../res/tb_remove.png',
     1977            wxTheApp->resource_path('tb_remove.png'),
    19811978            gettext("Remove photo from selection. Files are not deleted ")
    19821979        ],
     
    19841981            103,
    19851982            gettext("Upload to Piwigo"),
    1986             '../res/tb_upload.png',
     1983            wxTheApp->resource_path('tb_upload.png'),
    19871984            wxBITMAP_TYPE_PNG,
    19881985            wxTheApp->use_offline ? 0 : 1,
    1989             '../res/tb_upload.png',
     1986            wxTheApp->resource_path('tb_upload.png'),
    19901987            gettext("Upload photos to Piwigo.")
    19911988        ],
     
    19931990            104,
    19941991            gettext("Global settings"),
    1995             '../res/tb_settings.png',
     1992            wxTheApp->resource_path('tb_settings.png'),
    19961993            wxBITMAP_TYPE_PNG,
    19971994            0,
    1998             '../res/tb_settings.png',
     1995            wxTheApp->resource_path('tb_settings.png'),
    19991996            gettext("Change global settings.")
    20001997        ],
     
    20021999            105,
    20032000            gettext("Language choice"),
    2004             '../res/tb_i18n.png',
     2001            wxTheApp->resource_path('tb_i18n.png'),
    20052002            wxBITMAP_TYPE_PNG,
    20062003            1,
    2007             '../res/tb_i18n.png',
     2004            wxTheApp->resource_path('tb_i18n.png'),
    20082005            gettext("Language choice")
    20092006        ],
     
    21692166}
    21702167
     2168
    217121691;
  • extensions/pLoader/trunk/src/Uploader/GUI/wxImageListCtrl.pm

    r4588 r4632  
    4646             wxLIST_STATE_FOCUSED
    4747             wxIMAGE_LIST_SMALL
     48             wxTheApp
    4849         /;
    4950use Wx::Event qw/
     
    9091    );
    9192    $self->wx_img->Add(
    92         Wx::Bitmap->new( '../res/image.png', wxBITMAP_TYPE_PNG )   
     93        Wx::Bitmap->new( wxTheApp->resource_path('image.png'), wxBITMAP_TYPE_PNG )   
    9394    );
    9495
  • extensions/pLoader/trunk/src/ploader.pl

    r4590 r4632  
    2020
    2121use strict;
     22use FindBin;
     23use lib "$FindBin::Bin";
     24use lib "$FindBin::Bin/../res";
     25use lib "$FindBin::Bin/../lib";
    2226use Wx;
    2327use Class::Accessor::Fast;
     
    2933$SIG{__DIE__} = \&OnDieHandler;
    3034
    31 require '../res/global_settings_wdr.pl';
    32 require '../res/progress_wdr.pl';
    33 require '../res/login_wdr.pl';
    34 require '../res/reupload_wdr.pl';
    35 require '../res/photo_properties_wdr.pl';
     35# search path defined by use lib "$Bin/../res"
     36require 'global_settings_wdr.pl';
     37require 'progress_wdr.pl';
     38require 'login_wdr.pl';
     39require 'reupload_wdr.pl';
     40require 'photo_properties_wdr.pl';
    3641
    3742eval {
    38     my $app = Uploader::GUI::wxApp->new(@_);
     43    my $app = Uploader::GUI::wxApp->new(
     44            {
     45                bin_dir      => $FindBin::Bin,
     46                resource_dir => 'res',
     47                locale_dir   => 'locale',
     48            }
     49    );
    3950    $app->MainLoop();
    4051};
Note: See TracChangeset for help on using the changeset viewer.