Debian Codegraph @

Debconf/Element/Editor/Boolean.pm

raw
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 Debconf::Element::Editor::Boolean - Yes/No question
6
7 =cut
8
9 package Debconf::Element::Editor::Boolean;
10 use warnings;
11 use strict;
12 use Debconf::Gettext;
13 use base qw(Debconf::Element);
14
15 =head1 DESCRIPTION
16
17 This is a yes or no question.
18
19 =cut
20
21 =head1 METHODS
22
23 =over 4
24
25 =cut
26
27 sub show {
28 my $this=shift;
29
30 $this->frontend->comment($this->question->extended_description."\n\n".
31 "(".gettext("Choices").": ".join(", ", gettext("yes"), gettext("no")).")\n".
32 $this->question->description."\n");
33
34 my $default='';
35 $default=$this->question->value if defined $this->question->value;
36 if ($default eq 'true') {
37 $default=gettext("yes");
38 }
39 elsif ($default eq 'false') {
40 $default=gettext("no");
41 }
42
43 $this->frontend->item($this->question->name, $default);
44 }
45
46 =item value
47
48 Overridden to handle translating the value that the user typed in. Also,
49 if the user typed in something invalid, the value is not changed.
50
51 =cut
52
53 sub value {
54 my $this=shift;
55
56 return $this->SUPER::value() unless @_;
57 my $value=shift;
58
59 # Handle translated and non-translated replies.
60 if ($value eq 'yes' || $value eq gettext("yes")) {
61 return $this->SUPER::value('true');
62 }
63 elsif ($value eq 'no' || $value eq gettext("no")) {
64 return $this->SUPER::value('false');
65 }
66 else {
67 return $this->SUPER::value($this->question->value);
68 }
69 }
70
71 =back
72
73 =head1 AUTHOR
74
75 Joey Hess <[email protected]>
76
77 =cut
78
79 1