• R/O
  • SSH
  • HTTPS

comatz: Commit


Commit MetaInfo

Revisão14 (tree)
Hora2007-04-20 16:52:46
Autorkous

Mensagem de Log

* comatz/cm-dict.[ch], module/anthy/cm-anthy-dict.c: implemented

register but may not work.

Mudança Sumário

Diff

--- comatz/trunk/module/anthy/cm-anthy-dict.c (revision 13)
+++ comatz/trunk/module/anthy/cm-anthy-dict.c (revision 14)
@@ -27,37 +27,45 @@
2727 #include "cm-module.h"
2828 #include "cm-module-impl.h"
2929
30-#define CM_TYPE_ANTHY_DICT (cm_type_anthy_dict)
31-#define CM_ANTHY_DICT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CM_TYPE_ANTHY_DICT, CmAnthyDict))
32-#define CM_IS_ANTHY_DICT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CM_TYPE_ANTHY_DICT))
33-#define CM_ANTHY_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CM_TYPE_ANTHY_DICT, CmAnthyDictClass))
34-#define CM_IS_ANTHY_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CM_TYPE_ANTHY_DICT))
35-#define CM_ANTHY_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CM_TYPE_ANTHY_DICT, CmAnthyDictClass))
30+#include <anthy/anthy.h>
31+#include <anthy/dicutil.h>
3632
37-typedef struct _CmAnthyDict CmAnthyDict;
33+#define DEFAULT_FREQUENCY 100 /* FIXME */
3834
35+#define CM_TYPE_ANTHY_DICT (cm_type_anthy_dict)
36+#define CM_ANTHY_DICT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CM_TYPE_ANTHY_DICT, CmAnthyDict))
37+#define CM_IS_ANTHY_DICT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CM_TYPE_ANTHY_DICT))
38+#define CM_ANTHY_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CM_TYPE_ANTHY_DICT, CmAnthyDictClass))
39+#define CM_IS_ANTHY_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CM_TYPE_ANTHY_DICT))
40+#define CM_ANTHY_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CM_TYPE_ANTHY_DICT, CmAnthyDictClass))
41+
42+typedef struct _CmAnthyDict CmAnthyDict;
43+
3944 struct _CmAnthyDict
4045 {
41- GObject parent;
46+ GObject parent;
4247 };
4348
44-typedef struct _CmAnthyDictClass CmAnthyDictClass;
49+typedef struct _CmAnthyDictClass CmAnthyDictClass;
4550 struct _CmAnthyDictClass
4651 {
47- GObjectClass parent_class;
52+ GObjectClass parent_class;
4853 };
4954
5055
5156 /* CmAnthyDict Class */
52-static void cm_anthy_dict_class_init (CmAnthyDictClass *klass);
53-static void cm_anthy_dict_init (CmAnthyDict *dict);
57+static void cm_anthy_dict_class_init (CmAnthyDictClass *klass);
58+static void cm_anthy_dict_init (CmAnthyDict *dict);
5459
5560 /* GObject Class */
56-static void dispose (GObject *object);
61+static void dispose (GObject *object);
5762
5863 /* CmDictIFace */
59-static void cm_anthy_dict_iface_init (CmDictIFace *iface);
64+static void cm_anthy_dict_iface_init (CmDictIFace *iface);
6065
66+static gboolean register_word (CmDict *dict,
67+ CmWord *word);
68+
6169 static GObjectClass *parent_class;
6270 static GType cm_type_anthy_dict = 0;
6371
@@ -64,55 +72,59 @@
6472 static void
6573 cm_anthy_dict_register_type (GTypeModule *module)
6674 {
67- static const GTypeInfo cm_anthy_dict_info =
68- {
69- sizeof (CmAnthyDictClass),
70- NULL, /* base_init */
71- NULL, /* base_finalize */
72- (GClassInitFunc)cm_anthy_dict_class_init,
73- NULL, /* class_finalize */
74- NULL, /* class_data */
75- sizeof (CmAnthyDict),
76- 0, /* n_preallocs */
77- (GInstanceInitFunc)cm_anthy_dict_init,
78- };
75+ static const GTypeInfo cm_anthy_dict_info =
76+ {
77+ sizeof (CmAnthyDictClass),
78+ NULL, /* base_init */
79+ NULL, /* base_finalize */
80+ (GClassInitFunc)cm_anthy_dict_class_init,
81+ NULL, /* class_finalize */
82+ NULL, /* class_data */
83+ sizeof (CmAnthyDict),
84+ 0, /* n_preallocs */
85+ (GInstanceInitFunc)cm_anthy_dict_init,
86+ };
7987
80- const GInterfaceInfo cm_dict_info =
81- {
82- (GInterfaceInitFunc)cm_anthy_dict_iface_init,
83- NULL,
84- NULL
85- };
88+ const GInterfaceInfo cm_dict_info =
89+ {
90+ (GInterfaceInitFunc)cm_anthy_dict_iface_init,
91+ NULL,
92+ NULL
93+ };
8694
87- cm_type_anthy_dict =
95+ cm_type_anthy_dict =
8896 g_type_module_register_type(module,
8997 G_TYPE_OBJECT,
9098 "CmAnthyDict",
9199 &cm_anthy_dict_info, 0);
92100
93- g_type_module_add_interface(module,
94- CM_TYPE_ANTHY_DICT,
95- CM_TYPE_DICT,
96- &cm_dict_info);
101+ g_type_module_add_interface(module,
102+ CM_TYPE_ANTHY_DICT,
103+ CM_TYPE_DICT,
104+ &cm_dict_info);
97105 }
98106
99107 G_MODULE_EXPORT void
100108 CM_MODULE_IMPL_INIT (GTypeModule *module)
101109 {
102- cm_anthy_dict_register_type(module);
110+ anthy_dic_util_init();
111+ anthy_dic_util_set_encoding(ANTHY_UTF8_ENCODING);
112+
113+ cm_anthy_dict_register_type(module);
103114 }
104115
105116 G_MODULE_EXPORT void
106117 CM_MODULE_IMPL_EXIT (void)
107118 {
119+ anthy_dic_util_quit();
108120 }
109121
110122 G_MODULE_EXPORT GObject *
111123 CM_MODULE_IMPL_INSTANTIATE (const gchar *first_property,
112- va_list var_args)
124+ va_list var_args)
113125 {
114- return g_object_new_valist(CM_TYPE_ANTHY_DICT,
115- first_property, var_args);
126+ return g_object_new_valist(CM_TYPE_ANTHY_DICT,
127+ first_property, var_args);
116128 }
117129
118130 G_MODULE_EXPORT const gchar *
@@ -125,17 +137,18 @@
125137 static void
126138 cm_anthy_dict_class_init (CmAnthyDictClass *klass)
127139 {
128- GObjectClass *object_class;
140+ GObjectClass *object_class;
129141
130- parent_class = g_type_class_peek_parent (klass);
131- object_class = (GObjectClass *) klass;
142+ parent_class = g_type_class_peek_parent (klass);
143+ object_class = (GObjectClass *) klass;
132144
133- object_class->dispose = dispose;
145+ object_class->dispose = dispose;
134146 }
135147
136148 static void
137149 cm_anthy_dict_iface_init (CmDictIFace *iface)
138150 {
151+ iface->register_word = register_word;
139152 }
140153
141154 static void
@@ -146,10 +159,36 @@
146159 static void
147160 dispose (GObject *object)
148161 {
149- if (G_OBJECT_CLASS(parent_class)->dispose)
150- G_OBJECT_CLASS(parent_class)->dispose(object);
162+ if (G_OBJECT_CLASS(parent_class)->dispose)
163+ G_OBJECT_CLASS(parent_class)->dispose(object);
151164 }
152165
166+static gboolean
167+register_word (CmDict *_dict, CmWord *word)
168+{
169+ const gchar *reading, *utf8, *anthy_word_type;
170+ gint frequency;
171+
172+ g_return_val_if_fail(CM_IS_ANTHY_DICT(_dict), FALSE);
173+
174+ reading = cm_word_get_reading(word);
175+ g_return_val_if_fail(reading, FALSE);
176+
177+ utf8 = cm_word_get_utf8(word);
178+ g_return_val_if_fail(utf8, FALSE);
179+
180+ anthy_word_type = "T35"; /* FIXME */
181+
182+ frequency = cm_word_get_frequency(word);
183+ if (frequency < 0)
184+ frequency = DEFAULT_FREQUENCY;
185+
186+ if (anthy_priv_dic_add_entry(reading, utf8, anthy_word_type, frequency))
187+ return TRUE;
188+ else
189+ return FALSE;
190+}
191+
153192 /*
154193 vi:ts=4:nowrap:ai:expandtab
155194 */
--- comatz/trunk/ChangeLog (revision 13)
+++ comatz/trunk/ChangeLog (revision 14)
@@ -1,5 +1,8 @@
11 2007-04-20 Kouhei Sutou <kou@cozmixng.org>
22
3+ * comatz/cm-dict.[ch], module/anthy/cm-anthy-dict.c: implemented
4+ register but may not work.
5+
36 * comatz/cm-word.[ch]: added frequency.
47
58 * comatz/cm-word.[ch]: renamed from ch-char.[ch]. We handle words
--- comatz/trunk/comatz/cm-dict.c (revision 13)
+++ comatz/trunk/comatz/cm-dict.c (revision 14)
@@ -157,6 +157,21 @@
157157 return type;
158158 }
159159
160+gboolean
161+cm_dict_register (CmDict *dict, CmWord *word)
162+{
163+ CmDictIFace *iface;
164+
165+ g_return_val_if_fail(CM_IS_DICT(dict), FALSE);
166+ g_return_val_if_fail(CM_IS_WORD(word), FALSE);
167+
168+ iface = CM_DICT_GET_IFACE(dict);
169+ g_return_val_if_fail(iface->register_word, FALSE);
170+
171+ return iface->register_word(dict, word);
172+}
173+
174+
160175 /*
161176 vi:ts=4:nowrap:ai:expandtab
162177 */
--- comatz/trunk/comatz/cm-dict.h (revision 13)
+++ comatz/trunk/comatz/cm-dict.h (revision 14)
@@ -23,32 +23,39 @@
2323 #define __CM_DICT_H__
2424
2525 #include <glib-object.h>
26+#include <cm-word.h>
2627
2728 G_BEGIN_DECLS
2829
29-#define CM_TYPE_DICT (cm_dict_get_type())
30-#define CM_DICT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), CM_TYPE_DICT, CmDict))
31-#define CM_IS_DICT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), CM_TYPE_DICT))
32-#define CM_DICT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), CM_TYPE_DICT, CmDictIFace))
30+#define CM_TYPE_DICT (cm_dict_get_type())
31+#define CM_DICT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), CM_TYPE_DICT, CmDict))
32+#define CM_IS_DICT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), CM_TYPE_DICT))
33+#define CM_DICT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), CM_TYPE_DICT, CmDictIFace))
3334
34-typedef struct _CmDict CmDict;
35-typedef struct _CmDictIFace CmDictIFace;
35+typedef struct _CmDict CmDict;
36+typedef struct _CmDictIFace CmDictIFace;
3637
3738 struct _CmDictIFace
3839 {
39- GTypeInterface g_iface;
40+ GTypeInterface g_iface;
41+
42+ gboolean (*register_word) (CmDict *dict,
43+ CmWord *word);
4044 };
4145
42-GType cm_dict_get_type (void) G_GNUC_CONST;
46+GType cm_dict_get_type (void) G_GNUC_CONST;
4347
44-void cm_dict_load (const gchar *base_dir);
45-void cm_dict_unload (void);
46-void cm_dict_exit (void);
47-GList *cm_dict_engine_names (void);
48-GList *cm_dict_engine_ids (void);
48+void cm_dict_load (const gchar *base_dir);
49+void cm_dict_unload (void);
50+void cm_dict_exit (void);
51+GList *cm_dict_engine_names (void);
52+GList *cm_dict_engine_ids (void);
4953
50-CmDict *cm_dict_new (const gchar *name);
54+CmDict *cm_dict_new (const gchar *name);
5155
56+gboolean cm_dict_register (CmDict *dict,
57+ CmWord *word);
58+
5259 G_END_DECLS
5360
5461 #endif /* __CM_DICT_H__ */
Show on old repository browser