diff options
Diffstat (limited to 'gurpmi2')
-rwxr-xr-x | gurpmi2 | 51 |
1 files changed, 11 insertions, 40 deletions
@@ -10,41 +10,12 @@ BEGIN { #- set up a safe path and environment delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; } -#- This is needed because text printed by Gtk2 will always be encoded -#- in UTF-8; we first check if LC_ALL is defined, because if it is, -#- changing only LC_COLLATE will have no effect. -use POSIX qw(setlocale LC_ALL LC_COLLATE); -use locale; -BEGIN { - my $collation_locale = $ENV{LC_ALL}; - if ($collation_locale) { - $collation_locale =~ /UTF-8/ or setlocale(LC_ALL, "$collation_locale.UTF-8"); - } else { - $collation_locale = setlocale(LC_COLLATE); - $collation_locale =~ /UTF-8/ or setlocale(LC_COLLATE, "$collation_locale.UTF-8"); - } -} - -use urpm; +use gurpmi; use urpm::msg qw(N); use Gtk2; -sub usage () { - print STDERR <<USAGE; -gurpmi2 version $urpm::VERSION -Usage : - gurpmi2 <rpm> [ <rpm>... ] -USAGE - exit 0; -} - -#- fatal gurpmi initialisation error (*not* fatal urpmi errors) -sub fatal { print STDERR "$_[0]\n"; exit 1 } - sub quit () { Gtk2->main_quit } -sub but ($) { " $_[0] " } - #- GUI globals my ($mainw, $mainbox); @@ -102,14 +73,14 @@ sub wait_label { my (@all_rpms); foreach (@ARGV) { if (/^-/) { - /^--?[hv?]/ and usage(); - fatal N("Unknown option %s", $_); + /^--?[hv?]/ and gurpmi::usage(); + gurpmi::fatal N("Unknown option %s", $_); } push @all_rpms, $_; } -@all_rpms or fatal N("No packages specified"); +@all_rpms or gurpmi::fatal N("No packages specified"); -$> and fatal N("Must be root"); +$> and gurpmi::fatal N("Must be root"); #- Now, the graphical stuff. @@ -149,7 +120,7 @@ $mainw->show_all; Gtk2->main; #- Creates and configure an urpm object for this application to use. -sub configure_urpm () { +sub configure_urpm { my $urpm = new urpm; $urpm->{fatal} = sub { Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'error', 'ok', $_[1])->run; @@ -187,8 +158,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(but N("_Cancel")); - my $choice_button = Gtk2::Button->new(but N("_Ok")); + my $cancel_button = Gtk2::Button->new(gurpmi::but N("_Cancel")); + my $choice_button = Gtk2::Button->new(gurpmi::but N("_Ok")); $cancel_button->signal_connect(clicked => \&quit); $choice_button->signal_connect(clicked => sub { my $n = 0; @@ -204,8 +175,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(but N("_Ok")); - my $quit_button = Gtk2::Button->new(but N("_Abort")); + my $continue_button = Gtk2::Button->new(gurpmi::but N("_Ok")); + my $quit_button = Gtk2::Button->new(gurpmi::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); @@ -355,7 +326,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(but N("_Done")); + my $quit_button = Gtk2::Button->new(gurpmi::but N("_Done")); $quit_button->signal_connect(clicked => \&quit); add_button_box($vbox, $quit_button); change_mainw($vbox); |