aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2008-02-21 14:25:03 +0000
committerThierry Vignaud <tv@mandriva.org>2008-02-21 14:25:03 +0000
commit472f9405bb5314cab4c72acd73bd61d1bb8dd137 (patch)
treed7d5910529bc2968a5b8cce6afb8c4e0405930de
parentaca63a54f07cb787a40fe459dc841fecd0dcf5d1 (diff)
downloadrpmdrake-472f9405bb5314cab4c72acd73bd61d1bb8dd137.tar
rpmdrake-472f9405bb5314cab4c72acd73bd61d1bb8dd137.tar.gz
rpmdrake-472f9405bb5314cab4c72acd73bd61d1bb8dd137.tar.bz2
rpmdrake-472f9405bb5314cab4c72acd73bd61d1bb8dd137.tar.xz
rpmdrake-472f9405bb5314cab4c72acd73bd61d1bb8dd137.zip
(remove_from_list) factorize duplicated code
-rw-r--r--Rpmdrake/edit_urpm_sources.pm32
1 files changed, 16 insertions, 16 deletions
diff --git a/Rpmdrake/edit_urpm_sources.pm b/Rpmdrake/edit_urpm_sources.pm
index 3ee402db..1ee810ad 100644
--- a/Rpmdrake/edit_urpm_sources.pm
+++ b/Rpmdrake/edit_urpm_sources.pm
@@ -95,6 +95,16 @@ sub remove_row {
$model->remove($iter);
}
+sub remove_from_list {
+ my ($list, $list_ref, $model) = @_;
+ my $row = selrow($list);
+ if ($row != -1) {
+ splice @$list_ref, $row, 1;
+ remove_row($model, $row);
+ }
+
+}
+
sub easy_add_callback() {
# when called on early init by rpmdrake
$urpm ||= fast_open_urpmi_db();
@@ -676,13 +686,6 @@ sub edit_parallel {
push @{$edited->{medias}}, $media;
}
};
- my $remove_media = sub {
- my $row = selrow($medias);
- if ($row != -1) {
- splice @{$edited->{medias}}, $row, 1;
- remove_row($medias_ls, $row);
- }
- };
my $hosts_ls = Gtk2::ListStore->new("Glib::String");
my $hosts = Gtk2::TreeView->new_with_model($hosts_ls);
@@ -716,13 +719,6 @@ sub edit_parallel {
push @$hosts_list, $value;
}
};
- my $remove_host = sub {
- my $row = selrow($hosts);
- if ($row != -1) {
- splice @$hosts_list, $row, 1;
- remove_row($hosts_ls, $row);
- }
- };
my @protocols_names = qw(ka-run ssh);
my @protocols;
@@ -745,14 +741,18 @@ sub edit_parallel {
gtknew('ScrolledWindow', h_policy => 'never', child => $medias)),
0, gtknew('VBox', children_tight => [
gtksignal_connect(Gtk2::Button->new(but(N("Add"))), clicked => sub { $add_media->() }),
- gtksignal_connect(Gtk2::Button->new(but(N("Remove"))), clicked => sub { $remove_media->() }) ]) ]) ],
+ gtksignal_connect(Gtk2::Button->new(but(N("Remove"))), clicked => sub {
+ remove_from_list($medias, $edited->{medias}, $medias_ls);
+ }) ]) ]) ],
[ N("Hosts:"),
gtknew('HBox', spacing => 5, children => [
1, gtknew('Frame', shadow_type => 'in', child =>
gtknew('ScrolledWindow', h_policy => 'never', child => $hosts)),
0, gtknew('VBox', children_tight => [
gtksignal_connect(Gtk2::Button->new(but(N("Add"))), clicked => sub { $add_host->() }),
- gtksignal_connect(Gtk2::Button->new(but(N("Remove"))), clicked => sub { $remove_host->() }) ]) ]) ]
+ gtksignal_connect(Gtk2::Button->new(but(N("Remove"))), clicked => sub {
+ remove_from_list($hosts, $hosts_list, $hosts_ls);
+ }) ]) ]) ]
),
0, gtknew('HSeparator'),
0, gtkpack(