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

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Gnome;
  6. use strict;
  7. use I18N::Langinfo qw(langinfo CODESET);
  8. use utf8;
  9. use Gtk2;
  10. use Debconf::Gettext;
  11. use Debconf::Encoding qw(to_Unicode);
  12. use base qw(Debconf::Element);
  13.  
  14.  
  15. sub init {
  16.     my $this=shift;
  17.  
  18.     $this->hbox(Gtk2::VBox->new(0, 10));
  19.  
  20.     $this->hline1(Gtk2::HBox->new(0, 10));
  21.     $this->hline1->show;
  22.     $this->line1(Gtk2::VBox->new(0, 10));
  23.     $this->line1->show;
  24.     $this->line1->pack_end ($this->hline1, 1, 1, 0);
  25.  
  26.     $this->hline2(Gtk2::HBox->new(0, 10));
  27.     $this->hline2->show;
  28.     $this->line2(Gtk2::VBox->new(0, 10));
  29.     $this->line2->show;
  30.     $this->line2->pack_end ($this->hline2, 1, 1, 0);
  31.  
  32.     $this->vbox(Gtk2::VBox->new(0, 5));
  33.     $this->vbox->pack_start($this->line1, 0, 0, 0);
  34.     $this->vbox->pack_start($this->line2, 1, 1, 0);
  35.     $this->vbox->show;
  36.  
  37.     $this->hbox->pack_start($this->vbox, 1, 1, 0);
  38.     $this->hbox->show;
  39.     
  40.     $this->fill(0);
  41.     $this->expand(0);
  42.     $this->multiline(0);
  43. }
  44.  
  45.  
  46. sub addwidget {
  47.     my $this=shift;
  48.     my $widget=shift;
  49.  
  50.     if ($this->multiline == 0) {
  51.         $this->hline1->pack_start($widget, 1, 1, 0);
  52.     }
  53.     else {
  54.         $this->hline2->pack_start($widget, 1, 1, 0);
  55.     }
  56. }
  57.  
  58.  
  59. sub adddescription {
  60.     my $this=shift;
  61.     my $description=to_Unicode($this->question->description);
  62.     
  63.     my $label=Gtk2::Label->new($description);
  64.     $label->show;
  65.     $this->line1->pack_start($label, 0, 0, 0);
  66. }
  67.  
  68.  
  69. sub addbutton {
  70.     my $this=shift;
  71.     my $text = shift;
  72.     my $callback = shift;
  73.     
  74.     my $button = Gtk2::Button->new_with_mnemonic(to_Unicode($text));
  75.     $button->show;
  76.     $button->signal_connect("clicked", $callback);
  77.     
  78.     my $vbox = Gtk2::VBox->new(0, 0);
  79.     $vbox->show;
  80.     $vbox->pack_start($button, 1, 0, 0);
  81.     $this->hline1->pack_end($vbox, 0, 0, 0);
  82. }
  83.  
  84.  
  85. sub create_message_dialog {
  86.     my $this = shift;
  87.     my $type = shift;
  88.     my $title = shift;
  89.     my $text = shift;
  90.     
  91.     my $dialog = 
  92.         Gtk2::Dialog->new_with_buttons(to_Unicode($title), undef, 
  93.                                        "modal", "gtk-close", "close");
  94.     $dialog->set_border_width(3);
  95.     
  96.     my $hbox = Gtk2::HBox->new(0);
  97.     $dialog->vbox->pack_start($hbox, 1, 1, 5);
  98.     $hbox->show;
  99.     
  100.     my $alignment = Gtk2::Alignment->new(0.5, 0.0, 1.0, 0.0);
  101.     $hbox->pack_start($alignment, 1, 1, 3);
  102.     $alignment->show;
  103.     
  104.     my $image = Gtk2::Image->new_from_stock($type, "dialog");
  105.     $alignment->add($image);
  106.     $image->show;
  107.     
  108.     my $label = Gtk2::Label->new(to_Unicode($text));
  109.     $label->set_line_wrap(1);
  110.     $hbox->pack_start($label, 1, 1, 2);
  111.     $label->show;
  112.     
  113.     $dialog->run;
  114.     $dialog->destroy;
  115. }
  116.  
  117.  
  118. sub addhelp {
  119.     my $this=shift;
  120.     
  121.     my $help=$this->question->extended_description;
  122.     return unless length $help;
  123.     
  124.     $this->addbutton(gettext("_Help"), sub {
  125.         $this->create_message_dialog("gtk-dialog-info",
  126.                                       gettext("Help"), 
  127.                          to_Unicode($help));
  128.     });
  129.  
  130.     if (defined $this->tip ){
  131.         $this->tooltips( Gtk2::Tooltips->new() );
  132.         $this->tooltips->set_tip($this->tip, to_Unicode($help), 
  133.                       undef );
  134.         $this->tooltips->enable;
  135.     }
  136. }
  137.  
  138.  
  139. sub value {
  140.     my $this=shift;
  141.  
  142.     return '';
  143. }
  144.  
  145.  
  146. 1
  147.