From bb4eb6bb98e98b33e83ba4ae934049a6f2cac4e0 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sun, 9 Sep 2001 16:13:16 +0000 Subject: clicked_may_quit used in place of clicked+exception to work-around perl-GTK bug (?) --- perl-install/any.pm | 6 +++--- perl-install/interactive.pm | 8 +++++--- perl-install/interactive_gtk.pm | 5 ++++- perl-install/interactive_newt.pm | 13 ++++++++----- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/perl-install/any.pm b/perl-install/any.pm index 02dfee4ce..e6660cfb7 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -206,7 +206,7 @@ sub setupBootloader { while ($::expert || $more > 1) { $in->set_help(arch() =~ /sparc/ ? 'setupSILOAddEntry' : arch() =~ /ppc/ ? 'setupYabootAddEntry' : 'setupBootloaderAddEntry') unless $::isStandalone; my ($c, $e); - eval { $in->ask_from_( + $in->ask_from_( { messages => _("Here are the different entries. @@ -219,9 +219,9 @@ You can add some more or change the existing ones."), "$e->{label} ($e->{kernel_or_dev})" . ($b->{default} eq $e->{label} && " *") : translate($e); }, list => [ @{$b->{entries}} ] }, - (map { my $s = $_; { val => translate($_), clicked => sub { $c = $s; die } } } (__("Modify"), __("Add"), __("Done"))), + (map { my $s = $_; { val => translate($_), clicked_may_quit => sub { $c = $s; 1 } } } (__("Modify"), __("Add"), __("Done"))), ] - ) }; + ); !$c || $c eq "Done" and last; if ($c eq "Add") { diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index bd8d4ed7a..b6c93b8e7 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -18,7 +18,9 @@ use common; #- disabled => function returning wether it should be disabled (grayed) #- gtk => gtk preferences #- type => -#- button => (with clicked) (type defaults to button if clicked is there) (val need not be a reference) +#- button => (with clicked or clicked_may_quit) +#- (type defaults to button if clicked or clicked_may_quit is there) +#- (val need not be a reference) (if clicked_may_quit return true, it's as if "Ok" was pressed) #- label => (val need not be a reference) (type defaults to label if val is not a reference) #- bool (with text) #- range (with min, max) @@ -253,9 +255,9 @@ sub ask_from_normalize { } elsif ($e->{type} eq 'range') { $e->{min} <= $e->{max} or die "bad range min $e->{min} > max $e->{max} (called from " . join(':', caller()) . ")"; ${$e->{val}} = max($e->{min}, min(${$e->{val}}, $e->{max})); - } elsif ($e->{type} eq 'button' || $e->{clicked}) { + } elsif ($e->{type} eq 'button' || $e->{clicked} || $e->{clicked_may_quit}) { $e->{type} = 'button'; - $e->{clicked} ||= sub {}; + $e->{clicked_may_quit} ||= $e->{clicked} ? sub { $e->{clicked}(); 0 } : sub {}; $e->{val} = \ (my $v = $e->{val}) if !ref($e->{val}); } elsif ($e->{type} eq 'label' || !ref($e->{val})) { $e->{type} = 'label'; diff --git a/perl-install/interactive_gtk.pm b/perl-install/interactive_gtk.pm index 6445b39b5..b10aba394 100644 --- a/perl-install/interactive_gtk.pm +++ b/perl-install/interactive_gtk.pm @@ -407,7 +407,10 @@ sub ask_fromW { $w->signal_connect(clicked => sub { $get_all->(); $mainw->{rwindow}->hide; - $e->{clicked}(); + if (my $v = $e->{clicked_may_quit}()) { + $o->{retval} = $v; + Gtk->main_quit; + } $mainw->{rwindow}->show; $set_all->(); }); diff --git a/perl-install/interactive_newt.pm b/perl-install/interactive_newt.pm index 3d5beabd0..abdb09503 100644 --- a/perl-install/interactive_newt.pm +++ b/perl-install/interactive_newt.pm @@ -186,23 +186,26 @@ sub ask_fromW { !$error; }; - my $canceled; + my ($destroyed, $canceled); do { my $r = $form->RunForm; foreach (@widgets) { if ($$r == ${$_->{w}}) { + $destroyed = 1; $form->FormDestroy; Newt::PopWindow; - $_->{e}{clicked}(); - return ask_fromW($o, $common, $l, $l2); + my $v = $_->{e}{clicked_may_quit}(); + $v or return ask_fromW($o, $common, $l, $l2); } } $canceled = $cancel && $$r == $$cancel; } until ($check->($common->{callbacks}{$canceled ? 'canceled' : 'complete'})); - $form->FormDestroy; - Newt::PopWindow; + if (!$destroyed) { + $form->FormDestroy; + Newt::PopWindow; + } !$canceled; } -- cgit v1.2.1