home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / Debconf / Element / Dialog / Progress.pm < prev    next >
Encoding:
Perl POD Document  |  2009-03-24  |  1.8 KB  |  88 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.     return 1;
  58. }
  59.  
  60. sub info {
  61.     my $this=shift;
  62.     my $question=shift;
  63.  
  64.     $this->_info($question);
  65.  
  66.     my ($text, $lines, $columns)=$this->frontend->sizetext($question->description);
  67.     if ($lines > $this->_lines or $columns > $this->_columns) {
  68.         $this->stop;
  69.         $this->start;
  70.     }
  71.  
  72.  
  73.     $this->_communicate(
  74.         sprintf("XXX\n%d\n%s\nXXX\n%d\n",
  75.             $this->_percent, $text, $this->_percent));
  76.  
  77.     return 1;
  78. }
  79.  
  80. sub stop {
  81.     my $this=shift;
  82.  
  83.     $this->frontend->waitdialog;
  84.     $this->frontend->title($this->frontend->requested_title);
  85. }
  86.  
  87. 1
  88.