aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2014-07-10 22:54:47 +0200
committerAngelo Naselli <anaselli@linux.it>2014-07-10 22:54:47 +0200
commit59f61c493be49dea24da69fc64076eaf2f708946 (patch)
tree6c074ceb5e433d3a4cbc03e73192bea9fa482396 /lib/AdminPanel
parent48b22dca97fa8a84912a60bc835645e8fbbe1952 (diff)
downloadmanatools-59f61c493be49dea24da69fc64076eaf2f708946.tar
manatools-59f61c493be49dea24da69fc64076eaf2f708946.tar.gz
manatools-59f61c493be49dea24da69fc64076eaf2f708946.tar.bz2
manatools-59f61c493be49dea24da69fc64076eaf2f708946.tar.xz
manatools-59f61c493be49dea24da69fc64076eaf2f708946.zip
Added enable/disable and set/reset as Updates media functionalities
Diffstat (limited to 'lib/AdminPanel')
-rw-r--r--lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm58
1 files changed, 51 insertions, 7 deletions
diff --git a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
index 4e668533..11aad8d3 100644
--- a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
+++ b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
@@ -529,10 +529,11 @@ sub downwards_callback {
return $row + 1;
}
-#- returns the name of the media for which edition failed, or undef on success
+#- returns 1 if something changed to force readMedia()
sub edit_callback {
my $table = shift;
+ my $changed = 0;
## get the first
my $item = $table->selectedItem();
!$item and return 0;
@@ -588,10 +589,10 @@ sub edit_callback {
### TODO cell to get info
my $tableItem = yui::toYTableItem($item);
# enabled cell 0, updates cell 1
- my $cellEnabled = $tableItem->cell(0);
- my $enabled = $factory->createCheckBox($hbox, N("Enabled"), $cellEnabled->label? 1:0);
- my $cellUpdates = $tableItem->cell(1);
- my $update = $factory->createCheckBox($hbox, N("Updates"), $cellUpdates->label? 1:0);
+ my $cellEnabled = $tableItem->cell(0)->label() ? 1 : 0;
+ my $enabled = $factory->createCheckBox($hbox, N("Enabled"), $cellEnabled);
+ my $cellUpdates = $tableItem->cell(1)->label() ? 1 : 0;
+ my $update = $factory->createCheckBox($hbox, N("Updates"), $cellUpdates);
$update->setDisabled() if (!$::expert);
$factory->createVSpacing($vbox, 0.5);
@@ -620,6 +621,19 @@ sub edit_callback {
last;
}
elsif ($widget == $saveButton) {
+ if ($cellEnabled != $enabled->value()) {
+ $urpm->{media}[$row]{ignore} = !$urpm->{media}[$row]{ignore} || undef;
+ $changed = 1;
+ }
+ if ($cellUpdates != $update->value()) {
+ $urpm->{media}[$row]{update} = !$urpm->{media}[$row]{update} || undef;
+ $changed = 1;
+ }
+ if ( $changed ) {
+ urpm::media::write_config($urpm);
+ }
+ ## TODO proxy and URL data save
+ last;
}
elsif ($widget == $proxyButton) {
proxy_callback($medium);
@@ -716,7 +730,7 @@ sub tobe_removed {
}
}
- return undef;
+ return $changed;
}
sub update_callback() {
@@ -1489,7 +1503,37 @@ sub mainwindow() {
yui::YUI::app()->normalCursor();
}
elsif ($widget == $edtButton) {
- edit_callback($mirrorTbl);
+ my $item = $mirrorTbl->selectedItem();
+ if ($item && edit_callback($mirrorTbl) ) {
+ my $row = $item->index();
+ yui::YUI::app()->busyCursor();
+ $dialog->startMultipleChanges();
+
+ $mirrorTbl->deleteAllItems();
+ my $ignored = $urpm->{media}[$row]{ignore};
+ my $itemCollection = readMedia();
+ if (!$ignored && $urpm->{media}[$row]{ignore}) {
+ # reread media failed to un-ignore an ignored medium
+ # probably because urpm::media::check_existing_medium() complains
+ # about missing synthesis when the medium never was enabled before;
+ # thus it restored the ignore bit
+ $urpm->{media}[$row]{ignore} = !$urpm->{media}[$row]{ignore} || undef;
+ urpm::media::write_config($urpm);
+ #- Enabling this media failed, force update
+ interactive_msg('rpmdragora',
+ N("This medium needs to be updated to be usable. Update it now?"),
+ yesno => 1,
+ ) and $itemCollection = readMedia($urpm->{media}[$row]{name});
+ }
+ $mirrorTbl->addItems($itemCollection);
+
+ $dialog->recalcLayout();
+ $dialog->doneMultipleChanges();
+ yui::YUI::app()->normalCursor();
+
+
+ }
+
# my $sel = $mirrorTbl->selectedItem();
# print " ITEM #" . $sel->index() . " -> " .$sel->label() . "\n" if $sel;
}