aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2008-02-08 17:56:04 +0000
committerThierry Vignaud <tv@mandriva.org>2008-02-08 17:56:04 +0000
commitb14a27edd226a46ddddd012ec68fa88cdb3c4045 (patch)
treea1e31778e3484481ce99063ec90940e658f610c2
parent6fb41ace5c3ee7ab7e0a36c0e2840801772911d0 (diff)
downloadrpmdrake-b14a27edd226a46ddddd012ec68fa88cdb3c4045.tar
rpmdrake-b14a27edd226a46ddddd012ec68fa88cdb3c4045.tar.gz
rpmdrake-b14a27edd226a46ddddd012ec68fa88cdb3c4045.tar.bz2
rpmdrake-b14a27edd226a46ddddd012ec68fa88cdb3c4045.tar.xz
rpmdrake-b14a27edd226a46ddddd012ec68fa88cdb3c4045.zip
(format_changelog_string) highlight relevant parts of the changelog (#37208);
updating callers (build_expander, extract_header, format_changelog_changelogs, format_pkg_simplifiedinfo)
-rw-r--r--Rpmdrake/formatting.pm20
-rw-r--r--Rpmdrake/gui.pm6
-rw-r--r--Rpmdrake/pkg.pm9
3 files changed, 25 insertions, 10 deletions
diff --git a/Rpmdrake/formatting.pm b/Rpmdrake/formatting.pm
index 29f187ea..bf8aa987 100644
--- a/Rpmdrake/formatting.pm
+++ b/Rpmdrake/formatting.pm
@@ -98,13 +98,27 @@ sub localtime2changelog { to_utf8(POSIX::strftime("%c", localtime($_[0]))) }
our $spacing = " ";
sub format_changelog_string {
+ my ($installed_version, $string) = @_;
#- preprocess changelog for faster TextView insert reaction
- [ map { [ "$spacing$_\n", if_(/^\*/, { 'weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD }) ] } split("\n", $_[0]) ];
+ my %date_attr = ( 'weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD );
+ my %update_attr = ( 'style' => 'italic');
+ my $version;
+ my $highlight;
+ [ map {
+ my %attrs;
+ if (/^\*/) {
+ add2hash(\%attrs, \%date_attr);
+ ($version) = /(\S*-\S*)\s*$/;
+ $highlight = $installed_version ne N("(none)") && 0 < URPM::rpmvercmp($version, $installed_version);
+ }
+ add2hash(\%attrs, \%update_attr) if $highlight;
+ [ "$spacing$_\n", if_(%attrs, \%attrs) ]
+ } split("\n", $string) ];
}
sub format_changelog_changelogs {
- my (@changelogs) = @_;
- format_changelog_string(join("\n", map {
+ my ($installed_version, @changelogs) = @_;
+ format_changelog_string($installed_version, join("\n", map {
"* " . localtime2changelog($_->{time}) . " $_->{name}\n\n$_->{text}\n";
} @changelogs));
}
diff --git a/Rpmdrake/gui.pm b/Rpmdrake/gui.pm
index 3a46c643..60a9cf5e 100644
--- a/Rpmdrake/gui.pm
+++ b/Rpmdrake/gui.pm
@@ -80,7 +80,7 @@ sub get_summary {
}
sub build_expander {
- my ($pkg, $label, $type, $get_data) = @_;
+ my ($pkg, $label, $type, $get_data, $o_installed_version) = @_;
my $textview;
gtkadd(
gtkshow(my $exp = gtksignal_connect(
@@ -90,7 +90,7 @@ sub build_expander {
return if $first;
$first = 1;
slow_func($::main_window->window, sub {
- extract_header($pkg, $urpm, $type);
+ extract_header($pkg, $urpm, $type, $o_installed_version);
gtktext_insert($textview, $get_data->() || [ [ N("(Not available)") ] ]);
});
})),
@@ -161,7 +161,7 @@ sub format_pkg_simplifiedinfo {
) . '</tt>') #- to highlight information
: ()}) ];
push @$s, [ "\n\n" ];
- push @$s, [ build_expander($pkg, N("Changelog:"), 'changelog', sub { $pkg->{changelog} }) ];
+ push @$s, [ build_expander($pkg, N("Changelog:"), 'changelog', sub { $pkg->{changelog} }, $installed_version) ];
$s;
}
diff --git a/Rpmdrake/pkg.pm b/Rpmdrake/pkg.pm
index 36bfc244..685f7177 100644
--- a/Rpmdrake/pkg.pm
+++ b/Rpmdrake/pkg.pm
@@ -91,7 +91,7 @@ sub run_rpm {
sub extract_header {
- my ($pkg, $urpm, $xml_info) = @_;
+ my ($pkg, $urpm, $xml_info, $o_installed_version) = @_;
my %fields = (
info => 'description',
files => 'files',
@@ -108,7 +108,7 @@ sub extract_header {
if ($p->flag_installed && !$p->flag_upgrade) {
my @files = map { chomp_(to_utf8($_)) } run_rpm("rpm -ql $name");
add2hash($pkg, { files => [ @files ? @files : N("(none)") ],
- changelog => format_changelog_string(to_utf8(scalar(run_rpm("rpm -q --changelog $name")))) });
+ changelog => format_changelog_string($o_installed_version, to_utf8(scalar(run_rpm("rpm -q --changelog $name")))) });
} else {
my $medium = pkg2medium($p, $urpm);
my ($local_source, %xml_info_pkgs, $bar_id);
@@ -153,7 +153,7 @@ sub extract_header {
};
add2hash($pkg, { description => rpm_description($p->description),
files => scalar($p->files) ? [ $p->files ] : [ N("(none)") ],
- changelog => format_changelog_changelogs($p->changelogs) });
+ changelog => format_changelog_changelogs($o_installed_version, $p->changelogs) });
$p->pack_header; # needed in order to call methods on objects outside ->traverse
} elsif ($xml_info_pkgs{$name}) {
if ($xml_info eq 'info') {
@@ -163,7 +163,8 @@ sub extract_header {
add2hash($pkg, { files => [ @files ? @files : N("(none)") ] });
} elsif ($xml_info eq 'changelog') {
add2hash($pkg, {
- changelog => format_changelog_changelogs(@{$xml_info_pkgs{$name}{changelogs}})
+ changelog => format_changelog_changelogs($o_installed_version,
+ @{$xml_info_pkgs{$name}{changelogs}})
});
}
$p->pack_header; # needed in order to call methods on objects outside ->traverse