CPANPLUS-Shell-Wx
view release on metacpan or search on metacpan
lib/CPANPLUS/Shell/Wx/Frame.pm view on Meta::CPAN
Wx::LogMessage(_T("Initializing Log Console..."));
print _T("[DONE]\nNew messages will be redirected to Logging console, under the Log Tab\n");
#create references for easier access and faster execution
$self->{cpan} = CPANPLUS::Backend->new(); #only one Backend per running program
$self->{config} = $self->{cpan}->configure_object;
# $self->{categories}=$self->_get_categories;
#unused variable used to initialize cpan
my $unused_var_to_init_cpanpp=$self->{cpan}->module_tree('CPANPLUS');
$self->{is_created}=1;
#ssetup various controls
$self->_setup_toolbar();
$self->_setup_menu();
$self->_setup_modules();
# $self->_setup_actionslist();
my $main_nb=Wx::Window::FindWindowByName('nb_main');
$self->{podReader}=CPANPLUS::Shell::Wx::PODReader::Embed->new($main_nb);
$main_nb->AddPage(
$self->{podReader},
_T("POD Reader")
);
EVT_BUTTON($self, Wx::Window::FindWindowByName('actions_clear'),\&ClearActions);
EVT_BUTTON($self, Wx::Window::FindWindowByName('actions_process'),\&ProcessActions);
#destroy splash screen, if any.
$self->{parent}->{splash}->Destroy if $self->{parent}->{splash};
#check for updated version of CPANPLUS and First Time usage
$self->CheckUpdate();
$self->CheckFirstTime();
#$self->ShowPrefs; #for testing
_uShowErr;
}
sub _setup_modules{
my $self=shift;
print "Setting up modules...\n";
my $panel=Wx::Window::FindWindowByName('nb_main_mod_tree_pane');
$self->{status_icons}=_uGetImageData();
# print "Setting Module tree...\n";
$self->{panel}=$panel;
$panel->SetModuleTree(Wx::Window::FindWindowByName('tree_modules'));
# print "Setting Image list...\n";
$panel->SetCPP($self->{cpan});
$panel->SetImageList($self->{status_icons});
$panel->SetStatusBar(Wx::Window::FindWindowByName('main_window_status'));
$panel->SetPODReader($self->{podReader});
print "Initializing ModulePanel...\n";
$panel->Init();
$panel->SetDblClickHandler(sub{$self->ShowPODReader(@_)});
$panel->SetInstallMenuHandler(sub{$self->SetAction(@_,_T('Install'))});
$panel->SetUpdateMenuHandler(sub{$self->SetAction(@_,_T('Update'))});
$panel->SetUninstallMenuHandler(sub{$self->SetAction(@_,_T('Uninstall'))});
$panel->SetFetchMenuHandler(sub{$self->SetAction(@_,_T('Fetch'))});
$panel->SetPrepareMenuHandler(sub{$self->SetAction(@_,_T('Prepare'))});
$panel->SetBuildMenuHandler(sub{$self->SetAction(@_,_T('Build'))});
$panel->SetTestMenuHandler(sub{$self->SetAction(@_,_T('Test'))});
}
#this method shows the PODReader tab and displays the documentation for the selected module
sub ShowPODReader{
my $self = shift;
my ($event) = @_;
print "Showing POD Reader\n";
# $self->{podReader}=CPANPLUS::Shell::Wx::PODReader::Frame->new($self) unless $self->{podReader};
# $self->{podReader}->Show(1) if ($self->{podReader} && $self->{podReader}->isa('Wx::Frame'));
$self->{podReader}->Search($self->{panel}->{thisName});
Wx::Window::FindWindowByName('nb_main')->ChangeSelection(3);
}
sub SetAction{
my ($self,$menu,$cmd_event,$modName,$cmd)=@_;
my $actionslist=Wx::Window::FindWindowByName('main_actions_list');
my $modtree=Wx::Window::FindWindowByName('tree_modules');
$actionslist->AddActionWithPre($modName,undef,$cmd);
}
sub CheckUpdate{
my $self=shift;
my $cp=$self->{cpan}->module_tree('CPANPLUS');
unless ($cp->is_uptodate()){
my $reply=Wx::MessageBox(_T("CPANPLUS needs to be updated. Would you like to update now?"), _T("Update CPANPLUS?"),
wxYES_NO, $self);
$self->ShowUpdateWizard() if ($reply==wxYES);
}
}
sub CheckFirstTime{
my $self = shift;
my ($event) = @_;
unless (-e _uGetPath($self->{config},'app_config')){
my $reply=Wx::MessageBox(_T("This is the first time you have run wxCPAN. Would you like to review your preferences?"), _T("Update CPANPLUS?"),
wxYES_NO, $self);
$self->ShowPrefs if $reply==wxYES;
}
}
sub ShowUpdateWizard{
my $self = shift;
my ($event) = @_;
use CPANPLUS::Shell::Wx::UpdateWizard;
my $wizard=new CPANPLUS::Shell::Wx::UpdateWizard();
$wizard->SetCPPObject($self->{cpan});
$wizard->Run();
}
#opens an actions file (.cpan default extension)
sub OnOpen{
my $self = shift;
my ($event) = @_;
my $actionslist=Wx::Window::FindWindowByName('main_actions_list');
my $dlg=Wx::FileDialog->new($self,_T("Open Actions File:"),'','',_T("CPAN Actions files (*.cpan)|*.cpan|All files (*.*)|*.*"),wxFD_OPEN);
if ($dlg->ShowModal() == wxID_OK){
Wx::LogMessage( _T("Opening ").$dlg->GetPath() );
if (open(F,$dlg->GetPath())){
my @lines=<F>;
close F;
( run in 2.159 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )