diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-01-24 15:05:03 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-01-24 15:05:03 +0000 |
commit | 27f824577805d11bd50f5fcdefa4343c5b32b028 (patch) | |
tree | 32078da7a01b92b46df238e55bc9475f23d34435 /gurpmi.pm | |
parent | e9bca51a4155e9afe46ee816560609a530893e24 (diff) | |
download | urpmi-27f824577805d11bd50f5fcdefa4343c5b32b028.tar urpmi-27f824577805d11bd50f5fcdefa4343c5b32b028.tar.gz urpmi-27f824577805d11bd50f5fcdefa4343c5b32b028.tar.bz2 urpmi-27f824577805d11bd50f5fcdefa4343c5b32b028.tar.xz urpmi-27f824577805d11bd50f5fcdefa4343c5b32b028.zip |
More refactorisation
Diffstat (limited to 'gurpmi.pm')
-rw-r--r-- | gurpmi.pm | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -16,6 +16,11 @@ BEGIN { } use urpm; +use strict; + +use Exporter; +our @ISA = qw(Exporter); +our @EXPORT = qw(usage fatal but quit add_button_box new_label); sub usage () { print STDERR <<USAGE; @@ -31,4 +36,30 @@ sub fatal { print STDERR "$_[0]\n"; exit 1 } sub but ($) { " $_[0] " } +sub quit () { Gtk2->main_quit } + +sub add_button_box { + my ($vbox, @buttons) = @_; + my $hbox = Gtk2::HButtonBox->new; + $vbox->pack_start($hbox, 0, 0, 0); + $hbox->set_layout('edge'); + $_->set_alignment(0.5, 0.5), $hbox->add($_) foreach @buttons; +} + +sub new_label { + my ($msg) = @_; + my $label = Gtk2::Label->new($msg); + $label->set_line_wrap(1); + $label->set_alignment(0.5, 0.5); + if (($msg =~ tr/\n/\n/) > 5) { + my $sw = Gtk2::ScrolledWindow->new; + $sw->set_policy('never', 'automatic'); + $sw->add_with_viewport($label); + $sw->set_size_request(-1,200); + return $sw; + } else { + return $label; + } +} + 1; |