Debian Codegraph @

Debconf/Element/Editor/Multiselect.pm

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