[uim-commit] r607 - in trunk: . gtk po scm
makeinu at freedesktop.org
makeinu at freedesktop.org
Mon Feb 7 20:06:22 PST 2005
Author: makeinu
Date: 2005-02-07 20:06:19 -0800 (Mon, 07 Feb 2005)
New Revision: 607
Added:
trunk/gtk/uim-eb.c
trunk/gtk/uim-eb.h
Modified:
trunk/configure.ac
trunk/gtk/Makefile.am
trunk/gtk/uim-cand-win-gtk.c
trunk/po/ja.po
trunk/po/uim.pot
trunk/scm/im-custom.scm
Log:
* gtk/uim-eb.[ch]
- New files to add EB support for annotation. This code is based on
kzk-san's patch.
But it is a very ad-hoc solution. Although it shoud be written in
scheme code, I commit the ad-hoc solution to advance annotation
and sub-window related discussion.
* gtk/uim-cand-win-gtk.c
- (tree_selection_changed): Added EB support.
* gtk/Makefile.am
- Ditto
* scm/im-custom.scm
- Added EB related settings.
* po/ja.po, po/uim.pot
- Updated.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/configure.ac 2005-02-08 04:06:19 UTC (rev 607)
@@ -398,7 +398,52 @@
],
[ use_dict="no" ])
+dnl ****************************
+dnl *** Tests for EB Library ***
+dnl ****************************
+use_eb="no"
+AC_ARG_WITH(eb,
+ AS_HELP_STRING([--without-eb],
+ [Don't build against EB]),
+ [
+ if test "x$with_eb" = "xyes"; then
+ _SAVE_LDFLAGS=$LDFLAGS
+ EB_LDFLAGS="-lz"
+ LDFLAGS="$LDFLAGS $EB_LDFLAGS"
+ AC_CHECK_LIB(eb, eb_initialize_library, HAVE_EBLIB=yes, HAVE_EBLIB=no)
+ if test "x$HAVE_EBLIB" = "xyes"; then
+ AC_CHECK_HEADER(eb/eb.h, HAVE_EBLIB=yes, HAVE_EBLIB=no)
+ if test "x$HAVE_EBLIB" = "xyes"; then
+ AC_DEFINE(HAVE_EBLIB, 1,
+ [Define to 1 if you have EB library and header file])
+ EBLIB_LIBS="-leb -lz"
+ use_eb="yes"
+ fi
+ LDFLAGS=$_SAVE_LDFLAGS
+ fi
+ fi
+ ],
+ [
+ _SAVE_LDFLAGS=$LDFLAGS
+ EB_LDFLAGS="-lz"
+ LDFLAGS="$LDFLAGS $EB_LDFLAGS"
+ AC_CHECK_LIB(eb, eb_initialize_library, HAVE_EBLIB=yes, HAVE_EBLIB=no)
+ if test "x$HAVE_EBLIB" = "xyes"; then
+ AC_CHECK_HEADER(eb/eb.h, HAVE_EBLIB=yes, HAVE_EBLIB=no)
+ if test "x$HAVE_EBLIB" = "xyes"; then
+ AC_DEFINE(HAVE_EBLIB, 1,
+ [Define to 1 if you have EB library and header file])
+ EBLIB_LIBS="-leb"
+ use_eb="yes"
+ fi
+ fi
+ LDFLAGS=$_SAVE_LDFLAGS
+])
+
+AC_SUBST(EBLIB_LIBS)
+
+
AM_CONDITIONAL(M17NLIB, test x$use_m17nlib = xyes)
AM_CONDITIONAL(SCIM, test x$use_scim = xyes)
AM_CONDITIONAL(ANTHY, test x$use_anthy = xyes)
@@ -414,6 +459,7 @@
AM_CONDITIONAL(UIM_FEP, test x$use_uim_fep = xyes)
AM_CONDITIONAL(XIM, test x$use_xim = xyes)
AM_CONDITIONAL(DICT, test x$use_dict = xyes)
+AM_CONDITIONAL(EB, test x$use_eb = xyes)
AM_CONDITIONAL(DEBUG, test x$enable_debug = xyes)
AM_CONDITIONAL(COMPAT_SCM, test x$enable_compat_scm = xyes)
AM_CONDITIONAL(COMPAT_TABLE, test x$enable_compat_table = xyes)
@@ -684,6 +730,7 @@
FEP : ${use_uim_fep}
XIM : ${use_xim}
DICT : ${use_dict}
+ EB : ${use_eb}
Default toolkit : ${default_toolkit}
])
Modified: trunk/gtk/Makefile.am
===================================================================
--- trunk/gtk/Makefile.am 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/gtk/Makefile.am 2005-02-08 04:06:19 UTC (rev 607)
@@ -11,13 +11,17 @@
im_uim_la_SOURCES = $(IM_UIM_SOURCES)
im_uim_la_LDFLAGS = -module -avoid-version @GTK2_LIBS@
-im_uim_la_LIBADD = $(top_builddir)/uim/libuim.la
+im_uim_la_LIBADD = $(top_builddir)/uim/libuim.la $(EBLIB_LIBS)
IM_UIM_SOURCES = \
gtk-im-uim.c \
uim-cand-win-gtk.c uim-cand-win-gtk.h
+if EB
+IM_UIM_SOURCES += uim-eb.c uim-eb.h
+endif
+
install-data-hook:
if test -f $(GTK_IMMODULES); then \
gtk-query-immodules-2.0 > $(GTK_IMMODULES); \
Modified: trunk/gtk/uim-cand-win-gtk.c
===================================================================
--- trunk/gtk/uim-cand-win-gtk.c 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/gtk/uim-cand-win-gtk.c 2005-02-08 04:06:19 UTC (rev 607)
@@ -34,6 +34,11 @@
#include "uim-cand-win-gtk.h"
#include <string.h>
#include <uim/uim.h>
+#include <uim/uim-compat-scm.h>
+#include "uim/config.h"
+#if HAVE_EBLIB
+#include "uim-eb.h"
+#endif /* HAVE_EBLIB */
#define NR_CANDIDATES 20 /* FIXME! not used yet */
#define DEFAULT_MIN_WINDOW_WIDTH 80
@@ -341,9 +346,36 @@
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
gchar *annotation = NULL;
+#if HAVE_EBLIB
+ /* FIXME! This is a ad-hoc solution to advance
+ annotation related discussion. */
+ if (uim_scm_symbol_value_bool("eb-enable?")) {
+ gchar *cand = NULL;
+
+ gtk_tree_model_get(model, &iter,
+ COLUMN_CANDIDATE, &cand,
+ -1);
+ if (cand && *cand) {
+ char *book;
+ uim_eb *ueb = NULL;
+
+ book = uim_scm_symbol_value_str("eb-dic-path");
+ if (book && *book)
+ ueb = uim_eb_new(book);
+ if (ueb) {
+ annotation = uim_eb_search_text(ueb, cand);
+ uim_eb_destroy(ueb);
+ }
+ g_free(book);
+ }
+ g_free(cand);
+ }
+#else /* HAVE_EB_LIB */
gtk_tree_model_get(model, &iter,
COLUMN_ANNOTATION, &annotation,
-1);
+#endif /* HAVE_EB_LIB */
+
if (annotation && *annotation) {
if (!cwin->sub_window.window)
uim_cand_win_gtk_create_sub_window(cwin);
Added: trunk/gtk/uim-eb.c
===================================================================
--- trunk/gtk/uim-eb.c 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/gtk/uim-eb.c 2005-02-08 04:06:19 UTC (rev 607)
@@ -0,0 +1,195 @@
+/*
+
+ Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+*/
+
+/* FIXME! This is a ad-hoc solution to advance
+ annotation related discussion. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <eb/eb.h>
+#include <eb/text.h>
+#include <eb/font.h>
+#include <eb/binary.h>
+#include <eb/error.h>
+
+#include "uim-eb.h"
+
+#define MAX_HITS 10
+#define MAX_TEXT 1000
+#define MAX_LENGTH 10000
+
+struct _uim_eb {
+ EB_Book book;
+ EB_Subbook_Code subCodes[EB_MAX_SUBBOOKS];
+ int subCount;
+};
+
+static void go_text_eb (uim_eb *ueb,
+ EB_Position position,
+ GString *str);
+
+static unsigned int eb_ref_count = 0;
+
+uim_eb *
+uim_eb_new (const char *bookpath)
+{
+ uim_eb *ueb;
+ EB_Error_Code err;
+
+ ueb = malloc(sizeof(uim_eb));
+ eb_ref_count++;
+
+ err = eb_initialize_library();
+ if (err != EB_SUCCESS)
+ fprintf(stderr, "failed to initialize EB library : error = %s\n",
+ eb_error_message(err));
+
+ eb_initialize_book(&ueb->book);
+
+ err = eb_bind(&ueb->book, bookpath);
+ if (err != EB_SUCCESS) {
+ fprintf(stderr, "wrong bookpath\n");
+ free(ueb);
+ return NULL;
+ }
+
+ err = eb_subbook_list(&ueb->book, ueb->subCodes, &ueb->subCount);
+ if (err != EB_SUCCESS) {
+ g_printerr("eb_subbook_list() failed\n");
+ free(ueb);
+ return NULL;
+ }
+
+ return ueb;
+}
+
+
+void
+uim_eb_destroy (uim_eb *ueb)
+{
+ if (!ueb)
+ return;
+
+ eb_finalize_book(&ueb->book);
+
+ eb_ref_count--;
+ if (eb_ref_count == 0)
+ eb_finalize_library();
+}
+
+
+char *
+uim_eb_search_text (uim_eb *ueb, const gchar *text_utf8)
+{
+ gchar *text;
+ int i;
+ gsize bytes_read, bytes_written;
+ GString *str;
+
+ /* FIXME! check return value */
+ text = g_convert(text_utf8, strlen(text_utf8),
+ "EUC-JP", "UTF-8",
+ &bytes_read, &bytes_written,
+ NULL);
+ g_return_val_if_fail(text, FALSE);
+
+ str = g_string_new("");
+
+ for (i = 0; i < ueb->subCount; i++) {
+ EB_Hit hits[MAX_HITS];
+ int hitCount;
+ int j;
+
+ /* specify subbook */
+ if (eb_set_subbook(&ueb->book, ueb->subCodes[i]) != EB_SUCCESS) {
+ g_print("eb_set_subbook() failed\n"); continue;
+ }
+
+ eb_search_word(&ueb->book, text);
+ eb_hit_list(&ueb->book, MAX_HITS, hits, &hitCount);
+ for (j = 0; j < hitCount; j++) {
+ /*EB_Position headp = hits[j].heading;*/
+ EB_Position textp = hits[j].text;
+
+ go_text_eb(ueb, textp, str);
+ g_string_append(str, "\n");
+ }
+ }
+
+ g_free(text);
+
+ return g_string_free(str, FALSE);
+}
+
+
+static void
+go_text_eb (uim_eb *ueb, EB_Position position, GString *str)
+{
+ EB_Hookset hookset;
+ char text[MAX_TEXT + 1];
+ int text_length;
+ int bytes;
+ int i;
+
+ if (eb_seek_text(&ueb->book, &position) != EB_SUCCESS) {
+ g_print("eb_seek_text error occurs");
+ return;
+ }
+
+ eb_initialize_hookset(&hookset);
+ for (i = 0; i < 1; i++) {
+ gchar *text_utf8;
+ gsize bytes_read, bytes_written;
+
+ if (eb_read_text(&ueb->book, NULL, &hookset,
+ NULL, MAX_TEXT, text, &text_length) != EB_SUCCESS) {
+ bytes = 0;
+ g_print("eb_read_text : an error occurs.\n");
+ return;
+ }
+
+ bytes += text_length;
+ if (text_length < 1)
+ break;
+
+ /* FIXME! check return value */
+ text_utf8 = g_convert(text, strlen(text),
+ "UTF-8", "EUC-JP",
+ &bytes_read, &bytes_written,
+ NULL);
+ g_string_append(str, text_utf8);
+ g_free(text_utf8);
+ }
+ eb_finalize_hookset(&hookset);
+}
Added: trunk/gtk/uim-eb.h
===================================================================
--- trunk/gtk/uim-eb.h 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/gtk/uim-eb.h 2005-02-08 04:06:19 UTC (rev 607)
@@ -0,0 +1,53 @@
+/*
+
+ Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+*/
+
+/* FIXME! This is a ad-hoc solution to advance
+ annotation related discussion. */
+
+#ifndef _uim_eb_h_included_
+#define _uim_eb_h_included_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _uim_eb uim_eb;
+
+uim_eb *uim_eb_new (const char *bookpath);
+char *uim_eb_search_text (uim_eb *ueb,
+ const gchar *text);
+void uim_eb_destroy (uim_eb *ueb);
+
+G_END_DECLS
+
+#endif /* _uim_eb_h_included_ */
Modified: trunk/po/ja.po
===================================================================
--- trunk/po/ja.po 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/po/ja.po 2005-02-08 04:06:19 UTC (rev 607)
@@ -13,9 +13,9 @@
msgstr ""
"Project-Id-Version: uim 0.4.6-alpha1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-02-08 02:49+0900\n"
-"PO-Revision-Date: 2005-02-08 02:58+0900\n"
-"Last-Translator: YamaKen <yamaken at bp.iij4u.or.jp>\n"
+"POT-Creation-Date: 2005-02-08 12:53+0900\n"
+"PO-Revision-Date: 2005-02-08 12:54+0900\n"
+"Last-Translator: Takuro Ashie <ashie at homa.ne.jp>\n"
"Language-Team: Japanese <LL at li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=EUC-JP\n"
@@ -546,6 +546,7 @@
#: scm/im-custom.lisp:101 scm/im-custom.lisp:112 scm/im-custom.lisp:122
#: scm/im-custom.lisp:215 scm/im-custom.lisp:275 scm/im-custom.lisp:291
#: scm/im-custom.lisp:297 scm/im-custom.lisp:303 scm/im-custom.lisp:310
+#: scm/im-custom.lisp:318 scm/im-custom.lisp:324 scm/im-custom.lisp:331
#: scm/prime-custom.lisp:58 scm/prime-custom.lisp:64 scm/prime-custom.lisp:70
#: scm/prime-custom.lisp:76 scm/prime-custom.lisp:82 scm/prime-custom.lisp:90
#: scm/prime-custom.lisp:96 scm/prime-custom.lisp:102
@@ -1227,6 +1228,18 @@
msgid "Enable lazy input method loading for fast startup"
msgstr "¹â®µ¯Æ°¤Î¤¿¤á¤ÎÃÙ±ä¥í¡¼¥Ç¥£¥ó¥°¤ò͸ú¤Ë¤¹¤ë"
+#: scm/im-custom.lisp:317
+msgid "EB library settings"
+msgstr "EB¥é¥¤¥Ö¥é¥êÀßÄê"
+
+#: scm/im-custom.lisp:323
+msgid "Use EB library to search annotations"
+msgstr "Ãí¼á¤Î¸¡º÷¤ËEB¥é¥¤¥Ö¥é¥ê¤ò»ÈÍѤ¹¤ë"
+
+#: scm/im-custom.lisp:330
+msgid "The directory which contains EB dictionary file"
+msgstr "EB¼½ñ¥Õ¥¡¥¤¥ë¤ò³ÊǼ¤·¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥ê"
+
#: scm/ipa.lisp:227 scm/ipa.lisp:228
msgid "International Phonetic Alphabet (X-SAMPA)"
msgstr "IPA (¹ñºÝȯÀ¼µ¹æ X-SAMPAÈÇ)"
Modified: trunk/po/uim.pot
===================================================================
--- trunk/po/uim.pot 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/po/uim.pot 2005-02-08 04:06:19 UTC (rev 607)
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-02-08 02:49+0900\n"
+"POT-Creation-Date: 2005-02-08 12:53+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
@@ -527,6 +527,7 @@
#: scm/im-custom.lisp:101 scm/im-custom.lisp:112 scm/im-custom.lisp:122
#: scm/im-custom.lisp:215 scm/im-custom.lisp:275 scm/im-custom.lisp:291
#: scm/im-custom.lisp:297 scm/im-custom.lisp:303 scm/im-custom.lisp:310
+#: scm/im-custom.lisp:318 scm/im-custom.lisp:324 scm/im-custom.lisp:331
#: scm/prime-custom.lisp:58 scm/prime-custom.lisp:64 scm/prime-custom.lisp:70
#: scm/prime-custom.lisp:76 scm/prime-custom.lisp:82 scm/prime-custom.lisp:90
#: scm/prime-custom.lisp:96 scm/prime-custom.lisp:102
@@ -1207,6 +1208,18 @@
msgid "Enable lazy input method loading for fast startup"
msgstr ""
+#: scm/im-custom.lisp:317
+msgid "EB library settings"
+msgstr ""
+
+#: scm/im-custom.lisp:323
+msgid "Use EB library to search annotations"
+msgstr ""
+
+#: scm/im-custom.lisp:330
+msgid "The directory which contains EB dictionary file"
+msgstr ""
+
#: scm/ipa.lisp:227 scm/ipa.lisp:228
msgid "International Phonetic Alphabet (X-SAMPA)"
msgstr ""
Modified: trunk/scm/im-custom.scm
===================================================================
--- trunk/scm/im-custom.scm 2005-02-08 02:48:24 UTC (rev 606)
+++ trunk/scm/im-custom.scm 2005-02-08 04:06:19 UTC (rev 607)
@@ -308,3 +308,24 @@
'(boolean)
(_ "Enable lazy input method loading for fast startup")
(_ "long description will be here."))
+
+
+;; EB Library support
+;; 2005-02-08 Takuro Ashie <ashie at homa.ne.jp>
+;; FIXME! Here isn't suitable position for EB support preference
+(define-custom-group 'eb
+ (_ "EB library settings")
+ (_ "long description will be here."))
+
+(define-custom 'eb-enable? #f
+ '(eb candwin)
+ '(boolean)
+ (_ "Use EB library to search annotations")
+ (_ "long description will be here."))
+
+(define-custom 'eb-dic-path
+ (string-append (getenv "HOME") "/dict")
+ '(eb candwin)
+ '(pathname)
+ (_ "The directory which contains EB dictionary file")
+ (_ "long description will be here."))
More information about the Uim-commit
mailing list