| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Debconf::Element::Dialog::Boolean - Yes/No dialog box |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
package Debconf::Element::Dialog::Boolean; |
| 10 |
use warnings; |
| 11 |
use strict; |
| 12 |
use base qw(Debconf::Element); |
| 13 |
|
| 14 |
=head1 DESCRIPTION |
| 15 |
|
| 16 |
This is an input element that can display a dialog box with Yes and No buttons |
| 17 |
on it. |
| 18 |
|
| 19 |
=cut |
| 20 |
|
| 21 |
sub show { |
| 22 |
my $this=shift; |
| 23 |
|
| 24 |
my @params=('--yesno'); |
| 25 |
push @params, $this->frontend->dashsep if $this->frontend->dashsep; |
| 26 |
# Note 1 is passed in, because we can squeeze on one more line |
| 27 |
# in a yesno dialog than in other types. |
| 28 |
push @params, $this->frontend->makeprompt($this->question, 1); |
| 29 |
if (defined $this->question->value && $this->question->value eq 'false') { |
| 30 |
# Put it at the start of the option list, |
| 31 |
# where dialog likes it. |
| 32 |
unshift @params, '--defaultno'; |
| 33 |
} |
| 34 |
|
| 35 |
my ($ret, $value)=$this->frontend->showdialog($this->question, @params); |
| 36 |
if (defined $ret) { |
| 37 |
$this->value($ret eq 0 ? 'true' : 'false'); |
| 38 |
} |
| 39 |
else { |
| 40 |
my $default=''; |
| 41 |
$default=$this->question->value |
| 42 |
if defined $this->question->value; |
| 43 |
$this->value($default); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
1 |