aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/AdminPanel/Rpmdragora/formatting.pm30
-rw-r--r--lib/AdminPanel/Rpmdragora/gui.pm87
-rw-r--r--lib/AdminPanel/Rpmdragora/pkg.pm4
-rw-r--r--lib/AdminPanel/rpmdragora.pm34
4 files changed, 82 insertions, 73 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,
diff --git a/lib/AdminPanel/rpmdragora.pm b/lib/AdminPanel/rpmdragora.pm
index f4eaac93..76e16e74 100644
--- a/lib/AdminPanel/rpmdragora.pm
+++ b/lib/AdminPanel/rpmdragora.pm
@@ -25,6 +25,7 @@
# $Id: rpmdragora.pm 267936 2010-04-26 16:40:21Z jvictor $
package AdminPanel::rpmdragora;
+use warnings::register;
use lib qw(/usr/lib/libDrakX);
use urpm::download ();
@@ -379,22 +380,17 @@ sub fatal_msg {
sub wait_msg {
my ($msg, %options) = @_;
- #OLD my $mainw = ugtk2->new($loc->N("Please wait"), grab => 1, if_(exists $options{transient}, transient => $options{transient}));
- #$mainw->{real_window}->set_position($options{transient} ? 'center_on_parent' : 'center_always');
- #my $label = $factory->createLabel($vbox, $msg);
- #OLD my $label = ref($msg) =~ /^Gtk/ ? $msg : Gtk2::WrappedLabel->new($msg);
- #gtkadd(
- #$mainw->{window},
- #gtkpack__(
- # gtkset_border_width(Gtk2::VBox->new(0, 5), 6),
- # $label,
- # if_(exists $options{widgets}, @{$options{widgets}}),
- #)
- #);
+
+ if (ref \%options) {
+ warnings::warn("AdminPanel::rpmdragora::wait_msg: options parameter is deprecated, and discarded");
+ }
+
+ my $label = $msg ? $msg : $loc->N("Please wait");
+
my $factory = yui::YUI::widgetFactory;
my $mainw = $factory->createPopupDialog();
my $vbox = $factory->createVBox($mainw);
- my $title = $factory->createLabel($vbox, $loc->N("Please wait"));
+ my $title = $factory->createLabel($vbox, $label);
#$mainw->recalcLayout();
#$mainw->doneMultipleChanges();
$mainw->waitForEvent(10);
@@ -419,23 +415,26 @@ sub but_ { " $_[0] " }
sub slow_func ($&) {
my ($param, $func) = @_;
+ my $retval = 1;
# NOTE busy cursor is not implemented in yui-ncurses
# but we can avoid a waiting dialog in Gtk and QT
if (yui::YUI::app()->isTextMode()) {
my $w = wait_msg($param);
- $func->();
+ $retval = $func->();
remove_wait_msg($w)
}
else {
yui::YUI::app()->busyCursor();
- $func->();
+ $retval = $func->();
yui::YUI::app()->normalCursor();
}
+ return $retval;
}
sub statusbar_msg {
unless ($::statusbar) { #- fallback if no status bar
- if (defined &::wait_msg_) { goto &::wait_msg_ } else { goto &wait_msg }
+ my $msg = shift;
+ return wait_msg($msg);
}
my ($msg, $o_timeout) = @_;
$::statusbar->setLabel($msg);
@@ -454,7 +453,8 @@ sub statusbar_msg {
sub statusbar_msg_remove {
if (!$::statusbar) { #- fallback if no status bar
- goto &remove_wait_msg;
+ my $id = shift;
+ return remove_wait_msg($id);;
}
my ($msg_id) = @_;
#my $cx = $::statusbar->get_context_id("foo");