diff options
author | Thierry Vignaud <tv@mandriva.org> | 2008-02-06 14:05:53 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mandriva.org> | 2008-02-06 14:05:53 +0000 |
commit | 04c78941c004b63807cfd18b0566bf4dd1200180 (patch) | |
tree | d10a9bfde0f6d72bfd1478137d4c25ed5bd5943e /Rpmdrake/gui.pm | |
parent | 1b8061fbbe7bcbfea0402cf1dbec1792d2d62904 (diff) | |
download | rpmdrake-04c78941c004b63807cfd18b0566bf4dd1200180.tar rpmdrake-04c78941c004b63807cfd18b0566bf4dd1200180.tar.gz rpmdrake-04c78941c004b63807cfd18b0566bf4dd1200180.tar.bz2 rpmdrake-04c78941c004b63807cfd18b0566bf4dd1200180.tar.xz rpmdrake-04c78941c004b63807cfd18b0566bf4dd1200180.zip |
(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)
Diffstat (limited to 'Rpmdrake/gui.pm')
-rw-r--r-- | Rpmdrake/gui.pm | 45 |
1 files changed, 32 insertions, 13 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); } |