transliterate

Transliteration engine
git clone git://lumidify.org/transliterate.git (fast, but not encrypted)
git clone https://lumidify.org/git/transliterate.git (encrypted, but very slow)
Log | Files | Refs | README | LICENSE

commit 2b32e7b889de2f89a1f4a6c0dd5ca7a441d65fae
parent 30989566256dc25ac95db7b9ccaefd4a400cad2c
Author: lumidify <nobody@lumidify.org>
Date:   Tue,  9 Mar 2021 10:58:42 +0100

Add several shortcuts/mnemonics to unknown word window

Diffstat:
Mtransliterate.pl | 37++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/transliterate.pl b/transliterate.pl @@ -119,10 +119,11 @@ sub prompt_unknown_word { # of the entire word that was not found has to be replaced my $make_context_box = sub { # look, don't blame me for these miserably named variables... - my ($ctxtl, $wrd, $ctxtr, $lbl) = @_; + my ($ctxtl, $wrd, $ctxtr, $lbl, $btn_lbl) = @_; my $hbox = Gtk2::HBox->new(FALSE, 5); - my $label = Gtk2::Label->new($lbl); + my $label = Gtk2::Label->new_with_mnemonic($lbl); my $text = Gtk2::TextView->new; + $label->set_mnemonic_widget($text); $text->set_wrap_mode("word"); my $buffer = $text->get_buffer(); $buffer->set_text($ctxtr); @@ -131,7 +132,7 @@ sub prompt_unknown_word { $buffer->insert_with_tags($start_iter, $wrd, $highlight); $start_iter = $buffer->get_start_iter(); $buffer->insert($start_iter, $ctxtl); - my $button = Gtk2::Button->new("Use selection as word"); + my $button = Gtk2::Button->new($btn_lbl); $button->signal_connect( clicked => sub { if (my ($start, $end) = $buffer->get_selection_bounds()) { @@ -153,27 +154,27 @@ sub prompt_unknown_word { $hbox->pack_start($button, FALSE, FALSE, 0); $vbox->pack_start($hbox, FALSE, FALSE, 0); }; - $make_context_box->($contextl, $word_repl, $contextr, "Context: "); - $make_context_box->($contextl_orig, $word, $contextr_orig, "Original: "); + $make_context_box->($contextl, $word_repl, $contextr, "Transliterated _context: ", "Use _transliterated selection as word"); + $make_context_box->($contextl_orig, $word, $contextr_orig, "Ori_ginal context: ", "Use _original selection as word"); my $hbox = Gtk2::HBox->new(FALSE, 5); my $label = Gtk2::Label->new("Ignore: "); $hbox->pack_start($label, FALSE, FALSE, 0); - my $button = Gtk2::Button->new("This run"); + my $button = Gtk2::Button->new("Th_is run"); $button->signal_connect( clicked => sub { $action = ["ignore", "run", $word]; $window->destroy; }, $window); $hbox->pack_start($button, FALSE, FALSE, 0); - $button = Gtk2::Button->new("Permanently"); + $button = Gtk2::Button->new("_Permanently"); $button->signal_connect( clicked => sub { $action = ["ignore", "permanent", $word]; $window->destroy; }, $window); $hbox->pack_start($button, FALSE, FALSE, 0); - $button = Gtk2::Button->new("Whole line"); + $button = Gtk2::Button->new("_Whole line"); $button->signal_connect( clicked => sub { $action = ["ignore", "wholeline"]; @@ -187,9 +188,10 @@ sub prompt_unknown_word { # features without rethinking your basic design. $hbox = Gtk2::HBox->new(FALSE, 5); - $label = Gtk2::Label->new("Add to list: "); + $label = Gtk2::Label->new_with_mnemonic("Add to _list: "); $hbox->pack_start($label, FALSE, FALSE, 0); my $path_list = Gtk2::ComboBox->new_text; + $label->set_mnemonic_widget($path_list); foreach my $path (sort keys %{$config->{"display_tables"}}) { $path_list->append_text($path); } @@ -197,18 +199,24 @@ sub prompt_unknown_word { $vbox->pack_start($hbox, FALSE, FALSE, 0); $hbox = Gtk2::HBox->new(FALSE, 5); - $label = Gtk2::Label->new("Replacement: "); + $label = Gtk2::Label->new_with_mnemonic("_Replacement: "); $hbox->pack_start($label, FALSE, FALSE, 0); my $replace_entry = Gtk2::Entry->new; + $label->set_mnemonic_widget($replace_entry); $hbox->pack_start($replace_entry, TRUE, TRUE, 0); $vbox->pack_start($hbox, FALSE, FALSE, 0); if (exists $config->{"retrywithout"}) { $hbox = Gtk2::HBox->new(FALSE, 5); - $label = Gtk2::Label->new("Retry without: "); + # Pressing Alt+e just activates the first of the retrywithout buttons + $label = Gtk2::Label->new_with_mnemonic("R_etry without: "); $hbox->pack_start($label, FALSE, FALSE, 0); + my $first_button = 0; foreach my $without (@{$config->{"retrywithout"}}) { $button = Gtk2::Button->new("$without->[0]"); + if (!$first_button) { + $first_button = $button; + } $button->signal_connect( clicked => sub { my @chars = @{$without}[1..$#$without]; @@ -220,11 +228,14 @@ sub prompt_unknown_word { }, $window); $hbox->pack_start($button, FALSE, FALSE, 0); } + if ($first_button) { + $label->set_mnemonic_widget($first_button); + } $vbox->pack_start($hbox, FALSE, FALSE, 0); } $hbox = Gtk2::HBox->new(FALSE, 0); - $button = Gtk2::Button->new("Add replacement"); + $button = Gtk2::Button->new("_Add replacement"); $button->signal_connect( clicked => sub { if ($path_list->get_active != -1) { @@ -236,7 +247,7 @@ sub prompt_unknown_word { $vbox->pack_start($hbox, FALSE, FALSE, 0); $hbox = Gtk2::HBox->new(FALSE, 5); - $button = Gtk2::Button->new("Stop processing"); + $button = Gtk2::Button->new("_Stop processing"); $button->signal_connect( clicked => sub { $stop = 1;