summaryrefslogtreecommitdiffstats
path: root/perl-install/install_steps_gtk.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/install_steps_gtk.pm')
-rw-r--r--perl-install/install_steps_gtk.pm95
1 files changed, 71 insertions, 24 deletions
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm
index 71f05d3bf..13f2485bc 100644
--- a/perl-install/install_steps_gtk.pm
+++ b/perl-install/install_steps_gtk.pm
@@ -347,7 +347,7 @@ sub choosePackagesTree {
my ($o, $packages, $compss) = @_;
my ($curr, $info_widget, $w_size, $go, $idle);
- my %wtree;
+ my (%wtree, %ptree);
my $w = my_gtk->new('');
my $details = new Gtk::VBox(0,0);
@@ -355,21 +355,6 @@ sub choosePackagesTree {
$tree->set_selection_mode('browse');
$tree->set_column_auto_resize($_, 1) foreach 0..1;
- my $parent; $parent = sub {
- if (my $w = $wtree{$_[0]}) { return $w }
- my $s; foreach (split '/', $_[0]) {
- $wtree{"$s/$_"} ||=
- $tree->insert_node($s ? $parent->($s) : undef, undef, [$_], 5, (undef) x 4, 0, 0);
- $s = "$s/$_";
- }
- $wtree{$s};
- };
- my ($root, $leaf);
- foreach (@$compss) {
- ($root, $leaf) = m|(.*)/(.+)|o or ($root, $leaf) = ('', $_);
- my $node = $tree->insert_node($parent->($root), undef, [$leaf], 5, (undef) x 4, 1, 0);
- }
-
gtkadd($w->{window},
gtkpack_(new Gtk::VBox(0,5),
0, _("Choose the packages you want to install"),
@@ -387,6 +372,40 @@ sub choosePackagesTree {
$go->grab_focus;
$w->show;
+ $tree->freeze;
+ my $dir = $::testing && $ENV{SHARE_PATH} || "/usr/share";
+ my $pix_base = [ Gtk::Gdk::Pixmap->create_from_xpm($w->{window}->window, $w->{window}->style->bg('normal'), "$dir/rpm-base.xpm") ];
+ my $pix_selected = [ Gtk::Gdk::Pixmap->create_from_xpm($w->{window}->window, $w->{window}->style->bg('normal'), "$dir/rpm-selected.xpm") ];
+ my $pix_unselect = [ Gtk::Gdk::Pixmap->create_from_xpm_d($w->{window}->window, undef, "1 1 1 1", " c None", " ") ];
+
+ my $parent; $parent = sub {
+ if (my $w = $wtree{$_[0]}) { return $w }
+ my $s; foreach (split '/', $_[0]) {
+ $wtree{"$s/$_"} ||=
+ $tree->insert_node($s ? $parent->($s) : undef, undef, [$_], 5, (undef) x 4, 0, 0);
+ $s = "$s/$_";
+ }
+ $wtree{$s};
+ };
+ my $add_node = sub {
+ my ($leaf, $root) = @_;
+ my $node = $tree->insert_node($parent->($root), undef, [$leaf], 5, (undef) x 4, 1, 0);
+ my $p = $packages->[0]{$leaf} or return;
+ my $pix = pkgs::packageFlagBase($p) ? $pix_base : pkgs::packageFlagSelected($p) ? $pix_selected : $pix_unselect;
+ $tree->node_set_pixmap($node, 1, $pix->[0], $pix->[1]);
+ push @{$ptree{$leaf}}, $node;
+ };
+
+ my ($root, $leaf);
+ foreach (sort keys %{$packages->[0]}) {
+ $add_node->($_, 'all');
+ }
+ foreach (sort @$compss) {
+ ($root, $leaf) = m|(.*)/(.+)|o or ($root, $leaf) = ('', $_);
+ $add_node->($leaf, $root);
+ }
+ $tree->thaw;
+
my $display_info = sub {
my $p = $packages->[0]{$curr} or return gtktext_insert($info_widget, '');
pkgs::extractHeaders($o->{prefix}, [$p]);
@@ -398,7 +417,7 @@ sub choosePackagesTree {
gtktext_insert($info_widget, $@ ? _("Bad package") :
_("Version: %s\n", pkgs::packageVersion($p) . '-' . pkgs::packageRelease($p)) .
_("Size: %d KB\n", pkgs::packageSize($p) / 1024) .
- ($imp && _("Importance: %s\n", $imp)) .
+ ($imp && _("Importance: %s\n", $imp)) . "\n" .
formatLines(c::headerGetEntry($p->{header}, 'description')));
c::headerFree(delete $p->{header});
0;
@@ -407,23 +426,51 @@ sub choosePackagesTree {
$tree->signal_connect(tree_select_row => sub {
Gtk->timeout_remove($idle) if $idle;
- $_[1]->row->is_leaf or return;
- ($curr) = $tree->node_get_pixtext($_[1], 0);
-
- $idle = Gtk->timeout_add(100, $display_info);
+ if ($_[1]->row->is_leaf) {
+ ($curr) = $tree->node_get_pixtext($_[1], 0);
+ $idle = Gtk->timeout_add(100, $display_info);
+ } else {
+ $curr = $_[1];
+ }
});
-
my $update_size = sub {
my $size = 0;
foreach (values %{$packages->[0]}) {
$size += pkgs::packageSize($_) - ($_->{installedCumulSize} || 0) if pkgs::packageFlagSelected($_); #- on upgrade, installed packages will be removed.
}
- $w_size->set(_("Total size: %d / %d KB",
+ $w_size->set(_("Total size: %d / %d MB",
pkgs::correctSize($size / sqr(1024)),
install_any::getAvailableSpace($o) / sqr(1024)));
};
- &$update_size();
+ my $toggle = sub {
+ if (ref $curr) {
+ $tree->toggle_expansion($curr);
+ } else {
+ my $p = $packages->[0]{$curr} or return;
+ pkgs::togglePackageSelection($packages, $p, my $l = {});
+ if (my @l = grep { $l->{$_} } keys %$l) {
+ @l > 1 and $o->ask_okcancel('', [ _("The following packages are going to be install/removed"), join(", ", sort @l) ], 1) || return;
+ pkgs::togglePackageSelection($packages, $p);
+ foreach (@l) {
+ my $p = $packages->[0]{$_};
+ my $pix = pkgs::packageFlagSelected($p) ? $pix_selected : $pix_unselect;
+ $tree->node_set_pixmap($_, 1, $pix->[0], $pix->[1]) foreach @{$ptree{$_}};
+ }
+ &$update_size;
+ } else {
+ $o->ask_warn('', _("This is a mandatory package, it can't unselected"));
+ }
+ }
+ };
+ $tree->signal_connect(button_press_event => sub { &$toggle if $_[1]{type} =~ /^2/ });
+ $tree->signal_connect(key_press_event => sub {
+ my ($w, $e) = @_;
+ my $c = chr $e->{keyval};
+ &$toggle if $e->{keyval} >= 0x100 ? $c eq "\r" || $c eq "\x8d" : $c eq ' ';
+ 1;
+ });
+ &$update_size;
$w->main;
}