Curses-Devkit
view release on metacpan or search on metacpan
demos/pkgInfo view on Meta::CPAN
next if $file =~ /^\./;
push (@packageList, $file) if (-d "$pkgDir/$file");
}
# Create a selection list and display the known packages.
my $select = new Cdk::Selection ('Title' => "Add Which Packages?",
'List' => \@packageList,
'Choices' => ["Yes ", "No"],
'Height' => 20,
'Width' => 50);
# Activate the packages.
my @choiceList = $select->activate();
my @selectedPackages = ();
return if ! defined @choiceList;
# Generate the names of the selected packages.
for ($x=0; $x <= $#choiceList; $x++)
{
if ($choiceList[$x] == 1)
{
push (@selectedPackages, $packageNames[$x]);
}
}
my $label = new Cdk::Label ('Message' => \@selectedPackages);
$label->draw();
$label->wait();
}
#
# This function removes a package.
#
sub removePackage
{
# Get the packages to remove.
my @packageNames = selectPackages("<C></U>Select the packages to delete.");
my @buttons = ("<No>", "<Yes>", "<Yes To ALL>");
my $yesToAll = 0;
# Now that we have the package names, ask for each one.
foreach $name (@packageNames)
{
# If they asked for all to be deleted, no need to ask
if (! $yesToAll)
{
# Create the dialog message.
my @mesg = ("<C>Are you sure you want",
"to delete the package </U>$name<!U>?");
# Make sure they want to do it.
my $dialog = new Cdk::Dialog ('Message' => \@mesg,
'Buttons' => \@buttons);
# Activate it.
my $answer = $dialog->activate();
# If the user hit escape, let the user know the package
# was NOT deleted.
if (!defined $answer)
{
popupLabel (["<C>Escape Hit", "<C>The package was </R>Not<!R> deleted."]);
next;
}
# Check the answer
if ($answer == 1)
{
# Delete the package
system ("pkgrm $name");
}
else
{
# Set the yes to all flag.
$yesToAll = 1;
# Delete the package
system ("pkgrm $name");
}
}
else
{
# Delete the package
system ("pkgrm $name");
}
}
}
#
# This function provides information about packages.
#
sub packageInfo
{
# Get the package to view.
my $packageName = selectPackage("<C></U>Select a package to view.");
# Get the information about the selected package.
my @pinfo = qx (pkginfo -l $packageName); chomp @pinfo;
# Create the information viewer.
my $viewer = new Cdk::Viewer ('Buttons' => ["OK"],
'Height' => -2,
'Width' => -4);
# Activate the viewer.
$viewer->set ('Title' => "<C>Package Name: </U>$packageName<!U>",
'Info' => \@pinfo,
'Interp' => "FALSE");
$viewer->activate ();
}
#
# This function creates a scrolling list of all the packages on the system
# and returns the name of the package selected.
#
sub selectPackage
{
my $title = shift;
# Get a list of all the packages installed on the system.
my @packageList = qx (pkginfo);
my @packageNames = ();
( run in 1.563 second using v1.01-cache-2.11-cpan-364913b4093 )