From 390efecb238391bfe4b0335b4742d66054bde44c Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Thu, 6 Nov 2014 17:44:21 +0100 Subject: Fixed package info layout --- lib/AdminPanel/Rpmdragora/gui.pm | 78 ++++++++++++++++++++++++++++------------ lib/AdminPanel/Rpmdragora/pkg.pm | 2 +- modules/rpmdragora/dragoraUpdate | 19 ++++++++-- modules/rpmdragora/rpmdragora | 17 ++++++--- 4 files changed, 84 insertions(+), 32 deletions(-) diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm index 8bbf859c..5606c7cb 100644 --- a/lib/AdminPanel/Rpmdragora/gui.pm +++ b/lib/AdminPanel/Rpmdragora/gui.pm @@ -87,6 +87,7 @@ our @EXPORT = qw( toggle_all toggle_nodes fast_toggle + setInfoOnWidget ); my $loc = AdminPanel::rpmdragora::locale(); @@ -175,9 +176,11 @@ sub get_string_from_keywords { @media_types = split(':', $distribconf->getvalue($medium_path, 'media_type')) if $distribconf; } + $DB::single = 1; + my $unsupported = $loc->N("It is not supported by Mageia."); my $dangerous = $loc->N("It may break your system."); - my $s; + my $s = ""; $s .= $loc->N("This package is not free software") . "\n" if member('non-free', @media_types); if ($pkgs->{$name}{is_backport} || member('backport', @media_types)) { return join("\n", @@ -204,19 +207,25 @@ sub get_main_text { my ($medium, $fullname, $name, $summary, $is_update, $update_descr) = @_; my $txt = get_string_from_keywords($medium, $fullname); - # TODO my $string = encode_entities($txt); - ensure_utf8($txt); + my $notice = if_($txt, format_field($loc->N("Notice: ")) . $txt . "\n"); + ensure_utf8($notice); - join("
", - format_header(join(' - ', $name, $summary)), - "
" , - if_($txt, format_field($loc->N("Notice: ")) . $txt), - if_($is_update, # is it an update? - format_field($loc->N("Importance: ")) . format_update_field($update_descr->{importance}), - format_field($loc->N("Reason for update: ")) . format_update_field(rpm_description($update_descr->{pre})), - ), - '' # extra empty line - ); + my $hdr = format_header(join(' - ', $name, $summary)) . "\n"; + ensure_utf8($hdr); + + my $update = if_($is_update, # is it an update? + format_field($loc->N("Importance: ")) . format_update_field($update_descr->{importance}) . "\n", + format_field($loc->N("Reason for update: ")) . format_update_field(rpm_description($update_descr->{pre})) . "\n", + ); + ensure_utf8($update); + + # TODO Too many lines + join( + "\n", + $hdr, + $notice, + $update + ); } sub get_details { @@ -276,7 +285,7 @@ sub get_url_link { return if !$url; my @a; - push @a, format_field($loc->N("URL: "))."${spacing}$url"; + push @a, format_field($loc->N("URL: ")) . ${spacing} . "". $url .""; @a; } @@ -992,22 +1001,46 @@ sub callback_choices { } -sub _setInfoOnWidget { +#============================================================= + +=head2 setInfoOnWidget + +=head3 INPUT + + $pckgname: full name of the package + $infoWidget: YRichText object to fill + +=head3 DESCRIPTION + + This function writes on a YRichText object package info + +=cut + +#============================================================= +sub setInfoOnWidget { my ($pkgname, $infoWidget) = @_; + + return if( ref $infoWidget ne "yui::YRichText"); + $infoWidget->setValue(""); - $infoWidget->setValue("

".$loc->N("Informations")."

"); + + my $info_text ="

" . $loc->N("Informations") . "

"; my @data = get_info($pkgname); for(@{$data[0]}){ if(ref $_ ne "ARRAY"){ - $infoWidget->setValue($infoWidget->value()."
$_"); + $info_text .= "
" . $_; }else{ - $infoWidget->setValue($infoWidget->value()."
"); - for my $subitem(@{$_}){ - $infoWidget->setValue($infoWidget->value()."
   ".$subitem); + $info_text .= "
"; + for my $subitem(@{$_}) { + $info_text .= "
" . "
   " . $subitem; } } } + # change \n to
+ $info_text =~ s|\n|
|g; + + $infoWidget->setValue($info_text); } @@ -1067,7 +1100,7 @@ sub deps_msg { my $item = $pkgList->selectedItem(); if ($item) { my $pkg = $item->label(); - _setInfoOnWidget($pkg, $infoBox); + setInfoOnWidget($pkg, $infoBox); } my $retval = 0; @@ -1090,8 +1123,7 @@ sub deps_msg { $item = $pkgList->selectedItem(); if ( $item ) { my $pkg = $item->label(); - $DB::single = 1; - _setInfoOnWidget($pkg, $infoBox); + setInfoOnWidget($pkg, $infoBox); } # $infoBox->setValue( get_info($pkg) ); } diff --git a/lib/AdminPanel/Rpmdragora/pkg.pm b/lib/AdminPanel/Rpmdragora/pkg.pm index 01013ae1..77819285 100644 --- a/lib/AdminPanel/Rpmdragora/pkg.pm +++ b/lib/AdminPanel/Rpmdragora/pkg.pm @@ -125,7 +125,7 @@ sub extract_header { print "p->filename: ". $p->filename."\n"; $local_source = "$dir/" . $p->filename if $dir; print "local_source: $local_source\n"; - if (-e $local_source) { + if ($local_source && -e $local_source) { $bar_id = statusbar_msg($loc->N("Getting information from %s...", $dir), 0); $urpm->{log}("getting information from rpms from $dir"); } else { diff --git a/modules/rpmdragora/dragoraUpdate b/modules/rpmdragora/dragoraUpdate index 1c06f9de..b0c4247d 100755 --- a/modules/rpmdragora/dragoraUpdate +++ b/modules/rpmdragora/dragoraUpdate @@ -216,7 +216,8 @@ sub run_treeview_dialog { ## service list (serviceBox) my $packageTbl = $mgaFactory->createCBTable($vbox, $yTableHeader, $yui::YCBTableCheckBoxOnFirstColumn); - + $factory->createVSpacing($vbox, 1); + my $infoBox = $factory->createRichText($vbox, "", 0); $AdminPanel::Rpmdragora::pkg::probe_only_for_updates = 1; # faster startup $DB::single = 1; @@ -227,7 +228,11 @@ sub run_treeview_dialog { $packageTbl->setImmediateMode(1); $packageTbl->setWeight(0, 50); - + my $item = $packageTbl->selectedItem(); + if ($item) { + my $pkg = $data{$item->index()}{fullname}; + AdminPanel::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox); + } # dialog buttons $factory->createVSpacing($vbox, 1.0); @@ -287,9 +292,14 @@ sub run_treeview_dialog { } elsif ($widget == $packageTbl) { yui::YUI::app()->busyCursor(); + my $item = $packageTbl->selectedItem(); + if ($item) { + my $pkg = $data{$item->index()}{fullname}; + AdminPanel::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox); + } my $wEvent = yui::toYWidgetEvent($event); if ($wEvent->reason() == $yui::YEvent::ValueChanged) { - my $item = $packageTbl->changedItem(); + $item = $packageTbl->changedItem(); if ($item) { my $name = $data{$item->index()}{fullname}; $DB::single = 1; @@ -298,6 +308,9 @@ sub run_treeview_dialog { } yui::YUI::app()->normalCursor(); } + elsif ($widget == $infoBox) { + print "RichText widget Event\n"; + } elsif ($widget == $selectButton) { yui::YUI::app()->busyCursor(); $initialized = 0; diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index ccb53f4e..51f2b55b 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -199,20 +199,27 @@ sub detaillist_changeditem_callback { sub detaillist_callback { my ($selection, $info, $options) = @_; + $info->setValue(""); - $info->setValue("

" . $loc->N("Informations") . "

"); return if( ref $selection ne "yui::YItem"); + + my $info_text ="

" . $loc->N("Informations") . "

"; + my @data = get_info($options->{table_item_list}[$selection->index()],$info->parent()->parent()); for(@{$data[0]}){ if(ref $_ ne "ARRAY"){ - $info->setValue($info->value()."
$_"); + $info_text .= "
" . $_; }else{ - $info->setValue($info->value()."
"); - for my $subitem(@{$_}){ - $info->setValue($info->value()."
   ".$subitem); + $info_text .= "
"; + for my $subitem(@{$_}) { + $info_text .= "
" . "
   " . $subitem; } } } + # change \n to
+ $info_text =~ s|\n|
|g; + + $info->setValue($info_text); } sub do_search($$$$$$$) { -- cgit v1.2.1