aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2009-02-13 23:26:53 +0000
committerThierry Vignaud <tv@mandriva.org>2009-02-13 23:26:53 +0000
commit10ed71e25f1bf2a603fc2f7f0ab9085362af1f57 (patch)
treef81a6dad28a6827c69d8a219836a37ee664f7dad
parentcef6fafa2a5f4a0a94c1a9171ac9dd0a1fd7cbcb (diff)
downloadrpmdrake-10ed71e25f1bf2a603fc2f7f0ab9085362af1f57.tar
rpmdrake-10ed71e25f1bf2a603fc2f7f0ab9085362af1f57.tar.gz
rpmdrake-10ed71e25f1bf2a603fc2f7f0ab9085362af1f57.tar.bz2
rpmdrake-10ed71e25f1bf2a603fc2f7f0ab9085362af1f57.tar.xz
rpmdrake-10ed71e25f1bf2a603fc2f7f0ab9085362af1f57.zip
(toggle_nodes) previous commit nicely showed some duplicated code ;
let's factorize it
-rw-r--r--Rpmdrake/gui.pm21
1 files changed, 13 insertions, 8 deletions
diff --git a/Rpmdrake/gui.pm b/Rpmdrake/gui.pm
index e3a73cb25..09cfbd83 100644
--- a/Rpmdrake/gui.pm
+++ b/Rpmdrake/gui.pm
@@ -633,15 +633,22 @@ sub toggle_nodes {
my @nodes_with_deps;
my $bar_id = statusbar_msg(N("Checking dependencies of package..."), 0);
+
+ my $warn_about_additional_packages_to_remove = sub {
+ my ($msg) = @_;
+ statusbar_msg_remove($bar_id);
+ deps_msg(N("Some additional packages need to be removed"),
+ formatAlaTeX($msg) . "\n\n",
+ \@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
+ };
+
if (member($old_state, qw(to_remove installed))) { # remove pacckages
if ($new_state) {
my @remove;
slow_func($widget, sub { @remove = closure_removal(@nodes) });
@nodes_with_deps = grep { !$pkgs->{$_}{selected} && !/^basesystem/ } @remove;
- statusbar_msg_remove($bar_id);
- deps_msg(N("Some additional packages need to be removed"),
- formatAlaTeX(N("Because of their dependencies, the following package(s) also need to be\nremoved:")) . "\n\n",
- \@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
+ $warn_about_additional_packages_to_remove->(
+ N("Because of their dependencies, the following package(s) also need to be\nremoved:"));
my @impossible_to_remove;
foreach (grep { exists $pkgs->{$_}{base} } @remove) {
${$pkgs->{$_}{base}} == 1 ? push @impossible_to_remove, $_ : ${$pkgs->{$_}{base}}--;
@@ -655,10 +662,8 @@ sub toggle_nodes {
sub { @nodes_with_deps = grep { intersection(\@nodes, [ closure_removal($_) ]) }
grep { $pkgs->{$_}{selected} && !member($_, @nodes) } keys %$pkgs });
push @nodes_with_deps, @nodes;
- statusbar_msg_remove($bar_id);
- deps_msg(N("Some additional packages need to be removed"),
- N("Because of their dependencies, the following package(s) must be\nunselected now:\n\n"),
- \@nodes, \@nodes_with_deps) or @nodes_with_deps = ();
+ $warn_about_additional_packages_to_remove->(
+ N("Because of their dependencies, the following package(s) must be\nunselected now:\n\n"));
$pkgs->{$_}{base} && ${$pkgs->{$_}{base}}++ foreach @nodes_with_deps;
}
} else {