From df74e103d8de6d7cc45cc3e2a99f4b9c8fff6085 Mon Sep 17 00:00:00 2001 From: "Thierry.Vignaud" Date: Wed, 28 May 2014 22:37:23 +0200 Subject: simplify using member() --- perl-install/interactive/curses.pm | 6 +++--- perl-install/interactive/gtk.pm | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'perl-install/interactive') diff --git a/perl-install/interactive/curses.pm b/perl-install/interactive/curses.pm index 7b81e9e09..b2dc94bc4 100644 --- a/perl-install/interactive/curses.pm +++ b/perl-install/interactive/curses.pm @@ -177,7 +177,7 @@ sub compute_size { $e->{curses}{'-width'} ||= length($s); } elsif ($e->{type} eq 'expander') { $e->{curses}{'-width'} ||= length("<+> $e->{text}"); - } elsif ($e->{type} eq 'text' || $e->{type} eq 'label' || $e->{type} eq 'only_label') { + } elsif (member($e->{type}, qw(text label only_label))) { my @text = _messages(min(80, $width_avail - 1), ${$e->{val}}); #- -1 because of the scrollbar $e->{curses}{'-focusable'} = 0; $e->{curses}{'-height'} ||= heights(int(@text), 10, 4); @@ -352,7 +352,7 @@ sub create_widget { $w->set_binding('focus-up', Curses::KEY_LEFT()); $w->set_binding('focus-down', Curses::KEY_RIGHT()); $set = sub { $w->set_label(0, sprintf('< %s >', may_apply($e->{format}, $_[0]))) }; - } elsif ($e->{type} eq 'list' || $e->{type} eq 'combo') { + } elsif (member($e->{type}, qw(list combo))) { $w = $win->add(undef, $e->{type} eq 'combo' ? 'Popupmenu' : 'Listbox', '-values' => $e->{formatted_list}, '-onchange' => $onchange->(sub { $e->{list}[$w->id] }), @@ -405,7 +405,7 @@ sub create_widget { } elsif ($e->{type} eq 'label' && $e->{curses}{'-height'} == 1) { $w = $win->add(undef, 'Label', %options); $set = sub { $w->text($_[0] || '') }; - } elsif ($e->{type} eq 'label' || $e->{type} eq 'only_label' || $e->{type} eq 'text') { + } elsif (member($e->{type}, qw(label only_label text))) { $w = $win->add(undef, 'TextViewer', %options); $set = sub { my ($text) = @_; diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index 9b989b84f..98f1eb2a7 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -112,7 +112,7 @@ sub create_treeview_list { } else { $e->{may_go_to_next}(), return 1 if $c eq ' '; - $curr++ if $starting_word eq '' || $starting_word eq $c; + $curr++ if member($starting_word, '', $c); $starting_word .= $c unless $starting_word eq $c; } my @l = @{$e->{formatted_list}}; @@ -276,7 +276,7 @@ sub create_treeview_tree { $next = 1; } else { &$toggle and return 1 if $c eq ' '; - $next = 1 if $starting_word eq '' || $starting_word eq $c; + $next = 1 if member($starting_word, '', $c); $starting_word .= $c unless $starting_word eq $c; } my $word = quotemeta $starting_word; @@ -561,7 +561,7 @@ sub create_widget { $w->set_active_iter($model->get_iter_from_string($path_str)); }; } else { - $w->set_text($s) if $s ne $w->get_text && $_[0] ne $w->get_text; + $w->set_text($s) if !member($w->get_text, $s, $_[0]); } }; } else { -- cgit v1.2.1