From 04c78941c004b63807cfd18b0566bf4dd1200180 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 6 Feb 2008 14:05:53 +0000 Subject: (build_expander,extract_header,format_pkg_simplifiedinfo) - stop downloading & parsing the XML meta data on selecting a package (side effect of urpmi-5.x) - download & parse the needed XML meta data on demand (aka only download & parse the needed ones and not all of them) --- Rpmdrake/gui.pm | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'Rpmdrake/gui.pm') 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('' . $spacing . join("\n$spacing", map { "\x{200e}$_" } @{$pkgs->{$key}{files}}) . '') #- 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('' . $spacing . + join("\n$spacing", + map { "\x{200e}$_" } @{$pkgs->{$key}{files}} + ) . '') #- 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); } -- cgit v1.2.1