home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / perl5 / Debconf / Element / Dialog / Multiselect.pm < prev    next >
Encoding:
Perl POD Document  |  2006-07-24  |  1.8 KB  |  70 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Dialog::Multiselect;
  6. use strict;
  7. use base qw(Debconf::Element::Multiselect);
  8. use Debconf::Encoding qw(width);
  9.  
  10.  
  11. sub show {
  12.     my $this=shift;
  13.     
  14.     my ($text, $lines, $columns)=
  15.         $this->frontend->makeprompt($this->question, -2);
  16.  
  17.     my $screen_lines=$this->frontend->screenheight - $this->frontend->spacer;
  18.     my @params=();
  19.     my @choices=$this->question->choices_split;
  20.     my %value = map { $_ => 1 } $this->translate_default;
  21.  
  22.     my $menu_height=$#choices + 1;
  23.     if ($lines + $#choices + 2 >= $screen_lines) {
  24.         $menu_height = $screen_lines - $lines - 4;
  25.         if ($menu_height < 3 && $#choices + 1 > 2) {
  26.             $this->frontend->showtext($this->question, $this->question->extended_description);
  27.             ($text, $lines, $columns)=$this->frontend->sizetext($this->question->description);
  28.             $menu_height=$#choices + 1;
  29.             if ($lines + $#choices + 2 >= $screen_lines) {
  30.                 $menu_height = $screen_lines - $lines - 4;
  31.             }
  32.         }
  33.     }
  34.     
  35.     $lines=$lines + $menu_height + $this->frontend->spacer;
  36.     my $selectspacer = $this->frontend->selectspacer;
  37.     my $c=1;
  38.     foreach (@choices) {
  39.         push @params, ($_, "");
  40.         push @params, ($value{$_} ? 'on' : 'off');
  41.  
  42.         if ($columns < width($_) + $selectspacer) {
  43.             $columns = width($_) + $selectspacer;
  44.         }
  45.     }
  46.     
  47.     if ($this->frontend->dashsep) {
  48.         unshift @params, $this->frontend->dashsep;
  49.     }
  50.     
  51.     @params=('--separate-output', '--checklist', 
  52.              $text, $lines, $columns, $menu_height, @params);
  53.  
  54.     my $value=$this->frontend->showdialog($this->question, @params);
  55.  
  56.     if (defined $value) {
  57.         $this->value(join(", ", $this->order_values(
  58.                     map { $this->translate_to_C($_) }
  59.                     split(/\n/, $value))));
  60.     }
  61.     else {
  62.         my $default='';
  63.         $default=$this->question->value
  64.             if defined $this->question->value;
  65.         $this->value($default);
  66.     }
  67. }
  68.  
  69. 1
  70.