aboutsummaryrefslogtreecommitdiff
path: root/misc/translator
diff options
context:
space:
mode:
authorFlorent Thoumie <flz@FreeBSD.org>2005-03-09 16:01:13 +0000
committerFlorent Thoumie <flz@FreeBSD.org>2005-03-09 16:01:13 +0000
commit6dc74323adef17092bc223dd9346eaa4e1e480a6 (patch)
tree9ce02914f0c1d40879bbbc90befd39deca2340a1 /misc/translator
parent3430b5984cb31fa8c4558e0730e9b5b6f7bce86b (diff)
downloadports-6dc74323adef17092bc223dd9346eaa4e1e480a6.tar.gz
ports-6dc74323adef17092bc223dd9346eaa4e1e480a6.zip
- Add translator 0.1.0, a GTK+ frontend to the Babelfish translation service.
PR: ports/73063 Submitted by: Jean-Yves Lefort <jylefort@brutele.be> Approved by: pav (mentor)
Notes
Notes: svn path=/head/; revision=130733
Diffstat (limited to 'misc/translator')
-rw-r--r--misc/translator/Makefile47
-rw-r--r--misc/translator/distinfo2
-rw-r--r--misc/translator/files/patch-translator.pl187
-rw-r--r--misc/translator/pkg-descr9
-rw-r--r--misc/translator/pkg-plist4
5 files changed, 249 insertions, 0 deletions
diff --git a/misc/translator/Makefile b/misc/translator/Makefile
new file mode 100644
index 000000000000..8dc3e38871ae
--- /dev/null
+++ b/misc/translator/Makefile
@@ -0,0 +1,47 @@
+# New ports collection makefile for: translator
+# Date created: 24 Oct 2004
+# Whom: Jean-Yves Lefort <jylefort@brutele.be>
+#
+# $FreeBSD$
+#
+
+PORTNAME= translator
+PORTVERSION= 0.1.0
+CATEGORIES= misc
+MASTER_SITES= http://jodrell.net/files/translator/
+
+MAINTAINER= jylefort@brutele.be
+COMMENT= A GTK+ frontend to the Babelfish translation service
+
+RUN_DEPENDS= ${SITE_PERL}/${PERL_ARCH}/Gtk2.pm:${PORTSDIR}/x11-toolkits/p5-Gtk2 \
+ ${SITE_PERL}/${PERL_ARCH}/Gtk2/GladeXML.pm:${PORTSDIR}/x11-toolkits/p5-Glade2 \
+ ${SITE_PERL}/${PERL_ARCH}/Gnome2/GConf.pm:${PORTSDIR}/devel/p5-Gnome2-GConf \
+ ${SITE_PERL}/WWW/Babelfish.pm:${PORTSDIR}/www/p5-WWW-Babelfish
+
+USE_X_PREFIX= yes
+USE_PERL5= yes
+NO_BUILD= yes
+
+.include <bsd.port.pre.mk>
+
+HAVE_THREADS!= ${PERL} -mthreads -e '' >/dev/null 2>&1 && ${ECHO} 'yes' || true
+
+.if ${PERL_LEVEL} < 500800 || empty(HAVE_THREADS)
+IGNORE= "Needs threaded perl 5.8.0 or higher, install lang/perl5.8 with threads support and try again"
+.endif
+
+post-patch:
+ @${SED} -e \
+ 's|share/pixmaps|share/gnome/pixmaps| ; \
+ s|@PREFIX@|${PREFIX}|' \
+ ${WRKSRC}/translator.pl > ${WRKSRC}/translator
+
+do-install:
+ ${MKDIR} ${PREFIX}/bin
+ ${INSTALL_SCRIPT} ${WRKSRC}/translator ${PREFIX}/bin
+ ${MKDIR} ${PREFIX}/share/gnome/pixmaps
+ ${INSTALL_DATA} ${WRKSRC}/translator.png ${PREFIX}/share/gnome/pixmaps
+ ${MKDIR} ${PREFIX}/share/translator
+ ${INSTALL_DATA} ${WRKSRC}/translator.glade ${PREFIX}/share/translator
+
+.include <bsd.port.post.mk>
diff --git a/misc/translator/distinfo b/misc/translator/distinfo
new file mode 100644
index 000000000000..a52c81282738
--- /dev/null
+++ b/misc/translator/distinfo
@@ -0,0 +1,2 @@
+MD5 (translator-0.1.0.tar.gz) = abaae4506a2ea366b35423289034eeaf
+SIZE (translator-0.1.0.tar.gz) = 17214
diff --git a/misc/translator/files/patch-translator.pl b/misc/translator/files/patch-translator.pl
new file mode 100644
index 000000000000..e61d9db0cdb7
--- /dev/null
+++ b/misc/translator/files/patch-translator.pl
@@ -0,0 +1,187 @@
+
+$FreeBSD$
+
+--- translator.pl.orig
++++ translator.pl
+@@ -2,20 +2,19 @@
+ # nifty front-end to Altavista's Babel Fish.
+ # $Id: translator.pl,v 1.13 2003/12/19 11:50:02 jodrell Exp $
+ use WWW::Babelfish;
+-use IO::Scalar;
+ use threads;
+ use threads::shared;
++use Thread::Queue;
+ use File::Basename qw(basename);
+-use Data::Dumper;
+ use strict;
+
+ #
+ # these are shared between the main thread and the worker:
+ #
+-my @queue : shared;
++my $input_queue = new Thread::Queue;
++my $output_queue = new Thread::Queue;
++
+ my @errors : shared;
+-my $finished : shared;
+-my $output : shared;
+ my $source : shared;
+ my $dest : shared;
+ my $running : shared;
+@@ -30,9 +29,6 @@
+ #
+ # set up the application:
+ #
+-$finished = 0;
+-$pending = 0;
+-
+ my $NAME = 'Translator';
+ my $VERSION = '0.1.0';
+ my $RCFILE = sprintf('%s/.%src', $ENV{HOME}, lc($NAME));
+@@ -80,24 +76,25 @@
+ # places output into the $output array, and we need to keep the entry up to date:
+ #
+ Glib::Timeout->add(50, sub {
+- if ($pending == 1) {
+- $app->get_widget('output')->get_buffer->set_text($output) ;
+- $pending = 0;
++ if (defined(my $output = $output_queue->dequeue_nb)) {
++ $app->get_widget('output')->get_buffer->set_text($output);
+ }
+- if ($running == 1) {
+- $app->get_widget('main_window')->get_root_window->set_cursor($busy);
+- $app->get_widget('translate_button')->set_sensitive(0);
+- $app->get_widget('input')->set_editable(0);
+- } else {
+- $app->get_widget('main_window')->get_root_window->set_cursor($normal);
+- $app->get_widget('translate_button')->set_sensitive(1);
+- $app->get_widget('input')->set_editable(1);
++
++ {
++ lock($running);
++ $app->get_widget('main_window')->get_root_window->set_cursor($running ? $busy: $normal);
++ $app->get_widget('translate_button')->set_sensitive(! $running);
++ $app->get_widget('input')->set_editable(! $running);
+ }
+- if (scalar(@errors) > 0) {
+- my $error_dialog = Gtk2::MessageDialog->new($app->get_widget('main_window'), 'modal', 'error', 'ok', shift(@errors));
+- $error_dialog->set_icon($app->get_widget('main_window')->get_icon);
+- $error_dialog->signal_connect('response', sub { $error_dialog->destroy });
+- $error_dialog->show_all;
++
++ {
++ lock(@errors);
++ if (scalar(@errors) > 0) {
++ my $error_dialog = Gtk2::MessageDialog->new($app->get_widget('main_window'), 'modal', 'error', 'ok', shift(@errors));
++ $error_dialog->set_icon($app->get_widget('main_window')->get_icon);
++ $error_dialog->signal_connect('response', sub { $error_dialog->destroy });
++ $error_dialog->show_all;
++ }
+ }
+ return 1;
+ });
+@@ -107,46 +104,60 @@
+ Gtk2->main;
+
+ sub worker {
+- my $fish = WWW::Babelfish->new;
++ my $fish = WWW::Babelfish->new(agent => 'Mozilla/8.0');
+ $fish->{ua}->timeout(10);
+- while ($finished == 0) {
+- if (scalar(@queue) > 0) {
++ while (my $input = $input_queue->dequeue) {
++ my $output = '';
++ {
++ lock($running);
+ $running = 1;
+- $output = '';
+- my $input = shift(@queue);
+- my $fh = IO::Scalar->new(\$output);
++ }
++ open my $fh, ">", \$output or die;
++ {
++ lock($proxy);
+ if ($proxy ne '') {
+ $fish->{proxy} = $proxy;
+ $fish->{ua}->proxy('http', 'http://'.$proxy.'/');
+ }
++ }
++ {
++ lock($source);
++ lock($dest);
+ if (!$fish->translate(
+ source => $source,
+ destination => $dest,
+ ofh => $fh,
+ text => $input,
+ )) {
++ lock(@errors);
+ push(@errors, "Error: $!");
+ }
+- $pending = 1;
+- } else {
++ }
++ {
++ lock($running);
+ $running = 0;
+- threads->yield;
+ }
++ $output_queue->enqueue($output);
+ }
+- return 1;
+ }
+
+ sub close_program {
+ save_options();
+- $finished = 1;
++ $input_queue->enqueue(undef); # terminate the worker thread
+ Gtk2->main_quit;
+ $worker->join;
+ exit;
+ }
+
+ sub translate {
+- $source = $app->get_widget('from_combo')->entry->get_text;
+- $dest = $app->get_widget('to_combo')->entry->get_text;
++ {
++ lock($source);
++ $source = $app->get_widget('from_combo')->entry->get_text;
++ }
++ {
++ lock($dest);
++ $dest = $app->get_widget('to_combo')->entry->get_text;
++ }
+ my $input = $app->get_widget('input')->get_buffer->get_text(
+ $app->get_widget('input')->get_buffer->get_start_iter,
+ $app->get_widget('input')->get_buffer->get_end_iter,
+@@ -159,9 +170,12 @@
+ } else {
+ $message = 'Please enter some text to translate.';
+ }
+- push(@errors, $message);
++ {
++ lock(@errors);
++ push(@errors, $message);
++ }
+ } else {
+- push(@queue, $input);
++ $input_queue->enqueue($input);
+ }
+ return 1;
+ }
+@@ -284,6 +298,7 @@
+ }
+
+ sub source_changed {
++ lock($source);
+ $source = $app->get_widget('from_combo')->entry->get_text;
+ return undef if ($source eq '');
+ $app->get_widget('to_combo')->set_popdown_strings(sort(keys(%{$pairs->{$source}})));
+@@ -292,6 +307,7 @@
+
+ sub set_proxy {
+ if ($client->get_bool($use_proxy_key) == 1) {
++ lock($proxy);
+ $proxy = sprintf(
+ '%s:%d',
+ $client->get_string($proxy_host),
diff --git a/misc/translator/pkg-descr b/misc/translator/pkg-descr
new file mode 100644
index 000000000000..a43d78eeb467
--- /dev/null
+++ b/misc/translator/pkg-descr
@@ -0,0 +1,9 @@
+Translator is a simple front-end to AltaVista's excellent
+Babelfish. It is designed to integrate into the GNOME desktop, and as
+such features an (almost) HIG compliant interface, and support for
+GNOME's HTTP proxy settings.
+
+WWW: http://jodrell.net/projects/translator/
+
+- Jean-Yves Lefort
+jylefort@brutele.be
diff --git a/misc/translator/pkg-plist b/misc/translator/pkg-plist
new file mode 100644
index 000000000000..4244db74f1a3
--- /dev/null
+++ b/misc/translator/pkg-plist
@@ -0,0 +1,4 @@
+bin/translator
+share/gnome/pixmaps/translator.png
+%%DATADIR%%/translator.glade
+@dirrm %%DATADIR%%