aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Rpmdrake/gui.pm45
-rw-r--r--Rpmdrake/pkg.pm22
2 files changed, 44 insertions, 23 deletions
diff --git a/Rpmdrake/gui.pm b/Rpmdrake/gui.pm
index 3295db1f..be9951a9 100644
--- a/Rpmdrake/gui.pm
+++ b/Rpmdrake/gui.pm
@@ -39,6 +39,7 @@ use Rpmdrake::icon;
use Rpmdrake::pkg;
use Rpmdrake::icon;
use Gtk2::Gdk::Keysyms;
+use feature 'state';
our @EXPORT = qw(ask_browse_tree_given_widgets_for_rpmdrake build_tree callback_choices compute_main_window_size do_action get_info get_summary is_locale_available node_state pkgs_provider reset_search set_node_state switch_pkg_list_mode toggle_all toggle_nodes
sort_callback
@@ -78,6 +79,27 @@ sub get_summary {
utf8::valid($summary) ? $summary : ();
}
+sub build_expander {
+ my ($key, $label, $type, $get_data) = @_;
+ my $textview;
+ gtkadd(
+ gtkshow(my $exp = gtksignal_connect(
+ Gtk2::Expander->new(format_field($label)),
+ activate => sub {
+ state $first;
+ return if $first;
+ $first = 1;
+ slow_func($::main_window->window, sub {
+ extract_header($pkgs->{$key}, $urpm, $type);
+ gtktext_insert($textview, $get_data->() || [ [ N("(Not available)") ] ]);
+ });
+ })),
+ $textview = gtknew('TextView')
+ );
+ $exp->set_use_markup(1);
+ $exp;
+}
+
sub format_pkg_simplifiedinfo {
my ($pkgs, $key, $urpm, $descriptions) = @_;
@@ -128,18 +150,15 @@ sub format_pkg_simplifiedinfo {
)) ];
$exp0->set_use_markup(1);
push @$s, [ "\n\n" ];
- push @$s, [ gtkadd(gtkshow(my $exp = Gtk2::Expander->new(format_field(N("Files:")))),
- gtknew('TextView', text =>
- exists $pkgs->{$key}{files} ?
- ugtk2::markup_to_TextView_format('<tt>' . $spacing . join("\n$spacing", map { "\x{200e}$_" } @{$pkgs->{$key}{files}}) . '</tt>') #- to highlight information
- : N("(Not available)"),
- )) ];
- $exp->set_use_markup(1);
+ push @$s, [ build_expander($key, N("Files:"), 'files', sub {
+ exists $pkgs->{$key}{files} ?
+ ugtk2::markup_to_TextView_format('<tt>' . $spacing .
+ join("\n$spacing",
+ map { "\x{200e}$_" } @{$pkgs->{$key}{files}}
+ ) . '</tt>') #- to highlight information
+ : ()}) ];
push @$s, [ "\n\n" ];
- push @$s, [ gtkadd(gtkshow(my $exp2 = Gtk2::Expander->new(format_field(N("Changelog:")))),
- gtknew('TextView', text => $pkgs->{$key}{changelog} || N("(Not available)"))
- ) ];
- $exp2->set_use_markup(1);
+ push @$s, [ build_expander($key, N("Changelog:"), 'changelog', sub { $pkgs->{$key}{changelog} }) ];
$s;
}
@@ -785,8 +804,8 @@ sub get_info {
my ($key, $widget) = @_;
#- the package information hasn't been loaded. Instead of rescanning the media, just give up.
exists $pkgs->{$key} or return [ [ N("Description not available for this package\n") ] ];
- exists $pkgs->{$key}{description} && exists $pkgs->{$key}{files}
- or slow_func($widget, sub { extract_header($pkgs->{$key}, $urpm) });
+ #- get the description if needed:
+ exists $pkgs->{$key}{description} or slow_func($widget, sub { extract_header($pkgs->{$key}, $urpm, 'info') });
format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions);
}
diff --git a/Rpmdrake/pkg.pm b/Rpmdrake/pkg.pm
index 66c9dae2..9808974d 100644
--- a/Rpmdrake/pkg.pm
+++ b/Rpmdrake/pkg.pm
@@ -92,7 +92,7 @@ sub run_rpm {
our $spacing = " ";
sub extract_header {
- my ($pkg, $urpm) = @_;
+ my ($pkg, $urpm, $xml_info) = @_;
my $chg_prepro = sub {
#- preprocess changelog for faster TextView insert reaction
[ map { [ "$spacing$_\n", if_(/^\*/, { 'weight' => Gtk2::Pango->PANGO_WEIGHT_BOLD }) ] } split("\n", $_[0]) ];
@@ -112,7 +112,6 @@ sub extract_header {
$local_source = "$dir/" . $p->filename;
$urpm->{log}("getting information from rpms from $dir");
} else {
- foreach my $xml_info ('info', 'files', 'changelog') {
my $gurpm = Rpmdrake::gurpm->new(N("Please wait"), transient => $::main_window);
if (my $xml_info_file = urpm::media::any_xml_info($urpm, $medium, $xml_info, undef, sub {
download_callback($gurpm, @_)
@@ -131,7 +130,6 @@ sub extract_header {
$urpm->{error}(N("No xml info for medium \"%s\", unable to return any result for package %s", $medium->{name}, $name));
}
}
- }
}
#- even if non-root, search for a header in the global cachedir
@@ -148,13 +146,17 @@ sub extract_header {
[ $p->changelog_name ], [ $p->changelog_text ], [ $p->changelog_time ])) });
$p->pack_header; # needed in order to call methods on objects outside ->traverse
} elsif ($xml_info_pkgs{$name}) {
- add2hash($pkg, { description => rpm_description($xml_info_pkgs{$name}{description}) });
- add2hash($pkg, {
- files => [ $xml_info_pkgs{$name}{files} || N("(none)") ],
- changelog => $chg_prepro->(join("\n", map {
- "* " . localtime2changelog($_->{time}) . " $_->{name}\n$_->{text}\n\n";
- } @{$xml_info_pkgs{$name}{changelogs}}))
- });
+ if ($xml_info eq 'info') {
+ add2hash($pkg, { description => rpm_description($xml_info_pkgs{$name}{description}) });
+ } elsif ($xml_info eq 'files') {
+ add2hash($pkg, { files => [ $xml_info_pkgs{$name}{files} || N("(none)") ] });
+ } elsif ($xml_info eq 'changelog') {
+ add2hash($pkg, {
+ changelog => $chg_prepro->(join("\n", map {
+ "* " . localtime2changelog($_->{time}) . " $_->{name}\n$_->{text}\n\n";
+ } @{$xml_info_pkgs{$name}{changelogs}}))
+ });
+ }
$p->pack_header; # needed in order to call methods on objects outside ->traverse
} else {
goto header_non_available;