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 / Progress.pm < prev    next >
Encoding:
Perl POD Document  |  2006-07-24  |  1.8 KB  |  84 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Dialog::Progress;
  6. use strict;
  7. use base qw(Debconf::Element);
  8.  
  9.  
  10. sub _communicate {
  11.     my $this=shift;
  12.     my $data=shift;
  13.     my $dialoginput = $this->frontend->dialog_input_wtr;
  14.  
  15.     print $dialoginput $data;
  16. }
  17.  
  18. sub _percent {
  19.     my $this=shift;
  20.  
  21.     use integer;
  22.     return (($this->progress_cur() - $this->progress_min()) * 100 / ($this->progress_max() - $this->progress_min()));
  23. }
  24.  
  25. sub start {
  26.     my $this=shift;
  27.  
  28.     $this->frontend->title($this->question->description);
  29.  
  30.     my ($text, $lines, $columns);
  31.     if (defined $this->_info) {
  32.         ($text, $lines, $columns)=$this->frontend->sizetext($this->_info->description);
  33.     } else {
  34.         ($text, $lines, $columns)=$this->frontend->sizetext(' ');
  35.     }
  36.     if ($this->frontend->screenwidth - $this->frontend->columnspacer > $columns) {
  37.         $columns = $this->frontend->screenwidth - $this->frontend->columnspacer;
  38.     }
  39.  
  40.     my @params=('--gauge');
  41.     push @params, $this->frontend->dashsep if $this->frontend->dashsep;
  42.     push @params, ($text, $lines + $this->frontend->spacer, $columns, $this->_percent);
  43.  
  44.     $this->frontend->startdialog($this->question, 1, @params);
  45.  
  46.     $this->_lines($lines);
  47.     $this->_columns($columns);
  48. }
  49.  
  50. sub set {
  51.     my $this=shift;
  52.     my $value=shift;
  53.  
  54.     $this->progress_cur($value);
  55.     $this->_communicate($this->_percent . "\n");
  56. }
  57.  
  58. sub info {
  59.     my $this=shift;
  60.     my $question=shift;
  61.  
  62.     $this->_info($question);
  63.  
  64.     my ($text, $lines, $columns)=$this->frontend->sizetext($question->description);
  65.     if ($lines > $this->_lines or $columns > $this->_columns) {
  66.         $this->stop;
  67.         $this->start;
  68.     }
  69.  
  70.  
  71.     $this->_communicate(
  72.         sprintf("XXX\n%d\n%s\nXXX\n%d\n",
  73.             $this->_percent, $text, $this->_percent));
  74. }
  75.  
  76. sub stop {
  77.     my $this=shift;
  78.  
  79.     $this->frontend->waitdialog;
  80.     $this->frontend->title($this->frontend->requested_title);
  81. }
  82.  
  83. 1
  84.