aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2014-11-07 00:20:53 +0100
committerAngelo Naselli <anaselli@linux.it>2014-11-07 00:20:53 +0100
commit95592ce9fc2e0edd1168d6d80152730cce9bb2a1 (patch)
tree4c1e8c0080bb87223dd2f2068d77fedc327d597f
parent390efecb238391bfe4b0335b4742d66054bde44c (diff)
downloadcolin-keep-95592ce9fc2e0edd1168d6d80152730cce9bb2a1.tar
colin-keep-95592ce9fc2e0edd1168d6d80152730cce9bb2a1.tar.gz
colin-keep-95592ce9fc2e0edd1168d6d80152730cce9bb2a1.tar.bz2
colin-keep-95592ce9fc2e0edd1168d6d80152730cce9bb2a1.tar.xz
colin-keep-95592ce9fc2e0edd1168d6d80152730cce9bb2a1.zip
- More porting for packages info
- Added a link to manage hidden information (though has problems in ncurses)
-rw-r--r--lib/AdminPanel/Rpmdragora/gui.pm125
-rwxr-xr-xmodules/rpmdragora/dragoraUpdate31
-rwxr-xr-xmodules/rpmdragora/rpmdragora120
3 files changed, 207 insertions, 69 deletions
diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm
index 5606c7c..6985b1a 100644
--- a/lib/AdminPanel/Rpmdragora/gui.pm
+++ b/lib/AdminPanel/Rpmdragora/gui.pm
@@ -64,6 +64,7 @@ our @EXPORT = qw(
$urpm
%grp_columns
%pkg_columns
+ %hidden_info
@filtered_pkgs
@initial_selection
ask_browse_tree_given_widgets_for_rpmdragora
@@ -95,6 +96,13 @@ my $loc = AdminPanel::rpmdragora::locale();
our ($descriptions, %filters, @filtered_pkgs, %filter_methods, $force_displaying_group, $force_rebuild, @initial_selection, $pkgs, $size_free, $size_selected, $urpm);
our ($results_ok, $results_none) = ($loc->N("Search results"), $loc->N("Search results (none)"));
+our %hidden_info = (
+ details => "details",
+ changelog => "changelog",
+ files => "file",
+ new_deps => "new_deps",
+
+);
our %grp_columns = (
label => 0,
icon => 2,
@@ -291,14 +299,42 @@ sub get_url_link {
sub files_format {
my ($files) = @_;
- ugtk2::markup_to_TextView_format(
+# ugtk2::markup_to_TextView_format(
'<tt>' . $spacing #- to highlight information
. join("\n$spacing", map { "\x{200e}$_" } @$files)
- . '</tt>');
+ . '</tt>';
+}
+
+#=============================================================
+
+=head2 format_link
+
+=head3 INPUT
+
+ $description: Description to be shown as link
+ $url: to be reach when click on $description link
+
+=head3 OUTPUT
+
+ $webref: href HTML tag
+
+=head3 DESCRIPTION
+
+ This function returns an href string to be published
+
+=cut
+
+#=============================================================
+sub format_link {
+ my ($description, $url) = @_;
+
+ my $webref = "<a href=\"". $url ."\">". $description ."</a>";
+
+ return $webref;
}
sub format_pkg_simplifiedinfo {
- my ($pkgs, $key, $urpm, $descriptions) = @_;
+ my ($pkgs, $key, $urpm, $descriptions, $options) = @_;
my ($name) = split_fullname($key);
my $pkg = $pkgs->{$key};
my $upkg = $pkg->{pkg};
@@ -323,16 +359,32 @@ sub format_pkg_simplifiedinfo {
#push @$s, [ gtkadd(gtkshow(my $details_exp = Gtk2::Expander->new(format_field($loc->N("Details:")))),
# gtknew('TextView', text => get_details($pkg, $upkg, $installed_version, $raw_medium))) ];
- my $details = get_details($pkg, $upkg, $installed_version, $raw_medium);
- utf8::encode($details);
- push @$s, join("\n", format_field($loc->N("Details:")). "\n" . $details);
- #$details_exp->set_use_markup(1);
- push @$s, [ "\n\n" ];
+ my $detail_link = format_link(format_field($loc->N("Details:")), $hidden_info{details} );
+ if ($options->{details}) {
+ my $details = get_details($pkg, $upkg, $installed_version, $raw_medium);
+ utf8::encode($details);
+ $detail_link .= "\n" . $details;
+ }
+ push @$s, join("\n", $detail_link, "\n");
+
#push @$s, [ build_expander($pkg, $loc->N("Files:"), 'files', sub { files_format($pkg->{files}) }) ];
- push @$s, [ "\n\n" ];
+ my $files_link = format_link(format_field($loc->N("Files:")), $hidden_info{files} );
+ if ($options->{files}) {
+# my $files = files_format($pkg->{files});
+# utf8::encode($files);
+# $files_link .= "\n" . $files;
+ }
+ 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->{files}) {
+# my $changelog = $pkg->{changelog};
+# utf8::encode($changelog);
+# $changelog_link .= "\n" . $changelog;
+ }
+ push @$s, join("\n", $changelog_link, "\n");
- push @$s, [ "\n\n" ];
if ($upkg->id) { # If not installed
# push @$s, get_new_deps($urpm, $upkg);
}
@@ -1018,7 +1070,7 @@ sub callback_choices {
#=============================================================
sub setInfoOnWidget {
- my ($pkgname, $infoWidget) = @_;
+ my ($pkgname, $infoWidget, $options) = @_;
return if( ref $infoWidget ne "yui::YRichText");
@@ -1026,7 +1078,7 @@ sub setInfoOnWidget {
my $info_text ="<h2>" . $loc->N("Informations") . "</h2>";
- my @data = get_info($pkgname);
+ my @data = get_info($pkgname, $options);
for(@{$data[0]}){
if(ref $_ ne "ARRAY"){
$info_text .= "<br />" . $_;
@@ -1467,13 +1519,33 @@ or you already installed all of them."));
statusbar_msg_remove($wait) if defined $wait;
}
+#=============================================================
+
+=head2 get_info
+
+=head3 INPUT
+
+ $key: package full name
+ $options: HASH reference containing:
+ details => show details
+ changelog => show changelog
+ files => show files
+ new_deps => show new dependencies
+
+=head3 DESCRIPTION
+
+ return a format_pkg_simplifiedinfo
+
+=cut
+
+#=============================================================
sub get_info {
- my ($key, $widget) = @_;
+ my ($key, $options) = @_;
#- the package information hasn't been loaded. Instead of rescanning the media, just give up.
exists $pkgs->{$key} or return [ [ $loc->N("Description not available for this package\n") ] ];
#- get the description if needed:
- exists $pkgs->{$key}{description} or slow_func($widget, sub { extract_header($pkgs->{$key}, $urpm, 'info', find_installed_version($pkgs->{$key}{pkg})) });
- format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions);
+ exists $pkgs->{$key}{description} or slow_func("", sub { extract_header($pkgs->{$key}, $urpm, 'info', find_installed_version($pkgs->{$key}{pkg})) });
+ format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions, $options);
}
sub sort_callback {
@@ -1488,6 +1560,29 @@ sub run_help_callback {
run_program::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
}
+#=============================================================
+
+=head2 run_browser
+
+=head3 INPUT
+
+ $url: url to be passed to the configured browser
+
+=head3 DESCRIPTION
+
+ This function calls the browser with the given URL
+
+=cut
+
+#=============================================================
+sub run_browser {
+ my $url = shift;
+
+ my ($user) = grep { $_->[2] eq $ENV{USERHELPER_UID} } list_passwd();
+ local $ENV{HOME} = $user->[7] if $user && $ENV{USERHELPER_UID};
+ run_program::raw({ detach => 1, as_user => 1 }, 'www-browser', $url);
+}
+
sub groups_tree {
return %groups_tree;
}
diff --git a/modules/rpmdragora/dragoraUpdate b/modules/rpmdragora/dragoraUpdate
index b0c4247..cdc5c47 100755
--- a/modules/rpmdragora/dragoraUpdate
+++ b/modules/rpmdragora/dragoraUpdate
@@ -252,6 +252,8 @@ sub run_treeview_dialog {
my $closeButton = $factory->createPushButton($hbox, $loc->N("Quit") );
$statusbar = $factory->createBusyIndicator($vbox, "" );
+ my $info_options = {};
+
while(1) {
my $event = $dialog->waitForEvent();
my $eventType = $event->eventType();
@@ -260,6 +262,31 @@ sub run_treeview_dialog {
if ($eventType == $yui::YEvent::CancelEvent) {
last if quit();
}
+ elsif ($eventType == $yui::YEvent::MenuEvent) {
+ my $item = $event->item();
+ if (!$item) {
+ #URL emitted or at least a ref into RichText widget
+ my $url = yui::toYMenuEvent($event)->id ();
+ $item = $packageTbl->selectedItem();
+ my $pkg = $data{$item->index()}{fullname};
+ if ($url eq $AdminPanel::Rpmdragora::gui::hidden_info{details}) {
+ $info_options->{details} = 1;
+ AdminPanel::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox, $info_options);
+ }
+ elsif ($url eq $AdminPanel::Rpmdragora::gui::hidden_info{files}) {
+ $info_options->{files} = 1;
+ AdminPanel::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox, $info_options);
+ }
+ elsif ($url eq $AdminPanel::Rpmdragora::gui::hidden_info{changelog}) {
+ $info_options->{changelog} = 1;
+ AdminPanel::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox, $info_options);
+ }
+ else {
+ # default it's really a URL
+ AdminPanel::Rpmdragora::gui::run_browser($url);
+ }
+ }
+ }
elsif ($eventType == $yui::YEvent::WidgetEvent) {
# widget selected
my $widget = $event->widget();
@@ -295,6 +322,7 @@ sub run_treeview_dialog {
my $item = $packageTbl->selectedItem();
if ($item) {
my $pkg = $data{$item->index()}{fullname};
+ $info_options = {};
AdminPanel::Rpmdragora::gui::setInfoOnWidget($pkg, $infoBox);
}
my $wEvent = yui::toYWidgetEvent($event);
@@ -308,9 +336,6 @@ sub run_treeview_dialog {
}
yui::YUI::app()->normalCursor();
}
- elsif ($widget == $infoBox) {
- print "RichText widget Event\n";
- }
elsif ($widget == $selectButton) {
yui::YUI::app()->busyCursor();
$initialized = 0;
diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora
index 51f2b55..f566a76 100755
--- a/modules/rpmdragora/rpmdragora
+++ b/modules/rpmdragora/rpmdragora
@@ -198,14 +198,14 @@ sub detaillist_changeditem_callback {
}
sub detaillist_callback {
- my ($selection, $info, $options) = @_;
+ my ($selection, $info, $options, $show_options) = @_;
$info->setValue("");
return if( ref $selection ne "yui::YItem");
my $info_text ="<h2>" . $loc->N("Informations") . "</h2>";
- my @data = get_info($options->{table_item_list}[$selection->index()],$info->parent()->parent());
+ my @data = get_info($options->{table_item_list}[$selection->index()], $show_options);
for(@{$data[0]}){
if(ref $_ ne "ARRAY"){
$info_text .= "<br />" . $_;
@@ -1084,6 +1084,8 @@ sub run_treeview_dialog {
ask_browse_tree_given_widgets_for_rpmdragora($options);
+ my $info_options = {};
+
######## main loop ####################
while(1) {
my $event = $my_win->waitForEvent();
@@ -1098,58 +1100,73 @@ sub run_treeview_dialog {
elsif ($eventType == $yui::YEvent::MenuEvent) {
### MENU ###
my $item = $event->item();
- my $menuLabel = $item->label();
- if ($menuLabel eq $fileMenu{ quit }->label()) {
- #menu File->Quit
- quit();
- last;
- }
- elsif ($menuLabel eq $fileMenu{ update }->label()) {
- update_sources_interactive($urpm, transient => $my_win)
- and $reload_db_and_clear_all->();
+ if (!$item) {
+ #URL emitted or at least a ref into RichText widget
+ my $url = yui::toYMenuEvent($event)->id ();
+ $item = $detail_list->selectedItem();
+ if ($url eq $AdminPanel::Rpmdragora::gui::hidden_info{details}) {
+ $info_options->{details} = 1;
+ detaillist_callback($item, $info, \%$options, $info_options);
+ }
+ else {
+ # default it's really a URL
+ AdminPanel::Rpmdragora::gui::run_browser($url);
+ }
}
- elsif ($menuLabel eq $fileMenu{ reset_sel }->label()) {
- if ($MODE ne 'remove') {
- my $db = eval { open_rpm_db() };
- if (!ref($db)) {
- statusbar_msg($loc->N("Reset aborted (RPM DB is locked by another process)"), 1);
- return;
+ else {
+ my $menuLabel = $item->label();
+ if ($menuLabel eq $fileMenu{ quit }->label()) {
+ #menu File->Quit
+ quit();
+ last;
+ }
+ elsif ($menuLabel eq $fileMenu{ update }->label()) {
+ update_sources_interactive($urpm, transient => $my_win)
+ and $reload_db_and_clear_all->();
+ }
+ elsif ($menuLabel eq $fileMenu{ reset_sel }->label()) {
+ if ($MODE ne 'remove') {
+ my $db = eval { open_rpm_db() };
+ if (!ref($db)) {
+ statusbar_msg($loc->N("Reset aborted (RPM DB is locked by another process)"), 1);
+ return;
+ }
+ $urpm->disable_selected(
+ $db, $urpm->{state},
+ map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}) } keys %$pkgs,);
}
- $urpm->disable_selected(
- $db, $urpm->{state},
- map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}) } keys %$pkgs,);
+ undef $pkgs->{$_}{selected} foreach keys %$pkgs;
+ reset_search();
+ $size_selected = 0;
+ $force_displaying_group = 1;
+ my $tree_selection = $tree->currentItem();
+ }
+ elsif ($menuLabel eq $fileMenu{ reload }->label()) {
+ $reload_db_and_clear_all->();
+ }
+ elsif ($menuLabel eq $helpMenu{ about }->label()) {
+ my $translators = $loc->N("_: Translator(s) name(s) & email(s)\n");
+ $translators =~ s/\</\&lt\;/g;
+ $translators =~ s/\>/\&gt\;/g;
+ my $sh_gui = AdminPanel::Shared::GUI->new();
+ $sh_gui->AboutDialog({ name => "Rpmdragora",
+ version => "TODO",
+ credits => $loc->N("Copyright (C) %s Mageia community", '2013-2014'),
+ license => $loc->N("GPLv2"),
+ description => $loc->N("Rpmdragora is the Mageia package management tool."),
+ authors => $loc->N("<h3>Developers</h3>
+ <ul><li>%s</li>
+ <li>%s</li>
+ </ul>
+ <h3>Translators</h3>
+ <ul><li>%s</li></ul>",
+ "Angelo Naselli &lt;anaselli\@linux.it&gt;",
+ "Matteo Pasotti &lt;matteo.pasotti\@gmail.com&gt;",
+ $translators
+ ),
+ }
+ );
}
- undef $pkgs->{$_}{selected} foreach keys %$pkgs;
- reset_search();
- $size_selected = 0;
- $force_displaying_group = 1;
- my $tree_selection = $tree->currentItem();
- }
- elsif ($menuLabel eq $fileMenu{ reload }->label()) {
- $reload_db_and_clear_all->();
- }
- elsif ($menuLabel eq $helpMenu{ about }->label()) {
- my $translators = $loc->N("_: Translator(s) name(s) & email(s)\n");
- $translators =~ s/\</\&lt\;/g;
- $translators =~ s/\>/\&gt\;/g;
- my $sh_gui = AdminPanel::Shared::GUI->new();
- $sh_gui->AboutDialog({ name => "Rpmdragora",
- version => "TODO",
- credits => $loc->N("Copyright (C) %s Mageia community", '2013-2014'),
- license => $loc->N("GPLv2"),
- description => $loc->N("Rpmdragora is the Mageia package management tool."),
- authors => $loc->N("<h3>Developers</h3>
- <ul><li>%s</li>
- <li>%s</li>
- </ul>
- <h3>Translators</h3>
- <ul><li>%s</li></ul>",
- "Angelo Naselli &lt;anaselli\@linux.it&gt;",
- "Matteo Pasotti &lt;matteo.pasotti\@gmail.com&gt;",
- $translators
- ),
- }
- );
}
}
elsif ($eventType == $yui::YEvent::WidgetEvent) {
@@ -1180,6 +1197,7 @@ sub run_treeview_dialog {
tree_callback($tree->currentItem(),\%$options);
}
elsif ($widget == $detail_list){
+ $info_options = {};
detaillist_callback($detail_list->selectedItem(), $info, \%$options);
detaillist_changeditem_callback($detail_list, \%$options);
}