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

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::FrontEnd::Gnome;
  6. use strict;
  7. use utf8;
  8. use Debconf::Gettext;
  9. use Debconf::Config;
  10. use Debconf::Encoding qw(to_Unicode);
  11. use base qw{Debconf::FrontEnd};
  12.  
  13. eval q{
  14.     use Gtk2;
  15.     use Gnome2;
  16. };
  17. die "Unable to load Gnome -- is libgnome2-perl installed?\n" if $@;
  18.  
  19.  
  20. our @ARGV_for_gnome=('--sm-disable');
  21.  
  22. sub create_druid_page {
  23.     my $this=shift;
  24.     
  25.        $this->druid_page(Gnome2::DruidPageStandard->new);
  26.     $this->druid_page->set_logo($this->logo);
  27.     $this->druid_page->signal_connect("back", sub {
  28.         $this->goback(1);
  29.         Gtk2->main_quit;
  30.         return 1;
  31.     });
  32.     $this->druid_page->signal_connect("next", sub {
  33.         $this->goback(0);
  34.         Gtk2->main_quit;
  35.         return 1;
  36.     });
  37.     $this->druid_page->signal_connect("cancel", sub { exit 1 });
  38.     $this->druid_page->show;
  39.     $this->druid->append_page($this->druid_page);
  40.     $this->druid->set_page($this->druid_page);
  41. }
  42.  
  43. sub init {
  44.     my $this=shift;
  45.     
  46.     if (fork) {
  47.         wait(); # for child
  48.         if ($? != 0) {
  49.             die "DISPLAY problem?\n";
  50.         }
  51.     }
  52.     else {
  53.         @ARGV=@ARGV_for_gnome; # temporary change at first
  54.         Gnome2::Program->init('GNOME Debconf', '2.0');
  55.         exit(0); # success
  56.     }
  57.     
  58.     my @gnome_sucks=@ARGV;
  59.     @ARGV=@ARGV_for_gnome;
  60.     Gnome2::Program->init('GNOME Debconf', '2.0');
  61.     @ARGV=@gnome_sucks;
  62.     
  63.     $this->SUPER::init(@_);
  64.     $this->interactive(1);
  65.     $this->capb('backup');
  66.     
  67.     $this->win(Gtk2::Window->new("toplevel"));
  68.     $this->win->set_position("center");
  69.     $this->win->set_default_size(600, 400);
  70.     my $hostname = `hostname`;
  71.     chomp $hostname;
  72.     $this->win->set_title(to_Unicode(sprintf(gettext("Debconf on %s"), $hostname)));
  73.     $this->win->signal_connect("delete_event", sub { exit 1 });
  74.     
  75.     my $distribution='';
  76.     if (system('type lsb_release >/dev/null 2>&1') == 0) {
  77.         $distribution=lc(`lsb_release -is`);
  78.         chomp $distribution;
  79.     } elsif (-e '/etc/debian_version') {
  80.         $distribution='debian';
  81.     }
  82.  
  83.     my $logo="/usr/share/pixmaps/$distribution-logo.png";
  84.     if (-e $logo) {
  85.         $this->logo(Gtk2::Gdk::Pixbuf->new_from_file($logo));
  86.     }
  87.     
  88.     $this->druid(Gnome2::Druid->new);
  89.     $this->druid->show;
  90.     $this->win->add($this->druid);
  91.     
  92.     $this->create_druid_page ();
  93. }
  94.  
  95.  
  96. sub go {
  97.         my $this=shift;
  98.     my @elements=@{$this->elements};
  99.     
  100.     my $interactive='';
  101.     foreach my $element (@elements) {
  102.         next unless $element->hbox;
  103.  
  104.         $interactive=1;
  105.         $this->druid_page->vbox->pack_start($element->hbox, $element->fill, $element->expand, 0);
  106.     }
  107.  
  108.     if ($interactive) {
  109.             $this->druid_page->set_title(to_Unicode($this->title));
  110.         if ($this->capb_backup) {
  111.             $this->druid->set_buttons_sensitive(1, 1, 1, 1);
  112.         }
  113.         else {
  114.             $this->druid->set_buttons_sensitive(0, 1, 1, 1);
  115.         }
  116.         $this->win->show;
  117.         Gtk2->main;
  118.         $this->create_druid_page ();
  119.     }
  120.  
  121.     foreach my $element (@elements) {
  122.         $element->show;
  123.     }
  124.  
  125.     return '' if $this->goback;
  126.     return 1;
  127. }
  128.  
  129. sub progress_start {
  130.     my $this=shift;
  131.     $this->SUPER::progress_start(@_);
  132.  
  133.     my $element=$this->progress_bar;
  134.     $this->druid_page->vbox->pack_start($element->hbox, $element->fill, $element->expand, 0);
  135.     $this->druid_page->set_title(to_Unicode($this->title));
  136.     $this->druid->set_buttons_sensitive(0, 0, 1, 1);
  137.     $this->win->show;
  138.  
  139.     while (Gtk2->events_pending) {
  140.         Gtk2->main_iteration;
  141.     }
  142. }
  143.  
  144. sub progress_set {
  145.     my $this=shift;
  146.     $this->SUPER::progress_set(@_);
  147.  
  148.     while (Gtk2->events_pending) {
  149.         Gtk2->main_iteration;
  150.     }
  151. }
  152.  
  153. sub progress_info {
  154.     my $this=shift;
  155.     $this->SUPER::progress_info(@_);
  156.  
  157.     while (Gtk2->events_pending) {
  158.         Gtk2->main_iteration;
  159.     }
  160. }
  161.  
  162. sub progress_stop {
  163.     my $this=shift;
  164.     $this->SUPER::progress_stop(@_);
  165.  
  166.     while (Gtk2->events_pending) {
  167.         Gtk2->main_iteration;
  168.     }
  169.  
  170.     $this->create_druid_page();
  171. }
  172.  
  173.  
  174. 1
  175.