Author: ek.kato
Date: Mon Jan 26 00:34:33 2009
New Revision: 5781
Modified:
trunk/configure.ac
trunk/helper/dict-anthy.c
trunk/helper/dict-word-win-gtk.c
Log:
* configure.ac : AC_DEFINE(LIBANTHY_UTF8_CAPABLE) for
uim-dict-gtk.
* helper/dict-anthy.c
- (dict_anthy_init)
- (dict_anthy_read_priv_dic_list)
- (uim_dict_anthy_open)
- Use UTF-8 if LIBANTHY_UTF8_CAPABLE is defined.
* dict-word-win-gtk.c
- (word_window_set_word)
- (word_window_add)
- Convert cclass_desc appropriately.
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Jan 26 00:34:33 2009
@@ -124,6 +124,9 @@
if test "x$use_anthy" = "xyes"; then
ANTHY_LIBS="-lanthy -lanthydic"
ANTHY_CFLAGS=""
+ PKG_CHECK_EXISTS(anthy >= 8622,
+ [AC_DEFINE(LIBANTHY_UTF8_CAPABLE, 1,
+ "libanthy can handle UTF-8")])
fi
AC_SUBST(ANTHY_LIBS)
AC_SUBST(ANTHY_CFLAGS)
@@ -141,8 +144,11 @@
use_anthy_utf8="no"
;;
yes|*)
- PKG_CHECK_MODULES(ANTHY_UTF8, anthy >= 8622, use_anthy_utf8="yes",
- use_anthy_utf8="no")
+ PKG_CHECK_MODULES(ANTHY_UTF8, anthy >= 8622,
+ [use_anthy_utf8="yes"
+ AC_DEFINE(LIBANTHY_UTF8_CAPABLE, 1,
+ [libanthy can handle UTF-8])],
+ use_anthy_utf8="no")
;;
esac
],
Modified: trunk/helper/dict-anthy.c
==============================================================================
--- trunk/helper/dict-anthy.c (original)
+++ trunk/helper/dict-anthy.c Mon Jan 26 00:34:33 2009
@@ -39,11 +39,13 @@
#include <stdlib.h>
#include <glib.h>
+#include <anthy/anthy.h>
#include <anthy/dicutil.h>
#include "gettext.h"
#include "dict-anthy.h"
#include "dict-canna-cclass.h"
+#include "dict-util.h"
static uim_dict *uim_dict_anthy_open (const char *identifier);
static void uim_dict_anthy_close (uim_dict *dict);
@@ -86,6 +88,9 @@
dict_anthy_init(void)
{
anthy_dic_util_init();
+#if LIBANTHY_UTF8_CAPABLE
+ anthy_dic_util_set_encoding(ANTHY_UTF8_ENCODING);
+#endif
return 0;
}
@@ -130,10 +135,21 @@
break;
}
+#if LIBANTHY_UTF8_CAPABLE
+ {
+ gchar *cclass_code_utf8 = eucjp_to_utf8(cclass_code);
+ word_append(head, WORD_TYPE_ANTHY, "UTF-8",
+ phon, desc, cclass_code_utf8, cclass_native,
+ anthy_priv_dic_get_freq(),
+ 0, NULL);
+ g_free(cclass_code_utf8);
+ }
+#else /* EUC-JP */
word_append(head, WORD_TYPE_ANTHY, "EUC-JP",
phon, desc, cclass_code, cclass_native,
anthy_priv_dic_get_freq(),
0, NULL);
+#endif
}
ret = anthy_priv_dic_select_next_entry();
}
@@ -195,7 +211,11 @@
dict->funcs = &uim_dict_class_anthy;
dict->identifier = strdup(identifier);
dict->filename = NULL;
+#if LIBANTHY_UTF8_CAPABLE
+ dict->charset = strdup("UTF-8");
+#else
dict->charset = strdup("EUC-JP");
+#endif
dict->ref_count = 0; /* at this point, no window refers this */
dict->word_list = NULL;
Modified: trunk/helper/dict-word-win-gtk.c
==============================================================================
--- trunk/helper/dict-word-win-gtk.c (original)
+++ trunk/helper/dict-word-win-gtk.c Mon Jan 26 00:34:33 2009
@@ -395,7 +395,13 @@
adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->freq));
gtk_adjustment_set_value(adj, w->freq);
- cclass_type = find_cclass_type_from_desc(w->cclass_code);
+ if (!strcmp(w->charset, "UTF-8")) {
+ gchar *desc = utf8_to_eucjp(w->cclass_code);
+ cclass_type = find_cclass_type_from_desc(desc);
+ g_free(desc);
+ } else
+ cclass_type = find_cclass_type_from_desc(w->cclass_code);
+
if (cclass_type >= 0)
gtk_combo_box_set_active(GTK_COMBO_BOX(window->combobox_pos_broad),
cclass_type);
@@ -432,7 +438,7 @@
{
gboolean valid;
const char *utf8_phonetic, *utf8_literal, *utf8_cclass_desc;
- char *phonetic, *literal, *cclass_desc, *cclass_native = NULL;
+ gchar *phonetic, *literal, *cclass_desc, *cclass_native = NULL;
gint freq, ret, pos_id;
GtkWidget *dialog;
uim_word_type type;
@@ -451,7 +457,7 @@
phonetic = charset_convert(utf8_phonetic, "UTF-8",
window->dict->charset);
literal = charset_convert(utf8_literal, "UTF-8",
window->dict->charset);
- cclass_desc = charset_convert(utf8_cclass_desc, "UTF-8",
window->dict->charset);
+ cclass_desc = utf8_to_eucjp(utf8_cclass_desc);
type = dict_identifier_to_word_type(window->dict->identifier);
if (cclass_desc)
@@ -656,7 +662,7 @@
break;
}
- utf8_desc = charset_convert(desc, window->dict->charset, "UTF-8");
+ utf8_desc = eucjp_to_utf8(desc);
if (utf8_desc) {
gtk_entry_set_text(entry, utf8_desc);
g_free(utf8_desc);
@@ -687,7 +693,6 @@
cclass_desc = find_desc_from_code_with_type(cclass_code, type);
- /* FIXME!! cclass_desc is encoded in UTF-8 */
if (cclass_desc) {
utf8_cclass_desc = charset_convert(cclass_desc, "EUC-JP", "UTF-8");
} else {