diff options
author | Angelo Naselli <anaselli@linux.it> | 2014-11-06 17:44:21 +0100 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2014-11-06 17:44:21 +0100 |
commit | 390efecb238391bfe4b0335b4742d66054bde44c (patch) | |
tree | ec9d1fbdb0ee8064f15982d68b98b876b03d9dcd | |
parent | 24c4435d98ea0184bb0c5ccf826db1b993689411 (diff) | |
download | colin-keep-390efecb238391bfe4b0335b4742d66054bde44c.tar colin-keep-390efecb238391bfe4b0335b4742d66054bde44c.tar.gz colin-keep-390efecb238391bfe4b0335b4742d66054bde44c.tar.bz2 colin-keep-390efecb238391bfe4b0335b4742d66054bde44c.tar.xz colin-keep-390efecb238391bfe4b0335b4742d66054bde44c.zip |
Fixed package info layout
-rw-r--r-- | lib/AdminPanel/Rpmdragora/gui.pm | 78 | ||||
-rw-r--r-- | lib/AdminPanel/Rpmdragora/pkg.pm | 2 | ||||
-rwxr-xr-x | modules/rpmdragora/dragoraUpdate | 19 | ||||
-rwxr-xr-x | 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 8bbf859..5606c7c 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 <b>not supported</b> by Mageia."); my $dangerous = $loc->N("It may <b>break</b> 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("<br />", - format_header(join(' - ', $name, $summary)), - "<br />" , - 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} . "<a href=\"". $url ."\">". $url ."</a>"; @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("<h2>".$loc->N("Informations")."</h2>"); + + my $info_text ="<h2>" . $loc->N("Informations") . "</h2>"; my @data = get_info($pkgname); for(@{$data[0]}){ if(ref $_ ne "ARRAY"){ - $infoWidget->setValue($infoWidget->value()."<br />$_"); + $info_text .= "<br />" . $_; }else{ - $infoWidget->setValue($infoWidget->value()."<br />"); - for my $subitem(@{$_}){ - $infoWidget->setValue($infoWidget->value()."<br /> ".$subitem); + $info_text .= "<br />"; + for my $subitem(@{$_}) { + $info_text .= "<br />" . "<br /> " . $subitem; } } } + # change \n to <br/> + $info_text =~ s|\n|<br/>|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 01013ae..7781928 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 1c06f9d..b0c4247 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 ccb53f4..51f2b55 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("<h2>" . $loc->N("Informations") . "</h2>"); return if( ref $selection ne "yui::YItem"); + + my $info_text ="<h2>" . $loc->N("Informations") . "</h2>"; + my @data = get_info($options->{table_item_list}[$selection->index()],$info->parent()->parent()); for(@{$data[0]}){ if(ref $_ ne "ARRAY"){ - $info->setValue($info->value()."<br />$_"); + $info_text .= "<br />" . $_; }else{ - $info->setValue($info->value()."<br />"); - for my $subitem(@{$_}){ - $info->setValue($info->value()."<br /> ".$subitem); + $info_text .= "<br />"; + for my $subitem(@{$_}) { + $info_text .= "<br />" . "<br /> " . $subitem; } } } + # change \n to <br/> + $info_text =~ s|\n|<br/>|g; + + $info->setValue($info_text); } sub do_search($$$$$$$) { |