summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive_newt.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/interactive_newt.pm')
-rw-r--r--perl-install/interactive_newt.pm23
1 files changed, 18 insertions, 5 deletions
diff --git a/perl-install/interactive_newt.pm b/perl-install/interactive_newt.pm
index b5b167fb3..431a39930 100644
--- a/perl-install/interactive_newt.pm
+++ b/perl-install/interactive_newt.pm
@@ -102,7 +102,7 @@ sub ask_fromW {
$set = sub { $w->CheckboxSetValue(checkval($_[0])) };
$get = sub { $w->CheckboxGetValue == ord '*' };
} elsif ($e->{type} eq 'button') {
- $w = Newt::Component::Button(-1, -1, may_apply($e->{format}, ${$e->{val}}));
+ $w = Newt::Component::Button(-1, -1, simplify_string(may_apply($e->{format}, ${$e->{val}})));
} elsif ($e->{type} =~ /list/) {
my ($h, $wi) = (@$l == 1 && $height > 30 ? 10 : 5, 20);
my $scroll = @{$e->{list}} > $h ? 1 << 2 : 0;
@@ -110,7 +110,7 @@ sub ask_fromW {
$w = Newt::Component::Listbox(-1, -1, $h, $scroll); #- NEWT_FLAG_SCROLL
foreach (@{$e->{list}}) {
- my $t = may_apply($e->{format}, $_);
+ my $t = simplify_string(may_apply($e->{format}, $_));
$w->ListboxAddEntry($t, $_);
$wi = max($wi, length $t);
}
@@ -167,7 +167,8 @@ sub ask_fromW {
$grid;
}
};
- my ($buttons, $ok, $cancel) = Newt::Grid::ButtonBar($common->{ok} || _("Ok"), if_($common->{cancel}, $common->{cancel}));
+ my ($buttons, $ok, $cancel) = Newt::Grid::ButtonBar(simplify_string($common->{ok} || _("Ok")),
+ if_($common->{cancel}, simplify_string($common->{cancel})));
my $form = Newt::Component::Form(\undef, '', 0);
my $window = Newt::Grid::GridBasicWindow(first(myTextbox(@widgets == 0, @{$common->{messages}})), $listg, $buttons);
@@ -188,13 +189,19 @@ sub ask_fromW {
my ($destroyed, $canceled);
do {
- my $r = $form->RunForm;
+ my $r = do {
+ local $::setstep = 1;
+ $form->RunForm;
+ };
foreach (@widgets) {
if ($$r == ${$_->{w}}) {
$destroyed = 1;
$form->FormDestroy;
Newt::PopWindow;
- my $v = $_->{e}{clicked_may_quit}();
+ my $v = do {
+ local $::setstep = 1;
+ $_->{e}{clicked_may_quit}();
+ };
$v or return ask_fromW($o, $common, $l, $l2);
}
}
@@ -241,5 +248,11 @@ sub wait_message_endW {
Newt::PopWindow;
}
+sub simplify_string {
+ my ($s) = @_;
+ $s =~ s/\n/ /g;
+ $s = substr($s, 0, 40); #- truncate if too long
+ $s;
+}
1;
ref='#n193'>193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
package interactive_gtk;

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(interactive);

use interactive;
use common qw(:common :functional);
use my_gtk qw(:helpers :wrappers);

1;

#-#- redefine ask_warn
#-sub ask_warn {
#-    my $o = shift;
#-    local $my_gtk::grab = 1;
#-    $o->SUPER::ask_warn(@_);
#-}

sub exit { 
    c::_exit($_[0]) #- workaround 
}

sub ask_from_listW {
    my ($o, $title, $messages, $l, $def) = @_;
    my $r;

    my $w = my_gtk->new(first(deref($title)), %$o);
    $w->{retval} = $def || $l->[0]; #- nearly especially for the X test case (see timeout in Xconfigurator.pm)
    if (@$l < 5) {
	my $defW;
	my $f = sub { $w->{retval} = $_[1]; Gtk->main_quit };
	gtkadd($w->{window},
	       gtkpack(create_box_with_title($w, @$messages),
		       gtkadd(@$l < 3 && sum(map { length $_ } @$l) < 60 ? create_hbox() : create_vbox(),
			      map {