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

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::FrontEnd;
  6. use strict;
  7. use Debconf::Gettext;
  8. use Debconf::Priority;
  9. use Debconf::Log ':all';
  10. use base qw(Debconf::Base);
  11.  
  12.  
  13. sub init {
  14.     my $this=shift;
  15.     
  16.     $this->elements([]);
  17.     $this->interactive('');
  18.     $this->capb('');
  19.     $this->title('');
  20.     $this->requested_title('');
  21.     $this->info(undef);
  22. }
  23.  
  24.  
  25. sub elementtype {
  26.     my $this=shift;
  27.     
  28.     my $ret;
  29.     if (ref $this) {
  30.         ($ret) = ref($this) =~ m/Debconf::FrontEnd::(.*)/;
  31.     }
  32.     else {
  33.         ($ret) = $this =~ m/Debconf::FrontEnd::(.*)/;
  34.     }
  35.     return $ret;
  36. }
  37.  
  38. my %nouse;
  39.  
  40. sub _loadelementclass {
  41.     my $this=shift;
  42.     my $type=shift;
  43.     my $nodebug=shift;
  44.  
  45.     if (! UNIVERSAL::can("Debconf::Element::$type", 'new')) {
  46.         return if $nouse{$type};
  47.         eval qq{use Debconf::Element::$type};
  48.         if ($@ || ! UNIVERSAL::can("Debconf::Element::$type", 'new')) {
  49.             warn sprintf(gettext("Unable to load Debconf::Element::%s. Failed because: %s"), $type, $@) if ! $nodebug;
  50.             $nouse{$type}=1;
  51.             return;
  52.         }
  53.     }
  54. }
  55.  
  56.  
  57. sub makeelement {
  58.     my $this=shift;
  59.     my $question=shift;
  60.     my $nodebug=shift;
  61.  
  62.     my $type=$this->elementtype.'::'.ucfirst($question->type);
  63.     $type=~s/::$//; # in case the question has no type..
  64.  
  65.     $this->_loadelementclass($type, $nodebug);
  66.  
  67.     my $element="Debconf::Element::$type"->new(question => $question);
  68.     return if ! ref $element;
  69.     return $element;
  70. }
  71.  
  72.  
  73. sub add {
  74.     my $this=shift;
  75.     my $element=shift;
  76.  
  77.     foreach (@{$this->elements}) {
  78.         return if $element->question == $_->question;
  79.     }
  80.     
  81.     $element->frontend($this);
  82.     push @{$this->elements}, $element;
  83. }
  84.  
  85.  
  86. sub go {
  87.     my $this=shift;
  88.     $this->backup('');
  89.     foreach my $element (@{$this->elements}) {
  90.         $element->show;
  91.         return if $this->backup && $this->capb_backup;
  92.     }
  93.     return 1;
  94. }
  95.  
  96.  
  97. sub progress_start {
  98.     my $this=shift;
  99.     my $min=shift;
  100.     my $max=shift;
  101.     my $question=shift;
  102.  
  103.     my $type = $this->elementtype.'::Progress';
  104.     $this->_loadelementclass($type);
  105.  
  106.     my $element="Debconf::Element::$type"->new(question => $question);
  107.     unless (ref $element) {
  108.         return;
  109.     }
  110.     $element->frontend($this);
  111.     $element->progress_min($min);
  112.     $element->progress_max($max);
  113.     $element->progress_cur($min);
  114.  
  115.     $element->start;
  116.  
  117.     $this->progress_bar($element);
  118. }
  119.  
  120.  
  121. sub progress_set {
  122.     my $this=shift;
  123.     my $value=shift;
  124.  
  125.     $this->progress_bar->set($value);
  126. }
  127.  
  128.  
  129. sub progress_step {
  130.     my $this=shift;
  131.     my $inc=shift;
  132.  
  133.     $this->progress_set($this->progress_bar->progress_cur + $inc);
  134. }
  135.  
  136.  
  137. sub progress_info {
  138.     my $this=shift;
  139.     my $question=shift;
  140.  
  141.     $this->progress_bar->info($question);
  142. }
  143.  
  144.  
  145. sub progress_stop {
  146.     my $this=shift;
  147.  
  148.     $this->progress_bar->stop;
  149.     $this->progress_bar(undef);
  150. }
  151.  
  152.  
  153. sub clear {
  154.     my $this=shift;
  155.     
  156.     $this->elements([]);
  157. }
  158.  
  159.  
  160. sub default_title {
  161.     my $this=shift;
  162.     
  163.     $this->title(sprintf(gettext("Configuring %s"), shift));
  164.     $this->requested_title($this->title);
  165. }
  166.  
  167.  
  168. sub shutdown {}
  169.  
  170.  
  171. 1
  172.