aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel
diff options
context:
space:
mode:
authormatteo <matteo.pasotti@gmail.com>2014-07-02 01:14:27 +0300
committermatteo <matteo.pasotti@gmail.com>2014-07-02 01:14:27 +0300
commit25fab75015b8ad18acb27dcbf43122ca100ea3df (patch)
tree31420639c8fd7cc4bb472cab3901615de7e0d887 /lib/AdminPanel
parent64c6a43e2969ba1246ffb95416d6413e8b83ebb7 (diff)
parentd1bc4ec3ea484ed0dc4f490ae106d438d94b31b2 (diff)
downloadmanatools-25fab75015b8ad18acb27dcbf43122ca100ea3df.tar
manatools-25fab75015b8ad18acb27dcbf43122ca100ea3df.tar.gz
manatools-25fab75015b8ad18acb27dcbf43122ca100ea3df.tar.bz2
manatools-25fab75015b8ad18acb27dcbf43122ca100ea3df.tar.xz
manatools-25fab75015b8ad18acb27dcbf43122ca100ea3df.zip
Merge branch 'master' of ssh://git.mageia.org/software/adminpanel
Diffstat (limited to 'lib/AdminPanel')
-rw-r--r--lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm112
-rw-r--r--lib/AdminPanel/rpmdragora.pm11
2 files changed, 87 insertions, 36 deletions
diff --git a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
index f5181eaf..1756e0b3 100644
--- a/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
+++ b/lib/AdminPanel/Rpmdragora/edit_urpm_sources.pm
@@ -412,25 +412,50 @@ sub options_callback() {
$w->main;
}
-sub remove_callback() {
- my @rows = selected_rows();
+#=============================================================
+
+=head2 remove_callback
+
+=head3 INPUT
+
+$selection: YItemCollection (selected items)
+
+
+=head3 DESCRIPTION
+
+Remove the selected medias
+
+=cut
+
+#=============================================================
+
+sub remove_callback {
+ my $selection = shift;
+
+ my @rows;
+ $DB::single = 1;
+ for (my $it = 0; $it < $selection->size(); $it++) {
+ my $item = $selection->get($it);
+ push @rows, $item->label();
+ }
@rows == 0 and return;
interactive_msg(
N("Source Removal"),
@rows == 1 ?
- N("Are you sure you want to remove source \"%s\"?", $urpm->{media}[$rows[0]]{name}) :
- N("Are you sure you want to remove the following sources?") . "\n\n" .
- format_list(map { $urpm->{media}[$_]{name} } @rows),
+ N("Are you sure you want to remove source \"%s\"?", $urpm->{media}[$rows[0]]{name}) :
+ N("Are you sure you want to remove the following sources?") . "\n\n" .
+ format_list(map { $urpm->{media}[$_]{name} } @rows),
yesno => 1, scroll => 1,
- transient => $::main_window,
) or return;
- my $wait = wait_msg(N("Please wait, removing medium..."));
+ # TODO dialog waiting
+# my $wait = wait_msg(N("Please wait, removing medium..."));
foreach my $row (reverse(@rows)) {
$something_changed = 1;
urpm::media::remove_media($urpm, [ $urpm->{media}[$row] ]);
urpm::media::write_urpmi_cfg($urpm);
- remove_wait_msg($wait);
+# undef $wait
+# remove_wait_msg($wait);
}
return 1;
}
@@ -969,6 +994,7 @@ sub readMedia {
$urpm = fast_open_urpmi_db();
my $itemColl = new yui::YItemCollection;
+ my $row = 0;
foreach (grep { ! $_->{external} } @{$urpm->{media}}) {
my $name = $_->{name};
@@ -977,7 +1003,9 @@ sub readMedia {
get_medium_type($_),
$name);
# TODO manage to_bool($::expert)
- $item->setLabel( $name );
+ # row item contains row number for $urpm
+ $item->setLabel( "$row" );
+ $row++;
$itemColl->push($item);
$item->DISOWN();
}
@@ -1009,7 +1037,6 @@ sub mainwindow() {
my $headbar = $factory->createHBox($head_align_left);
my $headRight = $factory->createHBox($head_align_right);
- ## TODO fix menu order
my %fileMenu = (
widget => $factory->createMenuButton($headbar,N("File")),
update => new yui::YMenuItem(N("Update")),
@@ -1017,14 +1044,12 @@ sub mainwindow() {
custom => new yui::YMenuItem(N("Add a custom medium")),
quit => new yui::YMenuItem(N("&Close")),
);
- while ( my ($key, $value) = each(%fileMenu) ) {
- if ($key ne 'widget' ) {
- $fileMenu{ widget }->addItem($value);
- }
- }
+ $fileMenu{ widget }->addItem($fileMenu{ update });
+ $fileMenu{ widget }->addItem($fileMenu{ add_media });
+ $fileMenu{ widget }->addItem($fileMenu{ custom });
+ $fileMenu{ widget }->addItem($fileMenu{ quit });
$fileMenu{ widget }->rebuildMenuTree();
-
my %optionsMenu = (
widget => $factory->createMenuButton($headbar, N("Options")),
global => new yui::YMenuItem(N("Global options")),
@@ -1032,25 +1057,21 @@ sub mainwindow() {
parallel => new yui::YMenuItem(N("Parallel")),
proxy => new yui::YMenuItem(N("Proxy")),
);
- while ( my ($key, $value) = each(%optionsMenu) ) {
- if ($key ne 'widget' ) {
- $optionsMenu{ widget }->addItem($value);
- }
- }
+ $optionsMenu{ widget }->addItem($optionsMenu{ global });
+ $optionsMenu{ widget }->addItem($optionsMenu{ man_keys });
+ $optionsMenu{ widget }->addItem($optionsMenu{ parallel });
+ $optionsMenu{ widget }->addItem($optionsMenu{ proxy });
$optionsMenu{ widget }->rebuildMenuTree();
-
my %helpMenu = (
widget => $factory->createMenuButton($headRight, N("&Help")),
help => new yui::YMenuItem(N("Manual")),
report_bug => new yui::YMenuItem(N("Report Bug")),
about => new yui::YMenuItem(N("&About")),
);
- while ( my ($key, $value) = each(%helpMenu) ) {
- if ($key ne 'widget' ) {
- $helpMenu{ widget }->addItem($value);
- }
- }
+ $helpMenu{ widget }->addItem($helpMenu{ help });
+ $helpMenu{ widget }->addItem($helpMenu{ report_bug });
+ $helpMenu{ widget }->addItem($helpMenu{ about });
$helpMenu{ widget }->rebuildMenuTree();
my $hbox_content = $factory->createHBox($vbox);
@@ -1075,6 +1096,7 @@ sub mainwindow() {
my $multiselection = 1;
my $mirrorTbl = $factory->createTable($hbox, $yTableHeader, $multiselection);
$mirrorTbl->setKeepSorting(1);
+ $mirrorTbl->setImmediateMode(1);
my $itemCollection = readMedia();
$mirrorTbl->addItems($itemCollection);
@@ -1107,7 +1129,7 @@ sub mainwindow() {
$hbox = $factory->createHBox($align);
- my $aboutButton = $factory->createPushButton($hbox, N("Help") );
+ my $helpButton = $factory->createPushButton($hbox, N("Help") );
$align = $factory->createRight($hbox);
$hbox = $factory->createHBox($align);
@@ -1160,7 +1182,39 @@ sub mainwindow() {
if ($widget == $closeButton) {
last;
}
- elsif ($widget == $aboutButton) {
+ elsif ($widget == $helpButton) {
+ }
+ elsif ($widget == $edtButton) {
+ my $sel = $mirrorTbl->selectedItem();
+ print " ITEM " . $sel->label() . "\n" if $sel;
+ }
+ elsif ($widget == $remButton) {
+ yui::YUI::app()->busyCursor();
+ $dialog->startMultipleChanges();
+
+ my $sel = $mirrorTbl->selectedItems();
+ remove_callback($sel);
+ $mirrorTbl->deleteAllItems();
+ my $itemCollection = readMedia();
+ $mirrorTbl->addItems($itemCollection);
+
+ $dialog->recalcLayout();
+ $dialog->doneMultipleChanges();
+ yui::YUI::app()->normalCursor();
+
+ }
+ elsif ($widget == $mirrorTbl) {
+ my $sel = $mirrorTbl->selectedItems();
+ if ($sel->size() > 1 ) {
+ $edtButton->setEnabled(0);
+ $upButton->setEnabled(0);
+ $downButton->setEnabled(0);
+ }
+ else {
+ $edtButton->setEnabled(1);
+ $upButton->setEnabled(1);
+ $downButton->setEnabled(1);
+ }
}
}
}
diff --git a/lib/AdminPanel/rpmdragora.pm b/lib/AdminPanel/rpmdragora.pm
index aebb873f..11b549c1 100644
--- a/lib/AdminPanel/rpmdragora.pm
+++ b/lib/AdminPanel/rpmdragora.pm
@@ -388,9 +388,7 @@ sub wait_msg {
my $title = $factory->createLabel($vbox, N("Please wait"));
#$mainw->recalcLayout();
#$mainw->doneMultipleChanges();
- $mainw->open();
-# matteo do you really need a pollEvent? or it was just to show the dialog?
-# $mainw->pollEvent();
+ $mainw->pollEvent();
#$mainw->recalcLayout();
#$mainw->doneMultipleChanges();
$mainw;
@@ -633,9 +631,10 @@ sub update_sources {
yui::YUI::app()->setApplicationTitle(N("rpmdragora"));
my $dlg = $factory->createPopupDialog();
- my $vbox = $factory->createVBox($dlg);
+ my $minSize = $factory->createMinSize( $dlg, 80, 5 );
+ my $vbox = $factory->createVBox($minSize);
my $label = $factory->createLabel($vbox, N("Please wait, updating media...") );
-$label->setWeight($yui::YD_HORIZ, 1);
+ $label->setWeight($yui::YD_HORIZ, 1);
my $pb = $factory->createProgressBar( $vbox, "");
$dlg->open();
@@ -678,8 +677,6 @@ later.",
$media));
} else {
show_urpm_progress($label, $pb, @_);
-#Lose 5 msec to see the toolbar
- $dlg->waitForEvent(5);
$dlg->pollEvent();
}
},