From 6ff0be05d9d943943d47871c546df6fab5a149df Mon Sep 17 00:00:00 2001 From: freesource Date: Tue, 28 Aug 2001 17:00:30 +0000 Subject: [PATCH] Creating a search box is a lesson in study, and finding bugs in other programs. --- BootRoot/YardBox.pm | 63 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/BootRoot/YardBox.pm b/BootRoot/YardBox.pm index 4363a12..4cbab39 100644 --- a/BootRoot/YardBox.pm +++ b/BootRoot/YardBox.pm @@ -1207,6 +1207,11 @@ sub search { if ($tmp_k && $tmp_k ne $keywords) { ($tmp_k = $keywords) =~ tr/A-Z/a-z/; } + if ($tmp_ct + && $tmp_ct ne $changed_text_from_template) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + } $offset = rindex($tmp_ct, $tmp_k); } @@ -1234,6 +1239,11 @@ sub search { if ($tmp_k && $tmp_k ne $keywords) { ($tmp_k = $keywords) =~ tr/A-Z/a-z/; } + if ($tmp_ct + && $tmp_ct ne $changed_text_from_template) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + } $offset = rindex($tmp_ct, $tmp_k, $offset); } else { @@ -1269,6 +1279,11 @@ sub search { if ($tmp_k && $tmp_k ne $keywords) { ($tmp_k = $keywords) =~ tr/A-Z/a-z/; } + if ($tmp_ct + && $tmp_ct ne $changed_text_from_template) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + } $offset = index($tmp_ct, $tmp_k); } else { @@ -1296,6 +1311,11 @@ sub search { if ($tmp_k && $tmp_k ne $keywords) { ($tmp_k = $keywords) =~ tr/A-Z/a-z/; } + if ($tmp_ct + && $tmp_ct ne $changed_text_from_template) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + } $offset = index($tmp_ct, $tmp_k, $offset); } else { @@ -1342,6 +1362,7 @@ sub search { sub question_window { my ($output,$widget,$widget_button) = @_; + my ($ok_button, $c_button); if (not defined $question_window) { $question_window = new Gtk::Dialog; @@ -1351,36 +1372,54 @@ sub question_window { \$question_window); $question_window->signal_connect("delete_event", \&destroy_window, \$question_window); + $question_window->signal_connect("key_press_event", sub { + my $event = pop @_; + if ($event->{'keyval'}) { + if ($event->{'keyval'} == 65307) { + $question_window->destroy + } + elsif ($event->{'keyval'} == 65293) { + $widget_button->clicked; + $question_window->destroy; + } + } + }); $question_window->set_title("gBootRoot Question?"); $question_window->border_width(15); my $label = new Gtk::Label($output); #$label->set_justify("left") if $_[1]; $question_window->vbox->pack_start( $label, $true, $true, 15 ); $label->show(); - my $button = new Gtk::Button("OK"); - $button->signal_connect("clicked", sub { + + # OK button + #---------------------------------------- + $ok_button = new Gtk::Button("OK"); + $ok_button->signal_connect("clicked", sub { $widget_button->clicked; $question_window->destroy; }); - $button->can_default(1); - $question_window->action_area->pack_start($button, $false, $false,0); - $button->grab_default; - $button->show; - - my $c_button = new Gtk::Button("Cancel"); + $ok_button->can_default(1); + $question_window->action_area->pack_start($ok_button, $false, $false,0); + $ok_button->grab_default; + $ok_button->show; + + # Cancel button + #---------------------------------------- + $c_button = new Gtk::Button("Cancel"); $c_button->signal_connect("clicked", sub { - $question_window->destroy; + $question_window->destroy if $question_window; }); $question_window->action_area->pack_start($c_button, $false, $false,0); $c_button->show; - - } if (!visible $question_window) { $question_window->show; } -} + + return ($ok_button,$c_button); + +} # end sub question_window sub yard_menu {