1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/usr/bin/perl -w
=head1 NAME
Debconf::Element::Editor::MultiSelect - select from a list of choices
=cut
package Debconf::Element::Editor::Multiselect;
use strict;
use Debconf::Gettext;
use base qw(Debconf::Element::Multiselect);
=head1 DESCRIPTION
Presents a list of choices to be selected amoung. Multiple selection is
allowed.
=head1 METHODS
=over 4
=cut
sub show {
my $this=shift;
my @choices=$this->question->choices_split;
$this->frontend->comment($this->question->extended_description."\n\n".
"(".gettext("Choices").": ".join(", ", @choices).")\n".
gettext("(Enter zero or more items separated by a comma followed by a space (', ').)")."\n".
$this->question->description."\n");
$this->frontend->item($this->question->name, join ", ", $this->translate_default);
}
=item value
When value is set, convert from a space-separated list into the internal
format. At the same time, validate each item and make sure it is allowable,
or remove it.
=cut
sub value {
my $this=shift;
return $this->SUPER::value() unless @_;
my @values=split(',\s+', shift);
my %valid=map { $_ => 1 } $this->question->choices_split;
$this->SUPER::value(join(', ', $this->order_values(
map { $this->translate_to_C($_) }
grep { $valid{$_} } @values)));
}
=back
=head1 AUTHOR
Joey Hess <joeyh@debian.org>
=cut
1
|