aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel/Rpmdragora
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2014-11-11 16:02:14 +0100
committerAngelo Naselli <anaselli@linux.it>2014-11-11 16:02:14 +0100
commitde30aad1d8ebaecd288eeee8f8ec67ffae9f5457 (patch)
tree7fabfabcf95210bb0e0caba974a48395feffbe10 /lib/AdminPanel/Rpmdragora
parent3c2e6ffd9014d93ff8f36a71503cfe4424e46628 (diff)
downloadmanatools-de30aad1d8ebaecd288eeee8f8ec67ffae9f5457.tar
manatools-de30aad1d8ebaecd288eeee8f8ec67ffae9f5457.tar.gz
manatools-de30aad1d8ebaecd288eeee8f8ec67ffae9f5457.tar.bz2
manatools-de30aad1d8ebaecd288eeee8f8ec67ffae9f5457.tar.xz
manatools-de30aad1d8ebaecd288eeee8f8ec67ffae9f5457.zip
Fixed package info on demand (Details, Files, Changelog, Deps)
Diffstat (limited to 'lib/AdminPanel/Rpmdragora')
-rw-r--r--lib/AdminPanel/Rpmdragora/formatting.pm30
-rw-r--r--lib/AdminPanel/Rpmdragora/gui.pm87
-rw-r--r--lib/AdminPanel/Rpmdragora/pkg.pm4
3 files changed, 65 insertions, 56 deletions
diff --git a/lib/AdminPanel/Rpmdragora/formatting.pm b/lib/AdminPanel/Rpmdragora/formatting.pm
index c1d7aec4..7f81c298 100644
--- a/lib/AdminPanel/Rpmdragora/formatting.pm
+++ b/lib/AdminPanel/Rpmdragora/formatting.pm
@@ -29,10 +29,8 @@ use utf8;
use POSIX qw(strftime);
use AdminPanel::Shared::Locales;
use AdminPanel::rpmdragora;
-use lib qw(/usr/lib/libDrakX);
use MDK::Common::Various; # included for internal_error subroutine
-use common;
-#use ugtk2 qw(escape_text_for_TextView_markup_format);
+
use Exporter;
our @ISA = qw(Exporter);
@@ -86,11 +84,11 @@ sub ensure_utf8 {
sub rpm_description {
my ($description) = @_;
+
ensure_utf8($description);
- $DB::single = 1;
my ($t, $tmp);
foreach (split "\n", $description) {
- s/^\s*//;
+ s/^\s*//;
if (/^$/ || /^\s*(-|\*|\+|o)\s/) {
$t || $tmp and $t .= "$tmp\n";
$tmp = $_;
@@ -128,27 +126,33 @@ sub pkg2medium {
#- as to_utf8() uses LC_CTYPE for locale encoding and strftime() uses LC_TIME,
#- it doesn't work if those two variables have values with different
#- encodings; but if a user has a so broken setup we can't do much anyway
-sub localtime2changelog { to_utf8(POSIX::strftime("%c", localtime($_[0]))) }
+sub localtime2changelog { $loc->to_utf8(POSIX::strftime("%c", localtime($_[0]))) }
our $spacing = " ";
sub format_changelog_string {
my ($installed_version, $string) = @_;
+
#- preprocess changelog for faster TextView insert reaction
- require Gtk2::Pango;
- my %date_attr = ('weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD);
- my %update_attr = ('style' => 'italic');
my $version;
my $highlight;
- [ map {
+ my $chl = [ map {
my %attrs;
if (/^\*/) {
- add2hash(\%attrs, \%date_attr);
($version) = /(\S*-\S*)\s*$/;
$highlight = $installed_version ne $loc->N("(none)") && 0 < URPM::rpmvercmp($version, $installed_version);
+ if ($highlight) {
+ "<b><i>" . $_ . "</i></b>";
+ }
+ else {
+ "<b>" . $_ . "</b>";
+ }
+ }
+ else {
+ "$spacing" . $_ . "\n";
}
- add2hash(\%attrs, \%update_attr) if $highlight;
- [ "$spacing$_\n", if_(%attrs, \%attrs) ];
} split("\n", $string) ];
+
+ return $chl;
}
sub format_changelog_changelogs {
diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm
index 882187bf..4a3f4832 100644
--- a/lib/AdminPanel/Rpmdragora/gui.pm
+++ b/lib/AdminPanel/Rpmdragora/gui.pm
@@ -64,7 +64,6 @@ our @EXPORT = qw(
$urpm
%grp_columns
%pkg_columns
- %hidden_info
@filtered_pkgs
@initial_selection
ask_browse_tree_given_widgets_for_rpmdragora
@@ -252,31 +251,22 @@ sub get_details {
sub get_new_deps {
my ($urpm, $upkg) = @_;
- my $deps_textview;
- my @a = [ gtkadd(
- gtksignal_connect(
- gtkshow(my $dependencies = Gtk2::Expander->new(format_field($loc->N("New dependencies:")))),
- activate => sub {
- slow_func($::main_window->window, sub {
- my $state = {};
- my $db = open_rpm_db();
- my @requested = $urpm->resolve_requested__no_suggests_(
- $db, $state,
- { $upkg->id => 1 },
- );
- @requested = $urpm->resolve_requested_suggests($db, $state, \@requested);
- undef $db;
- my @nodes_with_deps = map { urpm_name($_) } @requested;
- my @deps = sort { $a cmp $b } difference2(\@nodes_with_deps, [ urpm_name($upkg) ]);
- @deps = $loc->N("All dependencies installed.") if !@deps;
- gtktext_insert($deps_textview, join("\n", @deps));
- });
- }
- ),
- $deps_textview = gtknew('TextView')
- ) ];
- $dependencies->set_use_markup(1);
- @a;
+
+ my $deps = slow_func(undef, sub {
+ my $state = {};
+ my $db = open_rpm_db();
+ my @requested = $urpm->resolve_requested__no_suggests_(
+ $db, $state,
+ { $upkg->id => 1 },
+ );
+ @requested = $urpm->resolve_requested_suggests($db, $state, \@requested);
+ undef $db;
+ my @nodes_with_deps = map { urpm_name($_) } @requested;
+ my @deps = sort { $a cmp $b } difference2(\@nodes_with_deps, [ urpm_name($upkg) ]);
+ @deps = $loc->N("All dependencies installed.") if !@deps;
+ return \@deps;
+ });
+ return $deps;
}
sub get_url_link {
@@ -299,7 +289,7 @@ sub files_format {
my ($files) = @_;
# ugtk2::markup_to_TextView_format(
'<tt>' . $spacing #- to highlight information
- . join("\n$spacing", map { "\x{200e}$_" } @$files)
+ . join("\n\t", @$files)
. '</tt>';
}
@@ -350,7 +340,7 @@ sub format_pkg_simplifiedinfo {
push @$s, get_advisory_link($update_descr) if $is_update;
push @$s, get_description($pkg, $update_descr);
- push @$s, [ "\n" ];
+
my $installed_version = eval { find_installed_version($upkg) };
#push @$s, [ gtkadd(gtkshow(my $details_exp = Gtk2::Expander->new(format_field($loc->N("Details:")))),
@@ -366,28 +356,43 @@ sub format_pkg_simplifiedinfo {
#push @$s, [ build_expander($pkg, $loc->N("Files:"), 'files', sub { files_format($pkg->{files}) }) ];
my $files_link = format_link(format_field($loc->N("Files:")), $hidden_info{files} );
if ($options->{files}) {
- $DB::single = 1;
-# my $files = files_format($pkg->{files});
-# utf8::encode($files);
- $files_link .= join("\n", $pkg->{files});
-# $files_link .= "\n" . $files;
+ my $wait = AdminPanel::rpmdragora::wait_msg();
+ if (!$pkg->{files}) {
+ extract_header($pkg, $urpm, 'files', $installed_version);
+ }
+ my $files = $pkg->{files} ? files_format($pkg->{files}) : $loc->N("(Not available)");
+ utf8::encode($files);
+ $files_link .= "\n\n" . $files;
+ AdminPanel::rpmdragora::remove_wait_msg($wait);
}
push @$s, join("\n", $files_link, "\n");
#push @$s, [ build_expander($pkg, $loc->N("Changelog:"), 'changelog', sub { $pkg->{changelog} }, $installed_version) ];
my $changelog_link = format_link(format_field($loc->N("Changelog:")), $hidden_info{changelog} );
if ($options->{changelog}) {
- $DB::single = 1;
-# my $changelog = $pkg->{changelog};
-# utf8::encode($changelog);
-# $changelog_link .= "\n" . $changelog;
+ my $wait = AdminPanel::rpmdragora::wait_msg();
+ my @changelog = $pkg->{changelog} ? @{$pkg->{changelog}} : ( $loc->N("(Not available)") );
+ if (!$pkg->{changelog} || !scalar @{$pkg->{changelog}} ) {
+ # my ($pkg, $label, $type, $get_data, $o_installed_version) = @_;
+ extract_header($pkg, $urpm, 'changelog', $installed_version);
+ @changelog = $pkg->{changelog} ? @{$pkg->{changelog}} : ( $loc->N("(Not available)") );
+ }
+ utf8::encode(\@changelog);
+ $changelog_link .= "\n\n". join("", @changelog);
+ AdminPanel::rpmdragora::remove_wait_msg($wait);
}
- push @$s, join("\n", $changelog_link, "\n");
+ push @$s, join("\n\n", $changelog_link, "\n");
- if ($upkg->id) { # If not installed
- # push @$s, get_new_deps($urpm, $upkg);
+ my $deps_link = format_link(format_field($loc->N("New dependencies:")), $hidden_info{new_deps} );
+ if ($options->{new_deps}) {
+ if ($upkg->id) { # If not installed
+ $deps_link .= "\n\n". join("\n", @{get_new_deps($urpm, $upkg)});
+ # push @$s, get_new_deps($urpm, $upkg);
+ }
}
- $s;
+ push @$s, join("\n", $deps_link, "\n");
+
+ return $s;
}
sub format_pkg_info {
diff --git a/lib/AdminPanel/Rpmdragora/pkg.pm b/lib/AdminPanel/Rpmdragora/pkg.pm
index 77819285..8f4636d9 100644
--- a/lib/AdminPanel/Rpmdragora/pkg.pm
+++ b/lib/AdminPanel/Rpmdragora/pkg.pm
@@ -173,8 +173,8 @@ sub extract_header {
url => $xml_info_pkgs{$name}{url}
});
} elsif ($xml_info eq 'files') {
- my @files = map { chomp_(to_utf8($_)) } split("\n", $xml_info_pkgs{$name}{files});
- add2hash($pkg, { files => [ @files ? @files : $loc->N("(none)") ] });
+ my @files = map { chomp_($loc->to_utf8($_)) } split("\n", $xml_info_pkgs{$name}{files});
+ add2hash($pkg, { files => scalar(@files) ? \@files : [ $loc->N("(none)") ] });
} elsif ($xml_info eq 'changelog') {
add2hash($pkg, {
changelog => format_changelog_changelogs($o_installed_version,