commit 7d64b33bfe7f2e7c3aaecbea93677c97d482e30f
parent 4303b5d3d14c5a111f24187212fafa44d3c33b6f
Author: lumidify <nobody@lumidify.org>
Date: Wed, 10 Mar 2021 08:25:33 +0100
Switch to gtk3
Diffstat:
M | README | | | 2 | +- |
M | transliterate.pl | | | 100 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
2 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/README b/README
@@ -6,7 +6,7 @@ https://lumidify.org/doc/transliterate.html
gopher://lumidify.org/0/doc/transliterate.txt
gopher://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/0/doc/transliterate.txt
-REQUIREMENTS: gtk2-perl
+REQUIREMENTS: gtk3-perl (or perl-gtk3, however your package manager calls it)
See the repository "transliterate_data" for a real-world configuration.
There are also some sample configuration files in "tests/".
diff --git a/transliterate.pl b/transliterate.pl
@@ -18,7 +18,7 @@ binmode STDOUT, ":encoding(UTF-8)";
binmode STDERR, ":encoding(UTF-8)";
use Unicode::Normalize;
use Glib qw/TRUE FALSE/;
-use Gtk2 '-init';
+use Gtk3 '-init';
use Getopt::Long;
use Pod::Usage;
use Scalar::Util qw(weaken);
@@ -97,18 +97,18 @@ sub prompt_unknown_word {
my $action;
my $stop = 0;
- my $window = Gtk2::Window->new('toplevel');
+ my $window = Gtk3::Window->new('toplevel');
$window->signal_connect(delete_event => sub {return FALSE});
- $window->signal_connect(destroy => sub { Gtk2->main_quit; });
+ $window->signal_connect(destroy => sub { Gtk3->main_quit; });
$window->set_border_width(10);
- my $vbox = Gtk2::VBox->new(FALSE, 10);
+ my $vbox = Gtk3::VBox->new(FALSE, 10);
- my $linelabel = Gtk2::Label->new("Current line: $cur_lineno");
+ my $linelabel = Gtk3::Label->new("Current line: $cur_lineno");
$vbox->pack_start($linelabel, FALSE, FALSE, 0);
$linelabel->show;
- my $wordlabel = Gtk2::Label->new("Word not found: $word");
+ my $wordlabel = Gtk3::Label->new("Word not found: $word");
$wordlabel->set_alignment(0.0, 0.0);
$vbox->pack_start($wordlabel, FALSE, FALSE, 0);
$wordlabel->show;
@@ -120,9 +120,9 @@ sub prompt_unknown_word {
my $make_context_box = sub {
# look, don't blame me for these miserably named variables...
my ($ctxtl, $wrd, $ctxtr, $lbl, $btn_lbl) = @_;
- my $hbox = Gtk2::HBox->new(FALSE, 5);
- my $label = Gtk2::Label->new_with_mnemonic($lbl);
- my $text = Gtk2::TextView->new;
+ my $hbox = Gtk3::HBox->new(FALSE, 5);
+ my $label = Gtk3::Label->new_with_mnemonic($lbl);
+ my $text = Gtk3::TextView->new;
$label->set_mnemonic_widget($text);
$text->set_wrap_mode("word");
my $buffer = $text->get_buffer();
@@ -132,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($btn_lbl);
+ my $button = Gtk3::Button->new($btn_lbl);
$button->signal_connect(
clicked => sub {
if (my ($start, $end) = $buffer->get_selection_bounds()) {
@@ -143,10 +143,10 @@ sub prompt_unknown_word {
$hbox->pack_start($label, FALSE, FALSE, 0);
$hbox->pack_start($text, TRUE, TRUE, 0);
$vbox->pack_start($hbox, FALSE, FALSE, 0);
- $hbox = Gtk2::HBox->new(FALSE, 5);
+ $hbox = Gtk3::HBox->new(FALSE, 5);
$hbox->pack_start($button, FALSE, FALSE, 0);
my $complete_text = $ctxtl . $wrd . $ctxtr;
- $button = Gtk2::Button->new("Reset text");
+ $button = Gtk3::Button->new("Reset text");
$button->signal_connect(
clicked => sub {
$buffer->set_text($complete_text);
@@ -157,24 +157,24 @@ sub prompt_unknown_word {
$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: ");
+ my $hbox = Gtk3::HBox->new(FALSE, 5);
+ my $label = Gtk3::Label->new("Ignore: ");
$hbox->pack_start($label, FALSE, FALSE, 0);
- my $button = Gtk2::Button->new("Th_is run");
+ my $button = Gtk3::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 = Gtk3::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 = Gtk3::Button->new("_Whole line");
$button->signal_connect(
clicked => sub {
$action = ["ignore", "wholeline"];
@@ -187,10 +187,10 @@ sub prompt_unknown_word {
# Take note, kids - this is what happens when you keep adding
# features without rethinking your basic design.
- $hbox = Gtk2::HBox->new(FALSE, 5);
- $label = Gtk2::Label->new_with_mnemonic("Add to _list: ");
+ $hbox = Gtk3::HBox->new(FALSE, 5);
+ $label = Gtk3::Label->new_with_mnemonic("Add to _list: ");
$hbox->pack_start($label, FALSE, FALSE, 0);
- my $path_list = Gtk2::ComboBox->new_text;
+ my $path_list = Gtk3::ComboBoxText->new;
$label->set_mnemonic_widget($path_list);
foreach my $path (sort keys %{$config->{"display_tables"}}) {
$path_list->append_text($path);
@@ -198,21 +198,21 @@ sub prompt_unknown_word {
$hbox->pack_start($path_list, FALSE, FALSE, 0);
$vbox->pack_start($hbox, FALSE, FALSE, 0);
- $hbox = Gtk2::HBox->new(FALSE, 5);
- $label = Gtk2::Label->new_with_mnemonic("_Replacement: ");
+ $hbox = Gtk3::HBox->new(FALSE, 5);
+ $label = Gtk3::Label->new_with_mnemonic("_Replacement: ");
$hbox->pack_start($label, FALSE, FALSE, 0);
- my $replace_entry = Gtk2::Entry->new;
+ my $replace_entry = Gtk3::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);
+ $hbox = Gtk3::HBox->new(FALSE, 5);
# Pressing Alt+e just activates the first of the retrywithout buttons
- $label = Gtk2::Label->new_with_mnemonic("Retry without: ");
+ $label = Gtk3::Label->new_with_mnemonic("Retry without: ");
$hbox->pack_start($label, FALSE, FALSE, 0);
foreach my $without (@{$config->{"retrywithout"}}) {
- $button = Gtk2::Button->new("$without->[0]");
+ $button = Gtk3::Button->new("$without->[0]");
$button->signal_connect(
clicked => sub {
my @chars = @{$without}[1..$#$without];
@@ -227,8 +227,8 @@ sub prompt_unknown_word {
$vbox->pack_start($hbox, FALSE, FALSE, 0);
}
- $hbox = Gtk2::HBox->new(FALSE, 0);
- $button = Gtk2::Button->new("_Add replacement");
+ $hbox = Gtk3::HBox->new(FALSE, 0);
+ $button = Gtk3::Button->new("_Add replacement");
$button->signal_connect(
clicked => sub {
if ($path_list->get_active != -1) {
@@ -239,8 +239,8 @@ sub prompt_unknown_word {
$hbox->pack_start($button, FALSE, FALSE, 0);
$vbox->pack_start($hbox, FALSE, FALSE, 0);
- $hbox = Gtk2::HBox->new(FALSE, 5);
- $button = Gtk2::Button->new("_Stop processing");
+ $hbox = Gtk3::HBox->new(FALSE, 5);
+ $button = Gtk3::Button->new("_Stop processing");
$button->signal_connect(
clicked => sub {
$stop = 1;
@@ -248,7 +248,7 @@ sub prompt_unknown_word {
}, $window);
$hbox->pack_start($button, FALSE, FALSE, 0);
- $button = Gtk2::Button->new("Reload config");
+ $button = Gtk3::Button->new("Reload config");
$button->signal_connect(
clicked => sub {
$action = ["reload"];
@@ -257,14 +257,14 @@ sub prompt_unknown_word {
$hbox->pack_start($button, FALSE, FALSE, 0);
if ($config_error) {
- $label = Gtk2::Label->new("Error loading config; see terminal output for details");
+ $label = Gtk3::Label->new("Error loading config; see terminal output for details");
$hbox->pack_start($label, FALSE, FALSE, 0);
}
$vbox->pack_start($hbox, FALSE, FALSE, 0);
$window->add($vbox);
$window->show_all;
- Gtk2->main;
+ Gtk3->main;
die "Processing stopped at line $cur_lineno\n" if $stop;
@@ -322,33 +322,33 @@ sub prompt_choose_word {
my $open_unknown = 0;
my $cur_replacement = 0;
- my $window = Gtk2::Window->new('toplevel');
+ my $window = Gtk3::Window->new('toplevel');
$window->signal_connect(delete_event => sub {return FALSE});
- $window->signal_connect(destroy => sub { Gtk2->main_quit; });
+ $window->signal_connect(destroy => sub { Gtk3->main_quit; });
$window->set_border_width(10);
- my $vbox = Gtk2::VBox->new(FALSE, 0);
+ my $vbox = Gtk3::VBox->new(FALSE, 0);
- my $linelabel = Gtk2::Label->new("Current line: $cur_lineno");
+ my $linelabel = Gtk3::Label->new("Current line: $cur_lineno");
$vbox->pack_start($linelabel, FALSE, FALSE, 0);
- my $wordlabel = Gtk2::Label->new("");
+ my $wordlabel = Gtk3::Label->new("");
$wordlabel->set_alignment(0.0, 0.0);
$vbox->pack_start($wordlabel, FALSE, FALSE, 0);
- my $undo = Gtk2::Button->new("Undo");
+ my $undo = Gtk3::Button->new("Undo");
$vbox->pack_start($undo, FALSE, FALSE, 0);
$undo->set_sensitive(FALSE);
- my $button_vbox = Gtk2::VBox->new(FALSE, 0);
+ my $button_vbox = Gtk3::VBox->new(FALSE, 0);
$vbox->pack_start($button_vbox, FALSE, FALSE, 0);
- my $accept = Gtk2::Button->new("Accept changes?");
+ my $accept = Gtk3::Button->new("Accept changes?");
$vbox->pack_start($accept, FALSE, FALSE, 0);
- my $hbox = Gtk2::HBox->new(FALSE, 0);
- my $label = Gtk2::Label->new("Context: ");
- my $text = Gtk2::TextView->new;
+ my $hbox = Gtk3::HBox->new(FALSE, 0);
+ my $label = Gtk3::Label->new("Context: ");
+ my $text = Gtk3::TextView->new;
$text->set_wrap_mode("word");
my $buffer = $text->get_buffer();
my $highlight = $buffer->create_tag("yellow_bg", "background", "yellow");
@@ -357,12 +357,12 @@ sub prompt_choose_word {
$hbox->pack_start($text, TRUE, TRUE, 10);
$vbox->pack_start($hbox, FALSE, FALSE, 10);
- $hbox = Gtk2::HBox->new(FALSE, 5);
- my $skip_button = Gtk2::Button->new("Skip word");
+ $hbox = Gtk3::HBox->new(FALSE, 5);
+ my $skip_button = Gtk3::Button->new("Skip word");
$hbox->pack_start($skip_button, FALSE, FALSE, 0);
- my $unknown_button = Gtk2::Button->new("Open in unknown word window");
+ my $unknown_button = Gtk3::Button->new("Open in unknown word window");
$hbox->pack_start($unknown_button, FALSE, FALSE, 0);
- my $stop_button = Gtk2::Button->new("Stop processing");
+ my $stop_button = Gtk3::Button->new("Stop processing");
$hbox->pack_start($stop_button, FALSE, FALSE, 0);
$vbox->pack_start($hbox, FALSE, FALSE, 0);
@@ -444,7 +444,7 @@ sub prompt_choose_word {
@choices = sort {$choice_nums{$b} <=> $choice_nums{$a}} @choices;
}
foreach my $word_choice (@choices) {
- my $button = Gtk2::Button->new($word_choice);
+ my $button = Gtk3::Button->new($word_choice);
$button->signal_connect(
clicked => sub {
$replacements[$cur_replacement]->[1] = $word_choice;
@@ -502,7 +502,7 @@ sub prompt_choose_word {
$window->add($vbox);
$window->show_all;
$accept->hide;
- Gtk2->main;
+ Gtk3->main;
die "Processing stopped at line $cur_lineno\n" if $stop;
if ($open_unknown) {
my $ret = call_unknown_word_window(