diff options
Diffstat (limited to 'gurpmi2')
-rwxr-xr-x | gurpmi2 | 46 |
1 files changed, 9 insertions, 37 deletions
@@ -14,13 +14,9 @@ use gurpmi; use urpm::msg qw(N); use Gtk2; -sub quit () { Gtk2->main_quit } - #- GUI globals my ($mainw, $mainbox); -#- Gtk2 helper functions - #- Replaces the contents of the main window with the specified box #- (avoids popup multiplication) sub change_mainw { @@ -30,35 +26,11 @@ sub change_mainw { $mainw->show_all; } -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 sync () { $mainw->show; Gtk2->main_iteration while Gtk2->events_pending; } -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; - } -} - #- sets the window to a please-wait message sub wait_label { my $wait_vbox = Gtk2::VBox->new(0, 5); @@ -73,14 +45,14 @@ sub wait_label { my (@all_rpms); foreach (@ARGV) { if (/^-/) { - /^--?[hv?]/ and gurpmi::usage(); - gurpmi::fatal N("Unknown option %s", $_); + /^--?[hv?]/ and usage(); + fatal(N("Unknown option %s", $_)); } push @all_rpms, $_; } -@all_rpms or gurpmi::fatal N("No packages specified"); +@all_rpms or fatal(N("No packages specified")); -$> and gurpmi::fatal N("Must be root"); +$> and fatal(N("Must be root")); #- Now, the graphical stuff. @@ -158,8 +130,8 @@ sub ask_choice { $label->set_alignment(0.5, 0.5); $vbox->pack_start($label, 1, 1, 0); $vbox->pack_start($_, 1, 1, 0) foreach @radios; - my $cancel_button = Gtk2::Button->new(gurpmi::but N("_Cancel")); - my $choice_button = Gtk2::Button->new(gurpmi::but N("_Ok")); + my $cancel_button = Gtk2::Button->new(but(N("_Cancel"))); + my $choice_button = Gtk2::Button->new(but(N("_Ok"))); $cancel_button->signal_connect(clicked => \&quit); $choice_button->signal_connect(clicked => sub { my $n = 0; @@ -175,8 +147,8 @@ sub ask_continue { my ($msg, $nextclosure) = @_; my $vbox = Gtk2::VBox->new(0, 5); $vbox->pack_start(new_label($msg), 1, 1, 0); - my $continue_button = Gtk2::Button->new(gurpmi::but N("_Ok")); - my $quit_button = Gtk2::Button->new(gurpmi::but N("_Abort")); + my $continue_button = Gtk2::Button->new(but(N("_Ok"))); + my $quit_button = Gtk2::Button->new(but(N("_Abort"))); $quit_button->signal_connect(clicked => \&quit); $continue_button->signal_connect(clicked => sub { goto &$nextclosure }); add_button_box($vbox, $quit_button, $continue_button); @@ -326,7 +298,7 @@ sub do_install_3 () { $vbox = Gtk2::VBox->new(0, 5); $progress_label = Gtk2::Label->new('-'); $vbox->pack_start($progress_label, 1, 1, 0); - my $quit_button = Gtk2::Button->new(gurpmi::but N("_Done")); + my $quit_button = Gtk2::Button->new(but(N("_Done"))); $quit_button->signal_connect(clicked => \&quit); add_button_box($vbox, $quit_button); change_mainw($vbox); |