Debian Codegraph @

Debconf/Element/Editor/Select.pm

raw
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 Debconf::Element::Editor::Select - select from a list of choices
6
7 =cut
8
9 package Debconf::Element::Editor::Select;
10 use warnings;
11 use strict;
12 use Debconf::Gettext;
13 use base qw(Debconf::Element::Select);
14
15 =head1 DESCRIPTION
16
17 Presents a list of choices to be selected among.
18
19 =head2 METHODS
20
21 =over 4
22
23 =cut
24
25 sub show {
26 my $this=shift;
27
28 my $default=$this->translate_default;
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 $this->question->description."\n");
34 $this->frontend->item($this->question->name, $default);
35 }
36
37 =item value
38
39 Verifies that the value is one of the choices. If not, or if the value
40 isn't set, the value is not changed.
41
42 =cut
43
44 sub value {
45 my $this=shift;
46
47 return $this->SUPER::value() unless @_;
48 my $value=shift;
49
50 my %valid=map { $_ => 1 } $this->question->choices_split;
51
52 if ($valid{$value}) {
53 return $this->SUPER::value($this->translate_to_C($value));
54 }
55 else {
56 return $this->SUPER::value($this->question->value);
57 }
58 }
59
60 =back
61
62 =head1 AUTHOR
63
64 Joey Hess <[email protected]>
65
66 =cut
67
68 1