diff options
-rw-r--r-- | Changes | 14 | ||||
-rw-r--r-- | lib/AdminPanel/Rpmdragora/gurpm.pm | 374 | ||||
-rw-r--r-- | lib/AdminPanel/Rpmdragora/pkg.pm | 25 | ||||
-rw-r--r-- | lib/AdminPanel/Shared/GUI.pm | 209 | ||||
-rw-r--r-- | lib/AdminPanel/Shared/TimeZone.pm | 6 | ||||
-rw-r--r-- | lib/AdminPanel/rpmdragora.pm | 14 | ||||
-rwxr-xr-x | modules/rpmdragora/rpmdragora | 472 | ||||
-rw-r--r-- | t/03-Shared_GUI.t | 16 |
8 files changed, 710 insertions, 420 deletions
@@ -1,4 +1,16 @@ -1.0.0-7 +1.0.0-8 + - rpmdragora: find string if present, after changing the + filter + - rpmdragora: gurpm module moved to Moose and allowed + to be instantiate as a part of an existing + dialog + - rpmdragora: fixed package searchs + - rpmdragora: used index for YItem + +1.0.0-7 04/01/2015 23:45 + - manaclock: /etc/localtime as link instead of a copy + - rpmdragora: readconf now lets default values if keys + do not have values into configuration files - rpmdragora: removed deprecated POSIX::isdigit() - rpmdragora: fixed button icons search and clear - rpmdragora: config file saved keys are sorted first diff --git a/lib/AdminPanel/Rpmdragora/gurpm.pm b/lib/AdminPanel/Rpmdragora/gurpm.pm index 9c0ea43a..7e9363a2 100644 --- a/lib/AdminPanel/Rpmdragora/gurpm.pm +++ b/lib/AdminPanel/Rpmdragora/gurpm.pm @@ -1,152 +1,296 @@ # vim: set et ts=4 sw=4: package AdminPanel::Rpmdragora::gurpm; -#***************************************************************************** -# -# Copyright (c) 2002 Guillaume Cottenceau -# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com> -# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA -# Copyright (c) 2005-2007 Mandriva SA -# Copyright (c) 2013 Matteo Pasotti <matteo.pasotti@gmail.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -#***************************************************************************** -# -# $Id: gurpm.pm 255450 2009-04-03 16:00:16Z tv $ -use strict; +#============================================================= -*-perl-*- -use yui; +=head1 NAME + + AdminPanel::Rpmdragora::gurpm - Module that shows the urpmi + progress status + +=head1 SYNOPSIS + + my %option = (title => "Urpmi action ivoked", text => "Please wait", ); + my $gurpmi = AdminPanel::Rpmdragora::gurpm->new(%option); + $gurpmi->progress(45); + + #add to an existing dialog + %option = (title => "Urpmi action ivoked", text => "Please wait", main_dialog => $dialog, parent => $parent_container); + $gurpmi = AdminPanel::Rpmdragora::gurpm->new(%option); + $gurpmi->progress(20); + +=head1 DESCRIPTION + + This class is used to show the progress of an urpmi operation on + its progress bar. It can be istantiated as a popup dialog or used + to add label and progress bar into a YLayoutBox container. + +=head1 SUPPORT + + You can find documentation for this module with the perldoc command: + + perldoc AdminPanel::Rpmdragora::gurpm + +=head1 AUTHOR + + Angelo Naselli <anaselli@linux.it> + +=head1 COPYRIGHT and LICENSE + + Copyright (c) 2002 Guillaume Cottenceau + Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com> + Copyright (c) 2003, 2004, 2005 MandrakeSoft SA + Copyright (c) 2005-2007 Mandriva SA + Copyright (c) 2013 Matteo Pasotti <matteo.pasotti@gmail.com> + Copyright (C) 2015, Angelo Naselli <anaselli@linux.it> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2, as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +=cut + + +use Moose; +use Carp; use Time::HiRes; + +use yui; use feature 'state'; -sub new { - my ($class, $title, $initializing, %options) = @_; - my $self = { - my $label = 0, - my $factory = 0, - my $mainw = 0, - my $vbox = 0, - my $progressbar = 0, - my $cancel = 0 - }; - bless $self, 'AdminPanel::Rpmdragora::gurpm'; - #my $mainw = bless(ugtk2->new($title, %options, default_width => 600, width => 600), $self); - $self->{factory} = yui::YUI::widgetFactory; - $self->{mainw} = $self->{factory}->createPopupDialog(); - - $self->{mainw}->startMultipleChanges(); - - #$::main_window = $self->{mainw}; - $self->{vbox} = $self->{factory}->createVBox($self->{mainw}); - #OLD $mainw->{label} = gtknew('Label', text => $initializing, alignment => [ 0.5, 0 ]); - $self->{label} = $self->{factory}->createLabel($self->{vbox}, $initializing); - $self->{label}->setStretchable( $yui::YD_HORIZ, 1 ); - # size label's heigh to 2 lines in order to prevent dummy vertical resizing: - #my $context = $mainw->{label}->get_layout->get_context; - #my $metrics = $context->get_metrics($mainw->{label}->style->font_desc, $context->get_language); - #$mainw->{label}->set_size_request(-1, 2 * Gtk2::Pango->PANGO_PIXELS($metrics->get_ascent + $metrics->get_descent)); - - #OLD $mainw->{progressbar} = gtknew('ProgressBar'); - $self->{progressbar} = $self->{factory}->createProgressBar($self->{vbox}, ""); - #gtkadd($mainw->{window}, $mainw->{vbox} = gtknew('VBox', spacing => 5, border_width => 6, children_tight => [ - # $mainw->{label}, - # $mainw->{progressbar} - #])); - #$mainw->{rwindow}->set_position('center-on-parent'); - #$mainw->{real_window}->show_all; - #select(undef, undef, undef, 0.1); #- hackish :-( - #$mainw->SUPER::sync; - $self->{mainw}->pollEvent(); - $self->flush(); - $self; +has 'title' => ( + is => 'rw', + isa => 'Str', +); + +has 'text' => ( + is => 'rw', + isa => 'Str', +); + +has 'main_dialog' => ( + is => 'rw', + isa => 'yui::YDialog', +); + +has 'parent' => ( + is => 'rw', + isa => 'yui::YReplacePoint', +); + +has 'label_widget' => ( + is => 'rw', + isa => 'yui::YLabel', + init_arg => undef, +); + +has 'progressbar' => ( + is => 'rw', + isa => 'yui::YProgressBar', + init_arg => undef, +); + +#============================================================= + +=head2 BUILD + +=head3 DESCRIPTION + + The BUILD method is called after a Moose object is created, + in this methods Services loads all the service information. + +=cut + +#============================================================= +sub BUILD { + my $self = shift; + + my $factory = yui::YUI::widgetFactory; + my $vbox; + + if (! $self->main_dialog) { + if ($self->parent) { + carp "WARNING: parent parameter is skipped without main_dialog set\n" ; + $self->parent(undef); + } + $self->main_dialog($factory->createPopupDialog()); + $vbox = $factory->createVBox($self->main_dialog); + } + else { + die "parent parameter is mandatory with main_dialog" if !$self->parent; + $self->main_dialog->startMultipleChanges(); + $self->parent->deleteChildren(); + $vbox = $factory->createVBox($self->parent); + $factory->createVSpacing($vbox, 0.5); + } + + $self->label_widget( $factory->createLabel($vbox, $self->text) ); + $self->label_widget->setStretchable( $yui::YD_HORIZ, 1 ); + $self->progressbar( $factory->createProgressBar($vbox, "") ); + + if ($self->parent) { + $factory->createVSpacing($vbox, 0.5); + $self->parent->showChild(); + $self->main_dialog->recalcLayout(); + $self->main_dialog->doneMultipleChanges(); + } + + $self->main_dialog->pollEvent(); + $self->flush(); } + +#============================================================= + +=head2 flush + +=head3 DESCRIPTION + + Polls a dialog event to refresh the dialog + +=cut + +#============================================================= sub flush { my ($self) = @_; - $self->{mainw}->recalcLayout(); - $self->{mainw}->doneMultipleChanges(); - $self->{mainw}->waitForEvent(10); + $self->main_dialog->startMultipleChanges(); + $self->main_dialog->recalcLayout(); + $self->main_dialog->doneMultipleChanges(); - $self->{mainw}->pollEvent(); + if ($self->main_dialog->isTopmostDialog()) { + $self->main_dialog->waitForEvent(10); + $self->main_dialog->pollEvent(); + } + else { + carp "This dialog is not a top most dialog\n"; + } yui::YUI::app()->redrawScreen(); } +#============================================================= + +=head2 label + +=head3 INPUT + + $text: text to be shown on label + +=head3 DESCRIPTION + + Sets the label text + +=cut + +#============================================================= sub label { - my ($self, $label) = @_; + my ($self, $text) = @_; + + $self->main_dialog->startMultipleChanges(); + $self->label_widget->setValue($text) if $text; + $self->main_dialog->doneMultipleChanges(); - $self->{mainw}->startMultipleChanges(); - $self->{label}->setValue($label) if $label; - #select(undef, undef, undef, 0.1); #- hackish :-( $self->flush(); } +#============================================================= + +=head2 progress + +=head3 INPUT + + $value: integer value in the range 0..100 + +=head3 DESCRIPTION + + Sets the progress bar percentage value + +=cut + +#============================================================= sub progress { my ($self, $value) = @_; - state $time; - $time = 0 if(!defined($time)); + state $time = 0; + $value = 0 if !defined($value) || $value < 0; $value = 100 if 100 < $value; - $self->{progressbar}->setValue($value); + + $self->progressbar->setValue($value); return if Time::HiRes::clock_gettime() - $time < 0.333; $time = Time::HiRes::clock_gettime(); - $self->{mainw}->startMultipleChanges(); + $self->flush(); } -sub DESTROY { - my ($self) = @_; - #mygtk2::may_destroy($self); - $self and $self->{mainw}->destroy; - #$self = undef; - $self->{cancel} = undef; #- in case we'll do another one later -} +#============================================================= -sub validate_cancel { - my ($self, $cancel_msg, $cancel_cb) = @_; - $self->{mainw}->startMultipleChanges(); - if (!$self->{cancel}) { - $self->{cancel} = $self->{factory}->createIconButton($self->{vbox},"",$cancel_msg); - #gtkpack__( - #$self->{vbox}, - #$self->{hbox_cancel} = gtkpack__( - #gtknew('HButtonBox'), - #$self->{cancel} = gtknew('Button', text => $cancel_msg, clicked => \&$cancel_cb), - #), - #); - } - #$self->{cancel}->set_sensitive(1); - #$self->{cancel}->show; - $self->flush(); -} +=head2 DEMOLISH -sub invalidate_cancel { - my ($self) = @_; - $self->{cancel} and $self->{cancel}->setEnabled(0); -} +=head3 INPUT -sub invalidate_cancel_forever { - my ($self) = @_; - #$self->{hbox_cancel} or return; - #$self->{hbox_cancel}->destroy; - # FIXME: temporary workaround that prevents - # Gtk2::Label::set_text() set_text_internal() -> queue_resize() -> - # size_allocate() call chain to mess up when ->shrink_topwindow() - # has been called (#32613): - #$self->shrink_topwindow; + $val: boolean value indicating whether or not this method + was called as part of the global destruction process + (when the Perl interpreter exits) + +=head3 DESCRIPTION + + Moose provides a hook for object destruction with the + DEMOLISH method as it does for construtor with BUILD + +=cut + +#============================================================= +sub DEMOLISH { + my ($self, $val) = @_; + + $self->main_dialog->destroy if !$self->parent; } +# TODO cancel button cannot be easily managed in libyui polling events +# removed atm +# +# sub validate_cancel { +# my ($self, $cancel_msg, $cancel_cb) = @_; +# $self->{main_dialog}->startMultipleChanges(); +# if (!$self->{cancel}) { +# $self->{cancel} = $self->{factory}->createIconButton($self->{vbox},"",$cancel_msg); +# #gtkpack__( +# #$self->{vbox}, +# #$self->{hbox_cancel} = gtkpack__( +# #gtknew('HButtonBox'), +# #$self->{cancel} = gtknew('Button', text => $cancel_msg, clicked => \&$cancel_cb), +# #), +# #); +# } +# #$self->{cancel}->set_sensitive(1); +# #$self->{cancel}->show; +# $self->flush(); +# } +# +# sub invalidate_cancel { +# my ($self) = @_; +# $self->{cancel} and $self->{cancel}->setEnabled(0); +# } +# +# sub invalidate_cancel_forever { +# my ($self) = @_; +# #$self->{hbox_cancel} or return; +# #$self->{hbox_cancel}->destroy; +# # FIXME: temporary workaround that prevents +# # Gtk2::Label::set_text() set_text_internal() -> queue_resize() -> +# # size_allocate() call chain to mess up when ->shrink_topwindow() +# # has been called (#32613): +# #$self->shrink_topwindow; +# } + 1; diff --git a/lib/AdminPanel/Rpmdragora/pkg.pm b/lib/AdminPanel/Rpmdragora/pkg.pm index 96e5b54d..f8495184 100644 --- a/lib/AdminPanel/Rpmdragora/pkg.pm +++ b/lib/AdminPanel/Rpmdragora/pkg.pm @@ -141,9 +141,9 @@ sub extract_header { $bar_id = statusbar_msg($loc->N("Getting '%s' from XML meta-data...", $xml_info), 0); my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm }; if (my $xml_info_file = eval { urpm::media::any_xml_info($urpm, $medium, $xml_info, undef, sub { - $gurpm ||= AdminPanel::Rpmdragora::gurpm->new($loc->N("Please wait"), - '', # FIXME: add a real string after cooker - transient => $::main_window); + $gurpm ||= AdminPanel::Rpmdragora::gurpm->new( + text => $loc->N("Please wait"), + ); download_callback($gurpm, @_) or goto header_non_available; }) }) { @@ -213,7 +213,7 @@ sub download_callback { if ($mode eq 'start') { $gurpm->label($loc->N("Downloading package `%s'...", urpm::util::basename($file))); - $gurpm->validate_cancel(but($loc->N("Cancel")), sub { $canceled = 1 }); +# $gurpm->validate_cancel(but($loc->N("Cancel")), sub { $canceled = 1 }); } elsif ($mode eq 'progress') { $gurpm->label( join("\n", @@ -228,7 +228,7 @@ sub download_callback { $gurpm->progress(ceil($percent)); } elsif ($mode eq 'end') { $gurpm->progress(100); - $gurpm->invalidate_cancel; +# $gurpm->invalidate_cancel; } !$canceled; } @@ -457,7 +457,9 @@ sub get_pkgs { myexit (-1) if (warn_about_media($w, %options) == -1); - my $gurpm = AdminPanel::Rpmdragora::gurpm->new(1 ? $loc->N("Please wait") : $loc->N("Package installation..."), $loc->N("Initializing..."), transient => $::main_window); + my $gurpm = AdminPanel::Rpmdragora::gurpm->new( + text => $loc->N("Please wait"), + ); my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm }; my $urpm = open_urpmi_db(update => $probe_only_for_updates && !is_it_a_devel_distro()); @@ -815,7 +817,10 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( # select packages to uninstall for !update mode: perform_removal($urpm, { map { $_ => $pkgs->{$_} } @to_remove }) if !$probe_only_for_updates; - $gurpm = AdminPanel::Rpmdragora::gurpm->new($loc->N("Please wait"), $loc->N("Initializing..."), transient => $::main_window); + $gurpm = AdminPanel::Rpmdragora::gurpm->new( + text => $loc->N("Please wait"), + title => $loc->N("Initializing..."), + ); # my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm }; my $something_installed; @@ -925,7 +930,7 @@ sub perform_installation { #- (partially) duplicated from /usr/sbin/urpmi :-( }, post_download => sub { $canceled and goto return_with_exit_code; - $gurpm->invalidate_cancel_forever; +# $gurpm->invalidate_cancel_forever; }, need_restart => sub { my ($need_restart_formatted) = @_; @@ -1025,7 +1030,9 @@ sub perform_removal { my ($urpm, $pkgs) = @_; my @toremove = map { MDK::Common::Func::if_($pkgs->{$_}{selected}, $pkgs->{$_}{urpm_name}) } keys %$pkgs; return if !@toremove; - my $gurpm = AdminPanel::Rpmdragora::gurpm->new(1 ? $loc->N("Please wait") : $loc->N("Please wait, removing packages..."), $loc->N("Initializing..."), transient => $::main_window); + my $gurpm = AdminPanel::Rpmdragora::gurpm->new( + text => $loc->N("Please wait") + ); my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm }; my $may_be_orphans = 1; diff --git a/lib/AdminPanel/Shared/GUI.pm b/lib/AdminPanel/Shared/GUI.pm index bdbc1fcf..e3052767 100644 --- a/lib/AdminPanel/Shared/GUI.pm +++ b/lib/AdminPanel/Shared/GUI.pm @@ -90,8 +90,8 @@ sub _localeInitialize { =head3 DESCRIPTION -This function creates an Warning dialog and show the message -passed as input. + This function creates an Warning dialog and show the message + passed as input. =cut @@ -128,15 +128,15 @@ sub warningMsgBox { =head3 INPUT -$info: HASH, information to be passed to the dialog. - title => dialog title - text => string to be swhon into the dialog - richtext => 1 if using rich text + $info: HASH, information to be passed to the dialog. + title => dialog title + text => string to be swhon into the dialog + richtext => 1 if using rich text =head3 DESCRIPTION -This function creates an Info dialog and show the message -passed as input. + This function creates an Info dialog and show the message + passed as input. =cut @@ -174,14 +174,14 @@ sub infoMsgBox { =head3 INPUT -$info: HASH, information to be passed to the dialog. - title => dialog title - text => string to be swhon into the dialog - richtext => 1 if using rich text + $info: HASH, information to be passed to the dialog. + title => dialog title + text => string to be swhon into the dialog + richtext => 1 if using rich text =head3 DESCRIPTION -This function creates a dialog and show the message passed as input. + This function creates a dialog and show the message passed as input. =cut @@ -218,10 +218,10 @@ sub msgBox { =head3 INPUT -$info: HASH, information to be passed to the dialog. - title => dialog title - text => string to be swhon into the dialog - richtext => 1 if using rich text + $info: HASH, information to be passed to the dialog. + title => dialog title + text => string to be swhon into the dialog + richtext => 1 if using rich text =head3 OUTPUT @@ -230,8 +230,8 @@ $info: HASH, information to be passed to the dialog. =head3 DESCRIPTION -This function create an OK-Cancel dialog with a 'title' and a -'text' passed as parameters. + This function create an OK-Cancel dialog with a 'title' and a + 'text' passed as parameters. =cut @@ -270,11 +270,11 @@ sub ask_OkCancel { =head3 INPUT -$info: HASH, information to be passed to the dialog. - title => dialog title - text => string to be swhon into the dialog - richtext => 1 if using rich text - default_button => (optional) 1: "Yes" (any other values "No") + $info: HASH, information to be passed to the dialog. + title => dialog title + text => string to be swhon into the dialog + richtext => 1 if using rich text + default_button => (optional) 1: "Yes" (any other values "No") =head3 OUTPUT @@ -283,8 +283,8 @@ $info: HASH, information to be passed to the dialog. =head3 DESCRIPTION -This function create a Yes-No dialog with a 'title' and a -question 'text' passed as parameters. + This function create a Yes-No dialog with a 'title' and a + question 'text' passed as parameters. =cut @@ -434,12 +434,12 @@ sub arrayListToYItemCollection { =head3 INPUT -$info: HASH, information to be passed to the dialog. - title => dialog title - header => combobox header - default_item => selected item if any - list => item list - default_button => (optional) 1: Select (any other values Cancel) + $info: HASH, information to be passed to the dialog. + title => dialog title + header => combobox header + default_item => selected item if any + list => item list + default_button => (optional) 1: Select (any other values Cancel) =head3 OUTPUT @@ -448,8 +448,8 @@ $info: HASH, information to be passed to the dialog. =head3 DESCRIPTION -This function create a dialog with a combobox in which to -choose an item from a given list. + This function create a dialog with a combobox in which to + choose an item from a given list. =cut @@ -849,8 +849,8 @@ sub hashTreeToYItemCollection { =head3 DESCRIPTION -This function create a dialog with a combobox in which to -choose an item from a given list. + This function create a dialog with a combobox in which to + choose an item from a given list. =cut @@ -966,6 +966,143 @@ sub ask_fromTreeList { } +#============================================================= + +=head2 select_fromList + +=head3 INPUT + + $info: HASH, information to be passed to the dialog. + title => dialog title + info_label => optional info text + header => column header hash reference{ + text_column => text column header + check_column => + } + list => item list hash reference + containing { + text => item text + selected => 0 ur undefined means unchecked + } + +=head3 OUTPUT + + selection: list of selected items + +=head3 DESCRIPTION + + This function create a dialog cotaining a table with a list of + items to be checked. The list of the checked items is returned. + +=cut + +#============================================================= + +sub select_fromList { + my ($self, $info) = @_; + + die "Missing dialog information" if (!$info); + die "Title is mandatory" if (! exists $info->{title}); + die "Header is mandatory" if (! exists $info->{header}); + die "Header text column is mandatory" if (! $info->{header}->{text_column}); + die "List is mandatory" if (! exists $info->{list} ); + my $list = $info->{list}; + die "At least one element is mandatory into list" if (scalar(@$list) < 1); + + my $selection = []; + + my $mageiaPlugin = "mga"; + my $factory = yui::YUI::widgetFactory; + my $mgaFactory = yui::YExternalWidgets::externalWidgetFactory($mageiaPlugin); + $mgaFactory = yui::YMGAWidgetFactory::getYMGAWidgetFactory($mgaFactory); + + ## push application title + my $appTitle = yui::YUI::app()->applicationTitle(); + ## set new title to get it in dialog + yui::YUI::app()->setApplicationTitle($info->{title}); + + my $dlg = $factory->createPopupDialog($yui::YDialogNormalColor); + my $layout = $factory->createVBox($dlg); + + if ($info->{info_label}) { + $factory->createLabel($layout, $info->{info_label}); + } + + my $yTableHeader = new yui::YTableHeader(); + $yTableHeader->addColumn($info->{header}->{text_column}, $yui::YAlignBegin); + $yTableHeader->addColumn($info->{header}->{check_column} || '', $yui::YAlignBegin); + + ## service list (serviceBox) + my $selectionTable = $mgaFactory->createCBTable( + $layout, + $yTableHeader, + $yui::YCBTableCheckBoxOnLastColumn + ); + $selectionTable->setImmediateMode(1); + $selectionTable->setWeight($yui::YD_HORIZ, 75); + + $selectionTable->startMultipleChanges(); + $selectionTable->deleteAllItems(); + my $itemCollection = new yui::YItemCollection; + ## NOTE do not sort to preserve item indexes + foreach (@{$list}) { + my $text = $_->{text} || die "item text is mandatory"; + + my $item = new yui::YCBTableItem($text); + $item->check( $_->{checked} ); + $itemCollection->push($item); + $item->DISOWN(); + } + $selectionTable->addItems($itemCollection); + $selectionTable->doneMultipleChanges(); + + my $align = $factory->createRight($layout); + my $hbox = $factory->createHBox($align); + $factory->createVSpacing($hbox, 1.0); + my $okButton = $factory->createPushButton($hbox, $self->loc->N("Ok")); + $dlg->setDefaultButton($okButton); + $dlg->recalcLayout(); + + while (1) { + my $event = $dlg->waitForEvent(); + + my $eventType = $event->eventType(); + #event type checking + if ($eventType == $yui::YEvent::CancelEvent) { + last; + } + elsif ($eventType == $yui::YEvent::WidgetEvent) { + # widget selected + my $widget = $event->widget(); + + if ($widget == $okButton) { + last; + } + elsif ($widget == $selectionTable) { + my $wEvent = yui::toYWidgetEvent($event); + if ($wEvent->reason() == $yui::YEvent::ValueChanged) { + my $item = $selectionTable->changedItem(); + if ($item) { + my $index = $item->index(); + $list->[$index]->{checked} = $item->checked(); + } + } + } + } + } + + destroy $dlg; + + #restore old application title + yui::YUI::app()->setApplicationTitle($appTitle); + + foreach (@{$list}) { + push @{$selection}, $_->{text} if $_->{checked}; + } + + return $selection; +} + no Moose; __PACKAGE__->meta->make_immutable; diff --git a/lib/AdminPanel/Shared/TimeZone.pm b/lib/AdminPanel/Shared/TimeZone.pm index 9add8014..112610c2 100644 --- a/lib/AdminPanel/Shared/TimeZone.pm +++ b/lib/AdminPanel/Shared/TimeZone.pm @@ -451,9 +451,9 @@ sub writeConfiguration { # if we are going to use systemd then we have to remove the link only # if it is not a link, becuase it should be managed by systemd it self # eval { unlink '/etc/localtime' } unless -l '/etc/localtime'; -# eval { unlink '/etc/localtime' }; -# eval { symlink $tz, '/etc/localtime' }; - eval { File::copy($tz, '/etc/localtime') } ; + unlink '/etc/localtime' or Sys::Syslog::syslog('info|local1', "unlinking /etc/localtime failed"); + Sys::Syslog::syslog('info|local1', "Setting $tz as localtime"); + symlink $tz, '/etc/localtime' or Sys::Syslog::syslog('info|local1', "linking $tz to /etc/localtime failed"); my $adjtime_file = '/etc/adjtime'; my @adjtime = MDK::Common::File::cat_($adjtime_file); diff --git a/lib/AdminPanel/rpmdragora.pm b/lib/AdminPanel/rpmdragora.pm index 16c91257..fd6f5e0c 100644 --- a/lib/AdminPanel/rpmdragora.pm +++ b/lib/AdminPanel/rpmdragora.pm @@ -233,9 +233,8 @@ our %config = ( sub readconf() { ${$config{$_}{var}} = $config{$_}{default} foreach keys %config; foreach my $l (MDK::Common::File::cat_($configfile)) { - foreach (keys %config) { - ${$config{$_}{var}} = [ split ' ', $1 ] if $l =~ /^\Q$_\E(.*)/; - } + my ($key, @values) = split ' ', $l; + ${$config{$key}{var}} = \@values if scalar @values; } # special cases: $::rpmdragora_options{'no-confirmation'} = $no_confirmation->[0] if !defined $::rpmdragora_options{'no-confirmation'}; @@ -248,7 +247,9 @@ sub writeconf() { # special case: $no_confirmation->[0] = $::rpmdragora_options{'no-confirmation'}; - MDK::Common::File::output($configfile, map { "$_ " . (ref ${$config{$_}{var}} ? join(' ', @${$config{$_}{var}}) : '') . "\n" } sort keys %config); + my @config_content = map { "$_ " . (ref ${$config{$_}{var}} ? join(' ', @${$config{$_}{var}}) : '') . "\n" } sort keys %config; + MDK::Common::File::output($configfile, @config_content); + print "writeconf done!\n"; } sub getbanner() { @@ -1090,8 +1091,9 @@ sub mirrors { dir => $cachedir, callback => sub { $gurpm ||= - AdminPanel::Rpmdragora::gurpm->new($loc->N("Please wait"), - transient => $::main_window); + AdminPanel::Rpmdragora::gurpm->new( + text => $loc->N("Please wait"), + ); $canceled ||= !AdminPanel::Rpmdragora::pkg::download_callback($gurpm, @_); $gurpm->flush(); diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index e24b3865..29077b07 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -28,7 +28,7 @@ use File::ShareDir ':ALL'; -use MDK::Common::Func qw(any if_); +use MDK::Common::Func qw(any if_ before_leaving); use utf8; use MDK::Common::DataStructure qw(uniq intersection); @@ -73,46 +73,50 @@ my $loc = AdminPanel::rpmdragora::locale(); my %elems; -my $old_value; - -sub viewbox_callback { +sub _viewbox_callback { my ($selection, $options, $wanted_categories) = @_; - my $val = $selection; - $old_value="" if(!defined($old_value)); - return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events + state $old_index = -1; + + # TODO add a check on selection type YItem + my $curr_index = $selection->index(); + return 0 if $curr_index == $old_index; yui::YUI::app()->busyCursor(); - $old_value = $val; - $default_list_mode = $options->{rviews}{$val}; + $old_index = $curr_index; + $default_list_mode = $options->{rviews}->[$curr_index]; # NOTE an undef value assignment produces a an array containing undef that is not a valid value to pass to # join into writeconf() - @$mandrakeupdate_wanted_categories = $wanted_categories->{$options->{rviews}{$val}} ? - @{$wanted_categories->{$options->{rviews}{$val}}} : + @$mandrakeupdate_wanted_categories = $wanted_categories->{$options->{rviews}->[$curr_index]} ? + @{$wanted_categories->{$options->{rviews}->[$curr_index]}} : (); - if ($options->{tree_mode} ne $val) { - $tree_mode->[0] = $options->{tree_mode} = $options->{rviews}{$val}; + if ($options->{tree_mode} ne $options->{rviews}->[$curr_index]) { + $tree_mode->[0] = $options->{tree_mode} = $options->{rviews}->[$curr_index]; $tree_flat->[0] = $options->{state}{flat}; reset_search(); - switch_pkg_list_mode($options->{rviews}{$val}); + switch_pkg_list_mode($options->{rviews}->[$curr_index]); $options->{rebuild_tree}->(); } yui::YUI::app()->normalCursor(); + + return 1; } -sub filterbox_callback { +sub _filterbox_callback { my ($selection, $options, $rfilters) = @_; - state $oldval; - my $val = $selection; - return if $val eq $oldval; # workarounding gtk+ sending us sometimes twice events + state $old_index = -1; + + # TODO add a check on selection type YItem + my $curr_index = $selection->index(); + return 0 if $curr_index == $old_index; yui::YUI::app()->busyCursor(); - $oldval = $val; - $val = $$rfilters{$val}; + $old_index = $curr_index; + my $val = $rfilters->[$curr_index]; if ($filter->[0] ne $val) { $filter->[0] = $val; reset_search(); @@ -121,9 +125,37 @@ sub filterbox_callback { } yui::YUI::app()->normalCursor(); + + return 1; } + +sub _searchmenu_callback { + my ($selection, $options, $search_types, $current_search_type) = @_; + state $old_index = -1; + + # TODO add a check on selection type YItem + my $curr_index = $selection->index(); + return 0 if $curr_index == $old_index; + + yui::YUI::app()->busyCursor(); + + $old_index = $curr_index; + my $val = $search_types->[$curr_index]; + if ($$current_search_type ne $val) { + $$current_search_type = $val; + reset_search(); + slow_func(sub { switch_pkg_list_mode($default_list_mode) }); + $options->{rebuild_tree}->(); + } + + yui::YUI::app()->normalCursor(); + + return 1; +} + + my $current_group = -1; -sub tree_callback { +sub _tree_callback { my ($selection, $options) = @_; #OLD my ($model, $iter) = $tree->currentItem(); #OLD return if !$iter; @@ -154,7 +186,7 @@ sub tree_callback { return; } -sub detaillist_changeditem_callback { +sub _detaillist_changeditem_callback { my ($detail_list, $options) = @_; my $changedItem = $detail_list->changedItem(); return if (!$changedItem); @@ -227,8 +259,10 @@ sub _do_search($$$$$$) { my $searchw = $factory->createPopupDialog; my $vbox = $factory->createVBox($searchw); my $lblWIP = $factory->createLabel($vbox, $loc->N("Please wait, searching...")); - my $searchprogress = $factory->createProgressBar($vbox, 'ProgressBar'); - my $stop_button = $factory->createIconButton($vbox,"",$loc->N("Stop")); + my $searchprogress = $factory->createProgressBar($vbox, ''); + + my $replace_pnt = $factory->createReplacePoint($vbox); +# my $stop_button = $factory->createIconButton($vbox,"",$loc->N("Stop")); #gtkadd( #$searchw->{window}, @@ -246,86 +280,90 @@ sub _do_search($$$$$$) { #), #); #$searchw->sync; - $searchw->pollEvent(); $searchw->recalcLayout(); - $searchw->doneMultipleChanges(); + $searchw->pollEvent(); + # should probably not account backports packages or find a way to search them: - my $total_size = keys %$pkgs; - my $progresscount; - - my $update_search_pb = sub { - $progresscount++; - if (!($progresscount % 100)) { - $progresscount <= $total_size and $searchprogress->setValue($progresscount/$total_size); - $searchw->flush; # refresh and handle clicks - } - }; - foreach my $medium (grep { !$_->{ignore} } @{$urpm->{media}}) { - $searchstop and last; - my $gurpm; # per medium download progress bar (if needed) - my $_gurpm_clean_guard = before_leaving { undef $gurpm }; - my $xml_info_file = - urpm::media::any_xml_info($urpm, $medium, - ($current_search_type eq 'files' ? 'files' : 'info'), - undef, - sub { - $gurpm ||= AdminPanel::Rpmdragora::gurpm->new($loc->N("Please wait"), - transient => $::main_window); - download_callback($gurpm, @_) or do { - $searchstop = 1; - }; - }); - if (!$xml_info_file) { - $urpm->{error}($loc->N("no xml-info available for medium \"%s\"", $medium->{name})); - next; - } - $searchstop and last; - - require urpm::xml_info; - require urpm::xml_info_pkg; - - $urpm->{log}("getting information from $xml_info_file"); - if ($current_search_type eq 'files') { - # special version for speed (3x faster), hopefully fully compatible - my $F = urpm::xml_info::open_lzma($xml_info_file); - my $fn; - local $_; - while (<$F>) { - if ($searchstop) { - statusbar_msg($loc->N("Search aborted"), 1); - goto end_search; - } - if (m!^<!) { - ($fn) = /fn="(.*)"/; - $update_search_pb->(); - } elsif (/$entry_rx/) { - $fn or $urpm->{fatal}("fast algorithm is broken, please report a bug"); - push @search_results, $fn; - } - } - } else { - eval { - urpm::xml_info::do_something_with_nodes( - 'info', - $xml_info_file, - sub { - $searchstop and die 'search aborted'; - my ($node) = @_; - $update_search_pb->(); - push @search_results, $node->{fn} if $node->{description} =~ $entry_rx; - #$searchstop and last; - return 0 || $searchstop; - }, - ); - }; - my $err = $@; - if ($err =~ /search aborted/) { + my $total_size = scalar keys %$pkgs; + my $progresscount = 0; + + my $update_search_pb = sub { + $progresscount++; + my $val = int($progresscount * 100 / $total_size); + $searchprogress->setValue($val); + $searchw->pollEvent() if $searchw->isTopmostDialog(); # refresh only if top most or crashing + }; + my $gurpm; # per medium download progress bar (if needed) + my $_gurpm_clean_guard = MDK::Common::Func::before_leaving { undef $gurpm }; + foreach my $medium (grep { !$_->{ignore} } @{$urpm->{media}}) { + $searchstop and last; + + my $xml_info_file = + urpm::media::any_xml_info($urpm, $medium, + ($current_search_type eq 'files' ? 'files' : 'info'), + undef, + sub { + $gurpm ||= AdminPanel::Rpmdragora::gurpm->new( + text => $loc->N("Please wait"), + main_dialog => $searchw, + parent => $replace_pnt, + ); + $gurpm->progress(0); + download_callback($gurpm, @_) or do { + $searchstop = 1; + }; + }); + if (!$xml_info_file) { + $urpm->{error}($loc->N("no xml-info available for medium \"%s\"", $medium->{name})); + next; + } + $searchstop and last; + + require urpm::xml_info; + require urpm::xml_info_pkg; + + $urpm->{log}("getting information from $xml_info_file"); + if ($current_search_type eq 'files') { + # special version for speed (3x faster), hopefully fully compatible + my $F = urpm::xml_info::open_lzma($xml_info_file); + my $fn; + local $_; + while (<$F>) { + if ($searchstop) { statusbar_msg($loc->N("Search aborted"), 1); + goto end_search; } + if (m!^<!) { + ($fn) = /fn="(.*)"/; + $update_search_pb->(); + } elsif (/$entry_rx/) { + $fn or $urpm->{fatal}("fast algorithm is broken, please report a bug"); + push @search_results, $fn; + } + } + } else { + eval { + urpm::xml_info::do_something_with_nodes( + 'info', + $xml_info_file, + sub { + $searchstop and die 'search aborted'; + my ($node) = @_; + $update_search_pb->(); + push @search_results, $node->{fn} if $node->{description} =~ $entry_rx; + #$searchstop and last; + return 0 || $searchstop; + }, + ); + }; + my $err = $@; + if ($err =~ /search aborted/) { + statusbar_msg($loc->N("Search aborted"), 1); } } + } - end_search: + end_search: @search_results = uniq(@search_results); #- there can be multiple packages with same version/release for different arch's @search_results = intersection(\@search_results, \@filtered_pkgs); $searchw->destroy; @@ -358,11 +396,11 @@ sub _do_search($$$$$$) { my $tree_selection = $tree->currentItem(); } -sub quit { +sub _quit { real_quit(); } -sub run_treeview_dialog { +sub _run_treeview_dialog { my ($callback_action) = @_; my ($options, $tree, $detail_list, $detail_list_model); @@ -416,33 +454,8 @@ sub run_treeview_dialog { $tree = $factory->createTree($hbox_middle, ""); $tree->setWeight(0,20); $tree->setNotify(1); - #OLD $tree->get_selection->set_mode('browse'); - - #OLD $tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::MDV::CellRendererPixWithLabel->new, 'pixbuf' => $grp_columns{icon}, label => $grp_columns{label})); - #OLD $tree->set_headers_visible(0); - - #OLD $detail_list_model = Gtk2::ListStore->new("Glib::String", - # "Gtk2::Gdk::Pixbuf", - # "Glib::String", - # "Glib::Boolean", - # "Glib::String", - # "Glib::String", - # "Glib::String", - # "Glib::String", - # "Glib::Boolean"); - #OLD $detail_list = Gtk2::TreeView->new_with_model($detail_list_model); - my $detail_list_header = new yui::YTableHeader(); - #$detail_list->append_column( - # my $col_sel = Gtk2::TreeViewColumn->new_with_attributes( - # undef, - # Gtk2::CellRendererToggle->new, - # active => $pkg_columns{selected}, - # activatable => $pkg_columns{selectable} - # )); - #$col_sel->set_fixed_width(34); # w/o this the toggle cells are not displayed - #$col_sel->set_sizing('fixed'); - #$col_sel->set_sort_column_id($pkg_columns{selected}); + my $detail_list_header = new yui::YTableHeader(); my $display_arch_col = to_bool(arch() =~ /64/); my @columns = (qw(name summary version release), if_($display_arch_col, 'arch')); @@ -475,44 +488,14 @@ sub run_treeview_dialog { ## check column is first no title needed here, but we need to add it $detail_list_header->addColumn(""); foreach my $col (@columns{@columns}) { - #OLD $detail_list->append_column( - # $col->{widget} = - # Gtk2::TreeViewColumn->new_with_attributes( - # ' ' . $col->{title} . ' ', - # $col->{renderer} = Gtk2::CellRendererText->new, - # ($col->{markup} ? (markup => $col->{markup}) : (text => $col->{text})), - # ) - # ); - #$col->{widget}->set_sort_column_id($col->{markup} || $col->{text}); $detail_list_header->addColumn($col->{title}); } - #OLD $columns{$_}{widget}->set_sizing('autosize') foreach @columns; - #OLD $columns{name}{widget}->set_property('expand', '1'); - #OLD $columns{name}{renderer}->set_property('ellipsize', 'end'); - #OLD $columns{$_}{renderer}->set_property('xpad', '6') foreach @columns; - #OLD $columns{name}{widget}->set_resizable(1); - #OLD $detail_list_model->set_sort_column_id($pkg_columns{text}, 'ascending'); - #OLD $detail_list_model->set_sort_func($pkg_columns{version}, \&sort_callback); - #OLD $detail_list->set_rules_hint(1); - - #OLD $detail_list->append_column( - # my $pixcolumn = - # Gtk2::TreeViewColumn->new_with_attributes( - # #-PO: "Status" should be kept *small* !!! - # $loc->N("Status"), - # my $rdr = Gtk2::CellRendererPixbuf->new, - # 'pixbuf' => $pkg_columns{state_icon}) - # ); - #$rdr->set_fixed_size(34, 24); - #$pixcolumn->set_sort_column_id($pkg_columns{state}); $detail_list_header->addColumn($loc->N("Status")); - # it should be istanciated this way $detail_list = $mgaFactory->createCBTable($hbox_middle,$detail_list_header,$yui::YCBTableCheckBoxOnFirstColumn); $detail_list->setWeight(0,50); $detail_list->setImmediateMode(1); - #OLD compute_main_window_size($w); =for comment my $cursor_to_restore; @@ -548,13 +531,12 @@ sub run_treeview_dialog { my $is_backports = get_inactive_backport_media(fast_open_urpmi_db()); - my %filters = (all => $loc->N("All"), - installed => $loc->N("Installed"), - non_installed => $loc->N("Not installed"), - ); - - my %rfilters = reverse %filters; - + my %filters = ( + all => $loc->N("All"), + installed => $loc->N("Installed"), + non_installed => $loc->N("Not installed"), + ); + my @ordered_filters = (qw (all installed non_installed) ); # handle migrating config file from rpmdragora <= 4.9 if (exists $filters{$default_list_mode}) { @@ -574,21 +556,20 @@ sub run_treeview_dialog { by_source => $loc->N("All packages, by medium repository"), ); - - my %views = (all => $loc->N("All"), - if_($is_backports, backports => - #-PO: Backports media are newer but less-tested versions of some packages in main - #-PO: See http://wiki.mandriva.com/en/Policies/SoftwareMedia#.2Fmain.2Fbackports - $loc->N("Backports")), - meta_pkgs => $loc->N("Meta packages"), - gui_pkgs => $loc->N("Packages with GUI"), - all_updates => $loc->N("All updates"), - security => $loc->N("Security updates"), - bugfix => $loc->N("Bugfixes updates"), - normal => $loc->N("General updates") - ); - my %rviews = reverse %views; - $options->{rviews} = \%rviews; + my %views = ( + all => $loc->N("All"), + if_($is_backports, backports => $loc->N("Backports")), + meta_pkgs => $loc->N("Meta packages"), + gui_pkgs => $loc->N("Packages with GUI"), + all_updates => $loc->N("All updates"), + security => $loc->N("Security updates"), + bugfix => $loc->N("Bugfixes updates"), + normal => $loc->N("General updates") + ); + my @ordered_views = (qw (all meta_pkgs gui_pkgs all_updates security normal) ); + push @ordered_views, 'backports' if $is_backports; + + $options->{rviews} = \@ordered_views; my %default_mode = (install => 'all', # we want the new GUI by default instead of "non_installed" remove => 'installed', @@ -602,76 +583,52 @@ sub run_treeview_dialog { ); my $view_box = $factory->createComboBox($hbox_top,""); - $view_box->addItem($views{all}); - $view_box->addItem($views{meta_pkgs}); - $view_box->addItem($views{gui_pkgs}); - $view_box->addItem($views{all_updates}); - $view_box->addItem($views{security}); - $view_box->addItem($views{normal}); - $view_box->addItem($views{backports}) if($is_backports); + my $itemColl = new yui::YItemCollection; + + foreach (@ordered_views) { + my $item = yui::YItem->new("$views{$_}", 0); + $item->setSelected(1) if defined($views{$default_list_mode}) && $_ eq $default_list_mode; + $itemColl->push($item); + $item->DISOWN(); + } + $view_box->addItems($itemColl); $view_box->setNotify(1); - $view_box->selectItem($view_box->findItem($views{$default_list_mode})) if(defined($views{$default_list_mode})); $options->{tree_submode} ||= $default_list_mode; $options->{tree_subflat} ||= $options->{state}{flat}; -=for comment - * OLD * - my $filter_box = gtknew( - 'ComboBox', - list => [ qw(all installed non_installed) ], text => $filters{$filter->[0]}, - format => sub { $filters{$_[0]} }, - tip => $loc->N("Filter"), - changed => sub { - state $oldval; - my $val = $_[0]->get_text; - return if $val eq $oldval; # workarounding gtk+ sending us sometimes twice events - $oldval = $val; - $val = $rfilters{$val}; - if ($filter->[0] ne $val) { - $filter->[0] = $val; - reset_search(); - slow_func($::main_window->window, sub { switch_pkg_list_mode($default_list_mode) }); - $options->{rebuild_tree}->(); - } - } - ); - - my $view_callback = sub { - my ($val) = @_; - return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events - $old_value = $val; - return if $mode->[0] eq $val; - $mode->[0] = $val; - $tree_flat->[0] = $options->{state}{flat} = member($mode->[0], qw(flat by_leaves by_selection by_size)); - - if ($options->{tree_mode} ne $val) { - reset_search(); - $options->{rebuild_tree}->(); - } - }; -=cut my $filter_box = $factory->createComboBox($hbox_top,""); - $filter_box->addItem($filters{all}); - $filter_box->addItem($filters{installed}); - $filter_box->addItem($filters{non_installed}); - $filter_box->selectItem($filter_box->findItem($filters{$filter->[0]})) if(defined($filters{$filter->[0]})); + $itemColl = new yui::YItemCollection; + + foreach (@ordered_filters) { + my $item = yui::YItem->new("$filters{$_}", 0); + $item->setSelected(1) if defined($filters{$filter->[0]}) && $_ eq $filter->[0]; + $itemColl->push($item); + $item->DISOWN(); + } + $filter_box->addItems($itemColl); $filter_box->setNotify(1); - my @search_types = qw(normal descriptions summaries files); + + my %local_search_types = ( + normal => $loc->N("in names"), + descriptions => $loc->N("in descriptions"), + summaries => $loc->N("in summaries"), + files => $loc->N("in file names"), + ); + my @search_types = ( qw(normal descriptions summaries files) ); my $current_search_type = $search_types[0]; - #OLD my $search_menu = Gtk2::Menu->new; + my $search_menu = $factory->createComboBox($hbox_top,""); - my $i = 0; - my $previous; - foreach ($loc->N("in names"), $loc->N("in descriptions"), $loc->N("in summaries"), $loc->N("in file names")) { - my ($name, $val) = ($_, $i); - #OLD $search_menu->append(gtksignal_connect(gtkshow( - # $previous = Gtk2::RadioMenuItem->new_with_label($previous, $name)), - # activate => sub { $current_search_type = $search_types[$val] })); - $search_menu->addItem($name); - $i++; + $itemColl = new yui::YItemCollection; + foreach (@search_types) { + my $item = yui::YItem->new("$local_search_types{$_}", 0); + $item->setSelected(1) if defined($local_search_types{$current_search_type}) && $_ eq $current_search_type; + $itemColl->push($item); + $item->DISOWN(); } + $search_menu->addItems($itemColl); + $search_menu->setNotify(1); $find_entry = $factory->createInputField($hbox_top, ""); @@ -742,7 +699,7 @@ sub run_treeview_dialog { my $NVR_string = $loc->N("/_Options") . "/" . $loc->N("Search in _full package names"); my $regexp_search_string = $loc->N("/_Options") . "/" . $loc->N("Use _regular expressions in searches"); - my $itemColl = new yui::YItemCollection; + $itemColl = new yui::YItemCollection; # build File menu my %fileMenu = ( widget => $factory->createMenuButton($headbar,$loc->N("File")), @@ -1064,7 +1021,7 @@ sub run_treeview_dialog { my $info_options = {}; # select group and show items evenctually - tree_callback($tree->currentItem(),\%$options); + _tree_callback($tree->currentItem(),\%$options); ######## main loop #################### while(1) { @@ -1074,7 +1031,7 @@ sub run_treeview_dialog { #event type checking if ($eventType == $yui::YEvent::CancelEvent) { - last if quit(); + last if _quit(); } elsif ($eventType == $yui::YEvent::MenuEvent) { ### MENU ### @@ -1096,7 +1053,7 @@ sub run_treeview_dialog { print "Menu " . $menuLabel . " chosen\n"; if ($menuLabel eq $fileMenu{ quit }->label()) { #menu File->Quit - last if quit(); + last if _quit(); } elsif ($menuLabel eq $fileMenu{ update }->label()) { update_sources_interactive($urpm, transient => $my_win) @@ -1157,6 +1114,7 @@ print "Menu " . $menuLabel . " chosen\n"; # widget selected my $widget = $event->widget(); + my $perform_search = 0; if($widget == $reset_search_button) { $find_entry->setValue(''); @@ -1164,9 +1122,7 @@ print "Menu " . $menuLabel . " chosen\n"; $options->{rebuild_tree}->(); } elsif ($widget == $find_button) { - yui::YUI::app()->busyCursor(); - _do_search($find_entry, $tree, $options, $current_search_type, $urpm, $pkgs); - yui::YUI::app()->normalCursor(); + $perform_search = 1; } elsif ($widget == $select_all_button) { toggle_all($options, 1); @@ -1176,13 +1132,22 @@ print "Menu " . $menuLabel . " chosen\n"; do_action($options, $callback_action, $info); } elsif ($widget == $view_box) { - viewbox_callback($view_box->selectedItem()->label(), \%$options, \%wanted_categories); + if (_viewbox_callback($view_box->selectedItem(), \%$options, \%wanted_categories)) { + $perform_search = 1 if $find_entry->value(); + } } elsif ($widget == $filter_box) { - filterbox_callback($filter_box->selectedItem()->label(), \%$options, \%rfilters); + if (_filterbox_callback($filter_box->selectedItem(), \%$options, \@ordered_filters)) { + $perform_search = 1 if $find_entry->value(); + } + } + elsif ($widget == $search_menu) { + if (_searchmenu_callback($search_menu->selectedItem(), \%$options, \@search_types, \$current_search_type)) { + $perform_search = 1 if $find_entry->value(); + } } elsif ($widget == $tree) { - tree_callback($tree->currentItem(),\%$options); + _tree_callback($tree->currentItem(),\%$options); } elsif ($widget == $detail_list){ $info_options = {}; @@ -1190,14 +1155,21 @@ print "Menu " . $menuLabel . " chosen\n"; if ($wEvent->reason() == $yui::YEvent::ValueChanged) { yui::YUI::app()->busyCursor(); - detaillist_changeditem_callback($detail_list, \%$options); + _detaillist_changeditem_callback($detail_list, \%$options); yui::YUI::app()->normalCursor(); - tree_callback($tree->currentItem(),\%$options); + _tree_callback($tree->currentItem(),\%$options); } _detaillist_callback($detail_list->selectedItem(), $info, \%$options); } elsif ($widget == $QuitButton) { - last if quit(); + last if _quit(); + } + + if ($perform_search) { + yui::YUI::app()->busyCursor(); + _do_search($find_entry, $tree, $options, $current_search_type, $urpm, $pkgs); + yui::YUI::app()->normalCursor(); + $perform_search = 0; } } @@ -1238,7 +1210,7 @@ AdminPanel::Rpmdragora::rpmnew::do_merge_if_needed(); init(); -run_treeview_dialog(\&perform_installation); +_run_treeview_dialog(\&perform_installation); writeconf(); diff --git a/t/03-Shared_GUI.t b/t/03-Shared_GUI.t index 1a781cb4..695a4196 100644 --- a/t/03-Shared_GUI.t +++ b/t/03-Shared_GUI.t @@ -39,6 +39,22 @@ SKIP: { }), 'ask_fromList'); diag "ask_fromList got: < " . ($item ? $item : "none") . " >"; + ok(my $selection = $gui->select_fromList({ + title => "Select from list", + header => { + text_column => "Items", + check_column => "selected", + }, + list => [ + { text => 'item 1', checked => 1}, + { text => 'item 2', }, + { text => 'item 3', checked => 0}, + { text => 'item 4', checked => 1}, + { text => 'item 5',}, + ], + }), 'select_fromList'); + diag "select_fromList got: < " . join(' - ', @${selection}) . " >"; + #TODO cancel makes this test failing ok($item = $gui->ask_fromTreeList({title => "Choose from list", header => "Which one do you select? [default is leaf 2]", default_button => 1, default_item => 'leaf 2', |