From d2dd263af5e1437afa03b29ab5d4508be81683ab Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Tue, 7 Dec 2004 17:25:49 +0000 Subject: Remove GUI messages. --- urpm/msg.pm | 80 +++++++++++++++++++++---------------------------------------- 1 file changed, 27 insertions(+), 53 deletions(-) diff --git a/urpm/msg.pm b/urpm/msg.pm index 8c681fa9..00dc5b75 100644 --- a/urpm/msg.pm +++ b/urpm/msg.pm @@ -3,7 +3,7 @@ package urpm::msg; use strict; use Exporter; our @ISA = 'Exporter'; -our @EXPORT = qw(N log_it to_utf8 message_input gmessage message toMb); +our @EXPORT = qw(N log_it to_utf8 message_input message toMb); #- I18N. eval { @@ -35,68 +35,42 @@ sub log_it { sub to_utf8 { Locale::gettext::iconv($_[0], undef, "UTF-8") } -#- this function returns a value via $?. this is evil; FIXME (and use zenity) -sub gmessage { - my ($msg, %params) = @_; - my $ok = to_utf8($params{ok} || N("Ok")); - my $cancel = to_utf8($params{cancel} || N("Cancel")); - $ok =~ s/,/\\,/g; $cancel =~ s/,/\\,/g; - my $buttons = $params{ok_only} ? "$ok:0" : "$ok:0,$cancel:2"; - foreach (@{$params{add_buttons}}) { - s/,/\\,/g; - $buttons .= ",$_"; - } - $msg = to_utf8($msg); - `gmessage -default "$ok" -buttons "$buttons" "$msg"`; -} - sub message_input { my ($msg, $default_input, %opts) = @_; my $input; - if ($urpm::args::options{X} && !$default_input) { - #- if a default input is given, the user doesn't have to choose (and being asked). - gmessage($msg, ok_only => 1); - $urpm::args::options{bug} and log_it($msg); - } else { - while (1) { - if ($urpm::args::options{bug} || !defined fileno ::SAVEOUT) { - print STDOUT $msg; - } else { - print ::SAVEOUT $msg; - } - if ($default_input) { - $urpm::args::options{bug} and log_it($default_input); - return $default_input; - } - $input = ; - defined $input or return undef; - chomp $input; - $urpm::args::options{bug} and log_it($input); - if ($opts{boolean}) { - $input =~ /^[$noexpr$yesexpr]?$/ and last; - } elsif ($opts{range}) { - $input eq "" and $input = 1; #- defaults to first choice - (defined $opts{range_min} ? $opts{range_min} : 1) <= $input && $input <= $opts{range} and last; - } else { - last; - } - message(N("Sorry, bad choice, try again\n")); + while (1) { + if ($urpm::args::options{bug} || !defined fileno ::SAVEOUT) { + print STDOUT $msg; + } else { + print ::SAVEOUT $msg; } + if ($default_input) { + $urpm::args::options{bug} and log_it($default_input); + return $default_input; + } + $input = ; + defined $input or return undef; + chomp $input; + $urpm::args::options{bug} and log_it($input); + if ($opts{boolean}) { + $input =~ /^[$noexpr$yesexpr]?$/ and last; + } elsif ($opts{range}) { + $input eq "" and $input = 1; #- defaults to first choice + (defined $opts{range_min} ? $opts{range_min} : 1) <= $input && $input <= $opts{range} and last; + } else { + last; + } + message(N("Sorry, bad choice, try again\n")); } return $input; } sub message { - my ($msg, $no_X) = @_; - if ($urpm::args::options{X} && !$no_X && !$::auto) { - gmessage($msg, ok_only => 1); - $urpm::args::options{bug} and log_it($msg); + my ($msg) = @_; + if ($urpm::args::options{bug} || !defined fileno ::SAVEOUT) { + print STDOUT "$msg\n"; } else { - if ($urpm::args::options{bug} || !defined fileno ::SAVEOUT) { - print STDOUT "$msg\n"; - } else { - print ::SAVEOUT "$msg\n"; - } + print ::SAVEOUT "$msg\n"; } } -- cgit v1.2.1