CPANPLUS-Shell-Wx
view release on metacpan or search on metacpan
lib/CPANPLUS/Shell/Wx/Frame.pm view on Meta::CPAN
Wx::LogMessage( _T("Saving to ").$dlg->GetPath() );
if (open(F,">".$dlg->GetPath())){
for (my $i=0;$i<$numInList;$i++){
my $item=$actionslist->GetItemText($i);
my $action=$actionslist->GetItem(0,1)->GetText();
print F "$item,$action\n";
}
close F;
}
}
}
sub ClearActions{
my $self = shift;
my ($event) = @_;
my $actionslist=Wx::Window::FindWindowByName('main_actions_list');
$actionslist->DeleteAllItems();
}
sub ProcessActions{
my $self = shift;
my ($event) = @_;
my $actionslist=Wx::Window::FindWindowByName('main_actions_list');
while ($modName=$actionslist->GetItemText(0)){
my $action=$actionslist->GetItem(0,1)->GetText();
$action = "create" if $action eq "Build";
Wx::LogMessage(_T("Processing $action for $modName."));
my $mod=$self->{cpan}->module_tree($modName);
if ($mod){
my $bool=0;
eval "\$bool = \$mod->".lc($action)."();";
print $@ if $@;
Wx::LogMessage(_T("FAILED TO INSTALL ").$modName._T(". OUTPUT:")) if $bool;
_uShowErr;
}
$actionslist->DeleteItem(0);
}
}
sub ShowConfigDump{
my $self = shift;
my ($event) = @_;
Wx::Window::FindWindowByName('log_console')->AppendText(Dumper($self->{config}));
}
#exit program, destroy window
sub OnQuit{
my $self = shift;
$self->Close(1);
}
#show preferences dialog
sub ShowPrefs{
Wx::LogMessage _T("Displaying Preferences...");
my $self = shift;
my ($event) = @_;
my $xrc_file = _uGetInstallPath('CPANPLUS::Shell::Wx::res::PrefsWin.xrc');
unless ( -e $xrc_file ) {
Wx::LogError
_T("ERROR: Unable to find XRC Resource file: $xrc_file !\n Exiting...");
return 1;
}
my $prefsxrc = Wx::XmlResource->new();
$prefsxrc->InitAllHandlers();
$prefsxrc->Load($xrc_file);
#print Dumper $self,$parent;
$self->{prefsWin} = $prefsxrc->LoadDialog( $self, 'prefs_window' )
or return;
$self->{prefsWin}->Show(1);
}
#show podreader dialog
#sub ShowPODReader{
# my $self = shift;
# my ($event) = @_;
# $self->{podReader}=CPANPLUS::Shell::Wx::PODReader::Frame->new($self) unless $self->{podReader};
# $self->{podReader}->Show(1) if ($self->{podReader});
# Wx::Window::FindWindowByName('nb_main')->ChangeSelection(3);
#}
sub _setup_actionslist{
$self=shift;
my $actionslist=Wx::Window::FindWindowByName('main_actions_list');
$actionslist->InsertColumn( 0, _T('Module'));
$actionslist->InsertColumn( 1, _T('Action') );
$actionslist->SetColumnWidth(0,wxLIST_AUTOSIZE);
$actionslist->SetColumnWidth(1,wxLIST_AUTOSIZE);
}
sub _setup_menu{
$self=shift;
#attach menu events
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_file_quit'), \&OnQuit );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_file_open'), \&OnOpen );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_file_save'), \&OnSave );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_edit_prefs'), \&ShowPrefs );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_show_log_console'), \&ShowLog );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_show_config_dump'), \&ShowConfigDump );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_pod_reader'), \&ShowPODReader );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_about'), \&ShowAboutBox );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_help'), \&ShowHelpWindow );
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_updatewizard'), \&ShowUpdateWizard );
}
sub _setup_toolbar{
$self=shift;
my $tb=$self->GetToolBar() || $self->CreateToolBar(wxTB_TEXT);
$self->{toolbar}=$tb;
#get rid of old tools. The ones in XRC file are placeholders
$tb->ClearTools();
#set up icons
my $tb_icon_installed=Wx::ArtProvider::GetBitmap(wxART_TICK_MARK,wxART_TOOLBAR_C);
my $tb_icon_update=Wx::ArtProvider::GetBitmap(wxART_ADD_BOOKMARK,wxART_TOOLBAR_C);
my $tb_icon_remove=Wx::ArtProvider::GetBitmap(wxART_DEL_BOOKMARK,wxART_TOOLBAR_C);
my $tb_icon_not_installed=Wx::ArtProvider::GetBitmap(wxART_NEW_DIR,wxART_TOOLBAR_C);
my $tb_icon_unknown=Wx::ArtProvider::GetBitmap(wxART_QUESTION,wxART_TOOLBAR_C);
my $tb_icon_cat=Wx::ArtProvider::GetBitmap(wxART_QUESTION,wxART_TOOLBAR_C);
my $tb_icon_authors=Wx::ArtProvider::GetBitmap(wxART_HELP_SETTINGS,wxART_TOOLBAR_C);
my $tb_icon_names=Wx::ArtProvider::GetBitmap(wxART_QUESTION,wxART_TOOLBAR_C);
my $tb_icon_populate=Wx::ArtProvider::GetBitmap(wxART_EXECUTABLE_FILE,wxART_TOOLBAR_C);
#Add the tools. for some reason, we can't attach events in this step. It breaks.
my $idstart=10000; #the control IDs start here
my @tb_items=(
$tb->AddRadioTool($idstart,_T("Installed"),$tb_icon_installed,$tb_icon_installed,_T("Show Installed Modules")),
$tb->AddRadioTool($idstart+1,_T("Updates"),$tb_icon_update,$tb_icon_update,_T("List Modules to be Updated")),
$tb->AddRadioTool($idstart+2,_T("New"),$tb_icon_not_installed,$tb_icon_not_installed,_T("List New Modules")),
$tb->AddRadioTool($idstart+3,_T("All"),$tb_icon_installed,$tb_icon_installed,_T("List All Modules")),
$tb->AddSeparator(),
$tb->AddRadioTool($idstart+4,_T("Categories"),$tb_icon_cat,$tb_icon_cat,_T("Sort List by Category")),
$tb->AddRadioTool($idstart+5,_T("Names"),$tb_icon_names,$tb_icon_names,_T("Sort List by Module Name")),
$tb->AddRadioTool($idstart+6,_T("Authors"),$tb_icon_authors,$tb_icon_authors,_T("Sort List By Authors")),
$tb->AddSeparator(),
$tb->AddTool($idstart+7,_T("Update List"),$tb_icon_populate,_T("Re-Populate the tree"))
);
#attach events
EVT_TOOL( $self, $idstart, sub{$self->{list}->ShowInstalled();} );
EVT_TOOL( $self, $idstart+1, sub{$self->{list}->ShowUpdated();} );
EVT_TOOL( $self, $idstart+2, sub{$self->{list}->ShowNew();} );
EVT_TOOL( $self, $idstart+3, sub{$self->{list}->ShowAll();} );
EVT_TOOL( $self, $idstart+4, sub{$self->{list}->SortByCategory();} );
EVT_TOOL( $self, $idstart+5, sub{$self->{list}->SortByName();} );
EVT_TOOL( $self, $idstart+6, sub{$self->{list}->SortByAuthor();} );
EVT_TOOL( $self, $idstart+7, sub{$self->{list}->Populate();} );
}
sub ShowAboutBox{
my $self=shift;
my $info = Wx::AboutDialogInfo->new();
$info->AddArtist('Skaman Sam Tyler');
$info->AddArtist('');
$info->AddArtist(_T('Thanks to David Vignoni,'));
( run in 0.931 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )