From 60aac5852545cc4e94ab0f2d1bbb646eefdc68be Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 17 May 2013 10:30:16 +0000 Subject: (ask_warn) split it out of configure_urpm() (needed for next commit) --- gurpmi2 | 56 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/gurpmi2 b/gurpmi2 index 819d3187..3a3f620b 100755 --- a/gurpmi2 +++ b/gurpmi2 @@ -102,6 +102,34 @@ Gtk2->main; my ($rpm_lock, $urpmi_lock); +sub ask_warn { + my ($message) = @_; + printf STDERR "%s\n", $message; + + if (my $download_errors = delete $urpm->{download_errors}) { + $message = join("\n", @$download_errors, $message); + } + my $nb_lines = $message =~ tr/\n/\n/; + my $w; + if ($nb_lines > 30 || $message =~ /^transaction is too small/) { + $w = Gtk2::Dialog->new(N("Warning"), $mainw, [qw(modal destroy-with-parent)], N("Ok"), 'ok'); + $w->vbox->add(my $f = Gtk2::Frame->new); + my $sw = create_scrolled_window(my $text = Gtk2::TextView->new); + $sw->set_border_width(2); + $text->set_wrap_mode('word'); + $f->add($sw); + $text->get_buffer->set_text($message); + $text->set_editable(0); + $_->show foreach $f, $sw, $text; + $w->set_size_request(400, 400); + $w->set_default_response('ok'); + } else { + $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', $message); + } + $w->run; + $w->destroy; +} + #- Creates and configure an urpm object for this application to use. sub configure_urpm { my ($urpm) = @_; @@ -113,33 +141,7 @@ sub configure_urpm { exit $_[0]; }; $urpm->{log} = sub { printf "%s\n", $_[0] }; - $urpm->{error} = sub { - my ($message) = @_; - printf STDERR "%s\n", $message; - - if (my $download_errors = delete $urpm->{download_errors}) { - $message = join("\n", @$download_errors, $message); - } - my $nb_lines = $message =~ tr/\n/\n/; - my $w; - if ($nb_lines > 30 || $message =~ /^transaction is too small/) { - $w = Gtk2::Dialog->new(N("Warning"), $mainw, [qw(modal destroy-with-parent)], N("Ok"), 'ok'); - $w->vbox->add(my $f = Gtk2::Frame->new); - my $sw = create_scrolled_window(my $text = Gtk2::TextView->new); - $sw->set_border_width(2); - $text->set_wrap_mode('word'); - $f->add($sw); - $text->get_buffer->set_text($message); - $text->set_editable(0); - $_->show foreach $f, $sw, $text; - $w->set_size_request(400, 400); - $w->set_default_response('ok'); - } else { - $w = Gtk2::MessageDialog->new($mainw, [qw(modal destroy-with-parent)], 'warning', 'ok', $message); - } - $w->run; - $w->destroy; - }; + $urpm->{error} = \&ask_warn; urpm::select::set_priority_upgrade_option($urpm, $gurpmi::options{previous_priority_upgrade}); $rpm_lock = urpm::lock::rpm_db($urpm, 'exclusive'); $urpmi_lock = urpm::lock::urpmi_db($urpm); -- cgit v1.2.1