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 / Select.pm < prev    next >
Encoding:
Perl POD Document  |  2006-07-24  |  1.3 KB  |  58 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Dialog::Select;
  6. use strict;
  7. use base qw(Debconf::Element::Select);
  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 $default=$this->translate_default;
  19.     my @params=();
  20.     my @choices=$this->question->choices_split;
  21.     
  22.     my $menu_height=$#choices + 1;
  23.     if ($lines + $#choices + 2 >= $screen_lines) {
  24.         $menu_height = $screen_lines - $lines - 4;
  25.     }
  26.     
  27.     $lines=$lines + $menu_height + $this->frontend->spacer;
  28.     my $c=1;
  29.     my $selectspacer = $this->frontend->selectspacer;
  30.     foreach (@choices) {
  31.         push @params, $_, '';
  32.         
  33.         if ($columns < width($_) + $selectspacer) {
  34.             $columns = width($_) + $selectspacer;
  35.         }
  36.     }
  37.     
  38.     if ($this->frontend->dashsep) {
  39.         unshift @params, $this->frontend->dashsep;
  40.     }
  41.     
  42.     @params=('--default-item', $default, '--menu', 
  43.           $text, $lines, $columns, $menu_height, @params);
  44.  
  45.     my $value=$this->frontend->showdialog($this->question, @params);
  46.     if (defined $value) {
  47.         $this->value($this->translate_to_C($value)) if defined $value;
  48.     }
  49.     else {
  50.         my $default='';
  51.         $default=$this->question->value
  52.             if defined $this->question->value;
  53.         $this->value($default);
  54.     }
  55. }
  56.  
  57. 1
  58.