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

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::FrontEnd::Kde;
  6. use strict;
  7. use utf8;
  8. use Debconf::Gettext;
  9. use Debconf::Config;
  10. BEGIN {
  11.     eval { require Qt };
  12.     die "Unable to load Qt -- is libqt-perl installed?\n" if $@;
  13.     Qt->import;
  14. }
  15. use Debconf::FrontEnd::Kde::Wizard;
  16. use Debconf::Log ':all';
  17. use base qw{Debconf::FrontEnd};
  18. use Debconf::Encoding qw(to_Unicode);
  19.  
  20.  
  21. our @ARGV_KDE=();
  22.  
  23. sub init {
  24.     my $this=shift;
  25.     
  26.     $this->SUPER::init(@_);
  27.     $this->interactive(1);
  28.     $this->cancelled(0);
  29.     $this->createdelements([]);
  30.     $this->dupelements([]);
  31.     $this->capb('backup');
  32.  
  33.     if (fork) {
  34.         wait(); # for child
  35.         if ($? != 0) {
  36.             die "DISPLAY problem?\n";
  37.         }
  38.     }
  39.     else {
  40.         $this->qtapp(Qt::Application(\@ARGV_KDE));
  41.         exit(0); # success
  42.     }
  43.     
  44.     debug frontend => "QTF: initializing app";
  45.     $this->qtapp(Qt::Application(\@ARGV_KDE));
  46.     debug frontend => "QTF: initializing wizard";
  47.     $this->win(Debconf::FrontEnd::Kde::Wizard(undef, undef, $this));
  48.     debug frontend => "QTF: setting size";
  49.     $this->win->resize(620, 430);
  50.     my $hostname = `hostname`;
  51.     chomp $hostname;
  52.     $this->hostname($hostname);
  53.     debug frontend => "QTF: setting title";
  54.     $this->win->setCaption(to_Unicode(sprintf(gettext("Debconf on %s"), $this->hostname)));
  55.     debug frontend => "QTF: initializing main widget";
  56.     $this->toplayout(Qt::HBoxLayout($this->win->mainFrame));
  57.     $this->page(Qt::ScrollView($this->win->mainFrame));
  58.     $this->page->setResizePolicy(&Qt::ScrollView::AutoOneFit());
  59.     $this->page->setFrameStyle(&Qt::Frame::NoFrame());
  60.     $this->frame(Qt::Frame($this->page));
  61.     $this->page->addChild($this->frame);
  62.     $this->toplayout->addWidget($this->page);
  63.     $this->vbox(Qt::VBoxLayout($this->frame, 0, 6, "wizard-main-vbox"));
  64.     $this->space(Qt::SpacerItem(1, 1, 1, 5));
  65.     $this->win->setTitle(to_Unicode(sprintf(gettext("Debconf on %s"), $this->hostname)));
  66. }
  67.  
  68.  
  69. sub go {
  70.     my $this=shift;
  71.     my @elements=@{$this->elements};
  72.     
  73.     my $interactive='';
  74.     debug frontend => "QTF: -- START ------------------";
  75.     foreach my $element (@elements) {
  76.         $element->create($this->frame);
  77.         next unless $element->top;
  78.         $interactive=1;
  79.         debug frontend => "QTF: ADD: " . $element->question->description;
  80.         $this->vbox->addWidget ($element->top);
  81.     }
  82.     
  83.     if ($interactive) {
  84.         foreach my $element (@elements) {
  85.             next unless $element->top;
  86.             debug frontend => "QTF: SHOW: " . $element->question->description;
  87.             $element->top->show;
  88.         }
  89.     
  90.         $this->vbox->addItem($this->space);
  91.     
  92.         if ($this->capb_backup) {
  93.             $this->win->setBackEnabled(1);
  94.         }
  95.         else {
  96.             $this->win->setBackEnabled(0);
  97.         }
  98.         $this->win->setNextEnabled(1);
  99.     
  100.         $this->win->show;
  101.         debug frontend => "QTF: -- ENTER EVENTLOOP --------";
  102.         $this->qtapp->exec;
  103.         debug frontend => "QTF: -- LEFT EVENTLOOP --------";
  104.     
  105.         foreach my $element (@elements) {
  106.             next unless $element -> top;
  107.             debug frontend => "QTF: HIDE: " . $element->question->description;
  108.             $this->vbox->remove($element->top);
  109.             $element->top->hide;
  110.             debug frontend => "QTF: DESTROY: " . $element->question->description;
  111.             $element->destroy;
  112.         }
  113.         
  114.         $this->vbox->removeItem($this->space);
  115.     }
  116.     
  117.     debug frontend => "QTF: -- END --------------------";
  118.     if ($this->cancelled) {
  119.         exit 1;
  120.     }
  121.     return '' if $this->goback;
  122.     return 1;
  123. }
  124.  
  125. sub progress_start {
  126.     my $this=shift;
  127.     $this->SUPER::progress_start(@_);
  128.  
  129.     my $element=$this->progress_bar;
  130.     $this->vbox->addWidget($element->top);
  131.     $element->top->show;
  132.     $this->vbox->addItem($this->space);
  133.     $this->win->setBackEnabled(0);
  134.     $this->win->setNextEnabled(0);
  135.     $this->win->show;
  136.     $this->qtapp->processEvents;
  137. }
  138.  
  139. sub progress_set {
  140.     my $this=shift;
  141.     $this->SUPER::progress_set(@_);
  142.  
  143.     $this->qtapp->processEvents;
  144. }
  145.  
  146. sub progress_info {
  147.     my $this=shift;
  148.     $this->SUPER::progress_info(@_);
  149.  
  150.     $this->qtapp->processEvents;
  151. }
  152.  
  153. sub progress_stop {
  154.     my $this=shift;
  155.     my $element=$this->progress_bar;
  156.     $this->SUPER::progress_stop(@_);
  157.  
  158.     $this->qtapp->processEvents;
  159.  
  160.     $this->vbox->remove($element->top);
  161.     $element->top->hide;
  162.     $element->destroy;
  163.     $this->vbox->removeItem($this->space);
  164.  
  165.     if ($this->cancelled) {
  166.         exit 1;
  167.     }
  168. }
  169.  
  170.  
  171. sub shutdown {
  172.     my $this = shift;
  173.     $this->win->hide;
  174.     $this->frame->reparent(undef, 0, Qt::Point(0, 0), 0);
  175.     $this->frame(undef);
  176.     $this->win->mainFrame->reparent(undef, 0, Qt::Point(0, 0), 0);
  177.     $this->win->mainFrame(undef);
  178.     $this->win(undef);
  179.     $this->space(undef);
  180. }
  181.  
  182.  
  183. 1
  184.