From ikezoe users.sourceforge.jp Fri Dec 1 09:39:15 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 09:39:15 +0900 Subject: [Tomoe-cvs 1476] CVS update: tomoe/lib Message-ID: <20061201003915.2D6B22AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.41 tomoe/lib/tomoe-context.c:1.42 --- tomoe/lib/tomoe-context.c:1.41 Wed Nov 29 11:53:11 2006 +++ tomoe/lib/tomoe-context.c Fri Dec 1 09:39:14 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.41 2006/11/29 02:53:11 kous Exp $ + * $Id: tomoe-context.c,v 1.42 2006/12/01 00:39:14 ikezoe Exp $ */ #include "tomoe-dict.h" @@ -64,6 +64,13 @@ priv->recognizer = NULL; } +/** + * tomoe_context_new: + * + * Create a new #TomoeContext. + * + * Return value: a new #TomoeContext. + */ TomoeContext* tomoe_context_new(void) { @@ -98,6 +105,13 @@ G_OBJECT_CLASS (tomoe_context_parent_class)->dispose (object); } +/** + * tomoe_context_load_config: + * @ctx: a #TomoeContext. + * @config_file: the filename of configuration file to load. + * + * Load dictionaries into configuration file. + */ void tomoe_context_load_config (TomoeContext *ctx, const char *config_file) { Index: tomoe/lib/tomoe-context.h diff -u tomoe/lib/tomoe-context.h:1.29 tomoe/lib/tomoe-context.h:1.30 --- tomoe/lib/tomoe-context.h:1.29 Wed Nov 29 15:53:06 2006 +++ tomoe/lib/tomoe-context.h Fri Dec 1 09:39:15 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.h,v 1.29 2006/11/29 06:53:06 kous Exp $ + * $Id: tomoe-context.h,v 1.30 2006/12/01 00:39:15 ikezoe Exp $ */ /** @@ -58,18 +58,8 @@ GType tomoe_context_get_type (void) G_GNUC_CONST; -/** - * @brief Create a database. - * @return Pointer to newly allocated TomoeContext struct. - */ TomoeContext *tomoe_context_new (void); -/** - * @brief Load dictionary into database. - * @param ctx - Pointer to the TomoeContext struct to increase reference count. - * @param filename - Name of dictionary file to load. - * @return The TomoeContext. - */ void tomoe_context_load_config (TomoeContext *ctx, const gchar *config_file); From ikezoe users.sourceforge.jp Fri Dec 1 09:53:44 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 09:53:44 +0900 Subject: [Tomoe-cvs 1477] CVS update: tomoe/lib Message-ID: <20061201005344.E57AD2AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-char.c diff -u tomoe/lib/tomoe-char.c:1.59 tomoe/lib/tomoe-char.c:1.60 --- tomoe/lib/tomoe-char.c:1.59 Thu Nov 30 18:13:15 2006 +++ tomoe/lib/tomoe-char.c Fri Dec 1 09:53:44 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-char.c,v 1.59 2006/11/30 09:13:15 kous Exp $ + * $Id: tomoe-char.c,v 1.60 2006/12/01 00:53:44 ikezoe Exp $ */ #include @@ -123,6 +123,13 @@ g_free, g_free); } +/** + * tomoe_char_new: + * + * Create a new #TomoeChar. + * + * Return value: a new #TomoeChar + */ TomoeChar* tomoe_char_new (void) { @@ -415,6 +422,15 @@ g_hash_table_foreach (priv->meta_data, func, user_data); } +/** + * tomoe_char_compare: + * @a: a TomoeChar object. + * @b: a TomoeChar object to compare with. + * + * Compare to TomoeChar objects with its own utf8 character. + * + * Return value: -1 a < b, 0 a= b, 1 a > b + */ gint tomoe_char_compare (const TomoeChar *a, const TomoeChar *b) { Index: tomoe/lib/tomoe-char.h diff -u tomoe/lib/tomoe-char.h:1.52 tomoe/lib/tomoe-char.h:1.53 --- tomoe/lib/tomoe-char.h:1.52 Thu Nov 30 11:53:15 2006 +++ tomoe/lib/tomoe-char.h Fri Dec 1 09:53:44 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-char.h,v 1.52 2006/11/30 02:53:15 kous Exp $ + * $Id: tomoe-char.h,v 1.53 2006/12/01 00:53:44 ikezoe Exp $ */ /** @file tomoe-char.h @@ -57,10 +57,6 @@ GType tomoe_char_get_type (void) G_GNUC_CONST; -/** - * @brief Create a TomoeChar. - * @return Pointer to newly allocated TomoeChar struct. - */ TomoeChar *tomoe_char_new (void); TomoeChar *tomoe_char_new_from_xml_data (const gchar *data, gssize len); @@ -93,12 +89,6 @@ GHFunc func, gpointer user_data); -/** - * @brief Compare two tomoe_letter. - * @param a - Pointer to the tomoe_letter 1 pointer. - * @param b - Pointer to the tomoe_letter 2 pointer. - * @return -1 a < b, 0 a= b, 1 a > b - */ gint tomoe_char_compare (const TomoeChar *a, const TomoeChar *b); From ikezoe users.sourceforge.jp Fri Dec 1 10:05:31 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:05:31 +0900 Subject: [Tomoe-cvs 1478] CVS update: tomoe/lib Message-ID: <20061201010531.374F52AC1BE@users.sourceforge.jp> Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.18 tomoe/lib/tomoe-recognizer.c:1.19 --- tomoe/lib/tomoe-recognizer.c:1.18 Wed Nov 29 11:53:11 2006 +++ tomoe/lib/tomoe-recognizer.c Fri Dec 1 10:05:31 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.18 2006/11/29 02:53:11 kous Exp $ + * $Id: tomoe-recognizer.c,v 1.19 2006/12/01 01:05:31 ikezoe Exp $ */ #include @@ -73,6 +73,16 @@ return TOMOE_RECOGNIZER (recognizer); } +/** + * tomoe_recognizer_search: + * @recognizer: a TomoeRecognizer object. + * @dict - Pointer to the TomoeDict object. + * @input - Pointer to tomoe_glyph matchkey. + * + * Match strokes of TomoeChar with TomoeWriting. + * + * Return value: A newly-allocated list of TomoeCandidate. The each TomoeCandidate should be also freed with g_object_unref. + */ GList * tomoe_recognizer_search (TomoeRecognizer *recognizer, TomoeDict *dict, TomoeWriting *input) Index: tomoe/lib/tomoe-recognizer.h diff -u tomoe/lib/tomoe-recognizer.h:1.17 tomoe/lib/tomoe-recognizer.h:1.18 --- tomoe/lib/tomoe-recognizer.h:1.17 Wed Nov 29 11:53:11 2006 +++ tomoe/lib/tomoe-recognizer.h Fri Dec 1 10:05:31 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.h,v 1.17 2006/11/29 02:53:11 kous Exp $ + * $Id: tomoe-recognizer.h,v 1.18 2006/12/01 01:05:31 ikezoe Exp $ */ /** @@ -69,13 +69,6 @@ const gchar *first_property, ...); -/** - * @brief Match strokes of tomoe_char with input. - * @param recognizer - Pointer to the TomoeRecognizer object. - * @param dict - Pointer to the TomoeDict object. - * @param input - Pointer to tomoe_glyph matchkey. - * @return The array of TomoeCandidate. - */ GList *tomoe_recognizer_search (TomoeRecognizer *recognizer, TomoeDict *dict, TomoeWriting *input); From ikezoe users.sourceforge.jp Fri Dec 1 10:31:45 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:31:45 +0900 Subject: [Tomoe-cvs 1479] CVS update: tomoe/lib Message-ID: <20061201013145.A07BA2AC0DB@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.h diff -u tomoe/lib/tomoe-config.h:1.21 tomoe/lib/tomoe-config.h:1.22 --- tomoe/lib/tomoe-config.h:1.21 Mon Nov 27 16:49:17 2006 +++ tomoe/lib/tomoe-config.h Fri Dec 1 10:31:45 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.h,v 1.21 2006/11/27 07:49:17 kous Exp $ - */ - -/** - * @file tomoe-config.h - * @brief Manages tomoe configuration. + * $Id: tomoe-config.h,v 1.22 2006/12/01 01:31:45 ikezoe Exp $ */ #ifndef __TOMOE_CONFIG_H__ Index: tomoe/lib/tomoe-context.h diff -u tomoe/lib/tomoe-context.h:1.30 tomoe/lib/tomoe-context.h:1.31 --- tomoe/lib/tomoe-context.h:1.30 Fri Dec 1 09:39:15 2006 +++ tomoe/lib/tomoe-context.h Fri Dec 1 10:31:45 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.h,v 1.30 2006/12/01 00:39:15 ikezoe Exp $ - */ - -/** - * @file tomoe-context.h - * @brief Provides access to the tomoe context. + * $Id: tomoe-context.h,v 1.31 2006/12/01 01:31:45 ikezoe Exp $ */ #ifndef __TOMOE_CONTEXT_H__ Index: tomoe/lib/tomoe-dict.h diff -u tomoe/lib/tomoe-dict.h:1.53 tomoe/lib/tomoe-dict.h:1.54 --- tomoe/lib/tomoe-dict.h:1.53 Thu Nov 30 15:40:32 2006 +++ tomoe/lib/tomoe-dict.h Fri Dec 1 10:31:45 2006 @@ -21,12 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.h,v 1.53 2006/11/30 06:40:32 kous Exp $ - */ - -/** - * @file tomoe-dict.h - * @brief Provide a set of API to access to a tomoe dictionary. + * $Id: tomoe-dict.h,v 1.54 2006/12/01 01:31:45 ikezoe Exp $ */ #ifndef __TOMOE_DICT_H__ Index: tomoe/lib/tomoe.h diff -u tomoe/lib/tomoe.h:1.34 tomoe/lib/tomoe.h:1.35 --- tomoe/lib/tomoe.h:1.34 Wed Nov 29 11:53:11 2006 +++ tomoe/lib/tomoe.h Fri Dec 1 10:31:45 2006 @@ -20,11 +20,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe.h,v 1.34 2006/11/29 02:53:11 kous Exp $ - */ - -/** @file tomoe.h - * @brief Provide a set of API for handwriting recognition. + * $Id: tomoe.h,v 1.35 2006/12/01 01:31:45 ikezoe Exp $ */ #ifndef __TOMOE_H__ From ikezoe users.sourceforge.jp Fri Dec 1 10:33:34 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:33:34 +0900 Subject: [Tomoe-cvs 1480] CVS update: tomoe/lib Message-ID: <20061201013334.780162AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-recognizer.h diff -u tomoe/lib/tomoe-recognizer.h:1.18 tomoe/lib/tomoe-recognizer.h:1.19 --- tomoe/lib/tomoe-recognizer.h:1.18 Fri Dec 1 10:05:31 2006 +++ tomoe/lib/tomoe-recognizer.h Fri Dec 1 10:33:34 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.h,v 1.18 2006/12/01 01:05:31 ikezoe Exp $ - */ - -/** - * @file tomoe-recognizer.h - * @brief Provide a set of API to recognize handwriting. + * $Id: tomoe-recognizer.h,v 1.19 2006/12/01 01:33:34 ikezoe Exp $ */ #ifndef __TOMOE_RECOGNIZER_H__ From ikezoe users.sourceforge.jp Fri Dec 1 10:35:42 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:35:42 +0900 Subject: [Tomoe-cvs 1481] CVS update: tomoe/lib Message-ID: <20061201013542.342EB2AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-char.h diff -u tomoe/lib/tomoe-char.h:1.53 tomoe/lib/tomoe-char.h:1.54 --- tomoe/lib/tomoe-char.h:1.53 Fri Dec 1 09:53:44 2006 +++ tomoe/lib/tomoe-char.h Fri Dec 1 10:35:42 2006 @@ -18,11 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-char.h,v 1.53 2006/12/01 00:53:44 ikezoe Exp $ - */ - -/** @file tomoe-char.h - * @brief + * $Id: tomoe-char.h,v 1.54 2006/12/01 01:35:42 ikezoe Exp $ */ #ifndef __TOMOE_CHAR_H__ Index: tomoe/lib/tomoe-module-impl.h diff -u tomoe/lib/tomoe-module-impl.h:1.1 tomoe/lib/tomoe-module-impl.h:1.2 --- tomoe/lib/tomoe-module-impl.h:1.1 Wed Nov 29 11:57:16 2006 +++ tomoe/lib/tomoe-module-impl.h Fri Dec 1 10:35:42 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module-impl.h,v 1.1 2006/11/29 02:57:16 kous Exp $ - */ - -/** - * @file tomoe-module-impl.h - * @brief Provide a set of API to load dynamic module. + * $Id: tomoe-module-impl.h,v 1.2 2006/12/01 01:35:42 ikezoe Exp $ */ #ifndef __TOMOE_MODULE_IMPL_H__ Index: tomoe/lib/tomoe-reading.h diff -u tomoe/lib/tomoe-reading.h:1.4 tomoe/lib/tomoe-reading.h:1.5 --- tomoe/lib/tomoe-reading.h:1.4 Thu Nov 30 18:13:15 2006 +++ tomoe/lib/tomoe-reading.h Fri Dec 1 10:35:42 2006 @@ -17,11 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-reading.h,v 1.4 2006/11/30 09:13:15 kous Exp $ - */ - -/** @file tomoe-reading.h - * @brief + * $Id: tomoe-reading.h,v 1.5 2006/12/01 01:35:42 ikezoe Exp $ */ #ifndef __TOMOE_READING_H__ Index: tomoe/lib/tomoe-shelf.h diff -u tomoe/lib/tomoe-shelf.h:1.8 tomoe/lib/tomoe-shelf.h:1.9 --- tomoe/lib/tomoe-shelf.h:1.8 Mon Nov 27 16:49:18 2006 +++ tomoe/lib/tomoe-shelf.h Fri Dec 1 10:35:42 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-shelf.h,v 1.8 2006/11/27 07:49:18 kous Exp $ - */ - -/** - * @file tomoe-shelf.h - * @brief Provides access to the tomoe shelf. + * $Id: tomoe-shelf.h,v 1.9 2006/12/01 01:35:42 ikezoe Exp $ */ #ifndef __TOMOE_SHELF_H__ Index: tomoe/lib/tomoe-writing.h diff -u tomoe/lib/tomoe-writing.h:1.9 tomoe/lib/tomoe-writing.h:1.10 --- tomoe/lib/tomoe-writing.h:1.9 Mon Nov 27 18:11:09 2006 +++ tomoe/lib/tomoe-writing.h Fri Dec 1 10:35:42 2006 @@ -18,11 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-writing.h,v 1.9 2006/11/27 09:11:09 kous Exp $ - */ - -/** @file tomoe-handwrite.h - * @brief + * $Id: tomoe-writing.h,v 1.10 2006/12/01 01:35:42 ikezoe Exp $ */ #ifndef __TOMOE_WRITING_H__ Index: tomoe/lib/tomoe-xml-parser.h diff -u tomoe/lib/tomoe-xml-parser.h:1.1 tomoe/lib/tomoe-xml-parser.h:1.2 --- tomoe/lib/tomoe-xml-parser.h:1.1 Thu Nov 30 11:22:31 2006 +++ tomoe/lib/tomoe-xml-parser.h Fri Dec 1 10:35:42 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-xml-parser.h,v 1.1 2006/11/30 02:22:31 kous Exp $ - */ - -/** - * @file tomoe-xml-parser.h - * @brief Provide a set of API to parse XML data. + * $Id: tomoe-xml-parser.h,v 1.2 2006/12/01 01:35:42 ikezoe Exp $ */ #ifndef __TOMOE_XML_PARSER_H__ From ikezoe users.sourceforge.jp Fri Dec 1 10:37:38 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:37:38 +0900 Subject: [Tomoe-cvs 1482] CVS update: tomoe/lib Message-ID: <20061201013738.C9F162AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-query.h diff -u tomoe/lib/tomoe-query.h:1.4 tomoe/lib/tomoe-query.h:1.5 --- tomoe/lib/tomoe-query.h:1.4 Tue Nov 28 14:13:43 2006 +++ tomoe/lib/tomoe-query.h Fri Dec 1 10:37:38 2006 @@ -17,12 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.h,v 1.4 2006/11/28 05:13:43 kous Exp $ - */ - -/** - * @file tomoe-search-condition.h - * @brief + * $Id: tomoe-query.h,v 1.5 2006/12/01 01:37:38 ikezoe Exp $ */ #ifndef __TOMOE_QUERY_H__ @@ -58,10 +53,6 @@ GType tomoe_query_get_type (void) G_GNUC_CONST; -/** - * @brief Create a database. - * @return Pointer to newly allocated TomoeQuery struct. - */ TomoeQuery *tomoe_query_new (void); void tomoe_query_add_reading (TomoeQuery *query, Index: tomoe/lib/tomoe-reading.h diff -u tomoe/lib/tomoe-reading.h:1.5 tomoe/lib/tomoe-reading.h:1.6 --- tomoe/lib/tomoe-reading.h:1.5 Fri Dec 1 10:35:42 2006 +++ tomoe/lib/tomoe-reading.h Fri Dec 1 10:37:38 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-reading.h,v 1.5 2006/12/01 01:35:42 ikezoe Exp $ + * $Id: tomoe-reading.h,v 1.6 2006/12/01 01:37:38 ikezoe Exp $ */ #ifndef __TOMOE_READING_H__ @@ -56,10 +56,6 @@ GType tomoe_reading_get_type (void) G_GNUC_CONST; -/** - * @brief Create a TomoeReading. - * @return Pointer to newly allocated TomoeReading struct. - */ TomoeReading *tomoe_reading_new (TomoeReadingType type, const gchar *reading); From ikezoe users.sourceforge.jp Fri Dec 1 10:40:38 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:40:38 +0900 Subject: [Tomoe-cvs 1483] CVS update: tomoe/lib Message-ID: <20061201014038.EF2FD2AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-shelf.h diff -u tomoe/lib/tomoe-shelf.h:1.9 tomoe/lib/tomoe-shelf.h:1.10 --- tomoe/lib/tomoe-shelf.h:1.9 Fri Dec 1 10:35:42 2006 +++ tomoe/lib/tomoe-shelf.h Fri Dec 1 10:40:38 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-shelf.h,v 1.9 2006/12/01 01:35:42 ikezoe Exp $ + * $Id: tomoe-shelf.h,v 1.10 2006/12/01 01:40:38 ikezoe Exp $ */ #ifndef __TOMOE_SHELF_H__ @@ -51,18 +51,8 @@ GType tomoe_shelf_get_type (void) G_GNUC_CONST; -/** - * @brief Create a database. - * @return Pointer to newly allocated TomoeShelf struct. - */ TomoeShelf *tomoe_shelf_new (void); -/** - * @brief Load dictionary into database. - * @param shelf - Pointer to the TomoeShelf struct to increase reference count. - * @param filename - Name of dictionary file to load. - * @return The TomoeShelf. - */ void tomoe_shelf_add_dict (TomoeShelf *shelf, TomoeDict *dict); TomoeDict *tomoe_shelf_get_dict (TomoeShelf *shelf, Index: tomoe/lib/tomoe.c diff -u tomoe/lib/tomoe.c:1.48 tomoe/lib/tomoe.c:1.49 --- tomoe/lib/tomoe.c:1.48 Wed Nov 29 12:15:34 2006 +++ tomoe/lib/tomoe.c Fri Dec 1 10:40:38 2006 @@ -20,7 +20,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe.c,v 1.48 2006/11/29 03:15:34 kous Exp $ + * $Id: tomoe.c,v 1.49 2006/12/01 01:40:38 ikezoe Exp $ */ #include @@ -31,8 +31,11 @@ static gboolean initialized = FALSE; -/* - * Initialize tomoe +/** + * tomoe_init: + * + * Initialize tomoe library. + * */ void tomoe_init (void) @@ -46,7 +49,12 @@ } } -/* finalize tomoe */ +/** + * tomoe_quit: + * + * Terminate tomoe library. + * + */ void tomoe_quit (void) { Index: tomoe/lib/tomoe.h diff -u tomoe/lib/tomoe.h:1.35 tomoe/lib/tomoe.h:1.36 --- tomoe/lib/tomoe.h:1.35 Fri Dec 1 10:31:45 2006 +++ tomoe/lib/tomoe.h Fri Dec 1 10:40:38 2006 @@ -20,7 +20,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe.h,v 1.35 2006/12/01 01:31:45 ikezoe Exp $ + * $Id: tomoe.h,v 1.36 2006/12/01 01:40:38 ikezoe Exp $ */ #ifndef __TOMOE_H__ @@ -36,14 +36,8 @@ #include "tomoe-recognizer.h" #include "tomoe-writing.h" -/** - * @brief Initialize tomoe library. - */ void tomoe_init (void); -/** - * @brief Finalize tomoe library. - */ void tomoe_quit (void); G_END_DECLS From ikezoe users.sourceforge.jp Fri Dec 1 10:54:45 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:54:45 +0900 Subject: [Tomoe-cvs 1484] CVS update: tomoe/lib Message-ID: <20061201015445.0D85C2AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.127 tomoe/lib/tomoe-dict.c:1.128 --- tomoe/lib/tomoe-dict.c:1.127 Thu Nov 30 15:40:32 2006 +++ tomoe/lib/tomoe-dict.c Fri Dec 1 10:54:44 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.127 2006/11/30 06:40:32 kous Exp $ + * $Id: tomoe-dict.c,v 1.128 2006/12/01 01:54:44 ikezoe Exp $ */ #include "tomoe-dict.h" @@ -59,6 +59,16 @@ { } +/** + * tomoe_dict_new: + * @name: The name of dictionary type. + * @first_property: the name of the first property. + * ... : the value of the first property, followed optionally by more name/value pairs, followed by NULL + * + * Create a new #TomoeDict. + * + * Return value: a new #TomoeDict. + */ TomoeDict * tomoe_dict_new (const gchar *name, const gchar *first_property, ...) { @@ -72,6 +82,14 @@ return TOMOE_DICT (dict); } +/** + * tomoe_dict_get_name: + * @dict: a #TomoeDict. + * + * Get the dictionary name. + * + * Return value: the name of the dictionary. + */ const gchar * tomoe_dict_get_name (TomoeDict *dict) { @@ -86,6 +104,15 @@ return NULL; } +/** + * tomoe_dict_register_char: + * @dict: a TomoeDict object. + * @chr: a TomoeChar object to register. + * + * Register a TomoeChar object. + * + * Return value: TRUE if success. + */ gboolean tomoe_dict_register_char (TomoeDict *dict, TomoeChar *chr) { @@ -100,6 +127,15 @@ return FALSE; } +/** + * tomoe_dict_unregister_char: + * @dict: a TomoeDict object. + * @utf8: UTF-8 encoded value of the character. + * + * Unregister a TomoeChar object which has utf8 code point. + * + * Return value: TRUE if success. + */ gboolean tomoe_dict_unregister_char (TomoeDict *dict, const gchar *utf8) { @@ -114,6 +150,15 @@ return FALSE; } +/** + * tomoe_dict_get_char: + * @dict: a TomoeDict object. + * @utf8: UTF-8 encoded value of the character. + * + * Get a TomoeChar object which has utf8 code point + * + * Return value: a TomoeChar object. + */ TomoeChar * tomoe_dict_get_char (TomoeDict *dict, const gchar *utf8) { Index: tomoe/lib/tomoe-dict.h diff -u tomoe/lib/tomoe-dict.h:1.54 tomoe/lib/tomoe-dict.h:1.55 --- tomoe/lib/tomoe-dict.h:1.54 Fri Dec 1 10:31:45 2006 +++ tomoe/lib/tomoe-dict.h Fri Dec 1 10:54:44 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.h,v 1.54 2006/12/01 01:31:45 ikezoe Exp $ + * $Id: tomoe-dict.h,v 1.55 2006/12/01 01:54:44 ikezoe Exp $ */ #ifndef __TOMOE_DICT_H__ @@ -74,37 +74,16 @@ const gchar *first_property, ...); -/** - * @brief Get the dictionary name. - * @param dict - Pointer to the TomoeDict object. - * @return Name of the dictionary. - */ const gchar *tomoe_dict_get_name (TomoeDict *dict); /* Editable methods */ -/** - * @brief Register a character - * @param dict - Pointer to the TomoeDict object. - * @param chr - Pointer to the TomoeChar object. - */ gboolean tomoe_dict_register_char (TomoeDict *dict, TomoeChar *chr); -/** - * @brief Unregister a character by code point - * @param dict - Pointer to the TomoeDict object. - * @param utf8 - UTF-8 encoded value of the character. - */ gboolean tomoe_dict_unregister_char (TomoeDict *dict, const gchar *utf8); -/** - * @brief Get a character by code point - * @param dict - Pointer to the TomoeDict object. - * @param utf8 - UTF-8 encoded value of the character. - * @return TomoeChar object. - */ TomoeChar *tomoe_dict_get_char (TomoeDict *dict, const gchar *utf8); From ikezoe users.sourceforge.jp Fri Dec 1 10:56:42 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 10:56:42 +0900 Subject: [Tomoe-cvs 1485] CVS update: tomoe/lib Message-ID: <20061201015642.3C8DD2AC054@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.128 tomoe/lib/tomoe-dict.c:1.129 --- tomoe/lib/tomoe-dict.c:1.128 Fri Dec 1 10:54:44 2006 +++ tomoe/lib/tomoe-dict.c Fri Dec 1 10:56:42 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.128 2006/12/01 01:54:44 ikezoe Exp $ + * $Id: tomoe-dict.c,v 1.129 2006/12/01 01:56:42 ikezoe Exp $ */ #include "tomoe-dict.h" @@ -63,7 +63,7 @@ * tomoe_dict_new: * @name: The name of dictionary type. * @first_property: the name of the first property. - * ... : the value of the first property, followed optionally by more name/value pairs, followed by NULL + * @... : the value of the first property, followed optionally by more name/value pairs, followed by NULL * * Create a new #TomoeDict. * @@ -107,9 +107,9 @@ /** * tomoe_dict_register_char: * @dict: a TomoeDict object. - * @chr: a TomoeChar object to register. + * @chr: a #TomoeChar object to register. * - * Register a TomoeChar object. + * Register a #TomoeChar object. * * Return value: TRUE if success. */ @@ -132,7 +132,7 @@ * @dict: a TomoeDict object. * @utf8: UTF-8 encoded value of the character. * - * Unregister a TomoeChar object which has utf8 code point. + * Unregister a #TomoeChar object which has utf8 code point. * * Return value: TRUE if success. */ @@ -155,9 +155,9 @@ * @dict: a TomoeDict object. * @utf8: UTF-8 encoded value of the character. * - * Get a TomoeChar object which has utf8 code point + * Get a #TomoeChar object which has utf8 code point * - * Return value: a TomoeChar object. + * Return value: a #TomoeChar object. */ TomoeChar * tomoe_dict_get_char (TomoeDict *dict, const gchar *utf8) From kous users.sourceforge.jp Fri Dec 1 10:57:23 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 10:57:23 +0900 Subject: [Tomoe-cvs 1486] CVS update: tomoe Message-ID: <20061201015723.39D8E2AC054@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.359 tomoe/ChangeLog:1.360 --- tomoe/ChangeLog:1.359 Thu Nov 30 18:15:31 2006 +++ tomoe/ChangeLog Fri Dec 1 10:57:23 2006 @@ -1,3 +1,8 @@ +2006-12-01 Kouhei Sutou + + * module/dict/tomoe-dict-est.c: added cache mechanism but still + slow... + 2006-11-30 Kouhei Sutou * utils/xml2est.rb: added converter for Hyper Estraier backend. From kous users.sourceforge.jp Fri Dec 1 10:57:23 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 10:57:23 +0900 Subject: [Tomoe-cvs 1487] CVS update: tomoe/module/dict Message-ID: <20061201015723.66E362AC060@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.3 tomoe/module/dict/tomoe-dict-est.c:1.4 --- tomoe/module/dict/tomoe-dict-est.c:1.3 Thu Nov 30 18:13:15 2006 +++ tomoe/module/dict/tomoe-dict-est.c Fri Dec 1 10:57:23 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.3 2006/11/30 09:13:15 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.4 2006/12/01 01:57:23 kous Exp $ */ #include @@ -60,6 +60,8 @@ gboolean editable; ESTDB *db; + + GHashTable *cache; }; struct _TomoeDictEstClass @@ -158,6 +160,8 @@ dict->name = NULL; dict->database_name = NULL; dict->db = NULL; + dict->cache = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_object_unref); } static void @@ -277,9 +281,12 @@ g_free (dict->name); if (dict->database_name) g_free (dict->database_name); + if (dict->cache) + g_hash_table_destroy (dict->cache); dict->name = NULL; dict->database_name = NULL; + dict->cache = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -382,6 +389,34 @@ } static TomoeChar * +retrieve_char_by_id (TomoeDictEst *dict, int id) +{ + TomoeChar *chr = NULL; + ESTDOC *doc; + const gchar *utf8; + + utf8 = est_db_get_doc_attr (dict->db, id, "utf8"); + if (!utf8) + return NULL; + + chr = g_hash_table_lookup (dict->cache, utf8); + if (chr) + return chr; + + doc = est_db_get_doc (dict->db, id, 0); + if (!doc) + return NULL; + + chr = tomoe_char_new_from_xml_data (est_doc_hidden_texts (doc), -1); + if (chr) + g_hash_table_insert (dict->cache, g_strdup (utf8), chr); + + est_doc_delete (doc); + + return chr; +} + +static TomoeChar * get_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictEst *dict = TOMOE_DICT_EST (_dict); @@ -401,18 +436,7 @@ results = est_db_search (dict->db, cond, &n_results, NULL); for (i = 0; i < n_results; i++) { - ESTDOC *doc; - const gchar *xml; - - doc = est_db_get_doc (dict->db, results[i], 0); - if (!doc) continue; - - xml = est_doc_hidden_texts (doc); - if (xml) - chr = tomoe_char_new_from_xml_data (xml, -1); - - est_doc_delete (doc); - + chr = retrieve_char_by_id (dict, results[i]); if (chr) break; } g_free (results); @@ -459,21 +483,12 @@ results = est_db_search (dict->db, cond, &n_results, NULL); for (i = 0; i < n_results; i++) { - ESTDOC *doc; - const gchar *xml; - - doc = est_db_get_doc (dict->db, results[i], 0); - if (!doc) continue; + TomoeChar *chr; - xml = est_doc_hidden_texts (doc); - if (xml) { - TomoeChar *chr; - chr = tomoe_char_new_from_xml_data (xml, -1); - candidates = g_list_prepend (candidates, tomoe_candidate_new (chr)); - g_object_unref (chr); - } - - est_doc_delete (doc); + chr = retrieve_char_by_id (dict, results[i]); + if (chr) + candidates = g_list_prepend (candidates, + tomoe_candidate_new (chr)); } g_free (results); @@ -492,10 +507,10 @@ tomoe_dict_est_open (TomoeDictEst *dict) { gboolean success = TRUE; - int ecode; + int option, ecode; - dict->db = est_db_open (dict->database_name, ESTDBWRITER | ESTDBCREAT, - &ecode); + option = dict->editable ? ESTDBWRITER | ESTDBCREAT : ESTDBREADER; + dict->db = est_db_open (dict->database_name, option, &ecode); if (!dict->db) { g_warning ("open error: %s\n", est_err_msg (ecode)); From ikezoe users.sourceforge.jp Fri Dec 1 11:05:03 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:05:03 +0900 Subject: [Tomoe-cvs 1488] CVS update: tomoe/doc/reference Message-ID: <20061201020504.DDFDE2AC0A2@users.sourceforge.jp> Index: tomoe/doc/reference/tomoe-docs.sgml diff -u tomoe/doc/reference/tomoe-docs.sgml:1.2 tomoe/doc/reference/tomoe-docs.sgml:1.3 --- tomoe/doc/reference/tomoe-docs.sgml:1.2 Sun Nov 26 00:15:54 2006 +++ tomoe/doc/reference/tomoe-docs.sgml Fri Dec 1 11:05:03 2006 @@ -35,6 +35,7 @@ &tomoe-Dict; &tomoe-Query; &tomoe-Reading; + &tomoe-Recognizer; &tomoe-Shelf; &tomoe-Writing; Index: tomoe/doc/reference/tomoe.types diff -u tomoe/doc/reference/tomoe.types:1.5 tomoe/doc/reference/tomoe.types:1.6 --- tomoe/doc/reference/tomoe.types:1.5 Wed Nov 29 11:07:37 2006 +++ tomoe/doc/reference/tomoe.types Fri Dec 1 11:05:03 2006 @@ -1,10 +1,12 @@ #include +#include tomoe_candidate_get_type tomoe_char_get_type tomoe_config_get_type tomoe_context_get_type tomoe_dict_get_type +tomoe_module_get_type tomoe_query_get_type tomoe_reading_get_type tomoe_recognizer_get_type From ikezoe users.sourceforge.jp Fri Dec 1 11:05:05 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:05:05 +0900 Subject: [Tomoe-cvs 1489] CVS update: tomoe/doc/reference/tmpl Message-ID: <20061201020505.1395D2AC0DB@users.sourceforge.jp> Index: tomoe/doc/reference/tmpl/tomoe-dict.sgml diff -u tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.2 Thu Nov 30 18:27:24 2006 +++ tomoe/doc/reference/tmpl/tomoe-dict.sgml Fri Dec 1 11:05:04 2006 @@ -74,13 +74,3 @@ @Returns: - - - - - - dict: - query: - Returns: - - Index: tomoe/doc/reference/tmpl/tomoe-query.sgml diff -u tomoe/doc/reference/tmpl/tomoe-query.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-query.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-query.sgml:1.2 Thu Nov 30 18:22:01 2006 +++ tomoe/doc/reference/tmpl/tomoe-query.sgml Fri Dec 1 11:05:04 2006 @@ -59,69 +59,6 @@ @chr: - - - - - - query: - Returns: - - - - - - - - query: - chr: - - - - - - - - query: - Returns: - - - - - - - - query: - n_strokes: - - - - - - - - query: - Returns: - - - - - - - - query: - n_strokes: - - - - - - - - query: - Returns: - - Index: tomoe/doc/reference/tmpl/tomoe-unused.sgml diff -u tomoe/doc/reference/tmpl/tomoe-unused.sgml:1.1 tomoe/doc/reference/tmpl/tomoe-unused.sgml:1.2 --- tomoe/doc/reference/tmpl/tomoe-unused.sgml:1.1 Thu Nov 30 18:19:07 2006 +++ tomoe/doc/reference/tmpl/tomoe-unused.sgml Fri Dec 1 11:05:04 2006 @@ -1,3 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + +tomoe-dict-impl + + + + + + + + + + + + + + + + + + + + + + + +TomoeModule + + @@ -164,6 +212,13 @@ @utf8: @Returns: + + + + + + object: + @@ -229,6 +284,15 @@ @base_dir: @name: + + + + + + dict: + query: + Returns: + @@ -264,3 +328,59 @@ @module: + + + + + + query: + Returns: + + + + + + + query: + Returns: + + + + + + + query: + Returns: + + + + + + + query: + Returns: + + + + + + + query: + n_strokes: + + + + + + + query: + n_strokes: + + + + + + + query: + chr: + From ikezoe users.sourceforge.jp Fri Dec 1 11:07:00 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:07:00 +0900 Subject: [Tomoe-cvs 1490] CVS update: tomoe/lib Message-ID: <20061201020700.708432AC0DB@users.sourceforge.jp> Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.19 tomoe/lib/tomoe-recognizer.c:1.20 --- tomoe/lib/tomoe-recognizer.c:1.19 Fri Dec 1 10:05:31 2006 +++ tomoe/lib/tomoe-recognizer.c Fri Dec 1 11:07:00 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.19 2006/12/01 01:05:31 ikezoe Exp $ + * $Id: tomoe-recognizer.c,v 1.20 2006/12/01 02:07:00 ikezoe Exp $ */ #include @@ -76,12 +76,12 @@ /** * tomoe_recognizer_search: * @recognizer: a TomoeRecognizer object. - * @dict - Pointer to the TomoeDict object. - * @input - Pointer to tomoe_glyph matchkey. + * @dict: a #TomoeDict object. + * @input: a #TomoeWriting object for matching. * * Match strokes of TomoeChar with TomoeWriting. * - * Return value: A newly-allocated list of TomoeCandidate. The each TomoeCandidate should be also freed with g_object_unref. + * Return value: A newly-allocated list of #TomoeCandidate. The each #TomoeCandidate should be also freed with g_object_unref. */ GList * tomoe_recognizer_search (TomoeRecognizer *recognizer, From ikezoe users.sourceforge.jp Fri Dec 1 11:11:32 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:11:32 +0900 Subject: [Tomoe-cvs 1491] CVS update: tomoe/lib Message-ID: <20061201021132.665302AC062@users.sourceforge.jp> Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.20 tomoe/lib/tomoe-recognizer.c:1.21 --- tomoe/lib/tomoe-recognizer.c:1.20 Fri Dec 1 11:07:00 2006 +++ tomoe/lib/tomoe-recognizer.c Fri Dec 1 11:11:32 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.20 2006/12/01 02:07:00 ikezoe Exp $ + * $Id: tomoe-recognizer.c,v 1.21 2006/12/01 02:11:32 ikezoe Exp $ */ #include @@ -59,6 +59,16 @@ { } +/** + * tomoe_recognizer_new: + * @name: The name of recognizer type. + * @first_property: the name of the first property. + * @... : the value of the first property, followed optionally by more name/value pairs, followed by NULL + * + * Create a new #TomoeRecognizer. + * + * Return value: a new #TomoeRecognizer. + */ TomoeRecognizer * tomoe_recognizer_new (const gchar *name, const gchar *first_property, ...) { From ikezoe users.sourceforge.jp Fri Dec 1 11:15:55 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:15:55 +0900 Subject: [Tomoe-cvs 1492] CVS update: tomoe/doc/reference/tmpl Message-ID: <20061201021555.9CE0C2AC062@users.sourceforge.jp> Index: tomoe/doc/reference/tmpl/tomoe-recognizer.sgml diff -u tomoe/doc/reference/tmpl/tomoe-recognizer.sgml:1.1 tomoe/doc/reference/tmpl/tomoe-recognizer.sgml:1.2 --- tomoe/doc/reference/tmpl/tomoe-recognizer.sgml:1.1 Thu Nov 30 18:19:07 2006 +++ tomoe/doc/reference/tmpl/tomoe-recognizer.sgml Fri Dec 1 11:15:55 2006 @@ -2,7 +2,7 @@ TomoeRecognizer - +An abstract recognizer object @@ -19,7 +19,8 @@ - +The #TomoeRecognizer struct contains only +private fields and should not be directly accessed. From ikezoe users.sourceforge.jp Fri Dec 1 11:22:10 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:22:10 +0900 Subject: [Tomoe-cvs 1493] CVS update: tomoe/doc/reference/tmpl Message-ID: <20061201022210.3E7822AC062@users.sourceforge.jp> Index: tomoe/doc/reference/tmpl/tomoe-writing.sgml diff -u tomoe/doc/reference/tmpl/tomoe-writing.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-writing.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-writing.sgml:1.2 Thu Nov 30 18:27:24 2006 +++ tomoe/doc/reference/tmpl/tomoe-writing.sgml Fri Dec 1 11:22:10 2006 @@ -2,7 +2,7 @@ TomoeWriting - +An object for representing hand-writing strokes data From kous users.sourceforge.jp Fri Dec 1 11:23:38 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 11:23:38 +0900 Subject: [Tomoe-cvs 1494] CVS update: tomoe Message-ID: <20061201022338.4A9AA2AC062@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.360 tomoe/ChangeLog:1.361 --- tomoe/ChangeLog:1.360 Fri Dec 1 10:57:23 2006 +++ tomoe/ChangeLog Fri Dec 1 11:23:38 2006 @@ -1,5 +1,7 @@ 2006-12-01 Kouhei Sutou + * NEWS, TODO: updated. + * module/dict/tomoe-dict-est.c: added cache mechanism but still slow... Index: tomoe/NEWS diff -u tomoe/NEWS:1.5 tomoe/NEWS:1.6 --- tomoe/NEWS:1.5 Wed Nov 29 11:39:10 2006 +++ tomoe/NEWS Fri Dec 1 11:23:38 2006 @@ -1,3 +1,8 @@ +Overview of Changes from libtomoe-0.4.0 to libtomoe-0.4.1 +============================================================== +* New modulized dictionarys: + - Hyper Estraier + Overview of Changes from libtomoe-0.3.0 to libtomoe-0.4.0 ============================================================== * Shortening startup time. Index: tomoe/TODO diff -u tomoe/TODO:1.11 tomoe/TODO:1.12 --- tomoe/TODO:1.11 Wed Nov 29 16:31:23 2006 +++ tomoe/TODO Fri Dec 1 11:23:38 2006 @@ -3,9 +3,7 @@ should be language independent. * Add "register_char" function into TomoeContext. * Implement advanced searching. -* Modulized dictionary types. - - XML - - Hyper Estraier +* Add modulized dictionary types. - QDBM? - MySQL? - CHISE? From kous users.sourceforge.jp Fri Dec 1 11:23:38 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 11:23:38 +0900 Subject: [Tomoe-cvs 1495] CVS update: tomoe/module/dict Message-ID: <20061201022338.6DF3F2AC1BB@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.2 tomoe/module/dict/Makefile.am:1.3 --- tomoe/module/dict/Makefile.am:1.2 Thu Nov 30 15:27:19 2006 +++ tomoe/module/dict/Makefile.am Fri Dec 1 11:23:38 2006 @@ -25,7 +25,9 @@ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATADIR=\""$(datadir)"\" \ -DTOMOESYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ - -DTOMOEDATADIR=\""$(datadir)"/$(PACKAGE)\" + -DTOMOEDATADIR=\""$(datadir)"/$(PACKAGE)\" \ + -DRUBY_EXTDIR=\""$(RUBY_EXTDIR)"\" \ + -DRUBY_LIBDIR=\""$(RUBY_LIBDIR)"\" INCLUDES = -I$(top_srcdir)/lib $(GLIB_CFLAGS) $(EST_CFLAGS) LIBADD = $(GLIB_LIBS) From ikezoe users.sourceforge.jp Fri Dec 1 11:26:49 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 11:26:49 +0900 Subject: [Tomoe-cvs 1496] CVS update: tomoe/doc/reference/tmpl Message-ID: <20061201022649.9700F2AC110@users.sourceforge.jp> Index: tomoe/doc/reference/tmpl/tomoe-candidate.sgml diff -u tomoe/doc/reference/tmpl/tomoe-candidate.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-candidate.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-candidate.sgml:1.2 Thu Nov 30 18:19:07 2006 +++ tomoe/doc/reference/tmpl/tomoe-candidate.sgml Fri Dec 1 11:26:49 2006 @@ -2,7 +2,7 @@ TomoeCandidate - +An object of search results. Index: tomoe/doc/reference/tmpl/tomoe-char.sgml diff -u tomoe/doc/reference/tmpl/tomoe-char.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-char.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-char.sgml:1.2 Thu Nov 30 18:22:01 2006 +++ tomoe/doc/reference/tmpl/tomoe-char.sgml Fri Dec 1 11:26:49 2006 @@ -2,7 +2,7 @@ TomoeChar - +An object of character data. Index: tomoe/doc/reference/tmpl/tomoe-config.sgml diff -u tomoe/doc/reference/tmpl/tomoe-config.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-config.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-config.sgml:1.2 Thu Nov 30 18:27:24 2006 +++ tomoe/doc/reference/tmpl/tomoe-config.sgml Fri Dec 1 11:26:49 2006 @@ -2,6 +2,7 @@ TomoeConfig +An object of configuration file. Index: tomoe/doc/reference/tmpl/tomoe-context.sgml diff -u tomoe/doc/reference/tmpl/tomoe-context.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-context.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-context.sgml:1.2 Thu Nov 30 18:22:01 2006 +++ tomoe/doc/reference/tmpl/tomoe-context.sgml Fri Dec 1 11:26:49 2006 @@ -2,6 +2,7 @@ TomoeContext +An object of... Index: tomoe/doc/reference/tmpl/tomoe-dict.sgml diff -u tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.3 Fri Dec 1 11:05:04 2006 +++ tomoe/doc/reference/tmpl/tomoe-dict.sgml Fri Dec 1 11:26:49 2006 @@ -2,6 +2,7 @@ TomoeDict +An object of dictionary. Index: tomoe/doc/reference/tmpl/tomoe-query.sgml diff -u tomoe/doc/reference/tmpl/tomoe-query.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-query.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-query.sgml:1.3 Fri Dec 1 11:05:04 2006 +++ tomoe/doc/reference/tmpl/tomoe-query.sgml Fri Dec 1 11:26:49 2006 @@ -2,6 +2,7 @@ TomoeQuery +An object for representing search conditions. Index: tomoe/doc/reference/tmpl/tomoe-reading.sgml diff -u tomoe/doc/reference/tmpl/tomoe-reading.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-reading.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-reading.sgml:1.2 Thu Nov 30 18:22:01 2006 +++ tomoe/doc/reference/tmpl/tomoe-reading.sgml Fri Dec 1 11:26:49 2006 @@ -2,6 +2,7 @@ TomoeReading +An object of reading data of #TomoeChar. Index: tomoe/doc/reference/tmpl/tomoe-shelf.sgml diff -u tomoe/doc/reference/tmpl/tomoe-shelf.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-shelf.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-shelf.sgml:1.2 Thu Nov 30 18:22:01 2006 +++ tomoe/doc/reference/tmpl/tomoe-shelf.sgml Fri Dec 1 11:26:49 2006 @@ -2,6 +2,7 @@ TomoeShelf +An object of dictionaries. From makeinu users.sourceforge.jp Fri Dec 1 11:56:52 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 11:56:52 +0900 Subject: [Tomoe-cvs 1497] CVS update: libtomoe-gtk Message-ID: <20061201025652.045DC2AC062@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.197 libtomoe-gtk/ChangeLog:1.198 --- libtomoe-gtk/ChangeLog:1.197 Thu Nov 30 18:36:08 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 11:56:51 2006 @@ -1,3 +1,8 @@ +2006-12-01 Takuro Ashie + + * src/tomoe-gucharmap.[ch]: Add an option menu for selecting unicode + block, but it doesn't work yet. + 2006-11-30 Hiroyuki Ikezoe * src/tomoe-stroke-search.c: GTK_STOCK_GO_BACK -> GTK_STOCK_UNDO. From makeinu users.sourceforge.jp Fri Dec 1 11:56:52 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 11:56:52 +0900 Subject: [Tomoe-cvs 1498] CVS update: libtomoe-gtk/src Message-ID: <20061201025652.2F03A2AC110@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.6 libtomoe-gtk/src/tomoe-gucharmap.c:1.7 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.6 Thu Nov 30 19:10:00 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 11:56:52 2006 @@ -95,6 +95,9 @@ gtk_notebook_append_page (GTK_NOTEBOOK (widget), vbox, gtk_label_new (_("Writing"))); gtk_widget_show (vbox); + + + setup_chapters_option_menu (page); } static void @@ -123,6 +126,30 @@ setup_chapters_option_menu (TomoeGucharmap *page) { TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); - -#warning Implement me! + GtkTreeModel *model = priv->chapters->tree_model; + GtkTreeIter iter; + GtkWidget *menu; + gboolean iterate; + + menu = gtk_menu_new (); + + for (iterate = gtk_tree_model_get_iter_first (model, &iter); + iterate; + iterate = gtk_tree_model_iter_next (model, &iter)) + { + GtkWidget *menuitem; + gchar *text = NULL; + + gtk_tree_model_get (model, &iter, + 0, &text, + -1); + menuitem = gtk_menu_item_new_with_label (text); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); + gtk_widget_show (menuitem); + g_free (text); + } + + gtk_option_menu_set_menu (GTK_OPTION_MENU (priv->chapters_option_menu), + menu); + gtk_widget_show (menu); } From ikezoe users.sourceforge.jp Fri Dec 1 12:07:22 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 12:07:22 +0900 Subject: [Tomoe-cvs 1499] CVS update: libtomoe-gtk/doc Message-ID: <20061201030722.1F4042AC1BB@users.sourceforge.jp> From ikezoe users.sourceforge.jp Fri Dec 1 12:07:30 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 12:07:30 +0900 Subject: [Tomoe-cvs 1500] CVS update: libtomoe-gtk/doc/reference Message-ID: <20061201030730.9DF882AC1BE@users.sourceforge.jp> From makeinu users.sourceforge.jp Fri Dec 1 12:08:41 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 12:08:41 +0900 Subject: [Tomoe-cvs 1501] CVS update: libtomoe-gtk Message-ID: <20061201030841.44AF92AC110@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.198 libtomoe-gtk/ChangeLog:1.199 --- libtomoe-gtk/ChangeLog:1.198 Fri Dec 1 11:56:51 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 12:08:41 2006 @@ -1,5 +1,10 @@ 2006-12-01 Takuro Ashie + * data/tomoe-gucharmap.png: Add. + * data/Makefile.am, src/tomoe-window.c: Add guchamarp icon. + +2006-12-01 Takuro Ashie + * src/tomoe-gucharmap.[ch]: Add an option menu for selecting unicode block, but it doesn't work yet. From makeinu users.sourceforge.jp Fri Dec 1 12:08:41 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 12:08:41 +0900 Subject: [Tomoe-cvs 1502] CVS update: libtomoe-gtk/data Message-ID: <20061201030841.749002AC1BB@users.sourceforge.jp> Index: libtomoe-gtk/data/Makefile.am diff -u libtomoe-gtk/data/Makefile.am:1.3 libtomoe-gtk/data/Makefile.am:1.4 --- libtomoe-gtk/data/Makefile.am:1.3 Mon Oct 16 10:31:28 2006 +++ libtomoe-gtk/data/Makefile.am Fri Dec 1 12:08:41 2006 @@ -4,6 +4,7 @@ icon_DATA = tomoe-dictionary.png \ tomoe-handwriting.png \ tomoe-data-view.png \ - tomoe-search.png + tomoe-search.png \ + tomoe-gucharmap.png EXTRA_DIST = $(icon_DATA) Index: libtomoe-gtk/data/tomoe-gucharmap.png From makeinu users.sourceforge.jp Fri Dec 1 12:08:41 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 12:08:41 +0900 Subject: [Tomoe-cvs 1503] CVS update: libtomoe-gtk/src Message-ID: <20061201030841.956A42AC110@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.25 libtomoe-gtk/src/tomoe-window.c:1.26 --- libtomoe-gtk/src/tomoe-window.c:1.25 Thu Nov 30 15:42:50 2006 +++ libtomoe-gtk/src/tomoe-window.c Fri Dec 1 12:08:41 2006 @@ -36,6 +36,7 @@ #define TOMOE_DICTIONARY_ICON LIBTOMOEGTKDATADIR"/tomoe-dictionary.png" #define TOMOE_HANDWRITING_ICON LIBTOMOEGTKDATADIR"/tomoe-handwriting.png" #define TOMOE_SEARCHING_ICON LIBTOMOEGTKDATADIR"/tomoe-search.png" +#define TOMOE_GUCHARMAP_ICON LIBTOMOEGTKDATADIR"/tomoe-gucharmap.png" typedef struct _TomoeWindowPrivate TomoeWindowPrivate; struct _TomoeWindowPrivate @@ -133,7 +134,7 @@ priv->chartable = widget; gtk_widget_show (widget); tomoe_window_append_page (window, widget, - gtk_label_new ("T"), + gtk_image_new_from_file (TOMOE_GUCHARMAP_ICON), _("Character table")); } From ikezoe users.sourceforge.jp Fri Dec 1 12:09:27 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 12:09:27 +0900 Subject: [Tomoe-cvs 1504] CVS update: libtomoe-gtk Message-ID: <20061201030927.3D3A62AC110@users.sourceforge.jp> Index: libtomoe-gtk/Makefile.am diff -u libtomoe-gtk/Makefile.am:1.5 libtomoe-gtk/Makefile.am:1.6 --- libtomoe-gtk/Makefile.am:1.5 Fri Oct 13 16:01:33 2006 +++ libtomoe-gtk/Makefile.am Fri Dec 1 12:09:27 2006 @@ -1,4 +1,4 @@ -SUBDIRS=src data po test +SUBDIRS=src data po test doc EXTRA_DIST = autogen.sh libtomoe-gtk.pc Index: libtomoe-gtk/README diff -u libtomoe-gtk/README:1.3 libtomoe-gtk/README:1.4 --- libtomoe-gtk/README:1.3 Mon Oct 31 12:15:17 2005 +++ libtomoe-gtk/README Fri Dec 1 12:09:27 2006 @@ -1,4 +1,4 @@ -a class library for tomoe's GTK+ GUI parts + a class library for tomoe's GTK+ GUI parts libtomoe-gtk is a class library for tomoe that online handwriting recognition engine. It offers GTK+ GUI parts and is useful for Index: libtomoe-gtk/autogen.sh diff -u libtomoe-gtk/autogen.sh:1.2 libtomoe-gtk/autogen.sh:1.3 --- libtomoe-gtk/autogen.sh:1.2 Fri Oct 7 08:46:05 2005 +++ libtomoe-gtk/autogen.sh Fri Dec 1 12:09:27 2006 @@ -1,6 +1,7 @@ #!/bin/sh libtoolize --copy --force \ + && gtkdocize \ && aclocal \ && autoheader \ && automake --add-missing --foreign --copy Index: libtomoe-gtk/configure.ac diff -u libtomoe-gtk/configure.ac:1.14 libtomoe-gtk/configure.ac:1.15 --- libtomoe-gtk/configure.ac:1.14 Thu Nov 30 15:00:44 2006 +++ libtomoe-gtk/configure.ac Fri Dec 1 12:09:27 2006 @@ -97,6 +97,9 @@ AC_SUBST(GUCHARMAP_CFLAGS) AC_SUBST(GUCHARMAP_LIBS) +# Checks for gtk-doc +GTK_DOC_CHECK([1.4]) + GETTEXT_PACKAGE=libtomoe-gtk AC_SUBST(GETTEXT_PACKAGE) @@ -112,6 +115,9 @@ data/Makefile src/Makefile test/Makefile +doc/Makefile +doc/reference/Makefile +doc/reference/version.xml libtomoe-gtk.pc ]) From ikezoe users.sourceforge.jp Fri Dec 1 12:09:27 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 12:09:27 +0900 Subject: [Tomoe-cvs 1505] CVS update: libtomoe-gtk/doc Message-ID: <20061201030927.5DFED2AC1BB@users.sourceforge.jp> Index: libtomoe-gtk/doc/Makefile.am diff -u /dev/null libtomoe-gtk/doc/Makefile.am:1.1 --- /dev/null Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/Makefile.am Fri Dec 1 12:09:27 2006 @@ -0,0 +1 @@ +SUBDIRS = reference From ikezoe users.sourceforge.jp Fri Dec 1 12:09:27 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 12:09:27 +0900 Subject: [Tomoe-cvs 1506] CVS update: libtomoe-gtk/doc/reference Message-ID: <20061201030927.8C6D32AC110@users.sourceforge.jp> Index: libtomoe-gtk/doc/reference/.cvsignore diff -u /dev/null libtomoe-gtk/doc/reference/.cvsignore:1.1 --- /dev/null Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/reference/.cvsignore Fri Dec 1 12:09:27 2006 @@ -0,0 +1,21 @@ +Makefile +Makefile.in +doxygen.conf +html +xml +libtomoe-gtk-decl-list.txt +libtomoe-gtk-decl.txt +libtomoe-gtk-undocumented.txt +libtomoe-gtk-unused.txt +libtomoe-gtk.args +libtomoe-gtk.hierarchy +libtomoe-gtk.interfaces +libtomoe-gtk.prerequisites +libtomoe-gtk.signals +version.xml +*.bak +*~ +*.log +*.rej +*.orig +*.stamp Index: libtomoe-gtk/doc/reference/Makefile.am diff -u /dev/null libtomoe-gtk/doc/reference/Makefile.am:1.1 --- /dev/null Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/reference/Makefile.am Fri Dec 1 12:09:27 2006 @@ -0,0 +1,52 @@ +MAINTAINERCLEANFILE = Makefile.in + +## Process this file with automake to produce Makefile.in +AUTOMAKE_OPTIONS = 1.6 + +# The name of the module. +DOC_MODULE=libtomoe-gtk + +# The top-level SGML file. +DOC_MAIN_SGML_FILE=libtomoe-gtk-docs.sgml + +# Extra options to supply to gtkdoc-scan +SCAN_OPTIONS= + +# The directory containing the source code. Relative to $(srcdir) +DOC_SOURCE_DIR=../../src + +# Used for dependencies +HFILE_GLOB=$(top_srcdir)/src/*.h +CFILE_GLOB=$(top_srcdir)/src/*.c + +# Headers to ignore +IGNORE_HFILES= \ + config.h + +INCLUDES = \ + -I$(top_srcdir)/src \ + -I$(top_builddir)/src \ + $(GLIB_CFLAGS) +GTKDOC_LIBS = \ + $(top_builddir)/src/libtomoe-gtk.la \ + $(GLIB_LIBS) + +# Extra options to supply to gtkdoc-mkdb +MKDB_OPTIONS=--sgml-mode --output-format=xml --ignore-files=trio + +# Images to copy into HTML directory +HTML_IMAGES = + +# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE) +content_files = \ + version.xml + +# Extra options to supply to gtkdoc-fixref +FIXXREF_OPTIONS= + +# include common portion ... +include $(top_srcdir)/gtk-doc.make + +# Other files to distribute +EXTRA_DIST += \ + version.xml.in Index: libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml diff -u /dev/null libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml:1.1 --- /dev/null Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml Fri Dec 1 12:09:27 2006 @@ -0,0 +1,38 @@ + + + + + + + + +]> + + + libtomoe-gtk Reference Manual + for libtomoe-gtk &version; + + + + libtomoe-gtk Core + + &libtomoe-gtk-Canvas; + &libtomoe-gtk-CharTable; + &libtomoe-gtk-Window; + + + + Index + + + Index: libtomoe-gtk/doc/reference/version.xml.in diff -u /dev/null libtomoe-gtk/doc/reference/version.xml.in:1.1 --- /dev/null Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/reference/version.xml.in Fri Dec 1 12:09:27 2006 @@ -0,0 +1 @@ + VERSION@ From ikezoe users.sourceforge.jp Fri Dec 1 12:19:34 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 12:19:34 +0900 Subject: [Tomoe-cvs 1507] CVS update: libtomoe-gtk/doc/reference Message-ID: <20061201031934.BF3302AC016@users.sourceforge.jp> Index: libtomoe-gtk/doc/reference/Makefile.am diff -u libtomoe-gtk/doc/reference/Makefile.am:1.1 libtomoe-gtk/doc/reference/Makefile.am:1.2 --- libtomoe-gtk/doc/reference/Makefile.am:1.1 Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/reference/Makefile.am Fri Dec 1 12:19:34 2006 @@ -26,10 +26,12 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_builddir)/src \ - $(GLIB_CFLAGS) + $(TOMOE_CFLAGS) \ + $(GTK2_CFLAGS) GTKDOC_LIBS = \ - $(top_builddir)/src/libtomoe-gtk.la \ - $(GLIB_LIBS) + $(top_builddir)/src/libtomoe-gtk.la \ + $(TOMOE_LIBS) \ + $(GTK2_LIBS) # Extra options to supply to gtkdoc-mkdb MKDB_OPTIONS=--sgml-mode --output-format=xml --ignore-files=trio Index: libtomoe-gtk/doc/reference/libtomoe-gtk.types diff -u /dev/null libtomoe-gtk/doc/reference/libtomoe-gtk.types:1.1 --- /dev/null Fri Dec 1 12:19:34 2006 +++ libtomoe-gtk/doc/reference/libtomoe-gtk.types Fri Dec 1 12:19:34 2006 @@ -0,0 +1,5 @@ +#include + +tomoe_canvas_get_type +tomoe_char_table_get_type +tomoe_window_get_type From kous users.sourceforge.jp Fri Dec 1 12:29:28 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 12:29:28 +0900 Subject: [Tomoe-cvs 1508] CVS update: tomoe Message-ID: <20061201032928.205D42AC1BB@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.361 tomoe/ChangeLog:1.362 --- tomoe/ChangeLog:1.361 Fri Dec 1 11:23:38 2006 +++ tomoe/ChangeLog Fri Dec 1 12:29:27 2006 @@ -1,5 +1,7 @@ 2006-12-01 Kouhei Sutou + * lib/tomoe-xml-parser.c: added warning message. + * NEWS, TODO: updated. * module/dict/tomoe-dict-est.c: added cache mechanism but still From kous users.sourceforge.jp Fri Dec 1 12:29:28 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 12:29:28 +0900 Subject: [Tomoe-cvs 1509] CVS update: tomoe/lib Message-ID: <20061201032928.4CF012AC1BE@users.sourceforge.jp> Index: tomoe/lib/tomoe-xml-parser.c diff -u tomoe/lib/tomoe-xml-parser.c:1.1 tomoe/lib/tomoe-xml-parser.c:1.2 --- tomoe/lib/tomoe-xml-parser.c:1.1 Thu Nov 30 11:22:31 2006 +++ tomoe/lib/tomoe-xml-parser.c Fri Dec 1 12:29:28 2006 @@ -18,10 +18,12 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-xml-parser.c,v 1.1 2006/11/30 02:22:31 kous Exp $ + * $Id: tomoe-xml-parser.c,v 1.2 2006/12/01 03:29:28 kous Exp $ */ #include +#include + #include #include #include @@ -389,6 +391,10 @@ gboolean retval = TRUE; f = fopen (filename, "rb"); + if (!f) { + g_warning ("failed to open dictionary file %s: %s", filename, + sys_errlist[errno]); + } g_return_val_if_fail (f, FALSE); init_parse_data (&data, result, filename); From kous users.sourceforge.jp Fri Dec 1 12:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 12:51:42 +0900 Subject: [Tomoe-cvs 1510] CVS update: tomoe Message-ID: <20061201035142.63D672AC01A@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.362 tomoe/ChangeLog:1.363 --- tomoe/ChangeLog:1.362 Fri Dec 1 12:29:27 2006 +++ tomoe/ChangeLog Fri Dec 1 12:51:42 2006 @@ -1,5 +1,8 @@ 2006-12-01 Kouhei Sutou + * benchmark/convert-char.rb, benchmark/Makefile.am: added + a benchmark for converting TomoeChar to/from XML. + * lib/tomoe-xml-parser.c: added warning message. * NEWS, TODO: updated. From kous users.sourceforge.jp Fri Dec 1 12:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 12:51:42 +0900 Subject: [Tomoe-cvs 1511] CVS update: tomoe/benchmark Message-ID: <20061201035142.92F8E2AC062@users.sourceforge.jp> Index: tomoe/benchmark/Makefile.am diff -u tomoe/benchmark/Makefile.am:1.2 tomoe/benchmark/Makefile.am:1.3 --- tomoe/benchmark/Makefile.am:1.2 Tue Nov 28 15:39:34 2006 +++ tomoe/benchmark/Makefile.am Fri Dec 1 12:51:42 2006 @@ -2,7 +2,7 @@ .PHONY: benchamrk -benchmark_files = load-dict.rb search-by-recognizer.rb +benchmark_files = load-dict.rb search-by-recognizer.rb convert-char.rb benchmark: $(top_builddir)/ext/ruby/tomoe.la for bench in $(benchmark_files); \ Index: tomoe/benchmark/convert-char.rb diff -u /dev/null tomoe/benchmark/convert-char.rb:1.1 --- /dev/null Fri Dec 1 12:51:42 2006 +++ tomoe/benchmark/convert-char.rb Fri Dec 1 12:51:42 2006 @@ -0,0 +1,46 @@ +require "benchmark" + +benchmark_dir = File.expand_path(File.dirname(__FILE__)) +top_dir = File.expand_path(File.join(benchmark_dir, "..")) +test_dir = File.join(top_dir, "test") +$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby", ".libs")) +$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby")) +$LOAD_PATH.unshift(File.join(test_dir)) + +require "tomoe-spec-utils" + +xml = <<-XML + + ??/utf8> + + + + + + + + + + + + + + + + + + + + + + + +XML + +n = 5000 +Benchmark.bmbm do |x| + x.report("XML -> TomoeChar") {n.times {Tomoe::Char.new(xml)}} + GC.start + char = Tomoe::Char.new(xml) + x.report("TomoeChar -> XML") {n.times {char.to_xml}} +end From kous users.sourceforge.jp Fri Dec 1 12:53:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 12:53:51 +0900 Subject: [Tomoe-cvs 1512] CVS update: tomoe Message-ID: <20061201035351.156B22AC062@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.363 tomoe/ChangeLog:1.364 --- tomoe/ChangeLog:1.363 Fri Dec 1 12:51:42 2006 +++ tomoe/ChangeLog Fri Dec 1 12:53:50 2006 @@ -1,5 +1,8 @@ 2006-12-01 Kouhei Sutou + * benchmark/load-dict.rb: decremented number of loading from 10 to + 3. + * benchmark/convert-char.rb, benchmark/Makefile.am: added a benchmark for converting TomoeChar to/from XML. From kous users.sourceforge.jp Fri Dec 1 12:53:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 12:53:51 +0900 Subject: [Tomoe-cvs 1513] CVS update: tomoe/benchmark Message-ID: <20061201035351.3F2BF2AC108@users.sourceforge.jp> Index: tomoe/benchmark/load-dict.rb diff -u tomoe/benchmark/load-dict.rb:1.4 tomoe/benchmark/load-dict.rb:1.5 --- tomoe/benchmark/load-dict.rb:1.4 Thu Nov 30 16:35:07 2006 +++ tomoe/benchmark/load-dict.rb Fri Dec 1 12:53:51 2006 @@ -9,7 +9,7 @@ require "tomoe-spec-utils" -n = 10 +n = 3 Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| x.report(File.basename(dictionary)) do From ikezoe users.sourceforge.jp Fri Dec 1 13:07:51 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 13:07:51 +0900 Subject: [Tomoe-cvs 1514] CVS update: libtomoe-gtk/doc/reference/tmpl Message-ID: <20061201040751.2D2BD2AC108@users.sourceforge.jp> From ikezoe users.sourceforge.jp Fri Dec 1 13:08:44 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 13:08:44 +0900 Subject: [Tomoe-cvs 1515] CVS update: libtomoe-gtk/doc/reference/tmpl Message-ID: <20061201040844.D3AAB2AC1BE@users.sourceforge.jp> Index: libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml diff -u /dev/null libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml:1.1 --- /dev/null Fri Dec 1 13:08:44 2006 +++ libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml Fri Dec 1 13:08:44 2006 @@ -0,0 +1,245 @@ + +TomoeCanvas + + +A canvas widget for viewing and drawing strokes of hand-writing. + + + + + + + + + + + + + + + + +The #TomoeCanvas struct contains only +private fields and should not be directly accessed. + + + + + + + + + tomoecanvas: the object which received the signal. + + + + + + + tomoecanvas: the object which received the signal. + + + + + + + tomoecanvas: the object which received the signal. + + + + + + + tomoecanvas: the object which received the signal. + + + + + + + tomoecanvas: the object which received the signal. + + + + + + + Returns: + + + + + + + + canvas: + + + + + + + + canvas: + nth: + Returns: + + + + + + + + canvas: + Returns: + + + + + + + + canvas: + + + + + + + + canvas: + + + + + + + + canvas: + + + + + + + + canvas: + + + + + + + + canvas: + Returns: + + + + + + + + canvas: + size: + + + + + + + + canvas: + color: + + + + + + + + canvas: + color: + + + + + + + + canvas: + color: + + + + + + + + canvas: + color: + + + + + + + + canvas: + time_msec: + + + + + + + + canvas: + Returns: + + + + + + + + canvas: + context: + + + + + + + + canvas: + Returns: + + + + + + + + canvas: + writing: + + + + + + + + canvas: + lock: + + + + + + + + canvas: + Returns: + + From ikezoe users.sourceforge.jp Fri Dec 1 13:38:37 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 13:38:37 +0900 Subject: [Tomoe-cvs 1516] CVS update: libtomoe-gtk Message-ID: <20061201043837.A31902AC108@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.199 libtomoe-gtk/ChangeLog:1.200 --- libtomoe-gtk/ChangeLog:1.199 Fri Dec 1 12:08:41 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 13:38:37 2006 @@ -1,3 +1,8 @@ +2006-12-01 Hiroyuki Ikezoe + + * src/tomoe-stroke-search.[ch]: Emit "selected" signal from + TomoeStrokeSearch instead of TomoeCharTable directry. + 2006-12-01 Takuro Ashie * data/tomoe-gucharmap.png: Add. From ikezoe users.sourceforge.jp Fri Dec 1 13:38:37 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 13:38:37 +0900 Subject: [Tomoe-cvs 1517] CVS update: libtomoe-gtk/src Message-ID: <20061201043837.D00772AC1BE@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-stroke-search.c diff -u libtomoe-gtk/src/tomoe-stroke-search.c:1.16 libtomoe-gtk/src/tomoe-stroke-search.c:1.17 --- libtomoe-gtk/src/tomoe-stroke-search.c:1.16 Thu Nov 30 18:36:08 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.c Fri Dec 1 13:38:37 2006 @@ -68,7 +68,6 @@ gpointer user_data); #endif static gboolean on_candidate_selected (TomoeCharTable *table, - GdkEventButton *event, gpointer user_data); static guint stroke_search_signals[LAST_SIGNAL] = { 0 }; @@ -189,7 +188,7 @@ priv->candidates_view = table; tomoe_char_table_set_canvas (TOMOE_CHAR_TABLE (table), TOMOE_CANVAS (canvas)); - g_signal_connect (G_OBJECT (table), "button-release-event", + g_signal_connect (G_OBJECT (table), "selected", G_CALLBACK (on_candidate_selected), (gpointer) strokeSearch); gtk_container_add (GTK_CONTAINER (frame), table); @@ -292,18 +291,17 @@ tomoe_stroke_search_set_sensitive (strokeSearch); } - -/* TODO does not work */ static gboolean on_candidate_selected (TomoeCharTable *table, - GdkEventButton *event, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch), FALSE); + g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), FALSE); - tomoe_stroke_search_set_sensitive (strokeSearch); + g_signal_emit (G_OBJECT (stroke_search), + stroke_search_signals[SELECTED_SIGNAL], 0); + tomoe_stroke_search_set_sensitive (stroke_search); return FALSE; } @@ -318,15 +316,15 @@ return priv->button_area; } -GtkWidget * -tomoe_stroke_search_get_candidates_view (TomoeStrokeSearch *stroke_search) +TomoeChar * +tomoe_stroke_search_get_selected_candidate (TomoeStrokeSearch *stroke_search) { TomoeStrokeSearchPrivate *priv; g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), NULL); priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - return priv->candidates_view; + return tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); } #ifdef ENABLE_DUMPSTROKE Index: libtomoe-gtk/src/tomoe-stroke-search.h diff -u libtomoe-gtk/src/tomoe-stroke-search.h:1.6 libtomoe-gtk/src/tomoe-stroke-search.h:1.7 --- libtomoe-gtk/src/tomoe-stroke-search.h:1.6 Tue Nov 28 10:38:41 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.h Fri Dec 1 13:38:37 2006 @@ -24,6 +24,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -54,7 +55,7 @@ GType tomoe_stroke_search_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_stroke_search_new (void); GtkWidget *tomoe_stroke_search_get_canvas (TomoeStrokeSearch *stroke_search); -GtkWidget *tomoe_stroke_search_get_candidates_view +TomoeChar *tomoe_stroke_search_get_selected_candidate (TomoeStrokeSearch *stroke_search); GtkWidget *tomoe_stroke_search_get_button_area (TomoeStrokeSearch *stroke_search); From makeinu users.sourceforge.jp Fri Dec 1 13:43:05 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 13:43:05 +0900 Subject: [Tomoe-cvs 1518] CVS update: libtomoe-gtk Message-ID: <20061201044305.ECD7B2AC108@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.200 libtomoe-gtk/ChangeLog:1.201 --- libtomoe-gtk/ChangeLog:1.200 Fri Dec 1 13:38:37 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 13:43:05 2006 @@ -1,3 +1,8 @@ +2006-12-01 Takuro Ashie + + * src/tomoe-gucharmap.c: Replace option menu with combo box and connect + changed signal. + 2006-12-01 Hiroyuki Ikezoe * src/tomoe-stroke-search.[ch]: Emit "selected" signal from From makeinu users.sourceforge.jp Fri Dec 1 13:43:06 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 13:43:06 +0900 Subject: [Tomoe-cvs 1519] CVS update: libtomoe-gtk/src Message-ID: <20061201044306.26F8A2AC1BE@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.7 libtomoe-gtk/src/tomoe-gucharmap.c:1.8 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.7 Fri Dec 1 11:56:52 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 13:43:06 2006 @@ -23,7 +23,7 @@ typedef struct _TomoeGucharmapPrivate TomoeGucharmapPrivate; struct _TomoeGucharmapPrivate { - GtkWidget *chapters_option_menu; + GtkWidget *chapters_combo; GucharmapChapters *chapters; GucharmapCharmap *charmap; }; @@ -34,6 +34,8 @@ static void dispose (GObject *object); static void setup_chapters_option_menu (TomoeGucharmap *page); +static void on_chapters_combo_changed (GtkComboBox *option_menu, + gpointer data); GtkWidget * tomoe_gucharmap_new (void) @@ -55,7 +57,7 @@ tomoe_gucharmap_init (TomoeGucharmap *page) { TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); - GtkWidget *vbox, *hbox, *label, *option_menu, *widget; + GtkWidget *vbox, *hbox, *label, *combo, *widget; gtk_table_resize (GTK_TABLE (page), 1, 1); gtk_table_set_homogeneous (GTK_TABLE (page), FALSE); @@ -74,10 +76,10 @@ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); - option_menu = gtk_option_menu_new (); - priv->chapters_option_menu = option_menu; - gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 2); - gtk_widget_show (option_menu); + combo = gtk_combo_box_new_text (); + priv->chapters_combo = combo; + gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 2); + gtk_widget_show (combo); /* gucharmap */ priv->chapters = GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()); @@ -97,7 +99,11 @@ gtk_widget_show (vbox); + /* setup */ setup_chapters_option_menu (page); + g_signal_connect (G_OBJECT (combo), "changed", + G_CALLBACK (on_chapters_combo_changed), + (gpointer) page); } static void @@ -127,29 +133,24 @@ { TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); GtkTreeModel *model = priv->chapters->tree_model; - GtkTreeIter iter; - GtkWidget *menu; - gboolean iterate; - - menu = gtk_menu_new (); - - for (iterate = gtk_tree_model_get_iter_first (model, &iter); - iterate; - iterate = gtk_tree_model_iter_next (model, &iter)) - { - GtkWidget *menuitem; - gchar *text = NULL; - - gtk_tree_model_get (model, &iter, - 0, &text, - -1); - menuitem = gtk_menu_item_new_with_label (text); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - gtk_widget_show (menuitem); - g_free (text); - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (priv->chapters_option_menu), - menu); - gtk_widget_show (menu); + + gtk_combo_box_set_model (GTK_COMBO_BOX (priv->chapters_combo), model); + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->chapters_combo), 0); +} + +static void +on_chapters_combo_changed (GtkComboBox *combo, gpointer data) +{ + TomoeGucharmap *page = data; + TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); + GtkTreePath *path; + gchar buf[8]; + gint idx; + + idx = gtk_combo_box_get_active (combo); + g_snprintf (buf, 8 , "%d", idx); + path = gtk_tree_path_new_from_string (buf); + gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->chapters->tree_view), + path, NULL, FALSE); + gtk_tree_path_free (path); } From kous users.sourceforge.jp Fri Dec 1 13:47:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 13:47:26 +0900 Subject: [Tomoe-cvs 1520] CVS update: tomoe Message-ID: <20061201044726.118EA2AC1BE@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.364 tomoe/ChangeLog:1.365 --- tomoe/ChangeLog:1.364 Fri Dec 1 12:53:50 2006 +++ tomoe/ChangeLog Fri Dec 1 13:47:25 2006 @@ -1,5 +1,11 @@ 2006-12-01 Kouhei Sutou + * lib/tomoe-query.c: supported properties. + * lib/tomoe-query.[ch]: added tomoe_query_(set|get)_utf8(). + + * benchmark/search-by-dict.rb, benchmark/Makefile.am: added a + benchmark for searching by dictionary. + * benchmark/load-dict.rb: decremented number of loading from 10 to 3. From kous users.sourceforge.jp Fri Dec 1 13:47:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 13:47:26 +0900 Subject: [Tomoe-cvs 1521] CVS update: tomoe/benchmark Message-ID: <20061201044726.357682AC1D2@users.sourceforge.jp> Index: tomoe/benchmark/load-dict.rb diff -u tomoe/benchmark/load-dict.rb:1.5 tomoe/benchmark/load-dict.rb:1.6 --- tomoe/benchmark/load-dict.rb:1.5 Fri Dec 1 12:53:51 2006 +++ tomoe/benchmark/load-dict.rb Fri Dec 1 13:47:26 2006 @@ -17,6 +17,5 @@ "filename" => dictionary, "editable" => false)} end - GC.start end end Index: tomoe/benchmark/search-by-dict.rb diff -u /dev/null tomoe/benchmark/search-by-dict.rb:1.1 --- /dev/null Fri Dec 1 13:47:26 2006 +++ tomoe/benchmark/search-by-dict.rb Fri Dec 1 13:47:26 2006 @@ -0,0 +1,30 @@ +require "benchmark" + +benchmark_dir = File.expand_path(File.dirname(__FILE__)) +top_dir = File.expand_path(File.join(benchmark_dir, "..")) +test_dir = File.join(top_dir, "test") +$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby", ".libs")) +$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby")) +$LOAD_PATH.unshift(File.join(test_dir)) + +require "tomoe-spec-utils" + +n = 10 +Benchmark.bmbm do |x| + TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| + dict = Tomoe::Dict.new("xml", + "filename" => dictionary, + "editable" => false) + + x.report("#{File.basename(dictionary)}: all") do + query = Tomoe::Query.new + n.times {dict.search(query)} + end + + x.report("#{File.basename(dictionary)}: >= 5") do + query = Tomoe::Query.new + query.min_n_strokes = 10 + n.times {dict.search(query)} + end + end +end From kous users.sourceforge.jp Fri Dec 1 13:47:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 13:47:26 +0900 Subject: [Tomoe-cvs 1522] CVS update: tomoe/ext/ruby Message-ID: <20061201044726.8B0BD2AC1BE@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-query.c diff -u tomoe/ext/ruby/tomoe-rb-query.c:1.1 tomoe/ext/ruby/tomoe-rb-query.c:1.2 --- tomoe/ext/ruby/tomoe-rb-query.c:1.1 Wed Nov 22 18:04:47 2006 +++ tomoe/ext/ruby/tomoe-rb-query.c Fri Dec 1 13:47:26 2006 @@ -26,8 +26,6 @@ cTomoeQuery = G_DEF_CLASS(TOMOE_TYPE_QUERY, "Query", mTomoe); rb_define_method(cTomoeQuery, "add_reading", tq_add_reading, 1); -/* rb_define_method(cTomoeQuery, "set_number_of_stroke", */ -/* tq_set_number_of_stroke, 1); */ /* rb_define_method(cTomoeQuery, "add_radical", tq_add_radical, 1); */ /* rb_define_method(cTomoeQuery, "add_variant", tq_add_variant, 1); */ rb_define_method(cTomoeQuery, "set_writing", tq_set_writing, 1); From kous users.sourceforge.jp Fri Dec 1 13:47:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 13:47:26 +0900 Subject: [Tomoe-cvs 1523] CVS update: tomoe/lib Message-ID: <20061201044726.B009A2AC1D2@users.sourceforge.jp> Index: tomoe/lib/tomoe-query.c diff -u tomoe/lib/tomoe-query.c:1.5 tomoe/lib/tomoe-query.c:1.6 --- tomoe/lib/tomoe-query.c:1.5 Wed Nov 29 11:33:12 2006 +++ tomoe/lib/tomoe-query.c Fri Dec 1 13:47:26 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.c,v 1.5 2006/11/29 02:33:12 makeinu Exp $ + * $Id: tomoe-query.c,v 1.6 2006/12/01 04:47:26 kous Exp $ */ #include @@ -72,6 +72,7 @@ tomoe_query_class_init (TomoeQueryClass *klass) { GObjectClass *gobject_class; + GParamSpec *spec; gobject_class = G_OBJECT_CLASS (klass); @@ -79,6 +80,36 @@ gobject_class->set_property = tomoe_query_set_property; gobject_class->get_property = tomoe_query_get_property; + spec = g_param_spec_string ("utf8", + N_("UTF8"), + N_("UTF8 encoding of searched character."), + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_UTF8, spec); + + spec = g_param_spec_int ("min_n_strokes", + N_("Minimum number of strokes"), + N_("Minimum number of strokes of searched " + "character."), + -1, G_MAXINT32, -1, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_MIN_N_STROKES, spec); + + spec = g_param_spec_int ("max_n_strokes", + N_("Maximum number of strokes"), + N_("Maximum number of strokes of searched " + "character."), + -1, G_MAXINT32, -1, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_MAX_N_STROKES, spec); + + spec = g_param_spec_object ("writing", + N_("Writing"), + N_("Writing of searched character."), + TOMOE_TYPE_WRITING, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_WRITING, spec); + g_type_class_add_private (gobject_class, sizeof (TomoeQueryPrivate)); } @@ -145,6 +176,18 @@ priv = TOMOE_QUERY_GET_PRIVATE (query); switch (prop_id) { + case PROP_UTF8: + tomoe_query_set_utf8 (query, g_value_get_string (value)); + break; + case PROP_MIN_N_STROKES: + tomoe_query_set_min_n_strokes (query, g_value_get_int (value)); + break; + case PROP_MAX_N_STROKES: + tomoe_query_set_max_n_strokes (query, g_value_get_int (value)); + break; + case PROP_WRITING: + tomoe_query_set_writing (query, g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -164,21 +207,47 @@ priv = TOMOE_QUERY_GET_PRIVATE (query); switch (prop_id) { + case PROP_UTF8: + g_value_set_string (value, priv->utf8); + break; + case PROP_MIN_N_STROKES: + g_value_set_int (value, priv->min_n_strokes); + break; + case PROP_MAX_N_STROKES: + g_value_set_int (value, priv->max_n_strokes); + break; + case PROP_WRITING: + g_value_set_object (value, priv->writing); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } } +const gchar * +tomoe_query_get_utf8 (TomoeQuery* query) +{ + TomoeQueryPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_QUERY (query), NULL); + + priv = TOMOE_QUERY_GET_PRIVATE (query); + return priv->utf8; +} + void -tomoe_query_add_reading (TomoeQuery* query, TomoeReading *reading) +tomoe_query_set_utf8 (TomoeQuery* query, const gchar *utf8) { TomoeQueryPrivate *priv; g_return_if_fail (TOMOE_IS_QUERY (query)); priv = TOMOE_QUERY_GET_PRIVATE (query); - priv->readings = g_list_append (priv->readings, g_object_ref (reading)); + if (priv->utf8) + g_free (priv->utf8); + + priv->utf8 = utf8 ? g_strdup (utf8) : NULL; } const GList * @@ -192,6 +261,17 @@ return priv->readings; } +void +tomoe_query_add_reading (TomoeQuery* query, TomoeReading *reading) +{ + TomoeQueryPrivate *priv; + + g_return_if_fail (TOMOE_IS_QUERY (query)); + + priv = TOMOE_QUERY_GET_PRIVATE (query); + priv->readings = g_list_append (priv->readings, g_object_ref (reading)); +} + const GList * tomoe_query_get_radicals (TomoeQuery *query) { Index: tomoe/lib/tomoe-query.h diff -u tomoe/lib/tomoe-query.h:1.5 tomoe/lib/tomoe-query.h:1.6 --- tomoe/lib/tomoe-query.h:1.5 Fri Dec 1 10:37:38 2006 +++ tomoe/lib/tomoe-query.h Fri Dec 1 13:47:26 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.h,v 1.5 2006/12/01 01:37:38 ikezoe Exp $ + * $Id: tomoe-query.h,v 1.6 2006/12/01 04:47:26 kous Exp $ */ #ifndef __TOMOE_QUERY_H__ @@ -55,6 +55,10 @@ TomoeQuery *tomoe_query_new (void); +const gchar *tomoe_query_get_utf8 (TomoeQuery *query); +void tomoe_query_set_utf8 (TomoeQuery *query, + const gchar *utf8); + void tomoe_query_add_reading (TomoeQuery *query, TomoeReading *reading); const GList *tomoe_query_get_readings (TomoeQuery *query); From makeinu users.sourceforge.jp Fri Dec 1 13:49:36 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 13:49:36 +0900 Subject: [Tomoe-cvs 1524] CVS update: libtomoe-gtk/src Message-ID: <20061201044936.DFEED2AC108@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.8 libtomoe-gtk/src/tomoe-gucharmap.c:1.9 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.8 Fri Dec 1 13:43:06 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 13:49:36 2006 @@ -88,7 +88,7 @@ gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 2); gtk_widget_show (widget); - /* Hide chapters page by default. Usually use option menu instead. */ + /* Hide chapters page by default. Usually use combo box instead. */ gtk_widget_hide (GTK_WIDGET (priv->chapters)); /* Add test page */ From ikezoe users.sourceforge.jp Fri Dec 1 13:52:16 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 13:52:16 +0900 Subject: [Tomoe-cvs 1525] CVS update: libtomoe-gtk/src Message-ID: <20061201045216.B7C9C2AC108@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-stroke-search.c diff -u libtomoe-gtk/src/tomoe-stroke-search.c:1.17 libtomoe-gtk/src/tomoe-stroke-search.c:1.18 --- libtomoe-gtk/src/tomoe-stroke-search.c:1.17 Fri Dec 1 13:38:37 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.c Fri Dec 1 13:52:16 2006 @@ -67,7 +67,7 @@ static void on_dump_button_clicked (GtkButton *button, gpointer user_data); #endif -static gboolean on_candidate_selected (TomoeCharTable *table, +static void on_candidate_selected (TomoeCharTable *table, gpointer user_data); static guint stroke_search_signals[LAST_SIGNAL] = { 0 }; @@ -291,18 +291,17 @@ tomoe_stroke_search_set_sensitive (strokeSearch); } -static gboolean +static void on_candidate_selected (TomoeCharTable *table, gpointer user_data) { TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), FALSE); + g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); g_signal_emit (G_OBJECT (stroke_search), stroke_search_signals[SELECTED_SIGNAL], 0); tomoe_stroke_search_set_sensitive (stroke_search); - return FALSE; } GtkWidget * From ikezoe users.sourceforge.jp Fri Dec 1 14:03:37 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:03:37 +0900 Subject: [Tomoe-cvs 1526] CVS update: libtomoe-gtk Message-ID: <20061201050337.912A52AC02E@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.201 libtomoe-gtk/ChangeLog:1.202 --- libtomoe-gtk/ChangeLog:1.201 Fri Dec 1 13:43:05 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 14:03:37 2006 @@ -1,3 +1,9 @@ +2006-12-01 Hiroyuki Ikezoe + + * src/tomoe-window.[ch]: Add "selected" signal. + TomoeWindow is now a child of GtkWindow instead of GtkDialog. + * test/testtomoegtk.c: Follow above change. + 2006-12-01 Takuro Ashie * src/tomoe-gucharmap.c: Replace option menu with combo box and connect From ikezoe users.sourceforge.jp Fri Dec 1 14:03:37 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:03:37 +0900 Subject: [Tomoe-cvs 1527] CVS update: libtomoe-gtk/src Message-ID: <20061201050337.B58342AC0C5@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.26 libtomoe-gtk/src/tomoe-window.c:1.27 --- libtomoe-gtk/src/tomoe-window.c:1.26 Fri Dec 1 12:08:41 2006 +++ libtomoe-gtk/src/tomoe-window.c Fri Dec 1 14:03:37 2006 @@ -38,6 +38,11 @@ #define TOMOE_SEARCHING_ICON LIBTOMOEGTKDATADIR"/tomoe-search.png" #define TOMOE_GUCHARMAP_ICON LIBTOMOEGTKDATADIR"/tomoe-gucharmap.png" +enum { + SELECTED_SIGNAL, + LAST_SIGNAL +}; + typedef struct _TomoeWindowPrivate TomoeWindowPrivate; struct _TomoeWindowPrivate { @@ -53,16 +58,33 @@ #define TOMOE_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_WINDOW, TomoeWindowPrivate)) -G_DEFINE_TYPE (TomoeWindow, tomoe_window, GTK_TYPE_DIALOG) +G_DEFINE_TYPE (TomoeWindow, tomoe_window, GTK_TYPE_WINDOW) + +static void dispose (GObject *object); +static void destroy (GtkObject *object); + +static void on_handwriting_candidate_selected (TomoeStrokeSearch *view, + gpointer user_data); -static void dispose (GObject *object); +static guint window_signals[LAST_SIGNAL] = { 0 }; static void tomoe_window_class_init (TomoeWindowClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + + window_signals[SELECTED_SIGNAL] = + g_signal_new ("selected", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (TomoeWindowClass, selected), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); gobject_class->dispose = dispose; + object_class->destroy = destroy; g_type_class_add_private (gobject_class, sizeof (TomoeWindowPrivate)); } @@ -72,7 +94,7 @@ { TomoeStrokeSearch *handwriting_page; TomoeReadingSearch *reading_search; - GtkWidget *widget, *notebook; + GtkWidget *widget, *notebook, *vbox; TomoeCanvas *canvas; TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); @@ -99,13 +121,17 @@ /* FIXME! */ gtk_window_set_resizable (GTK_WINDOW (window), FALSE); + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), vbox); + gtk_widget_show (vbox); + /* create search pages view notebook */ notebook = gtk_notebook_new (); priv->notebook = notebook; gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_LEFT); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE); gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (window)->vbox), notebook); + gtk_container_add (GTK_CONTAINER (vbox), notebook); gtk_widget_show (notebook); /* handwriting page */ @@ -114,6 +140,9 @@ handwriting_page = TOMOE_STROKE_SEARCH (widget); canvas = TOMOE_CANVAS (tomoe_stroke_search_get_canvas (handwriting_page)); tomoe_canvas_set_context (canvas, priv->context); + g_signal_connect (G_OBJECT (widget), "selected", + G_CALLBACK (on_handwriting_candidate_selected), + (gpointer) window); gtk_widget_show (widget); tomoe_window_append_page (window, widget, gtk_image_new_from_file (TOMOE_HANDWRITING_ICON), @@ -154,6 +183,14 @@ G_OBJECT_CLASS(tomoe_window_parent_class)->dispose(object); } +static void +destroy (GtkObject *object) +{ + GTK_OBJECT_CLASS (tomoe_window_parent_class)->destroy (object); + + gtk_main_quit(); +} + GtkWidget * tomoe_window_new (void) { @@ -222,6 +259,17 @@ return TOMOE_WINDOW_GET_PRIVATE (window)->notebook; } +static void +on_handwriting_candidate_selected (TomoeStrokeSearch *view, gpointer user_data) +{ + TomoeWindow *window; + g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + + window = TOMOE_WINDOW (user_data); + g_signal_emit (G_OBJECT (window), + window_signals[SELECTED_SIGNAL], 0); +} + /* * vi:ts=4:nowrap:ai:expandtab */ Index: libtomoe-gtk/src/tomoe-window.h diff -u libtomoe-gtk/src/tomoe-window.h:1.10 libtomoe-gtk/src/tomoe-window.h:1.11 --- libtomoe-gtk/src/tomoe-window.h:1.10 Tue Nov 28 10:38:41 2006 +++ libtomoe-gtk/src/tomoe-window.h Fri Dec 1 14:03:37 2006 @@ -38,12 +38,14 @@ struct _TomoeWindow { - GtkDialog parent_instance; + GtkWindow parent_instance; }; struct _TomoeWindowClass { - GtkDialogClass parent_class; + GtkWindowClass parent_class; + /* -- signals -- */ + void (*selected) (TomoeWindow *window); }; From ikezoe users.sourceforge.jp Fri Dec 1 14:03:37 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:03:37 +0900 Subject: [Tomoe-cvs 1528] CVS update: libtomoe-gtk/test Message-ID: <20061201050337.D9A7A2AC02E@users.sourceforge.jp> Index: libtomoe-gtk/test/testtomoegtk.c diff -u libtomoe-gtk/test/testtomoegtk.c:1.3 libtomoe-gtk/test/testtomoegtk.c:1.4 --- libtomoe-gtk/test/testtomoegtk.c:1.3 Sat Nov 25 20:42:18 2006 +++ libtomoe-gtk/test/testtomoegtk.c Fri Dec 1 14:03:37 2006 @@ -9,8 +9,6 @@ /*g_setenv ("TOMOE_CONFIG_FILE", "./test-config.xml", FALSE);*/ gtk_init (&argc, &argv); win = tomoe_window_new (); - g_signal_connect (G_OBJECT (win), "response", - G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (win); gtk_main (); return 0; From ikezoe users.sourceforge.jp Fri Dec 1 14:12:36 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:12:36 +0900 Subject: [Tomoe-cvs 1529] CVS update: libtomoe-gtk Message-ID: <20061201051236.D62822AC108@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.202 libtomoe-gtk/ChangeLog:1.203 --- libtomoe-gtk/ChangeLog:1.202 Fri Dec 1 14:03:37 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 14:12:36 2006 @@ -1,5 +1,9 @@ 2006-12-01 Hiroyuki Ikezoe + * src/tomoe-window.[ch]: Add tomoe_window_get_selected_candidate(). + +2006-12-01 Hiroyuki Ikezoe + * src/tomoe-window.[ch]: Add "selected" signal. TomoeWindow is now a child of GtkWindow instead of GtkDialog. * test/testtomoegtk.c: Follow above change. From ikezoe users.sourceforge.jp Fri Dec 1 14:12:37 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:12:37 +0900 Subject: [Tomoe-cvs 1530] CVS update: libtomoe-gtk/src Message-ID: <20061201051237.04F872AC1BE@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.27 libtomoe-gtk/src/tomoe-window.c:1.28 --- libtomoe-gtk/src/tomoe-window.c:1.27 Fri Dec 1 14:03:37 2006 +++ libtomoe-gtk/src/tomoe-window.c Fri Dec 1 14:12:36 2006 @@ -270,6 +270,25 @@ window_signals[SELECTED_SIGNAL], 0); } +TomoeChar * +tomoe_window_get_selected_candidate (TomoeWindow *window) +{ + TomoeWindowPrivate *priv; + gint page_num; + GtkWidget *current_page; + + g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); + priv = TOMOE_WINDOW_GET_PRIVATE (window); + + page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook)); + current_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num); + +#warning FIX ME! + if (TOMOE_IS_STROKE_SEARCH (current_page)) + return tomoe_stroke_search_get_selected_candidate (TOMOE_STROKE_SEARCH (priv->handwriting)); + return NULL; +} + /* * vi:ts=4:nowrap:ai:expandtab */ Index: libtomoe-gtk/src/tomoe-window.h diff -u libtomoe-gtk/src/tomoe-window.h:1.11 libtomoe-gtk/src/tomoe-window.h:1.12 --- libtomoe-gtk/src/tomoe-window.h:1.11 Fri Dec 1 14:03:37 2006 +++ libtomoe-gtk/src/tomoe-window.h Fri Dec 1 14:12:36 2006 @@ -57,7 +57,8 @@ GtkWidget *label, const gchar *label_text); GtkWidget *tomoe_window_get_handwriting_page (TomoeWindow *window); - +TomoeChar *tomoe_window_get_selected_candidate + (TomoeWindow *window); G_END_DECLS #endif /* __TOMOE_WINDOW_H__ */ From kous users.sourceforge.jp Fri Dec 1 14:27:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 14:27:16 +0900 Subject: [Tomoe-cvs 1531] CVS update: tomoe Message-ID: <20061201052716.0ED5C2AC02E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.365 tomoe/ChangeLog:1.366 --- tomoe/ChangeLog:1.365 Fri Dec 1 13:47:25 2006 +++ tomoe/ChangeLog Fri Dec 1 14:27:15 2006 @@ -1,5 +1,11 @@ 2006-12-01 Kouhei Sutou + * module/dict/tomoe-dict-est.c: editable can be set when + constructing. + * ext/ruby/tomoe-rb-dict.c: supported name. + * benchmark/search-by-dict.rb: added est support. Hyper Estraier's + attribute search is too slow... + * lib/tomoe-query.c: supported properties. * lib/tomoe-query.[ch]: added tomoe_query_(set|get)_utf8(). From kous users.sourceforge.jp Fri Dec 1 14:27:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 14:27:16 +0900 Subject: [Tomoe-cvs 1532] CVS update: tomoe/benchmark Message-ID: <20061201052716.312792AC131@users.sourceforge.jp> Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.1 tomoe/benchmark/search-by-dict.rb:1.2 --- tomoe/benchmark/search-by-dict.rb:1.1 Fri Dec 1 13:47:26 2006 +++ tomoe/benchmark/search-by-dict.rb Fri Dec 1 14:27:16 2006 @@ -10,11 +10,19 @@ require "tomoe-spec-utils" n = 10 +use_est = false Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| - dict = Tomoe::Dict.new("xml", - "filename" => dictionary, - "editable" => false) + if use_est + dict = Tomoe::Dict.new("est", + "name" => File.basename(dictionary), + "database_name" => dictionary.sub(/\.xml$/, ''), + "editable" => false) + else + dict = Tomoe::Dict.new("xml", + "filename" => dictionary, + "editable" => false) + end x.report("#{File.basename(dictionary)}: all") do query = Tomoe::Query.new From kous users.sourceforge.jp Fri Dec 1 14:27:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 14:27:16 +0900 Subject: [Tomoe-cvs 1533] CVS update: tomoe/ext/ruby Message-ID: <20061201052716.8AB3F2AC02E@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.11 tomoe/ext/ruby/tomoe-rb-dict.c:1.12 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.11 Thu Nov 30 16:46:02 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Fri Dec 1 14:27:16 2006 @@ -32,10 +32,16 @@ "editable", RVAL2CBOOL(editable), NULL); } else if (strcmp(name, "est") == 0) { - VALUE database_name, editable; + VALUE rb_dict_name, database_name, editable; + gchar *dict_name; + + rb_dict_name = rb_hash_aref(props, CSTR2RVAL("name")); + dict_name = NIL_P(rb_dict_name) ? NULL : RVAL2CSTR(rb_dict_name); database_name = rb_hash_aref(props, CSTR2RVAL("database_name")); editable = rb_hash_aref(props, CSTR2RVAL("editable")); + dict = tomoe_dict_new(name, + "name", dict_name, "database_name", RVAL2CSTR(database_name), "editable", RVAL2CBOOL(editable), NULL); From kous users.sourceforge.jp Fri Dec 1 14:27:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 14:27:16 +0900 Subject: [Tomoe-cvs 1534] CVS update: tomoe/module/dict Message-ID: <20061201052716.B47942AC131@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.4 tomoe/module/dict/tomoe-dict-est.c:1.5 --- tomoe/module/dict/tomoe-dict-est.c:1.4 Fri Dec 1 10:57:23 2006 +++ tomoe/module/dict/tomoe-dict-est.c Fri Dec 1 14:27:16 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.4 2006/12/01 01:57:23 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.5 2006/12/01 05:27:16 kous Exp $ */ #include @@ -150,8 +150,8 @@ "editable", "Editable", "Editable flag", - TRUE, - G_PARAM_READWRITE)); + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void @@ -160,6 +160,7 @@ dict->name = NULL; dict->database_name = NULL; dict->db = NULL; + dict->editable = FALSE; dict->cache = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); } From ikezoe users.sourceforge.jp Fri Dec 1 14:39:00 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:39:00 +0900 Subject: [Tomoe-cvs 1535] CVS update: libtomoe-gtk/src Message-ID: <20061201053900.3FA412AC127@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-stroke-search.c diff -u libtomoe-gtk/src/tomoe-stroke-search.c:1.18 libtomoe-gtk/src/tomoe-stroke-search.c:1.19 --- libtomoe-gtk/src/tomoe-stroke-search.c:1.18 Fri Dec 1 13:52:16 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.c Fri Dec 1 14:39:00 2006 @@ -50,7 +50,7 @@ G_DEFINE_TYPE (TomoeStrokeSearch, tomoe_stroke_search, GTK_TYPE_TABLE) static void dispose (GObject *object); -static void tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *strokeSearch); +static void tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *stroke_search); /* callbacks for child widgets */ static void on_canvas_stroke_added (TomoeCanvas *canvas, @@ -94,18 +94,18 @@ } static void -tomoe_stroke_search_init (TomoeStrokeSearch *strokeSearch) +tomoe_stroke_search_init (TomoeStrokeSearch *stroke_search) { GtkWidget *main_vbox, *hbox, *vbox, *frame, *alignment; GtkWidget *canvas, *button, *table; - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - gtk_table_resize (GTK_TABLE (strokeSearch), 1, 1); - gtk_table_set_homogeneous (GTK_TABLE (strokeSearch), TRUE); + gtk_table_resize (GTK_TABLE (stroke_search), 1, 1); + gtk_table_set_homogeneous (GTK_TABLE (stroke_search), TRUE); main_vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 8); - gtk_table_attach_defaults (GTK_TABLE (strokeSearch), main_vbox, + gtk_table_attach_defaults (GTK_TABLE (stroke_search), main_vbox, 0, 1, 0, 1); gtk_widget_show (main_vbox); @@ -125,7 +125,7 @@ gtk_container_add (GTK_CONTAINER (frame), canvas); g_signal_connect (G_OBJECT (canvas), "stroke-added", G_CALLBACK (on_canvas_stroke_added), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_widget_show (canvas); /* button area */ @@ -144,7 +144,7 @@ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_find_button_clicked), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_UNDO); @@ -152,7 +152,7 @@ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_go_back_button_clicked), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); @@ -160,7 +160,7 @@ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_clear_button_clicked), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_FIT); @@ -168,14 +168,14 @@ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_normalize_button_clicked), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_widget_show (button); #ifdef ENABLE_DUMPSTROKE button = gtk_button_new_from_stock (GTK_STOCK_SAVE); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_dump_button_clicked), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_widget_show (button); #endif @@ -190,11 +190,11 @@ TOMOE_CANVAS (canvas)); g_signal_connect (G_OBJECT (table), "selected", G_CALLBACK (on_candidate_selected), - (gpointer) strokeSearch); + (gpointer) stroke_search); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); - tomoe_stroke_search_set_sensitive (strokeSearch); + tomoe_stroke_search_set_sensitive (stroke_search); } static void @@ -205,9 +205,9 @@ } static void -tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *strokeSearch) +tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *stroke_search) { - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); gboolean editable = tomoe_canvas_has_stroke (TOMOE_CANVAS (priv->canvas)); gtk_widget_set_sensitive (priv->find_button, editable); @@ -224,28 +224,28 @@ } GtkWidget * -tomoe_stroke_search_get_canvas (TomoeStrokeSearch *strokeSearch) +tomoe_stroke_search_get_canvas (TomoeStrokeSearch *stroke_search) { - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch), NULL); + g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), NULL); - return TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch)->canvas; + return TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search)->canvas; } static void on_canvas_stroke_added (TomoeCanvas *canvas, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - tomoe_stroke_search_set_sensitive (strokeSearch); + tomoe_stroke_search_set_sensitive (stroke_search); } static void on_find_button_clicked (GtkButton *button, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch)); + g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); @@ -254,41 +254,41 @@ static void on_go_back_button_clicked (GtkButton *button, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch)); + g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); tomoe_canvas_revert (TOMOE_CANVAS (priv->canvas)); tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); - tomoe_stroke_search_set_sensitive (strokeSearch); + tomoe_stroke_search_set_sensitive (stroke_search); } static void on_clear_button_clicked (GtkButton *button, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch)); + g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); tomoe_canvas_clear (TOMOE_CANVAS (priv->canvas)); - tomoe_stroke_search_set_sensitive (strokeSearch); + tomoe_stroke_search_set_sensitive (stroke_search); } static void on_normalize_button_clicked (GtkButton *button, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch)); + g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); tomoe_canvas_normalize (TOMOE_CANVAS (priv->canvas)); - tomoe_stroke_search_set_sensitive (strokeSearch); + tomoe_stroke_search_set_sensitive (stroke_search); } static void @@ -330,8 +330,8 @@ static void on_dump_button_clicked (GtkButton *button, gpointer user_data) { - TomoeStrokeSearch *strokeSearch = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (strokeSearch); + TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); + TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); TomoeWriting *writing; GtkWidget *dialog; GList *strokes, *list; @@ -339,7 +339,7 @@ GString *dump_string; gchar *filename; - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (strokeSearch)); + g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); dialog = gtk_file_chooser_dialog_new (_("Select the file name for dump"), From ikezoe users.sourceforge.jp Fri Dec 1 14:40:48 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:40:48 +0900 Subject: [Tomoe-cvs 1536] CVS update: libtomoe-gtk/src Message-ID: <20061201054048.191B52AC127@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-stroke-search.c diff -u libtomoe-gtk/src/tomoe-stroke-search.c:1.19 libtomoe-gtk/src/tomoe-stroke-search.c:1.20 --- libtomoe-gtk/src/tomoe-stroke-search.c:1.19 Fri Dec 1 14:39:00 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.c Fri Dec 1 14:40:47 2006 @@ -49,7 +49,6 @@ G_DEFINE_TYPE (TomoeStrokeSearch, tomoe_stroke_search, GTK_TYPE_TABLE) -static void dispose (GObject *object); static void tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *stroke_search); /* callbacks for child widgets */ @@ -86,8 +85,6 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gobject_class->dispose = dispose; - klass->selected = NULL; g_type_class_add_private (gobject_class, sizeof (TomoeStrokeSearchPrivate)); @@ -198,13 +195,6 @@ } static void -dispose (GObject *object) -{ - if (G_OBJECT_CLASS(tomoe_stroke_search_parent_class)->dispose) - G_OBJECT_CLASS(tomoe_stroke_search_parent_class)->dispose(object); -} - -static void tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *stroke_search) { TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); From makeinu users.sourceforge.jp Fri Dec 1 14:43:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 14:43:00 +0900 Subject: [Tomoe-cvs 1537] CVS update: libtomoe-gtk Message-ID: <20061201054300.3CE2E2AC016@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.203 libtomoe-gtk/ChangeLog:1.204 --- libtomoe-gtk/ChangeLog:1.203 Fri Dec 1 14:12:36 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 14:43:00 2006 @@ -1,3 +1,7 @@ +2006-12-01 Takuro Ashie + + * src/tomoe-gucharmap.c: Also create GucharmapScriptChapters on init. + 2006-12-01 Hiroyuki Ikezoe * src/tomoe-window.[ch]: Add tomoe_window_get_selected_candidate(). From makeinu users.sourceforge.jp Fri Dec 1 14:43:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 14:43:00 +0900 Subject: [Tomoe-cvs 1538] CVS update: libtomoe-gtk/src Message-ID: <20061201054300.684162AC127@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.9 libtomoe-gtk/src/tomoe-gucharmap.c:1.10 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.9 Fri Dec 1 13:49:36 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 14:43:00 2006 @@ -25,6 +25,8 @@ { GtkWidget *chapters_combo; GucharmapChapters *chapters; + GucharmapChapters *chapters_block; + GucharmapChapters *chapters_script; GucharmapCharmap *charmap; }; @@ -82,7 +84,9 @@ gtk_widget_show (combo); /* gucharmap */ - priv->chapters = GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()); + priv->chapters_block = GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()); + priv->chapters_script = GUCHARMAP_CHAPTERS (gucharmap_script_chapters_new ()); + priv->chapters = priv->chapters_block; priv->charmap = GUCHARMAP_CHARMAP (gucharmap_charmap_new (priv->chapters)); widget = GTK_WIDGET (priv->charmap); gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 2); From ikezoe users.sourceforge.jp Fri Dec 1 14:48:06 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:48:06 +0900 Subject: [Tomoe-cvs 1539] CVS update: libtomoe-gtk Message-ID: <20061201054806.DF83C2AC133@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.204 libtomoe-gtk/ChangeLog:1.205 --- libtomoe-gtk/ChangeLog:1.204 Fri Dec 1 14:43:00 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 14:48:06 2006 @@ -1,3 +1,11 @@ +2006-12-01 Hiroyuki Ikezoe + + * src/tomoe-stroke-search.[ch]: Removed. + * src/tomoe-handwriting.[ch]: Renamed from tomoe-stroke-search.[ch]. + tomoe-window.[ch]: Add tomoe_window_get_selected_candidate(). + * src/Makefile.am, src/tomow-gtk.h, src/tomow-window.c: Follow above + changes. + 2006-12-01 Takuro Ashie * src/tomoe-gucharmap.c: Also create GucharmapScriptChapters on init. From ikezoe users.sourceforge.jp Fri Dec 1 14:48:07 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 14:48:07 +0900 Subject: [Tomoe-cvs 1540] CVS update: libtomoe-gtk/src Message-ID: <20061201054807.204BE2AC14D@users.sourceforge.jp> Index: libtomoe-gtk/src/Makefile.am diff -u libtomoe-gtk/src/Makefile.am:1.19 libtomoe-gtk/src/Makefile.am:1.20 --- libtomoe-gtk/src/Makefile.am:1.19 Thu Nov 30 15:42:50 2006 +++ libtomoe-gtk/src/Makefile.am Fri Dec 1 14:48:06 2006 @@ -15,9 +15,9 @@ tomoe-edit-meta.c tomoe-edit-meta.h \ tomoe-edit-strokes.c tomoe-edit-strokes.h \ tomoe-gucharmap.c tomoe-gucharmap.h \ + tomoe-handwriting.c tomoe-handwriting.h \ tomoe-reading-search.c tomoe-reading-search.h \ tomoe-scrollable.c tomoe-scrollable.h \ - tomoe-stroke-search.c tomoe-stroke-search.h \ tomoe-window.c tomoe-window.h libtomoe_gtk_la_LDFLAGS = \ @@ -34,7 +34,7 @@ tomoe-edit-strokes.h \ tomoe-gtk.h \ tomoe-gucharmap.h \ + tomoe-handwriting.h \ tomoe-reading-search.h \ tomoe-scrollable.h \ - tomoe-stroke-search.h \ tomoe-window.h Index: libtomoe-gtk/src/tomoe-gtk.h diff -u libtomoe-gtk/src/tomoe-gtk.h:1.6 libtomoe-gtk/src/tomoe-gtk.h:1.7 --- libtomoe-gtk/src/tomoe-gtk.h:1.6 Thu Nov 16 14:23:23 2006 +++ libtomoe-gtk/src/tomoe-gtk.h Fri Dec 1 14:48:06 2006 @@ -24,6 +24,6 @@ #include #include #include -#include +#include #endif /* __TOMOE_GTK_H_INCLUDED__ */ Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u /dev/null libtomoe-gtk/src/tomoe-handwriting.c:1.1 --- /dev/null Fri Dec 1 14:48:07 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Fri Dec 1 14:48:06 2006 @@ -0,0 +1,387 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2005 Takuro Ashie + * Copyright (C) 2006 Juernjakob Harder + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#include "tomoe-handwriting.h" +#include "tomoe-canvas.h" +#include "tomoe-char-table.h" + +enum { + SELECTED_SIGNAL, + LAST_SIGNAL +}; + +typedef struct _TomoeHandwritingPrivate TomoeHandwritingPrivate; +struct _TomoeHandwritingPrivate +{ + GtkWidget *canvas; + GtkWidget *button_area; + GtkWidget *find_button; + GtkWidget *go_back_button; + GtkWidget *clear_button; + GtkWidget *normalize_button; + GtkWidget *candidates_view; +}; + +#define TOMOE_HANDWRITING_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_HANDWRITING, TomoeHandwritingPrivate)) + +G_DEFINE_TYPE (TomoeHandwriting, tomoe_handwriting, GTK_TYPE_TABLE) + +static void tomoe_handwriting_set_sensitive (TomoeHandwriting *handwriting); + +/* callbacks for child widgets */ +static void on_canvas_stroke_added (TomoeCanvas *canvas, + gpointer user_data); +static void on_find_button_clicked (GtkButton *button, + gpointer user_data); +static void on_go_back_button_clicked (GtkButton *button, + gpointer user_data); +static void on_clear_button_clicked (GtkButton *button, + gpointer user_data); +static void on_normalize_button_clicked (GtkButton *button, + gpointer user_data); +#ifdef ENABLE_DUMPSTROKE +static void on_dump_button_clicked (GtkButton *button, + gpointer user_data); +#endif +static void on_candidate_selected (TomoeCharTable *table, + gpointer user_data); + +static guint handwriting_signals[LAST_SIGNAL] = { 0 }; + +static void +tomoe_handwriting_class_init (TomoeHandwritingClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + handwriting_signals[SELECTED_SIGNAL] = + g_signal_new ("selected", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (TomoeHandwritingClass, selected), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + klass->selected = NULL; + + g_type_class_add_private (gobject_class, sizeof (TomoeHandwritingPrivate)); +} + +static void +tomoe_handwriting_init (TomoeHandwriting *handwriting) +{ + GtkWidget *main_vbox, *hbox, *vbox, *frame, *alignment; + GtkWidget *canvas, *button, *table; + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + gtk_table_resize (GTK_TABLE (handwriting), 1, 1); + gtk_table_set_homogeneous (GTK_TABLE (handwriting), TRUE); + + main_vbox = gtk_vbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 8); + gtk_table_attach_defaults (GTK_TABLE (handwriting), main_vbox, + 0, 1, 0, 1); + gtk_widget_show (main_vbox); + + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (main_vbox), hbox, + TRUE, TRUE, 0); + gtk_widget_show (hbox); + + /* canvas */ + frame = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); + gtk_widget_show (frame); + + canvas = tomoe_canvas_new (); + priv->canvas = canvas; + gtk_widget_set_size_request (canvas, 300, 300); + gtk_container_add (GTK_CONTAINER (frame), canvas); + g_signal_connect (G_OBJECT (canvas), "stroke-added", + G_CALLBACK (on_canvas_stroke_added), + (gpointer) handwriting); + gtk_widget_show (canvas); + + /* button area */ + alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 8, 0); + gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0); + gtk_widget_show (alignment); + + vbox = gtk_vbox_new (FALSE, 0); + priv->button_area = vbox; + gtk_container_add (GTK_CONTAINER (alignment), vbox); + gtk_widget_show (vbox); + + button = gtk_button_new_from_stock (GTK_STOCK_FIND); + priv->find_button = button; + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (on_find_button_clicked), + (gpointer) handwriting); + gtk_widget_show (button); + + button = gtk_button_new_from_stock (GTK_STOCK_UNDO); + priv->go_back_button = button; + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (on_go_back_button_clicked), + (gpointer) handwriting); + gtk_widget_show (button); + + button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); + priv->clear_button = button; + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (on_clear_button_clicked), + (gpointer) handwriting); + gtk_widget_show (button); + + button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_FIT); + priv->normalize_button = button; + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (on_normalize_button_clicked), + (gpointer) handwriting); + gtk_widget_show (button); +#ifdef ENABLE_DUMPSTROKE + button = gtk_button_new_from_stock (GTK_STOCK_SAVE); + gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (on_dump_button_clicked), + (gpointer) handwriting); + gtk_widget_show (button); +#endif + + /* candidates view */ + frame = gtk_frame_new (NULL); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 4); + gtk_widget_show (frame); + + table = tomoe_char_table_new (); + priv->candidates_view = table; + tomoe_char_table_set_canvas (TOMOE_CHAR_TABLE (table), + TOMOE_CANVAS (canvas)); + g_signal_connect (G_OBJECT (table), "selected", + G_CALLBACK (on_candidate_selected), + (gpointer) handwriting); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + tomoe_handwriting_set_sensitive (handwriting); +} + +static void +tomoe_handwriting_set_sensitive (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + gboolean editable = tomoe_canvas_has_stroke (TOMOE_CANVAS (priv->canvas)); + + gtk_widget_set_sensitive (priv->find_button, editable); + gtk_widget_set_sensitive (priv->go_back_button, editable); + gtk_widget_set_sensitive (priv->clear_button, editable); + gtk_widget_set_sensitive (priv->normalize_button, editable); +} + +GtkWidget * +tomoe_handwriting_new (void) +{ + return GTK_WIDGET(g_object_new (TOMOE_TYPE_HANDWRITING, + NULL)); +} + +GtkWidget * +tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting) +{ + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + + return TOMOE_HANDWRITING_GET_PRIVATE (handwriting)->canvas; +} + +static void +on_canvas_stroke_added (TomoeCanvas *canvas, gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + + tomoe_handwriting_set_sensitive (handwriting); +} + +static void +on_find_button_clicked (GtkButton *button, gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); + g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); + + tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); +} + +static void +on_go_back_button_clicked (GtkButton *button, gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); + g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); + + tomoe_canvas_revert (TOMOE_CANVAS (priv->canvas)); + tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); + tomoe_handwriting_set_sensitive (handwriting); +} + +static void +on_clear_button_clicked (GtkButton *button, gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); + g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); + + tomoe_canvas_clear (TOMOE_CANVAS (priv->canvas)); + tomoe_handwriting_set_sensitive (handwriting); +} + +static void +on_normalize_button_clicked (GtkButton *button, gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); + g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); + + tomoe_canvas_normalize (TOMOE_CANVAS (priv->canvas)); + tomoe_handwriting_set_sensitive (handwriting); +} + +static void +on_candidate_selected (TomoeCharTable *table, + gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + + g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); + + g_signal_emit (G_OBJECT (handwriting), + handwriting_signals[SELECTED_SIGNAL], 0); + tomoe_handwriting_set_sensitive (handwriting); +} + +GtkWidget * +tomoe_handwriting_get_button_area (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + return priv->button_area; +} + +TomoeChar * +tomoe_handwriting_get_selected_candidate (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + return tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); +} + +#ifdef ENABLE_DUMPSTROKE +static void +on_dump_button_clicked (GtkButton *button, gpointer user_data) +{ + TomoeHandwriting *handwriting = TOMOE_HANDWRITING (user_data); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + TomoeWriting *writing; + GtkWidget *dialog; + GList *strokes, *list; + GList *candidates; + GString *dump_string; + gchar *filename; + + g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); + g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); + + dialog = gtk_file_chooser_dialog_new (_("Select the file name for dump"), + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT) { + gtk_widget_destroy (dialog); + return; + } + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + gtk_widget_destroy (dialog); + + dump_string = g_string_new (NULL); + writing = tomoe_canvas_get_writing (TOMOE_CANVAS (priv->canvas)); + + /* set candidate data */ + candidates = (GList *) tomoe_canvas_get_candidates (TOMOE_CANVAS (priv->canvas)); + for (list = candidates; list; list = g_list_next (list)) { + TomoeCandidate *cand = TOMOE_CANDIDATE (list->data); + TomoeChar *c = tomoe_candidate_get_char (cand); + if (list != candidates) + g_string_append_c (dump_string, ' '); + g_string_append (dump_string, tomoe_char_get_utf8 (c)); + } + g_string_append_c (dump_string, '\n'); + + /* set stroke data */ + strokes = (GList *) tomoe_writing_get_strokes (writing); + for (list = strokes; list; list = g_list_next (list)) { + GList *points = (GList *) list->data; + GList *point; + + for (point = points; point; point = g_list_next (point)) { + TomoePoint *p = (TomoePoint *) point->data; + if (point != points) + g_string_append (dump_string, ", "); + g_string_append_printf (dump_string, "%d %d", p->x, p->y); + } + g_string_append_c (dump_string, '\n'); + } + + g_file_set_contents (filename, dump_string->str, dump_string->len, NULL); + + g_object_unref (writing); + g_string_free (dump_string, TRUE); + g_free (filename); +} +#endif + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u /dev/null libtomoe-gtk/src/tomoe-handwriting.h:1.1 --- /dev/null Fri Dec 1 14:48:07 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Fri Dec 1 14:48:06 2006 @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2005 Takuro Ashie + * Copyright (C) 2006 Juernjakob Harder + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TOMOE_HANDWRITING_H__ +#define __TOMOE_HANDWRITING_H__ + +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define TOMOE_TYPE_HANDWRITING (tomoe_handwriting_get_type ()) +#define TOMOE_HANDWRITING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_HANDWRITING, TomoeHandwriting)) +#define TOMOE_HANDWRITING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_HANDWRITING, TomoeHandwritingClass)) +#define TOMOE_IS_HANDWRITING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_HANDWRITING)) +#define TOMOE_IS_HANDWRITING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_HANDWRITING)) +#define TOMOE_HANDWRITING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOMOE_TYPE_HANDWRITING, TomoeHandwritingClass)) + + +typedef struct _TomoeHandwritingClass TomoeHandwritingClass; +typedef struct _TomoeHandwriting TomoeHandwriting; + +struct _TomoeHandwriting +{ + GtkTable parent_instance; +}; + +struct _TomoeHandwritingClass +{ + GtkTableClass parent_class; + /* -- signals -- */ + void (*selected) (TomoeHandwriting *search); +}; + + +GType tomoe_handwriting_get_type (void) G_GNUC_CONST; +GtkWidget *tomoe_handwriting_new (void); +GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); +TomoeChar *tomoe_handwriting_get_selected_candidate + (TomoeHandwriting *handwriting); +GtkWidget *tomoe_handwriting_get_button_area + (TomoeHandwriting *handwriting); + +G_END_DECLS + +#endif /* __TOMOE_HANDWRITING_H__ */ Index: libtomoe-gtk/src/tomoe-stroke-search.c diff -u libtomoe-gtk/src/tomoe-stroke-search.c:1.20 libtomoe-gtk/src/tomoe-stroke-search.c:removed --- libtomoe-gtk/src/tomoe-stroke-search.c:1.20 Fri Dec 1 14:40:47 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.c Fri Dec 1 14:48:07 2006 @@ -1,387 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2005 Takuro Ashie - * Copyright (C) 2006 Juernjakob Harder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -#include - -#include "tomoe-stroke-search.h" -#include "tomoe-canvas.h" -#include "tomoe-char-table.h" - -enum { - SELECTED_SIGNAL, - LAST_SIGNAL -}; - -typedef struct _TomoeStrokeSearchPrivate TomoeStrokeSearchPrivate; -struct _TomoeStrokeSearchPrivate -{ - GtkWidget *canvas; - GtkWidget *button_area; - GtkWidget *find_button; - GtkWidget *go_back_button; - GtkWidget *clear_button; - GtkWidget *normalize_button; - GtkWidget *candidates_view; -}; - -#define TOMOE_STROKE_SEARCH_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_STROKE_SEARCH, TomoeStrokeSearchPrivate)) - -G_DEFINE_TYPE (TomoeStrokeSearch, tomoe_stroke_search, GTK_TYPE_TABLE) - -static void tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *stroke_search); - -/* callbacks for child widgets */ -static void on_canvas_stroke_added (TomoeCanvas *canvas, - gpointer user_data); -static void on_find_button_clicked (GtkButton *button, - gpointer user_data); -static void on_go_back_button_clicked (GtkButton *button, - gpointer user_data); -static void on_clear_button_clicked (GtkButton *button, - gpointer user_data); -static void on_normalize_button_clicked (GtkButton *button, - gpointer user_data); -#ifdef ENABLE_DUMPSTROKE -static void on_dump_button_clicked (GtkButton *button, - gpointer user_data); -#endif -static void on_candidate_selected (TomoeCharTable *table, - gpointer user_data); - -static guint stroke_search_signals[LAST_SIGNAL] = { 0 }; - -static void -tomoe_stroke_search_class_init (TomoeStrokeSearchClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - stroke_search_signals[SELECTED_SIGNAL] = - g_signal_new ("selected", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (TomoeStrokeSearchClass, selected), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - klass->selected = NULL; - - g_type_class_add_private (gobject_class, sizeof (TomoeStrokeSearchPrivate)); -} - -static void -tomoe_stroke_search_init (TomoeStrokeSearch *stroke_search) -{ - GtkWidget *main_vbox, *hbox, *vbox, *frame, *alignment; - GtkWidget *canvas, *button, *table; - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - gtk_table_resize (GTK_TABLE (stroke_search), 1, 1); - gtk_table_set_homogeneous (GTK_TABLE (stroke_search), TRUE); - - main_vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 8); - gtk_table_attach_defaults (GTK_TABLE (stroke_search), main_vbox, - 0, 1, 0, 1); - gtk_widget_show (main_vbox); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (main_vbox), hbox, - TRUE, TRUE, 0); - gtk_widget_show (hbox); - - /* canvas */ - frame = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - gtk_widget_show (frame); - - canvas = tomoe_canvas_new (); - priv->canvas = canvas; - gtk_widget_set_size_request (canvas, 300, 300); - gtk_container_add (GTK_CONTAINER (frame), canvas); - g_signal_connect (G_OBJECT (canvas), "stroke-added", - G_CALLBACK (on_canvas_stroke_added), - (gpointer) stroke_search); - gtk_widget_show (canvas); - - /* button area */ - alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 8, 0); - gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0); - gtk_widget_show (alignment); - - vbox = gtk_vbox_new (FALSE, 0); - priv->button_area = vbox; - gtk_container_add (GTK_CONTAINER (alignment), vbox); - gtk_widget_show (vbox); - - button = gtk_button_new_from_stock (GTK_STOCK_FIND); - priv->find_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_find_button_clicked), - (gpointer) stroke_search); - gtk_widget_show (button); - - button = gtk_button_new_from_stock (GTK_STOCK_UNDO); - priv->go_back_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_go_back_button_clicked), - (gpointer) stroke_search); - gtk_widget_show (button); - - button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); - priv->clear_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_clear_button_clicked), - (gpointer) stroke_search); - gtk_widget_show (button); - - button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_FIT); - priv->normalize_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_normalize_button_clicked), - (gpointer) stroke_search); - gtk_widget_show (button); -#ifdef ENABLE_DUMPSTROKE - button = gtk_button_new_from_stock (GTK_STOCK_SAVE); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_dump_button_clicked), - (gpointer) stroke_search); - gtk_widget_show (button); -#endif - - /* candidates view */ - frame = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 4); - gtk_widget_show (frame); - - table = tomoe_char_table_new (); - priv->candidates_view = table; - tomoe_char_table_set_canvas (TOMOE_CHAR_TABLE (table), - TOMOE_CANVAS (canvas)); - g_signal_connect (G_OBJECT (table), "selected", - G_CALLBACK (on_candidate_selected), - (gpointer) stroke_search); - gtk_container_add (GTK_CONTAINER (frame), table); - gtk_widget_show (table); - - tomoe_stroke_search_set_sensitive (stroke_search); -} - -static void -tomoe_stroke_search_set_sensitive (TomoeStrokeSearch *stroke_search) -{ - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - gboolean editable = tomoe_canvas_has_stroke (TOMOE_CANVAS (priv->canvas)); - - gtk_widget_set_sensitive (priv->find_button, editable); - gtk_widget_set_sensitive (priv->go_back_button, editable); - gtk_widget_set_sensitive (priv->clear_button, editable); - gtk_widget_set_sensitive (priv->normalize_button, editable); -} - -GtkWidget * -tomoe_stroke_search_new (void) -{ - return GTK_WIDGET(g_object_new (TOMOE_TYPE_STROKE_SEARCH, - NULL)); -} - -GtkWidget * -tomoe_stroke_search_get_canvas (TomoeStrokeSearch *stroke_search) -{ - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), NULL); - - return TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search)->canvas; -} - -static void -on_canvas_stroke_added (TomoeCanvas *canvas, gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - - tomoe_stroke_search_set_sensitive (stroke_search); -} - -static void -on_find_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); - g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - - tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); -} - -static void -on_go_back_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); - g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - - tomoe_canvas_revert (TOMOE_CANVAS (priv->canvas)); - tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); - tomoe_stroke_search_set_sensitive (stroke_search); -} - -static void -on_clear_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); - g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - - tomoe_canvas_clear (TOMOE_CANVAS (priv->canvas)); - tomoe_stroke_search_set_sensitive (stroke_search); -} - -static void -on_normalize_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); - g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - - tomoe_canvas_normalize (TOMOE_CANVAS (priv->canvas)); - tomoe_stroke_search_set_sensitive (stroke_search); -} - -static void -on_candidate_selected (TomoeCharTable *table, - gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); - - g_signal_emit (G_OBJECT (stroke_search), - stroke_search_signals[SELECTED_SIGNAL], 0); - tomoe_stroke_search_set_sensitive (stroke_search); -} - -GtkWidget * -tomoe_stroke_search_get_button_area (TomoeStrokeSearch *stroke_search) -{ - TomoeStrokeSearchPrivate *priv; - - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), NULL); - priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - return priv->button_area; -} - -TomoeChar * -tomoe_stroke_search_get_selected_candidate (TomoeStrokeSearch *stroke_search) -{ - TomoeStrokeSearchPrivate *priv; - - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search), NULL); - priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - - return tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); -} - -#ifdef ENABLE_DUMPSTROKE -static void -on_dump_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeStrokeSearch *stroke_search = TOMOE_STROKE_SEARCH (user_data); - TomoeStrokeSearchPrivate *priv = TOMOE_STROKE_SEARCH_GET_PRIVATE (stroke_search); - TomoeWriting *writing; - GtkWidget *dialog; - GList *strokes, *list; - GList *candidates; - GString *dump_string; - gchar *filename; - - g_return_if_fail (TOMOE_IS_STROKE_SEARCH (stroke_search)); - g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - - dialog = gtk_file_chooser_dialog_new (_("Select the file name for dump"), - NULL, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy (dialog); - return; - } - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - gtk_widget_destroy (dialog); - - dump_string = g_string_new (NULL); - writing = tomoe_canvas_get_writing (TOMOE_CANVAS (priv->canvas)); - - /* set candidate data */ - candidates = (GList *) tomoe_canvas_get_candidates (TOMOE_CANVAS (priv->canvas)); - for (list = candidates; list; list = g_list_next (list)) { - TomoeCandidate *cand = TOMOE_CANDIDATE (list->data); - TomoeChar *c = tomoe_candidate_get_char (cand); - if (list != candidates) - g_string_append_c (dump_string, ' '); - g_string_append (dump_string, tomoe_char_get_utf8 (c)); - } - g_string_append_c (dump_string, '\n'); - - /* set stroke data */ - strokes = (GList *) tomoe_writing_get_strokes (writing); - for (list = strokes; list; list = g_list_next (list)) { - GList *points = (GList *) list->data; - GList *point; - - for (point = points; point; point = g_list_next (point)) { - TomoePoint *p = (TomoePoint *) point->data; - if (point != points) - g_string_append (dump_string, ", "); - g_string_append_printf (dump_string, "%d %d", p->x, p->y); - } - g_string_append_c (dump_string, '\n'); - } - - g_file_set_contents (filename, dump_string->str, dump_string->len, NULL); - - g_object_unref (writing); - g_string_free (dump_string, TRUE); - g_free (filename); -} -#endif - -/* - * vi:ts=4:nowrap:ai:expandtab - */ Index: libtomoe-gtk/src/tomoe-stroke-search.h diff -u libtomoe-gtk/src/tomoe-stroke-search.h:1.7 libtomoe-gtk/src/tomoe-stroke-search.h:removed --- libtomoe-gtk/src/tomoe-stroke-search.h:1.7 Fri Dec 1 13:38:37 2006 +++ libtomoe-gtk/src/tomoe-stroke-search.h Fri Dec 1 14:48:07 2006 @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2005 Takuro Ashie - * Copyright (C) 2006 Juernjakob Harder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __TOMOE_STROKE_SEARCH_H__ -#define __TOMOE_STROKE_SEARCH_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define TOMOE_TYPE_STROKE_SEARCH (tomoe_stroke_search_get_type ()) -#define TOMOE_STROKE_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_STROKE_SEARCH, TomoeStrokeSearch)) -#define TOMOE_STROKE_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_STROKE_SEARCH, TomoeStrokeSearchClass)) -#define TOMOE_IS_STROKE_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_STROKE_SEARCH)) -#define TOMOE_IS_STROKE_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_STROKE_SEARCH)) -#define TOMOE_STROKE_SEARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOMOE_TYPE_STROKE_SEARCH, TomoeStrokeSearchClass)) - - -typedef struct _TomoeStrokeSearchClass TomoeStrokeSearchClass; -typedef struct _TomoeStrokeSearch TomoeStrokeSearch; - -struct _TomoeStrokeSearch -{ - GtkTable parent_instance; -}; - -struct _TomoeStrokeSearchClass -{ - GtkTableClass parent_class; - /* -- signals -- */ - void (*selected) (TomoeStrokeSearch *search); -}; - - -GType tomoe_stroke_search_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_stroke_search_new (void); -GtkWidget *tomoe_stroke_search_get_canvas (TomoeStrokeSearch *stroke_search); -TomoeChar *tomoe_stroke_search_get_selected_candidate - (TomoeStrokeSearch *stroke_search); -GtkWidget *tomoe_stroke_search_get_button_area - (TomoeStrokeSearch *stroke_search); - -G_END_DECLS - -#endif /* __TOMOE_STROKE_SEARCH_H__ */ Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.28 libtomoe-gtk/src/tomoe-window.c:1.29 --- libtomoe-gtk/src/tomoe-window.c:1.28 Fri Dec 1 14:12:36 2006 +++ libtomoe-gtk/src/tomoe-window.c Fri Dec 1 14:48:06 2006 @@ -27,7 +27,7 @@ #include "tomoe-window.h" #include "tomoe-canvas.h" -#include "tomoe-stroke-search.h" +#include "tomoe-handwriting.h" #include "tomoe-char-table.h" #include "tomoe-reading-search.h" #include "tomoe-gucharmap.h" @@ -63,7 +63,7 @@ static void dispose (GObject *object); static void destroy (GtkObject *object); -static void on_handwriting_candidate_selected (TomoeStrokeSearch *view, +static void on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data); static guint window_signals[LAST_SIGNAL] = { 0 }; @@ -92,7 +92,7 @@ static void tomoe_window_init (TomoeWindow *window) { - TomoeStrokeSearch *handwriting_page; + TomoeHandwriting *handwriting_page; TomoeReadingSearch *reading_search; GtkWidget *widget, *notebook, *vbox; TomoeCanvas *canvas; @@ -135,10 +135,10 @@ gtk_widget_show (notebook); /* handwriting page */ - widget = tomoe_stroke_search_new (); + widget = tomoe_handwriting_new (); priv->handwriting = widget; - handwriting_page = TOMOE_STROKE_SEARCH (widget); - canvas = TOMOE_CANVAS (tomoe_stroke_search_get_canvas (handwriting_page)); + handwriting_page = TOMOE_HANDWRITING (widget); + canvas = TOMOE_CANVAS (tomoe_handwriting_get_canvas (handwriting_page)); tomoe_canvas_set_context (canvas, priv->context); g_signal_connect (G_OBJECT (widget), "selected", G_CALLBACK (on_handwriting_candidate_selected), @@ -202,15 +202,15 @@ tomoe_window_get_canvas (TomoeWindow *window) { TomoeWindowPrivate *priv; - TomoeStrokeSearch *handwriting_page; + TomoeHandwriting *handwriting_page; g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); priv = TOMOE_WINDOW_GET_PRIVATE (window); - g_return_val_if_fail (TOMOE_IS_STROKE_SEARCH (priv->handwriting), + g_return_val_if_fail (TOMOE_IS_HANDWRITING (priv->handwriting), NULL); - handwriting_page = TOMOE_STROKE_SEARCH (priv->handwriting); - return tomoe_stroke_search_get_canvas (handwriting_page); + handwriting_page = TOMOE_HANDWRITING (priv->handwriting); + return tomoe_handwriting_get_canvas (handwriting_page); } void @@ -260,7 +260,7 @@ } static void -on_handwriting_candidate_selected (TomoeStrokeSearch *view, gpointer user_data) +on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data) { TomoeWindow *window; g_return_if_fail (TOMOE_IS_WINDOW (user_data)); @@ -284,8 +284,8 @@ current_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num); #warning FIX ME! - if (TOMOE_IS_STROKE_SEARCH (current_page)) - return tomoe_stroke_search_get_selected_candidate (TOMOE_STROKE_SEARCH (priv->handwriting)); + if (TOMOE_IS_HANDWRITING (current_page)) + return tomoe_handwriting_get_selected_candidate (TOMOE_HANDWRITING (priv->handwriting)); return NULL; } From ikezoe users.sourceforge.jp Fri Dec 1 15:06:30 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 15:06:30 +0900 Subject: [Tomoe-cvs 1541] CVS update: libtomoe-gtk/doc/reference Message-ID: <20061201060630.33DF12AC04B@users.sourceforge.jp> Index: libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml diff -u libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml:1.1 libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml:1.2 --- libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml:1.1 Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/doc/reference/libtomoe-gtk-docs.sgml Fri Dec 1 15:06:30 2006 @@ -6,6 +6,8 @@ + + @@ -21,6 +23,8 @@ &libtomoe-gtk-Canvas; &libtomoe-gtk-CharTable; + &libtomoe-gtk-Handwriting; + &libtomoe-gtk-Scrollable; &libtomoe-gtk-Window; Index: libtomoe-gtk/doc/reference/libtomoe-gtk.types diff -u libtomoe-gtk/doc/reference/libtomoe-gtk.types:1.1 libtomoe-gtk/doc/reference/libtomoe-gtk.types:1.2 --- libtomoe-gtk/doc/reference/libtomoe-gtk.types:1.1 Fri Dec 1 12:19:34 2006 +++ libtomoe-gtk/doc/reference/libtomoe-gtk.types Fri Dec 1 15:06:30 2006 @@ -1,5 +1,8 @@ #include +#include tomoe_canvas_get_type tomoe_char_table_get_type +tomoe_handwriting_get_type +tomoe_scrollable_get_type tomoe_window_get_type From makeinu users.sourceforge.jp Fri Dec 1 15:14:34 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 15:14:34 +0900 Subject: [Tomoe-cvs 1542] CVS update: libtomoe-gtk Message-ID: <20061201061434.7E50C2AC0F1@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.205 libtomoe-gtk/ChangeLog:1.206 --- libtomoe-gtk/ChangeLog:1.205 Fri Dec 1 14:48:06 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 15:14:34 2006 @@ -1,3 +1,7 @@ +2006-12-01 Takuro Ashie + + * src/tomoe-gucharmap.c: Add chapters type combo box. + 2006-12-01 Hiroyuki Ikezoe * src/tomoe-stroke-search.[ch]: Removed. From makeinu users.sourceforge.jp Fri Dec 1 15:14:34 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 15:14:34 +0900 Subject: [Tomoe-cvs 1543] CVS update: libtomoe-gtk/src Message-ID: <20061201061434.A9FDF2AC127@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.10 libtomoe-gtk/src/tomoe-gucharmap.c:1.11 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.10 Fri Dec 1 14:43:00 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 15:14:34 2006 @@ -23,10 +23,9 @@ typedef struct _TomoeGucharmapPrivate TomoeGucharmapPrivate; struct _TomoeGucharmapPrivate { - GtkWidget *chapters_combo; + GtkWidget *chapters_type_combobox; + GtkWidget *chapters_combobox; GucharmapChapters *chapters; - GucharmapChapters *chapters_block; - GucharmapChapters *chapters_script; GucharmapCharmap *charmap; }; @@ -34,10 +33,12 @@ G_DEFINE_TYPE (TomoeGucharmap, tomoe_gucharmap, GTK_TYPE_TABLE) -static void dispose (GObject *object); -static void setup_chapters_option_menu (TomoeGucharmap *page); -static void on_chapters_combo_changed (GtkComboBox *option_menu, - gpointer data); +static void dispose (GObject *object); +static void setup_chapters_combo_box (TomoeGucharmap *page); +static void on_chapters_type_combo_changed (GtkComboBox *combobox, + gpointer data); +static void on_chapters_combo_changed (GtkComboBox *combobox, + gpointer data); GtkWidget * tomoe_gucharmap_new (void) @@ -59,7 +60,7 @@ tomoe_gucharmap_init (TomoeGucharmap *page) { TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); - GtkWidget *vbox, *hbox, *label, *combo, *widget; + GtkWidget *vbox, *hbox, *combobox, *widget; gtk_table_resize (GTK_TABLE (page), 1, 1); gtk_table_set_homogeneous (GTK_TABLE (page), FALSE); @@ -74,19 +75,27 @@ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2); gtk_widget_show (hbox); +#if 0 label = gtk_label_new (_("Unicode block:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); - - combo = gtk_combo_box_new_text (); - priv->chapters_combo = combo; - gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 2); - gtk_widget_show (combo); +#else + combobox = gtk_combo_box_new_text (); + priv->chapters_type_combobox = combobox; + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Unicode block")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Unicode script")); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); + gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, FALSE, 2); + gtk_widget_show (combobox); +#endif + + combobox = gtk_combo_box_new_text (); + priv->chapters_combobox = combobox; + gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, FALSE, 2); + gtk_widget_show (combobox); /* gucharmap */ - priv->chapters_block = GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()); - priv->chapters_script = GUCHARMAP_CHAPTERS (gucharmap_script_chapters_new ()); - priv->chapters = priv->chapters_block; + priv->chapters = GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()); priv->charmap = GUCHARMAP_CHARMAP (gucharmap_charmap_new (priv->chapters)); widget = GTK_WIDGET (priv->charmap); gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 2); @@ -99,13 +108,16 @@ widget = gtk_paned_get_child2 (GTK_PANED (widget)); vbox = gtk_vbox_new (FALSE, 0); gtk_notebook_append_page (GTK_NOTEBOOK (widget), - vbox, gtk_label_new (_("Writing"))); + vbox, gtk_label_new (_("Writing"))); gtk_widget_show (vbox); /* setup */ - setup_chapters_option_menu (page); - g_signal_connect (G_OBJECT (combo), "changed", + setup_chapters_combo_box (page); + g_signal_connect (G_OBJECT (priv->chapters_type_combobox), "changed", + G_CALLBACK (on_chapters_type_combo_changed), + (gpointer) page); + g_signal_connect (G_OBJECT (priv->chapters_combobox), "changed", G_CALLBACK (on_chapters_combo_changed), (gpointer) page); } @@ -133,17 +145,33 @@ } static void -setup_chapters_option_menu (TomoeGucharmap *page) +setup_chapters_combo_box (TomoeGucharmap *page) { TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); GtkTreeModel *model = priv->chapters->tree_model; - gtk_combo_box_set_model (GTK_COMBO_BOX (priv->chapters_combo), model); - gtk_combo_box_set_active (GTK_COMBO_BOX (priv->chapters_combo), 0); + gtk_combo_box_set_model (GTK_COMBO_BOX (priv->chapters_combobox), model); + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->chapters_combobox), 0); +} + +static void +on_chapters_type_combo_changed (GtkComboBox *combobox, gpointer data) +{ + TomoeGucharmap *page = data; + TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); + gint idx = gtk_combo_box_get_active (combobox); + + if (idx == 1) + priv->chapters = GUCHARMAP_CHAPTERS (gucharmap_script_chapters_new ()); + else + priv->chapters = GUCHARMAP_CHAPTERS (gucharmap_block_chapters_new ()); + gucharmap_charmap_set_chapters (priv->charmap, priv->chapters); + gtk_widget_hide (GTK_WIDGET (priv->chapters)); + setup_chapters_combo_box (page); } static void -on_chapters_combo_changed (GtkComboBox *combo, gpointer data) +on_chapters_combo_changed (GtkComboBox *combobox, gpointer data) { TomoeGucharmap *page = data; TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); @@ -151,7 +179,7 @@ gchar buf[8]; gint idx; - idx = gtk_combo_box_get_active (combo); + idx = gtk_combo_box_get_active (combobox); g_snprintf (buf, 8 , "%d", idx); path = gtk_tree_path_new_from_string (buf); gtk_tree_view_set_cursor (GTK_TREE_VIEW (priv->chapters->tree_view), From ikezoe users.sourceforge.jp Fri Dec 1 15:22:40 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 15:22:40 +0900 Subject: [Tomoe-cvs 1544] CVS update: libtomoe-gtk/src Message-ID: <20061201062240.E219C2AC04B@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.1 libtomoe-gtk/src/tomoe-handwriting.h:1.2 --- libtomoe-gtk/src/tomoe-handwriting.h:1.1 Fri Dec 1 14:48:06 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Fri Dec 1 15:22:40 2006 @@ -56,9 +56,9 @@ GtkWidget *tomoe_handwriting_new (void); GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); TomoeChar *tomoe_handwriting_get_selected_candidate - (TomoeHandwriting *handwriting); + (TomoeHandwriting *handwriting); GtkWidget *tomoe_handwriting_get_button_area - (TomoeHandwriting *handwriting); + (TomoeHandwriting *handwriting); G_END_DECLS From makeinu users.sourceforge.jp Fri Dec 1 15:54:02 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 15:54:02 +0900 Subject: [Tomoe-cvs 1545] CVS update: libtomoe-gtk/src Message-ID: <20061201065402.7B2592AC0B3@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.11 libtomoe-gtk/src/tomoe-gucharmap.c:1.12 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.11 Fri Dec 1 15:14:34 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 15:54:02 2006 @@ -75,11 +75,6 @@ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2); gtk_widget_show (hbox); -#if 0 - label = gtk_label_new (_("Unicode block:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); - gtk_widget_show (label); -#else combobox = gtk_combo_box_new_text (); priv->chapters_type_combobox = combobox; gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Unicode block")); @@ -87,7 +82,6 @@ gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, FALSE, 2); gtk_widget_show (combobox); -#endif combobox = gtk_combo_box_new_text (); priv->chapters_combobox = combobox; @@ -111,7 +105,6 @@ vbox, gtk_label_new (_("Writing"))); gtk_widget_show (vbox); - /* setup */ setup_chapters_combo_box (page); g_signal_connect (G_OBJECT (priv->chapters_type_combobox), "changed", From kous users.sourceforge.jp Fri Dec 1 16:28:04 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 16:28:04 +0900 Subject: [Tomoe-cvs 1546] CVS update: tomoe Message-ID: <20061201072804.78A5D2AC063@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.366 tomoe/ChangeLog:1.367 --- tomoe/ChangeLog:1.366 Fri Dec 1 14:27:15 2006 +++ tomoe/ChangeLog Fri Dec 1 16:28:04 2006 @@ -1,5 +1,7 @@ 2006-12-01 Kouhei Sutou + * data/kanjidic2-original.xsl: supported number-of-strokes. + * module/dict/tomoe-dict-est.c: editable can be set when constructing. * ext/ruby/tomoe-rb-dict.c: supported name. From kous users.sourceforge.jp Fri Dec 1 16:28:04 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 1 Dec 2006 16:28:04 +0900 Subject: [Tomoe-cvs 1547] CVS update: tomoe/data Message-ID: <20061201072804.CCB552AC063@users.sourceforge.jp> Index: tomoe/data/kanjidic2-original.xsl diff -u tomoe/data/kanjidic2-original.xsl:1.3 tomoe/data/kanjidic2-original.xsl:1.4 --- tomoe/data/kanjidic2-original.xsl:1.3 Mon Nov 27 15:58:39 2006 +++ tomoe/data/kanjidic2-original.xsl Fri Dec 1 16:28:04 2006 @@ -1,31 +1,41 @@ + + - + + + - - + + + + + + + + - + From ikezoe users.sourceforge.jp Fri Dec 1 16:32:57 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 16:32:57 +0900 Subject: [Tomoe-cvs 1548] CVS update: libtomoe-gtk Message-ID: <20061201073257.539962AC0C5@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.206 libtomoe-gtk/ChangeLog:1.207 --- libtomoe-gtk/ChangeLog:1.206 Fri Dec 1 15:14:34 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 16:32:57 2006 @@ -1,3 +1,7 @@ +2006-12-01 Hiroyuki Ikezoe + + * src/tomoe-reading-search.c: USe tomoe_char_get_n_strokes() first. + 2006-12-01 Takuro Ashie * src/tomoe-gucharmap.c: Add chapters type combo box. From ikezoe users.sourceforge.jp Fri Dec 1 16:32:57 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Fri, 1 Dec 2006 16:32:57 +0900 Subject: [Tomoe-cvs 1549] CVS update: libtomoe-gtk/src Message-ID: <20061201073257.7FF532AC0F3@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.11 libtomoe-gtk/src/tomoe-reading-search.c:1.12 --- libtomoe-gtk/src/tomoe-reading-search.c:1.11 Tue Nov 28 11:31:29 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Fri Dec 1 16:32:57 2006 @@ -217,7 +217,8 @@ gint strokes = 0; GtkTreeIter iter; - if (tomoe_char_get_writing (c)) + strokes = tomoe_char_get_n_strokes (c); + if (strokes == 0 && tomoe_char_get_writing (c)) strokes = tomoe_writing_get_n_strokes (tomoe_char_get_writing (c)); if (strokes > 0) From makeinu users.sourceforge.jp Fri Dec 1 17:34:17 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 17:34:17 +0900 Subject: [Tomoe-cvs 1550] CVS update: libtomoe-gtk Message-ID: <20061201083417.66AB82AC016@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.207 libtomoe-gtk/ChangeLog:1.208 --- libtomoe-gtk/ChangeLog:1.207 Fri Dec 1 16:32:57 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 17:34:17 2006 @@ -1,3 +1,9 @@ +2006-12-01 Takuro Ashie + + * src/tomoe-gucharmap.[ch], src/tomoe-window.: Add "selected" signal for + TomoeGucharmap, but retrieving the selected character is not implemented + yet. + 2006-12-01 Hiroyuki Ikezoe * src/tomoe-reading-search.c: USe tomoe_char_get_n_strokes() first. From makeinu users.sourceforge.jp Fri Dec 1 17:34:17 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 17:34:17 +0900 Subject: [Tomoe-cvs 1551] CVS update: libtomoe-gtk/src Message-ID: <20061201083417.921B32AC072@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.12 libtomoe-gtk/src/tomoe-gucharmap.c:1.13 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.12 Fri Dec 1 15:54:02 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 17:34:17 2006 @@ -20,6 +20,11 @@ #include #include "tomoe-gucharmap.h" +enum { + SELECTED_SIGNAL, + LAST_SIGNAL +}; + typedef struct _TomoeGucharmapPrivate TomoeGucharmapPrivate; struct _TomoeGucharmapPrivate { @@ -33,12 +38,17 @@ G_DEFINE_TYPE (TomoeGucharmap, tomoe_gucharmap, GTK_TYPE_TABLE) -static void dispose (GObject *object); -static void setup_chapters_combo_box (TomoeGucharmap *page); -static void on_chapters_type_combo_changed (GtkComboBox *combobox, - gpointer data); -static void on_chapters_combo_changed (GtkComboBox *combobox, - gpointer data); +static void dispose (GObject *object); +static void setup_chapters_combo_box (TomoeGucharmap *page); +static void on_chapters_type_combo_changed (GtkComboBox *combobox, + gpointer data); +static void on_chapters_combo_changed (GtkComboBox *combobox, + gpointer data); +static void on_gucharmap_activate (GucharmapCharmap *charmap, + gunichar ch, + gpointer data); + +static guint gucharmap_signals[LAST_SIGNAL] = { 0 }; GtkWidget * tomoe_gucharmap_new (void) @@ -53,6 +63,17 @@ gobject_class->dispose = dispose; + gucharmap_signals[SELECTED_SIGNAL] = + g_signal_new ("selected", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (TomoeGucharmapClass, selected), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + klass->selected = NULL; + g_type_class_add_private (gobject_class, sizeof (TomoeGucharmapPrivate)); } @@ -113,6 +134,9 @@ g_signal_connect (G_OBJECT (priv->chapters_combobox), "changed", G_CALLBACK (on_chapters_combo_changed), (gpointer) page); + g_signal_connect (G_OBJECT (priv->charmap->chartable), "activate", + G_CALLBACK (on_gucharmap_activate), + (gpointer) page); } static void @@ -179,3 +203,13 @@ path, NULL, FALSE); gtk_tree_path_free (path); } + +static void +on_gucharmap_activate (GucharmapCharmap *charmap, gunichar ch, + gpointer data) +{ + TomoeGucharmap *gucharmap = TOMOE_GUCHARMAP (data); + + g_signal_emit (G_OBJECT (gucharmap), + gucharmap_signals[SELECTED_SIGNAL], 0); +} Index: libtomoe-gtk/src/tomoe-gucharmap.h diff -u libtomoe-gtk/src/tomoe-gucharmap.h:1.2 libtomoe-gtk/src/tomoe-gucharmap.h:1.3 --- libtomoe-gtk/src/tomoe-gucharmap.h:1.2 Thu Nov 30 18:17:24 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.h Fri Dec 1 17:34:17 2006 @@ -46,6 +46,8 @@ struct _TomoeGucharmapClass { GtkTableClass parent_class; + /* -- signals -- */ + void (*selected) (TomoeGucharmap *gucharmap); }; Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.29 libtomoe-gtk/src/tomoe-window.c:1.30 --- libtomoe-gtk/src/tomoe-window.c:1.29 Fri Dec 1 14:48:06 2006 +++ libtomoe-gtk/src/tomoe-window.c Fri Dec 1 17:34:17 2006 @@ -64,7 +64,9 @@ static void destroy (GtkObject *object); static void on_handwriting_candidate_selected (TomoeHandwriting *view, - gpointer user_data); + gpointer user_data); +static void on_gucharmap_selected (TomoeGucharmap *gucharmap, + gpointer data); static guint window_signals[LAST_SIGNAL] = { 0 }; @@ -153,6 +155,11 @@ priv->reading = widget; reading_search = TOMOE_READING_SEARCH (priv->reading); tomoe_reading_search_set_context (reading_search, priv->context); +#if 0 + g_signal_connect (G_OBJECT (widget), "hoge", + G_CALLBACK (on_reading_search_selected), + (gpointer) window); +#endif gtk_widget_show (widget); tomoe_window_append_page (window, widget, gtk_image_new_from_file (TOMOE_SEARCHING_ICON), @@ -161,6 +168,9 @@ /* gucharmap page */ widget = tomoe_gucharmap_new (); priv->chartable = widget; + g_signal_connect (G_OBJECT (widget), "selected", + G_CALLBACK (on_gucharmap_selected), + (gpointer) window); gtk_widget_show (widget); tomoe_window_append_page (window, widget, gtk_image_new_from_file (TOMOE_GUCHARMAP_ICON), @@ -270,6 +280,17 @@ window_signals[SELECTED_SIGNAL], 0); } +static void +on_gucharmap_selected (TomoeGucharmap *gucharmap, gpointer user_data) +{ + TomoeWindow *window; + g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + + window = TOMOE_WINDOW (user_data); + g_signal_emit (G_OBJECT (window), + window_signals[SELECTED_SIGNAL], 0); +} + TomoeChar * tomoe_window_get_selected_candidate (TomoeWindow *window) { From makeinu users.sourceforge.jp Fri Dec 1 17:50:43 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 17:50:43 +0900 Subject: [Tomoe-cvs 1552] CVS update: libtomoe-gtk Message-ID: <20061201085043.724E02AC016@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.208 libtomoe-gtk/ChangeLog:1.209 --- libtomoe-gtk/ChangeLog:1.208 Fri Dec 1 17:34:17 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 17:50:43 2006 @@ -1,6 +1,6 @@ 2006-12-01 Takuro Ashie - * src/tomoe-gucharmap.[ch], src/tomoe-window.: Add "selected" signal for + * src/tomoe-gucharmap.[ch], src/tomoe-window.h: Add "selected" signal for TomoeGucharmap, but retrieving the selected character is not implemented yet. From makeinu users.sourceforge.jp Fri Dec 1 17:52:59 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 17:52:59 +0900 Subject: [Tomoe-cvs 1553] CVS update: libtomoe-gtk Message-ID: <20061201085259.C9CEC2AC016@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.209 libtomoe-gtk/ChangeLog:1.210 --- libtomoe-gtk/ChangeLog:1.209 Fri Dec 1 17:50:43 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 17:52:59 2006 @@ -6,7 +6,7 @@ 2006-12-01 Hiroyuki Ikezoe - * src/tomoe-reading-search.c: USe tomoe_char_get_n_strokes() first. + * src/tomoe-reading-search.c: Use tomoe_char_get_n_strokes() first. 2006-12-01 Takuro Ashie From makeinu users.sourceforge.jp Fri Dec 1 18:03:40 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 18:03:40 +0900 Subject: [Tomoe-cvs 1554] CVS update: libtomoe-gtk Message-ID: <20061201090340.6EC0C2AC016@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.210 libtomoe-gtk/ChangeLog:1.211 --- libtomoe-gtk/ChangeLog:1.210 Fri Dec 1 17:52:59 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 1 18:03:40 2006 @@ -1,5 +1,9 @@ 2006-12-01 Takuro Ashie + * src/tomoe-gucharmap.[ch]: Add tomoe_gucharmap_get_selected (). + +2006-12-01 Takuro Ashie + * src/tomoe-gucharmap.[ch], src/tomoe-window.h: Add "selected" signal for TomoeGucharmap, but retrieving the selected character is not implemented yet. From makeinu users.sourceforge.jp Fri Dec 1 18:03:40 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 1 Dec 2006 18:03:40 +0900 Subject: [Tomoe-cvs 1555] CVS update: libtomoe-gtk/src Message-ID: <20061201090340.9B95C2AC072@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.13 libtomoe-gtk/src/tomoe-gucharmap.c:1.14 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.13 Fri Dec 1 17:34:17 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Fri Dec 1 18:03:40 2006 @@ -161,6 +161,20 @@ return priv->charmap; } +gunichar +tomoe_gucharmap_get_selected (TomoeGucharmap *page) +{ + TomoeGucharmapPrivate *priv; + GucharmapTable *table; + + g_return_val_if_fail (TOMOE_IS_GUCHARMAP (page), NULL); + + priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); + table = GUCHARMAP_TABLE (priv->charmap->chartable); + + return gucharmap_table_get_active_character (table); +} + static void setup_chapters_combo_box (TomoeGucharmap *page) { Index: libtomoe-gtk/src/tomoe-gucharmap.h diff -u libtomoe-gtk/src/tomoe-gucharmap.h:1.3 libtomoe-gtk/src/tomoe-gucharmap.h:1.4 --- libtomoe-gtk/src/tomoe-gucharmap.h:1.3 Fri Dec 1 17:34:17 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.h Fri Dec 1 18:03:40 2006 @@ -55,6 +55,7 @@ GtkWidget *tomoe_gucharmap_new (void); GucharmapCharmap * tomoe_gucharmap_get_charmap (TomoeGucharmap *gucharmap); +gunichar tomoe_gucharmap_get_selected(TomoeGucharmap *gucharmap); G_END_DECLS From kous users.sourceforge.jp Mon Dec 4 00:04:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:04:42 +0900 Subject: [Tomoe-cvs 1556] CVS update: tomoe Message-ID: <20061203150442.11D062AC136@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.367 tomoe/ChangeLog:1.368 --- tomoe/ChangeLog:1.367 Fri Dec 1 16:28:04 2006 +++ tomoe/ChangeLog Mon Dec 4 00:04:41 2006 @@ -1,3 +1,11 @@ +2006-12-04 Kouhei Sutou + + * module/dict/unihan-compiler.rb, module/dict/tomoe-dict-unihan.c, + module/dict/Makefile.am, configure.in: supported Unihan database. + * lib/tomoe-config.c, benchmark/load-dict.rb, + ext/ruby/tomoe-rb-dict.c, test/dict_spec.rb, tomoe-spec-utils.rb: + followed the changes. + 2006-12-01 Kouhei Sutou * data/kanjidic2-original.xsl: supported number-of-strokes. Index: tomoe/configure.in diff -u tomoe/configure.in:1.33 tomoe/configure.in:1.34 --- tomoe/configure.in:1.33 Thu Nov 30 15:27:19 2006 +++ tomoe/configure.in Mon Dec 4 00:04:41 2006 @@ -150,9 +150,17 @@ dnl ************************************************************** dnl Configure for dictionaries. dnl ************************************************************** + dictdir="${libdir}/\$(PACKAGE)/dict" AC_SUBST(dictdir) +AC_ARG_ENABLE(unihan, + [ --enable-unihan use Unihan detabase + (You may not be able to compile)], + [use_unihan=$enableval], + [use_unihan=$enableval]) +AM_CONDITIONAL([WITH_UNIHAN], [test "$use_unihan" = "yes"]) + dnl ************************************************************** dnl Bindings: Check for Ruby. dnl ************************************************************** From kous users.sourceforge.jp Mon Dec 4 00:04:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:04:42 +0900 Subject: [Tomoe-cvs 1557] CVS update: tomoe/benchmark Message-ID: <20061203150442.34A732AC13E@users.sourceforge.jp> Index: tomoe/benchmark/load-dict.rb diff -u tomoe/benchmark/load-dict.rb:1.6 tomoe/benchmark/load-dict.rb:1.7 --- tomoe/benchmark/load-dict.rb:1.6 Fri Dec 1 13:47:26 2006 +++ tomoe/benchmark/load-dict.rb Mon Dec 4 00:04:42 2006 @@ -18,4 +18,8 @@ "editable" => false)} end end + + x.report("Unihan") do + n.times {Tomoe::Dict.new("unihan", {})} + end end From kous users.sourceforge.jp Mon Dec 4 00:04:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:04:42 +0900 Subject: [Tomoe-cvs 1558] CVS update: tomoe/ext/ruby Message-ID: <20061203150442.58CC02AC136@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.12 tomoe/ext/ruby/tomoe-rb-dict.c:1.13 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.12 Fri Dec 1 14:27:16 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Mon Dec 4 00:04:42 2006 @@ -45,6 +45,14 @@ "database_name", RVAL2CSTR(database_name), "editable", RVAL2CBOOL(editable), NULL); + } else if (strcmp(name, "unihan") == 0) { + VALUE rb_dict_name; + gchar *dict_name; + + rb_dict_name = rb_hash_aref(props, CSTR2RVAL("name")); + dict_name = NIL_P(rb_dict_name) ? NULL : RVAL2CSTR(rb_dict_name); + + dict = tomoe_dict_new(name, "name", dict_name, NULL); } else { rb_raise(rb_eArgError, "unknown dictionary type: %s", name); dict = NULL; From kous users.sourceforge.jp Mon Dec 4 00:04:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:04:42 +0900 Subject: [Tomoe-cvs 1559] CVS update: tomoe/lib Message-ID: <20061203150442.8605B2AC13E@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.45 tomoe/lib/tomoe-config.c:1.46 --- tomoe/lib/tomoe-config.c:1.45 Thu Nov 30 18:13:15 2006 +++ tomoe/lib/tomoe-config.c Mon Dec 4 00:04:42 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.45 2006/11/30 09:13:15 kous Exp $ + * $Id: tomoe-config.c,v 1.46 2006/12/03 15:04:42 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -427,6 +427,28 @@ } static TomoeDict * +load_unihan_dictionary (GKeyFile *key_file, const gchar *dict_name) +{ + TomoeDict *dict; + GError *error = NULL; + gchar *name; + + name = g_key_file_get_string (key_file, dict_name, "name", &error); + if (error) { + TOMOE_HANDLE_ERROR (error); + return NULL; + } + + dict = tomoe_dict_new ("unihan", + "name", name, + NULL); + + g_free (name); + + return dict; +} + +static TomoeDict * _tomoe_config_load_dictionary (GKeyFile *key_file, const gchar *dict_name, const gchar *type) @@ -435,6 +457,8 @@ return load_xml_dictionary (key_file, dict_name); } else if (strcmp (type, "est") == 0) { return load_est_dictionary (key_file, dict_name); + } else if (strcmp (type, "unihan") == 0) { + return load_unihan_dictionary (key_file, dict_name); } else { return NULL; } From kous users.sourceforge.jp Mon Dec 4 00:04:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:04:42 +0900 Subject: [Tomoe-cvs 1560] CVS update: tomoe/module/dict Message-ID: <20061203150442.ACBDE2AC136@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.3 tomoe/module/dict/Makefile.am:1.4 --- tomoe/module/dict/Makefile.am:1.3 Fri Dec 1 11:23:38 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 4 00:04:42 2006 @@ -45,3 +45,39 @@ libest_la_SOURCES = tomoe-dict-est.c libest_la_LIBADD = $(EST_LIBS) endif + +if WITH_UNIHAN +dict_LTLIBRARIES += libunihan.la + +unihan_built_sources = \ + tomoe-unihan.h \ + tomoe-unihan0.c \ + tomoe-unihan1.c \ + tomoe-unihan2.c \ + tomoe-unihan3.c \ + tomoe-unihan4.c \ + tomoe-unihan5.c \ + tomoe-unihan6.c \ + tomoe-unihan7.c \ + tomoe-unihan8.c \ + tomoe-unihan9.c + +CLEANFILES += $(unihan_built_sources) Unihan.zip Unihan.txt Unihan.txt.cache +BUILT_SOUCES = $(unihan_built_sources) + +libunihan_la_SOURCES = \ + tomoe-dict-unihan.c \ + tomoe-unihan.c \ + $(unihan_built_sources) + +tomoe-unihan.h: unihan-compiler.rb Unihan.txt + $(RUBY) unihan-compiler.rb Unihan.txt tomoe-unihan 10 + +Unihan.txt: Unihan.zip + unzip Unihan.zip + touch Unihan.txt + +Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip +Unihan.zip: + $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > $@ +endif Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u /dev/null tomoe/module/dict/tomoe-dict-unihan.c:1.1 --- /dev/null Mon Dec 4 00:04:42 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Mon Dec 4 00:04:42 2006 @@ -0,0 +1,393 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-unihan.c,v 1.1 2006/12/03 15:04:42 kous Exp $ + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "tomoe-unihan.h" + +#define TOMOE_TYPE_DICT_UNIHAN tomoe_type_dict_unihan +#define TOMOE_DICT_UNIHAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_UNIHAN, TomoeDictUnihan)) +#define TOMOE_DICT_UNIHAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_UNIHAN, TomoeDictUnihanClass)) +#define TOMOE_IS_DICT_UNIHAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_UNIHAN)) +#define TOMOE_IS_DICT_UNIHAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_UNIHAN)) +#define TOMOE_DICT_UNIHAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_UNIHAN, TomoeDictUnihanClass)) + +enum { + PROP_0, + PROP_NAME +}; + +#define DEFAULT_NAME "Unihan" + +typedef struct _TomoeDictUnihan TomoeDictUnihan; +typedef struct _TomoeDictUnihanClass TomoeDictUnihanClass; +struct _TomoeDictUnihan +{ + TomoeDict object; + gchar *name; +}; + +struct _TomoeDictUnihanClass +{ + TomoeDictClass parent_class; +}; + +typedef struct _TomoeDictSearchContext { + TomoeQuery *query; + GList *results; +} TomoeDictSearchContext; + +static GType tomoe_type_dict_unihan = 0; +static GObjectClass *parent_class; +static GPtrArray *chars = NULL; + +static GObject *constructor (GType type, + guint n_props, + GObjectConstructParam *props); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static const gchar *get_name (TomoeDict *dict); +static gboolean register_char (TomoeDict *dict, + TomoeChar *chr); +static gboolean unregister_char (TomoeDict *dict, + const gchar *utf8); +static TomoeChar *get_char (TomoeDict *dict, + const gchar *utf8); +static GList *search (TomoeDict *dict, + TomoeQuery *query); +static gboolean flush (TomoeDict *dict); + +static void +class_init (TomoeDictUnihanClass *klass) +{ + GObjectClass *gobject_class; + TomoeDictClass *dict_class; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->constructor = constructor; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + dict_class = TOMOE_DICT_CLASS (klass); + dict_class->get_name = get_name; + dict_class->register_char = register_char; + dict_class->unregister_char = unregister_char; + dict_class->get_char = get_char; + dict_class->search = search; + dict_class->flush = flush; + + g_object_class_install_property ( + gobject_class, + PROP_NAME, + g_param_spec_string ( + "name", + "Name", + "The name of the dictionary", + DEFAULT_NAME, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} + +static void +init (TomoeDictUnihan *dict) +{ + dict->name = NULL; +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (TomoeDictUnihanClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (TomoeDictUnihan), + 0, + (GInstanceInitFunc) init, + }; + + tomoe_type_dict_unihan = g_type_module_register_type (type_module, + TOMOE_TYPE_DICT, + "TomoeDictUnihan", + &info, 0); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + register_type (type_module); + + if (!chars) + chars = _tomoe_unihan_create (); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_EXIT (void) +{ + if (chars) { + TOMOE_PTR_ARRAY_FREE_ALL (chars, g_object_unref); + chars = NULL; + } +} + +G_MODULE_EXPORT GObject * +TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list args) +{ + return g_object_new_valist (TOMOE_TYPE_DICT_UNIHAN, first_property, args); +} + +static GObject * +constructor (GType type, guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GObjectClass *klass = G_OBJECT_CLASS (parent_class); + + object = klass->constructor (type, n_props, props); + + return object; +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (object); + + switch (prop_id) { + case PROP_NAME: + g_free (dict->name); + dict->name = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeDict *_dict = TOMOE_DICT (object); + + switch (prop_id) { + case PROP_NAME: + g_value_set_string (value, get_name (_dict)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + TomoeDictUnihan *dict; + + dict = TOMOE_DICT_UNIHAN (object); + + if (dict->name) + g_free (dict->name); + + dict->name = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static const gchar* +get_name (TomoeDict *_dict) +{ + TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); + g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), NULL); + return dict->name ? dict->name : DEFAULT_NAME; +} + +static gboolean +register_char (TomoeDict *_dict, TomoeChar *chr) +{ + TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); + g_return_val_if_fail (chr, FALSE); + + g_warning ("TomoeDictUnihan doesn't support register_char()"); + return FALSE; +} + +static gboolean +unregister_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); + g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); + + g_warning ("TomoeDictUnihan doesn't support register_char()"); + return FALSE; +} + +static TomoeChar * +get_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); + guint i; + + g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), NULL); + g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); + + for (i = 0; i < chars->len; i++) { + TomoeChar *chr = g_ptr_array_index (chars, i); + if (0 == strcmp(tomoe_char_get_utf8(chr), utf8)) { + return chr; + } + } + + return NULL; +} + +static gboolean +tomoe_dict_unihan_does_match_char_with_n_strokes (TomoeChar *chr, + gint min, gint max) +{ + TomoeWriting *writing; + gint n_strokes; + + if (min < 0 && max < 0) + return TRUE; + + writing = tomoe_char_get_writing (chr); + if (!writing) + return FALSE; + + n_strokes = tomoe_writing_get_n_strokes (writing); + return ((min < 0 || min <= n_strokes) && + (max < 0 || max >= n_strokes)); +} + +static gint +tomoe_dict_unihan_compare_reading (gconstpointer a, gconstpointer b) +{ + TomoeReading *reading, *searched_reading; + + reading = TOMOE_READING(a); + searched_reading = TOMOE_READING(b); + return strcmp(tomoe_reading_get_reading(reading), + tomoe_reading_get_reading(searched_reading)); +} + +static gboolean +tomoe_dict_unihan_does_match_char_with_readings (TomoeChar *chr, + TomoeReading *reading) +{ + if (!reading) + return TRUE; + + if (g_list_find_custom ((GList *)tomoe_char_get_readings (chr), + reading, tomoe_dict_unihan_compare_reading)) + return TRUE; + else + return FALSE; +} + +static void +tomoe_dict_unihan_collect_chars_by_query (gpointer data, gpointer user_data) +{ + TomoeChar *chr = data; + TomoeDictSearchContext *context = user_data; + TomoeQuery *query; + TomoeReading *reading; + gint min_n_strokes, max_n_strokes; + + query = context->query; + + min_n_strokes = tomoe_query_get_min_n_strokes (query); + max_n_strokes = tomoe_query_get_max_n_strokes (query); + if (!tomoe_dict_unihan_does_match_char_with_n_strokes (chr, + min_n_strokes, + max_n_strokes)) + return; + + reading = g_list_nth_data ((GList *)tomoe_query_get_readings (query), 0); + if (!tomoe_dict_unihan_does_match_char_with_readings (chr, reading)) + return; + + context->results = g_list_prepend (context->results, + tomoe_candidate_new (chr)); +} + +static GList * +search (TomoeDict *_dict, TomoeQuery *query) +{ + TomoeDictSearchContext search_context; + + search_context.query = g_object_ref (query); + search_context.results = NULL; + + g_ptr_array_foreach_reverse (chars, + tomoe_dict_unihan_collect_chars_by_query, + &search_context); + g_object_unref (search_context.query); + + return search_context.results; +} + +static gboolean +flush (TomoeDict *_dict) +{ + return TRUE; +} + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/module/dict/unihan-compiler.rb diff -u /dev/null tomoe/module/dict/unihan-compiler.rb:1.1 --- /dev/null Mon Dec 4 00:04:42 2006 +++ tomoe/module/dict/unihan-compiler.rb Mon Dec 4 00:04:42 2006 @@ -0,0 +1,215 @@ +#!/usr/bin/env ruby + +require 'uconv' + +unihan_txt = ARGV.shift +base = ARGV.shift +split_size = Integer(ARGV.shift) + +DO_NOT_EDIT_HEADER = <<-EOH +/* + DO NOT EDIT! + THIS FILE IS GENERATED BY Unihan.txt: + ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip +*/ +EOH + +def parse_unihan_txt(unihan_txt) + cache = "#{unihan_txt}.cache" + if File.exists?(cache) and (File.mtime(cache) > File.mtime(unihan_txt)) + begin + return Marshal.load(File.read(cache)) + rescue ArgumentError + end + end + + infos = {} + File.open(unihan_txt).each do |line| + case line + when /^#/ # + next + when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/ + ucs4 = $1 + key = $2 + value = $3 + + infos[ucs4] ||= {} + infos[ucs4][key] = value + else + STDERR.puts "Unknown line: #{line}" + end + end + + result = infos.collect do |ucs4, info| + [ucs4, info] + end.sort_by do |ucs4, info| + ucs4 + end + + File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} + result +end + +def generate_header(base, split_size, infos) + header = "#{base}.h" + block_macro = "__#{header.gsub(/[\.-]/, '_').upcase}__" + + File.open(header, "w") do |f| + f.puts <<-EOH +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#{DO_NOT_EDIT_HEADER} + +#ifndef #{block_macro} +#define #{block_macro} + +#include + +G_BEGIN_DECLS + +GPtrArray *_tomoe_unihan_create (void); +EOH + + split_size.times do |i| + f.puts("void _tomoe_unihan_create#{i} (GPtrArray *array);") + end + + f.puts <<-EOF + +G_END_DECLS + +#endif /* #{block_macro} */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ +EOF + end +end + +def generate_split_body(f, i, ucs4, info) + utf8 = Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) + + f.puts <<-EOB + chr = tomoe_char_new (); + tomoe_char_set_utf8 (chr, "#{utf8}"); +EOB + + n_strokes = info["kTotalStrokes"] + f.puts " tomoe_char_set_n_strokes (chr, #{n_strokes});" if n_strokes + + variant = info["kCompatibilityVariant"] + if variant + variant = variant.sub(/^U\+2?/, '') + f.puts <<-EOB + tomoe_char_set_variant (chr, "#{variant}"); +EOB + end + + kuns = info["kJapaneseKun"] + if kuns + kuns.split.each do |kun| + f.puts <<-EOB + reading = tomoe_reading_new (TOMOE_READING_JA_KUN, "#{kun}"); + tomoe_char_add_reading (chr, reading); + g_object_unref (reading); +EOB + end + end + + ons = info["kJapaneseOn"] + if ons + ons.split.each do |on| + f.puts <<-EOB + reading = tomoe_reading_new (TOMOE_READING_JA_ON, "#{on}"); + tomoe_char_add_reading (chr, reading); + g_object_unref (reading); +EOB + end + end + + f.puts <<-EOB + array->pdata[#{i}] = chr; + +EOB +end + +def generate_split(base, chunk_index, base_index, infos) + c_file = "#{base}#{chunk_index}.c" + + File.open(c_file, "w") do |f| + f.puts <<-EOH +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#{DO_NOT_EDIT_HEADER} + +#include "tomoe-unihan.h" + +#include + +void +_tomoe_unihan_create#{chunk_index} (GPtrArray *array) +{ + TomoeChar *chr; + TomoeReading *reading; + + reading = NULL; + +EOH + + infos.each_with_index do |(ucs4, info), i| + generate_split_body(f, base_index + i, ucs4, info) + end + + f.puts <<-EOF +} +EOF + end +end + +def generate_main(base, split_size, infos) + main_file = "#{base}.c" + + chunk = infos.size / split_size + split_size.times do |i| + next_i = i + 1 + if next_i == split_size + split_infos = infos[(i * chunk)..-1] + else + split_infos = infos[(i * chunk)...(next_i * chunk)] + end + generate_split(base, i, i * chunk, split_infos) + end + + File.open(main_file, "w") do |f| + f.puts <<-EOH +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#{DO_NOT_EDIT_HEADER} + +#include "tomoe-unihan.h" + +#include + +GPtrArray * +_tomoe_unihan_create (void) +{ + GPtrArray *array; + + array = g_ptr_array_sized_new (#{infos.size}); + array->len = #{infos.size}; + +EOH + + split_size.times do |i| + f.puts " _tomoe_unihan_create#{i} (array);" + end + + f.puts <<-EOF + + return array; +} +EOF + end +end + +infos = parse_unihan_txt(unihan_txt) +generate_header(base, split_size, infos) +generate_main(base, split_size, infos) From kous users.sourceforge.jp Mon Dec 4 00:04:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:04:42 +0900 Subject: [Tomoe-cvs 1561] CVS update: tomoe/test Message-ID: <20061203150442.D644E2AC13E@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.12 tomoe/test/dict_spec.rb:1.13 --- tomoe/test/dict_spec.rb:1.12 Thu Nov 30 15:27:19 2006 +++ tomoe/test/dict_spec.rb Mon Dec 4 00:04:42 2006 @@ -24,6 +24,7 @@ dict = Tomoe::Dict.new("est", "database_name" => est_db, "editable" => true) + return if dict.nil? a = dict[@utf8] a.writing.strokes.should == @strokes ensure Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.16 tomoe/test/tomoe-spec-utils.rb:1.17 --- tomoe/test/tomoe-spec-utils.rb:1.16 Thu Nov 30 18:13:15 2006 +++ tomoe/test/tomoe-spec-utils.rb Mon Dec 4 00:04:42 2006 @@ -109,7 +109,7 @@ Dir.glob(File.join(test_data_dir, "*.data")) end - def make_config_file(name=nil, use_est=false) + def make_config_file(name=nil, dict_type=:xml) name ||= "tomoe" config_file = Tempfile.new(name) config_file.open @@ -117,24 +117,41 @@ [config] use_system_dictionaries = false EOC - dictionaries.each_with_index do |dictionary, i| - if use_est - config_file.puts(<<-EOC) + + case dict_type + when :unihan + config_file.puts(<<-EOC) +[unihan-dictionary] +type = unihan +name = Unihan + +[all-dictionary] +type = xml +name = all +file = #{File.join(data_dir, "all.xml")} +EOC + else + dictionaries.each_with_index do |dictionary, i| + case dict_type + when :est + config_file.puts(<<-EOC) [#{File.basename(dictionary)}-dictionary] type = est name = #{File.basename(dictionary)} database = #{dictionary.sub(/\.xml$/, '')} #{(i % 2).zero? ? 'use = true' : ''} EOC - else - config_file.puts(<<-EOC) + else + config_file.puts(<<-EOC) [#{File.basename(dictionary)}-dictionary] type = xml file = #{dictionary} #{(i % 2).zero? ? 'use = true' : ''} EOC + end end end + config_file.close config_file end From kous users.sourceforge.jp Mon Dec 4 00:10:45 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:10:45 +0900 Subject: [Tomoe-cvs 1562] CVS update: tomoe Message-ID: <20061203151045.CECDB2AC136@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.368 tomoe/ChangeLog:1.369 --- tomoe/ChangeLog:1.368 Mon Dec 4 00:04:41 2006 +++ tomoe/ChangeLog Mon Dec 4 00:10:45 2006 @@ -1,5 +1,7 @@ 2006-12-04 Kouhei Sutou + * module/dict/Makefile.am: fixed dependencies. + * module/dict/unihan-compiler.rb, module/dict/tomoe-dict-unihan.c, module/dict/Makefile.am, configure.in: supported Unihan database. * lib/tomoe-config.c, benchmark/load-dict.rb, From kous users.sourceforge.jp Mon Dec 4 00:10:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:10:46 +0900 Subject: [Tomoe-cvs 1563] CVS update: tomoe/module/dict Message-ID: <20061203151046.05B5A2AC13E@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.4 tomoe/module/dict/Makefile.am:1.5 --- tomoe/module/dict/Makefile.am:1.4 Mon Dec 4 00:04:42 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 4 00:10:45 2006 @@ -50,6 +50,7 @@ dict_LTLIBRARIES += libunihan.la unihan_built_sources = \ + tomoe-unihan.c \ tomoe-unihan.h \ tomoe-unihan0.c \ tomoe-unihan1.c \ @@ -66,11 +67,10 @@ BUILT_SOUCES = $(unihan_built_sources) libunihan_la_SOURCES = \ - tomoe-dict-unihan.c \ - tomoe-unihan.c \ - $(unihan_built_sources) + $(unihan_built_sources) \ + tomoe-dict-unihan.c -tomoe-unihan.h: unihan-compiler.rb Unihan.txt +tomoe-unihan.c: unihan-compiler.rb Unihan.txt $(RUBY) unihan-compiler.rb Unihan.txt tomoe-unihan 10 Unihan.txt: Unihan.zip From kous users.sourceforge.jp Mon Dec 4 00:35:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:35:57 +0900 Subject: [Tomoe-cvs 1564] CVS update: tomoe Message-ID: <20061203153557.197072AC136@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.369 tomoe/ChangeLog:1.370 --- tomoe/ChangeLog:1.369 Mon Dec 4 00:10:45 2006 +++ tomoe/ChangeLog Mon Dec 4 00:35:56 2006 @@ -1,5 +1,8 @@ 2006-12-04 Kouhei Sutou + * configure.in: search unzip. + * module/dict/Makefile.am: fixed typo and clean-upped. + * module/dict/Makefile.am: fixed dependencies. * module/dict/unihan-compiler.rb, module/dict/tomoe-dict-unihan.c, Index: tomoe/configure.in diff -u tomoe/configure.in:1.34 tomoe/configure.in:1.35 --- tomoe/configure.in:1.34 Mon Dec 4 00:04:41 2006 +++ tomoe/configure.in Mon Dec 4 00:35:56 2006 @@ -161,6 +161,8 @@ [use_unihan=$enableval]) AM_CONDITIONAL([WITH_UNIHAN], [test "$use_unihan" = "yes"]) +AC_PATH_PROG(UNZIP, unzip, unzip-not-found) + dnl ************************************************************** dnl Bindings: Check for Ruby. dnl ************************************************************** From kous users.sourceforge.jp Mon Dec 4 00:35:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 00:35:57 +0900 Subject: [Tomoe-cvs 1565] CVS update: tomoe/module/dict Message-ID: <20061203153557.3CED82AC13E@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.5 tomoe/module/dict/Makefile.am:1.6 --- tomoe/module/dict/Makefile.am:1.5 Mon Dec 4 00:10:45 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 4 00:35:57 2006 @@ -63,8 +63,8 @@ tomoe-unihan8.c \ tomoe-unihan9.c -CLEANFILES += $(unihan_built_sources) Unihan.zip Unihan.txt Unihan.txt.cache -BUILT_SOUCES = $(unihan_built_sources) +CLEANFILES += Unihan.txt Unihan.txt.cache +BUILT_SOURCES = $(unihan_built_sources) Unihan.zip libunihan_la_SOURCES = \ $(unihan_built_sources) \ @@ -74,8 +74,8 @@ $(RUBY) unihan-compiler.rb Unihan.txt tomoe-unihan 10 Unihan.txt: Unihan.zip - unzip Unihan.zip - touch Unihan.txt + $(UNZIP) Unihan.zip + touch $@ Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip Unihan.zip: From ikezoe users.sourceforge.jp Mon Dec 4 10:27:46 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Mon, 4 Dec 2006 10:27:46 +0900 Subject: [Tomoe-cvs 1566] CVS update: tomoe/module/dict Message-ID: <20061204012746.C15882AC04E@users.sourceforge.jp> Index: tomoe/module/dict/.cvsignore diff -u /dev/null tomoe/module/dict/.cvsignore:1.1 --- /dev/null Mon Dec 4 10:27:46 2006 +++ tomoe/module/dict/.cvsignore Mon Dec 4 10:27:46 2006 @@ -0,0 +1,2 @@ +Unihan.txt +Unihan.zip From kous users.sourceforge.jp Mon Dec 4 10:29:21 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 10:29:21 +0900 Subject: [Tomoe-cvs 1567] CVS update: tomoe Message-ID: <20061204012921.BD8B72AC04E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.370 tomoe/ChangeLog:1.371 --- tomoe/ChangeLog:1.370 Mon Dec 4 00:35:56 2006 +++ tomoe/ChangeLog Mon Dec 4 10:29:21 2006 @@ -1,5 +1,9 @@ 2006-12-04 Kouhei Sutou + * module/dict/Makefile.am, module/dict/tomoe-dict-ruby.c: added + Ruby backend. (not worked) + * ext/ruby/rbtomoe.h (RVAL2TCND): added. + * configure.in: search unzip. * module/dict/Makefile.am: fixed typo and clean-upped. From kous users.sourceforge.jp Mon Dec 4 10:29:21 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 10:29:21 +0900 Subject: [Tomoe-cvs 1568] CVS update: tomoe/ext/ruby Message-ID: <20061204012921.EAD3E2AC163@users.sourceforge.jp> Index: tomoe/ext/ruby/rbtomoe.h diff -u tomoe/ext/ruby/rbtomoe.h:1.1 tomoe/ext/ruby/rbtomoe.h:1.2 --- tomoe/ext/ruby/rbtomoe.h:1.1 Tue Nov 28 13:26:23 2006 +++ tomoe/ext/ruby/rbtomoe.h Mon Dec 4 10:29:21 2006 @@ -16,6 +16,7 @@ #define RVAL2TQRY(obj) (TOMOE_QUERY(RVAL2GOBJ(obj))) #define RVAL2TRDG(obj) (TOMOE_READING(RVAL2GOBJ(obj))) #define RVAL2TCHR(obj) (TOMOE_CHAR(RVAL2GOBJ(obj))) +#define RVAL2TCND(obj) (TOMOE_CANDIDATE(RVAL2GOBJ(obj))) #define RVAL2TRT(obj) (RVAL2GENUM(obj, TOMOE_TYPE_READING_TYPE)) From kous users.sourceforge.jp Mon Dec 4 10:29:22 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 10:29:22 +0900 Subject: [Tomoe-cvs 1569] CVS update: tomoe/module/dict Message-ID: <20061204012922.1CFEB2AC04E@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.6 tomoe/module/dict/Makefile.am:1.7 --- tomoe/module/dict/Makefile.am:1.6 Mon Dec 4 00:35:57 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 4 10:29:21 2006 @@ -29,7 +29,13 @@ -DRUBY_EXTDIR=\""$(RUBY_EXTDIR)"\" \ -DRUBY_LIBDIR=\""$(RUBY_LIBDIR)"\" -INCLUDES = -I$(top_srcdir)/lib $(GLIB_CFLAGS) $(EST_CFLAGS) +INCLUDES = \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/ext/ruby \ + $(GLIB_CFLAGS) \ + $(EST_CFLAGS) \ + $(RUBY_CFLAGS) + LIBADD = $(GLIB_LIBS) LDFLAGS = \ -version-info $(LT_VERSION_INFO) \ @@ -46,6 +52,13 @@ libest_la_LIBADD = $(EST_LIBS) endif +if WITH_RUBY +dict_LTLIBRARIES += libruby.la + +libruby_la_SOURCES = tomoe-dict-ruby.c +libruby_la_LIBADD = $(RUBY_LIBS) +endif + if WITH_UNIHAN dict_LTLIBRARIES += libunihan.la Index: tomoe/module/dict/tomoe-dict-ruby.c diff -u /dev/null tomoe/module/dict/tomoe-dict-ruby.c:1.1 --- /dev/null Mon Dec 4 10:29:22 2006 +++ tomoe/module/dict/tomoe-dict-ruby.c Mon Dec 4 10:29:21 2006 @@ -0,0 +1,393 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-ruby.c,v 1.1 2006/12/04 01:29:21 kous Exp $ + */ + +#include + +#undef _ +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#define INIT_FILE "dict-init" + +#define TOMOE_TYPE_DICT_RUBY tomoe_type_dict_ruby +#define TOMOE_DICT_RUBY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_RUBY, TomoeDictRuby)) +#define TOMOE_DICT_RUBY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_RUBY, TomoeDictRubyClass)) +#define TOMOE_IS_DICT_RUBY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_RUBY)) +#define TOMOE_IS_DICT_RUBY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_RUBY)) +#define TOMOE_DICT_RUBY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_RUBY, TomoeDictRubyClass)) + +enum { + PROP_0, + PROP_FILENAME, + PROP_EDITABLE, + PROP_LOAD_PATH +}; + +typedef struct _TomoeDictRuby TomoeDictRuby; +typedef struct _TomoeDictRubyClass TomoeDictRubyClass; +struct _TomoeDictRuby +{ + TomoeDict object; + gchar *filename; + gchar *name; + gchar *load_path; + + gboolean editable; + + VALUE rb_dict; +}; + +struct _TomoeDictRubyClass +{ + TomoeDictClass parent_class; +}; + +typedef struct _TomoeDictSearchContext { + TomoeQuery *query; + GList *results; +} TomoeDictSearchContext; + +extern VALUE rb_load_path; + +static GType tomoe_type_dict_ruby = 0; +static GObjectClass *parent_class; + +static GObject *constructor (GType type, + guint n_props, + GObjectConstructParam *props); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static const gchar *get_name (TomoeDict *dict); +static gboolean register_char (TomoeDict *dict, + TomoeChar *chr); +static gboolean unregister_char (TomoeDict *dict, + const gchar *utf8); +static TomoeChar *get_char (TomoeDict *dict, + const gchar *utf8); +static GList *search (TomoeDict *dict, + TomoeQuery *query); + +static void +class_init (TomoeDictRubyClass *klass) +{ + GObjectClass *gobject_class; + TomoeDictClass *dict_class; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->constructor = constructor; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + dict_class = TOMOE_DICT_CLASS (klass); + dict_class->get_name = get_name; + dict_class->register_char = register_char; + dict_class->unregister_char = unregister_char; + dict_class->get_char = get_char; + dict_class->search = search; + + g_object_class_install_property ( + gobject_class, + PROP_FILENAME, + g_param_spec_string ( + "filename", + "Filename", + "The filename of xml file", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property( + gobject_class, + PROP_EDITABLE, + g_param_spec_boolean( + "editable", + "Editable", + "Editable flag", + TRUE, + G_PARAM_READWRITE)); +} + +static void +init (TomoeDictRuby *dict) +{ + dict->filename = NULL; + dict->name = NULL; + dict->load_path = NULL; + dict->editable = FALSE; + dict->rb_dict = Qnil; +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (TomoeDictRubyClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (TomoeDictRuby), + 0, + (GInstanceInitFunc) init, + }; + + tomoe_type_dict_ruby = g_type_module_register_type (type_module, + TOMOE_TYPE_DICT, + "TomoeDictRuby", + &info, 0); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + static gchar *argv[] = {G_STRINGIFY (PACKAGE)}; + + register_type (type_module); + + ruby_init (); + ruby_script (PACKAGE); + ruby_set_argv (1, argv); + + if (RARRAY(rb_load_path)->len == 0) { + ruby_init_loadpath (); + } + + rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_EXTDIR)); + rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_LIBDIR)); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_EXIT (void) +{ + ruby_cleanup (0); +} + +G_MODULE_EXPORT GObject * +TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list args) +{ + GObject *object; + + object = g_object_new_valist (TOMOE_TYPE_DICT_RUBY, + first_property, args); + return object; +} + +static GObject * +constructor (GType type, guint n_props, GObjectConstructParam *props) +{ + GObject *object; + GObjectClass *klass = G_OBJECT_CLASS (parent_class); + TomoeDictRuby *dict; + VALUE mTomoe, cTomoeDictRuby; + + object = klass->constructor (type, n_props, props); + dict = TOMOE_DICT_RUBY (object); + + if (dict->load_path) + rb_ary_unshift (rb_load_path, CSTR2RVAL (dict->load_path)); + + rb_funcall (Qnil, rb_intern ("require"), 1, rb_str_new2 (INIT_FILE)); + + mTomoe = rb_const_get (rb_cObject, rb_intern ("Tomoe")); + cTomoeDictRuby = rb_const_get (mTomoe, rb_intern ("DictRuby")); + dict->rb_dict = rb_funcall (cTomoeDictRuby, rb_intern ("find"), + 1, GOBJ2RVAL (dict)); + if (NIL_P (dict->rb_dict)) { + g_object_unref (object); + return NULL; + } + rb_gc_register_address (&dict->rb_dict); + + return object; +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (object); + + switch (prop_id) { + case PROP_FILENAME: + dict->filename = g_value_dup_string (value); + break; + case PROP_EDITABLE: + dict->editable = g_value_get_boolean (value); + break; + case PROP_LOAD_PATH: + dict->load_path = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (object); + + switch (prop_id) { + case PROP_FILENAME: + g_value_set_string (value, dict->filename); + break; + case PROP_EDITABLE: + g_value_set_boolean (value, dict->editable); + break; + case PROP_LOAD_PATH: + g_value_set_string (value, dict->load_path); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + TomoeDictRuby *dict; + + dict = TOMOE_DICT_RUBY(object); + + if (dict->name) + g_free (dict->name); + if (dict->filename) + g_free (dict->filename); + if (dict->load_path) + g_free (dict->load_path); + if (!NIL_P (dict->rb_dict)) + rb_gc_unregister_address (&dict->rb_dict); + + dict->name = NULL; + dict->filename = NULL; + dict->load_path = NULL; + dict->rb_dict = Qnil; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static const gchar* +get_name (TomoeDict *_dict) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (_dict); + VALUE name; + + g_return_val_if_fail (TOMOE_IS_DICT_RUBY (dict), NULL); + + name = rb_funcall (dict->rb_dict, rb_intern ("name"), 0); + return RVAL2CSTR (name); +} + +static gboolean +register_char (TomoeDict *_dict, TomoeChar *chr) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (_dict); + g_return_val_if_fail (TOMOE_IS_DICT_RUBY (dict), FALSE); + g_return_val_if_fail (chr, FALSE); + + return RVAL2CBOOL (rb_funcall (dict->rb_dict, rb_intern ("register"), + 1, GOBJ2RVAL (chr))); +} + +static gboolean +unregister_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_RUBY (dict), FALSE); + g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); + + return RVAL2CBOOL (rb_funcall (dict->rb_dict, rb_intern ("unregister"), + 1, CSTR2RVAL (utf8))); +} + +static TomoeChar * +get_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_RUBY (dict), NULL); + g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); + + return RVAL2TCHR (rb_funcall (dict->rb_dict, rb_intern ("[]"), + 1, CSTR2RVAL (utf8))); +} + +static GList * +search (TomoeDict *_dict, TomoeQuery *query) +{ + TomoeDictRuby *dict = TOMOE_DICT_RUBY (_dict); + GList *results = NULL; + VALUE rb_results; + int i, len; + + g_return_val_if_fail (TOMOE_IS_DICT_RUBY (dict), results); + + rb_results = rb_funcall (dict->rb_dict, rb_intern ("search"), + 1, GOBJ2RVAL (query)); + len = RARRAY (rb_results)->len; + for (i = len; i; i--) { + results = g_list_prepend (results, + RVAL2TCND (RARRAY (rb_results)->ptr[i])); + } + return results; +} + +/* +vi:ts=4:nowrap:ai:expandtab +*/ From ikezoe users.sourceforge.jp Mon Dec 4 10:55:40 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Mon, 4 Dec 2006 10:55:40 +0900 Subject: [Tomoe-cvs 1570] CVS update: tomoe Message-ID: <20061204015540.13A302AC07D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.371 tomoe/ChangeLog:1.372 --- tomoe/ChangeLog:1.371 Mon Dec 4 10:29:21 2006 +++ tomoe/ChangeLog Mon Dec 4 10:55:39 2006 @@ -1,3 +1,7 @@ +2006-12-04 Hiroyuki Ikezoe + + * configure.in, module/dict/Makefile.am: Add --with-ruby-dict option. + 2006-12-04 Kouhei Sutou * module/dict/Makefile.am, module/dict/tomoe-dict-ruby.c: added Index: tomoe/configure.in diff -u tomoe/configure.in:1.35 tomoe/configure.in:1.36 --- tomoe/configure.in:1.35 Mon Dec 4 00:35:56 2006 +++ tomoe/configure.in Mon Dec 4 10:55:39 2006 @@ -258,6 +258,12 @@ AM_CONDITIONAL([WITH_RUBY], [test "$ruby_available" = "yes"]) +dnl ************************************************************** +dnl Check for Ruby dictionary module +dnl ************************************************************** +AC_ARG_ENABLE(ruby_dict, [ --enable-ruby-dict + Enable Ruby-dict module]) +AM_CONDITIONAL(ENABLE_RUBY_DICT, test x"$enable_ruby" = "xyes") AC_CONFIG_FILES([ Makefile From ikezoe users.sourceforge.jp Mon Dec 4 10:55:40 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Mon, 4 Dec 2006 10:55:40 +0900 Subject: [Tomoe-cvs 1571] CVS update: tomoe/module/dict Message-ID: <20061204015540.392712AC163@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.7 tomoe/module/dict/Makefile.am:1.8 --- tomoe/module/dict/Makefile.am:1.7 Mon Dec 4 10:29:21 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 4 10:55:40 2006 @@ -52,7 +52,7 @@ libest_la_LIBADD = $(EST_LIBS) endif -if WITH_RUBY +if ENABLE_RUBY_DICT dict_LTLIBRARIES += libruby.la libruby_la_SOURCES = tomoe-dict-ruby.c From makeinu users.sourceforge.jp Mon Dec 4 11:00:39 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 11:00:39 +0900 Subject: [Tomoe-cvs 1572] CVS update: libtomoe-gtk Message-ID: <20061204020039.9F49F2AC07D@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.211 libtomoe-gtk/ChangeLog:1.212 --- libtomoe-gtk/ChangeLog:1.211 Fri Dec 1 18:03:40 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 11:00:39 2006 @@ -1,3 +1,8 @@ +2006-12-04 Takuro Ashie + + * lib/tomoe-reading-search.[ch]: Add "selected" signal, but never emited + yet. + 2006-12-01 Takuro Ashie * src/tomoe-gucharmap.[ch]: Add tomoe_gucharmap_get_selected (). From makeinu users.sourceforge.jp Mon Dec 4 11:00:39 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 11:00:39 +0900 Subject: [Tomoe-cvs 1573] CVS update: libtomoe-gtk/src Message-ID: <20061204020039.CD2B42AC090@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.12 libtomoe-gtk/src/tomoe-reading-search.c:1.13 --- libtomoe-gtk/src/tomoe-reading-search.c:1.12 Fri Dec 1 16:32:57 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 4 11:00:39 2006 @@ -28,6 +28,7 @@ #include "tomoe-char-table.h" enum { + SELECTED_SIGNAL, LAST_SIGNAL }; @@ -57,7 +58,7 @@ static void on_input_entry_activate (GtkEntry *entry, gpointer *user_data); -/*static guint reading_search_signals[LAST_SIGNAL] = { 0 };*/ +static guint reading_search_signals[LAST_SIGNAL] = { 0 }; GtkWidget * tomoe_reading_search_new (void) @@ -78,7 +79,17 @@ { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + reading_search_signals[SELECTED_SIGNAL] = + g_signal_new ("selected", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (TomoeReadingSearchClass, selected), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + gobject_class->dispose = dispose; + klass->selected = NULL; g_type_class_add_private (gobject_class, sizeof (TomoeReadingSearchPrivate)); } Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.1 libtomoe-gtk/src/tomoe-reading-search.h:1.2 --- libtomoe-gtk/src/tomoe-reading-search.h:1.1 Thu Nov 23 15:35:20 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Mon Dec 4 11:00:39 2006 @@ -45,6 +45,8 @@ struct _TomoeReadingSearchClass { GtkTableClass parent_class; + /* -- signals -- */ + void (*selected) (TomoeReadingSearch *search); }; From kous users.sourceforge.jp Mon Dec 4 11:45:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 11:45:26 +0900 Subject: [Tomoe-cvs 1574] CVS update: tomoe Message-ID: <20061204024526.2AFA42AC170@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.372 tomoe/ChangeLog:1.373 --- tomoe/ChangeLog:1.372 Mon Dec 4 10:55:39 2006 +++ tomoe/ChangeLog Mon Dec 4 11:45:26 2006 @@ -1,6 +1,11 @@ +2006-12-04 Kouhei Sutou + + * module/dict/Makefile.am, module/dict/unihan-compiler.rb: + improved strange Unihan compiling. + 2006-12-04 Hiroyuki Ikezoe - * configure.in, module/dict/Makefile.am: Add --with-ruby-dict option. + * configure.in, module/dict/Makefile.am: Add --enable-ruby-dict option. 2006-12-04 Kouhei Sutou Index: tomoe/configure.in diff -u tomoe/configure.in:1.36 tomoe/configure.in:1.37 --- tomoe/configure.in:1.36 Mon Dec 4 10:55:39 2006 +++ tomoe/configure.in Mon Dec 4 11:45:26 2006 @@ -142,6 +142,14 @@ AM_CONDITIONAL([WITH_EST], [test "$est_exists" = "yes"]) dnl ************************************************************** +dnl Check for neon. +dnl ************************************************************** + +neon_exists=no +PKG_CHECK_MODULES(NEON, neon, [neon_exists=yes], [neon_exists=no]) +AM_CONDITIONAL([WITH_NEON], [test "$neon_exists" = "yes"]) + +dnl ************************************************************** dnl Configure for recognizers. dnl ************************************************************** recognizerdir="${libdir}/\$(PACKAGE)/recognizer" From kous users.sourceforge.jp Mon Dec 4 11:45:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 11:45:26 +0900 Subject: [Tomoe-cvs 1575] CVS update: tomoe/module/dict Message-ID: <20061204024526.5043C2AC172@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.8 tomoe/module/dict/Makefile.am:1.9 --- tomoe/module/dict/Makefile.am:1.8 Mon Dec 4 10:55:40 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 4 11:45:26 2006 @@ -62,29 +62,19 @@ if WITH_UNIHAN dict_LTLIBRARIES += libunihan.la -unihan_built_sources = \ - tomoe-unihan.c \ - tomoe-unihan.h \ - tomoe-unihan0.c \ - tomoe-unihan1.c \ - tomoe-unihan2.c \ - tomoe-unihan3.c \ - tomoe-unihan4.c \ - tomoe-unihan5.c \ - tomoe-unihan6.c \ - tomoe-unihan7.c \ - tomoe-unihan8.c \ - tomoe-unihan9.c +unihan_built_sources = tomoe-unihan-data.h CLEANFILES += Unihan.txt Unihan.txt.cache BUILT_SOURCES = $(unihan_built_sources) Unihan.zip libunihan_la_SOURCES = \ - $(unihan_built_sources) \ - tomoe-dict-unihan.c + tomoe-dict-unihan.c \ + tomoe-unihan.c \ + tomoe-unihan.h \ + $(unihan_built_sources) -tomoe-unihan.c: unihan-compiler.rb Unihan.txt - $(RUBY) unihan-compiler.rb Unihan.txt tomoe-unihan 10 +tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt + $(RUBY) unihan-compiler.rb Unihan.txt > $@ Unihan.txt: Unihan.zip $(UNZIP) Unihan.zip Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.1 tomoe/module/dict/unihan-compiler.rb:1.2 --- tomoe/module/dict/unihan-compiler.rb:1.1 Mon Dec 4 00:04:42 2006 +++ tomoe/module/dict/unihan-compiler.rb Mon Dec 4 11:45:26 2006 @@ -3,17 +3,19 @@ require 'uconv' unihan_txt = ARGV.shift -base = ARGV.shift -split_size = Integer(ARGV.shift) DO_NOT_EDIT_HEADER = <<-EOH /* DO NOT EDIT! - THIS FILE IS GENERATED BY Unihan.txt: + THIS FILE IS GENERATED FROM Unihan.txt: ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip */ EOH +def ucs4_to_utf8(ucs4) + Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) +end + def parse_unihan_txt(unihan_txt) cache = "#{unihan_txt}.cache" if File.exists?(cache) and (File.mtime(cache) > File.mtime(unihan_txt)) @@ -50,94 +52,10 @@ result end -def generate_header(base, split_size, infos) - header = "#{base}.h" - block_macro = "__#{header.gsub(/[\.-]/, '_').upcase}__" +def generate_header(infos) + prefix = "tomoe_unihan_" - File.open(header, "w") do |f| - f.puts <<-EOH -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#{DO_NOT_EDIT_HEADER} - -#ifndef #{block_macro} -#define #{block_macro} - -#include - -G_BEGIN_DECLS - -GPtrArray *_tomoe_unihan_create (void); -EOH - - split_size.times do |i| - f.puts("void _tomoe_unihan_create#{i} (GPtrArray *array);") - end - - f.puts <<-EOF - -G_END_DECLS - -#endif /* #{block_macro} */ - -/* -vi:ts=4:nowrap:ai:expandtab -*/ -EOF - end -end - -def generate_split_body(f, i, ucs4, info) - utf8 = Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) - - f.puts <<-EOB - chr = tomoe_char_new (); - tomoe_char_set_utf8 (chr, "#{utf8}"); -EOB - - n_strokes = info["kTotalStrokes"] - f.puts " tomoe_char_set_n_strokes (chr, #{n_strokes});" if n_strokes - - variant = info["kCompatibilityVariant"] - if variant - variant = variant.sub(/^U\+2?/, '') - f.puts <<-EOB - tomoe_char_set_variant (chr, "#{variant}"); -EOB - end - - kuns = info["kJapaneseKun"] - if kuns - kuns.split.each do |kun| - f.puts <<-EOB - reading = tomoe_reading_new (TOMOE_READING_JA_KUN, "#{kun}"); - tomoe_char_add_reading (chr, reading); - g_object_unref (reading); -EOB - end - end - - ons = info["kJapaneseOn"] - if ons - ons.split.each do |on| - f.puts <<-EOB - reading = tomoe_reading_new (TOMOE_READING_JA_ON, "#{on}"); - tomoe_char_add_reading (chr, reading); - g_object_unref (reading); -EOB - end - end - - f.puts <<-EOB - array->pdata[#{i}] = chr; - -EOB -end - -def generate_split(base, chunk_index, base_index, infos) - c_file = "#{base}#{chunk_index}.c" - - File.open(c_file, "w") do |f| - f.puts <<-EOH + puts <<-EOH /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #{DO_NOT_EDIT_HEADER} @@ -145,71 +63,66 @@ #include -void -_tomoe_unihan_create#{chunk_index} (GPtrArray *array) -{ - TomoeChar *chr; - TomoeReading *reading; +typedef struct _TomoeUnihanReading TomoeUnihanReading; +typedef struct _TomoeUnihanInfo TomoeUnihanInfo; - reading = NULL; +struct _TomoeUnihanReading { + TomoeReadingType type; + gchar *reading; +}; + +struct _TomoeUnihanInfo { + gchar *utf8; + gint n_strokes; + gchar **variants; + TomoeUnihanReading *readings; +}; EOH - infos.each_with_index do |(ucs4, info), i| - generate_split_body(f, base_index + i, ucs4, info) - end - - f.puts <<-EOF -} -EOF - end -end - -def generate_main(base, split_size, infos) - main_file = "#{base}.c" - - chunk = infos.size / split_size - split_size.times do |i| - next_i = i + 1 - if next_i == split_size - split_infos = infos[(i * chunk)..-1] - else - split_infos = infos[(i * chunk)...(next_i * chunk)] + infos.each_with_index do |(ucs4, info), i| + variants = info["kCompatibilityVariant"] + if variants + info["have_variants"] = true + puts("static gchar *#{prefix}variant_#{ucs4}[] = {") + variants.split.each do |variant| + utf8_variant = ucs4_to_utf8(variant.sub(/^U\+2?/, '')) + puts(" \"#{utf8_variant}\",") + end + puts("};"); + end + + readings = [] + kuns = info["kJapaneseKun"] + ons = info["kJapaneseOn"] + if kuns + readings.concat(kuns.split.collect {|x| ["TOMOE_READING_JA_KUN", x]}) + end + if ons + readings.concat(ons.split.collect {|x| ["TOMOE_READING_JA_ON", x]}) + end + + unless readings.empty? + info["have_readings"] = true + puts("static TomoeUnihanReading #{prefix}reading_#{ucs4}[] = {") + readings.each do |type, reading| + puts(" {#{type}, \"#{reading}\"},") + end + puts("};") end - generate_split(base, i, i * chunk, split_infos) end - File.open(main_file, "w") do |f| - f.puts <<-EOH -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#{DO_NOT_EDIT_HEADER} - -#include "tomoe-unihan.h" - -#include - -GPtrArray * -_tomoe_unihan_create (void) -{ - GPtrArray *array; - - array = g_ptr_array_sized_new (#{infos.size}); - array->len = #{infos.size}; - -EOH - - split_size.times do |i| - f.puts " _tomoe_unihan_create#{i} (array);" - end - - f.puts <<-EOF + puts("static TomoeUnihanInfo #{prefix}infos[] = {") + infos.each_with_index do |(ucs4, info), i| + info["utf8"] = utf8 = Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) + n_strokes = info["kTotalStrokes"] || -1 + variants = info["have_variants"] ? "#{prefix}variant_#{ucs4}" : "NULL" + readings = info["have_readings"] ? "#{prefix}reading_#{ucs4}" : "NULL" - return array; -} -EOF + puts(" {\"#{utf8}\", #{n_strokes}, #{variants}, #{readings}},") end + puts("};") end infos = parse_unihan_txt(unihan_txt) -generate_header(base, split_size, infos) -generate_main(base, split_size, infos) +generate_header(infos) From kous users.sourceforge.jp Mon Dec 4 12:02:18 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 12:02:18 +0900 Subject: [Tomoe-cvs 1575] CVS update: tomoe Message-ID: <20061204030218.274B72AC173@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.373 tomoe/ChangeLog:1.374 --- tomoe/ChangeLog:1.373 Mon Dec 4 11:45:26 2006 +++ tomoe/ChangeLog Mon Dec 4 12:02:17 2006 @@ -1,5 +1,7 @@ 2006-12-04 Kouhei Sutou + * module/dict/tomoe-dict-unihan.c: set default name is NULL. + * module/dict/Makefile.am, module/dict/unihan-compiler.rb: improved strange Unihan compiling. Index: tomoe/configure.in diff -u tomoe/configure.in:1.37 tomoe/configure.in:1.38 --- tomoe/configure.in:1.37 Mon Dec 4 11:45:26 2006 +++ tomoe/configure.in Mon Dec 4 12:02:18 2006 @@ -162,9 +162,9 @@ dictdir="${libdir}/\$(PACKAGE)/dict" AC_SUBST(dictdir) +use_unihan=yes AC_ARG_ENABLE(unihan, - [ --enable-unihan use Unihan detabase - (You may not be able to compile)], + [ --disable-unihan disable Unihan detabase], [use_unihan=$enableval], [use_unihan=$enableval]) AM_CONDITIONAL([WITH_UNIHAN], [test "$use_unihan" = "yes"]) From kous users.sourceforge.jp Mon Dec 4 12:02:18 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 12:02:18 +0900 Subject: [Tomoe-cvs 1576] CVS update: tomoe/test Message-ID: <20061204030218.504262AC175@users.sourceforge.jp> Index: tomoe/test/run-spec.rb diff -u tomoe/test/run-spec.rb:1.3 tomoe/test/run-spec.rb:1.4 --- tomoe/test/run-spec.rb:1.3 Sun Nov 26 16:30:37 2006 +++ tomoe/test/run-spec.rb Mon Dec 4 12:02:18 2006 @@ -11,12 +11,6 @@ $LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby")) $LOAD_PATH.unshift(File.join(test_dir)) -class Spec::Runner::Formatter::ProgressBarFormatter - def format_backtrace(backtrace) - super.sub(/\A([^:]+:\d+)$/, '\\1:') - end -end - ARGV.unshift("--diff") Dir.glob(File.join(test_dir, "*_spec.rb")).each do |file| From kous users.sourceforge.jp Mon Dec 4 12:02:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 12:02:46 +0900 Subject: [Tomoe-cvs 1577] CVS update: tomoe/module/dict Message-ID: <20061204030246.132F02AC173@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.1 tomoe/module/dict/tomoe-dict-unihan.c:1.2 --- tomoe/module/dict/tomoe-dict-unihan.c:1.1 Mon Dec 4 00:04:42 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Mon Dec 4 12:02:45 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.1 2006/12/03 15:04:42 kous Exp $ + * $Id: tomoe-dict-unihan.c,v 1.2 2006/12/04 03:02:45 kous Exp $ */ #include @@ -124,7 +124,7 @@ "name", "Name", "The name of the dictionary", - DEFAULT_NAME, + NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } From kous users.sourceforge.jp Mon Dec 4 12:06:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 12:06:17 +0900 Subject: [Tomoe-cvs 1578] CVS update: tomoe Message-ID: <20061204030617.A75372AC175@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.374 tomoe/ChangeLog:1.375 --- tomoe/ChangeLog:1.374 Mon Dec 4 12:02:17 2006 +++ tomoe/ChangeLog Mon Dec 4 12:06:17 2006 @@ -1,5 +1,8 @@ 2006-12-04 Kouhei Sutou + * lib/tomoe-config.c: added Unihan dictionary backend to system + dictionary. + * module/dict/tomoe-dict-unihan.c: set default name is NULL. * module/dict/Makefile.am, module/dict/unihan-compiler.rb: From kous users.sourceforge.jp Mon Dec 4 12:06:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 12:06:17 +0900 Subject: [Tomoe-cvs 1579] CVS update: tomoe/lib Message-ID: <20061204030617.D3FB92AC176@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.46 tomoe/lib/tomoe-config.c:1.47 --- tomoe/lib/tomoe-config.c:1.46 Mon Dec 4 00:04:42 2006 +++ tomoe/lib/tomoe-config.c Mon Dec 4 12:06:17 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.46 2006/12/03 15:04:42 kous Exp $ + * $Id: tomoe-config.c,v 1.47 2006/12/04 03:06:17 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -321,10 +321,16 @@ { const gchar *filename; GDir *gdir; + TomoeDict *dict; + + dict = tomoe_dict_new ("unihan", NULL); + if (dict) { + tomoe_shelf_add_dict (shelf, dict); + g_object_unref (dict); + } gdir = g_dir_open (TOMOEDATADIR, 0, NULL); while ((filename = g_dir_read_name (gdir))) { - TomoeDict *dict; gchar *path; if (!g_str_has_suffix (filename, ".xml")) From makeinu users.sourceforge.jp Mon Dec 4 13:18:29 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 13:18:29 +0900 Subject: [Tomoe-cvs 1580] CVS update: libtomoe-gtk Message-ID: <20061204041829.CFA1A2AC179@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.212 libtomoe-gtk/ChangeLog:1.213 --- libtomoe-gtk/ChangeLog:1.212 Mon Dec 4 11:00:39 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 13:18:29 2006 @@ -1,6 +1,14 @@ 2006-12-04 Takuro Ashie - * lib/tomoe-reading-search.[ch]: Add "selected" signal, but never emited + * src/tomoe-reading-search.[ch]: Emit "selected" signal, and add + tomoe_reading_search_get_selected_tomoe_char. + * src/tomoe-handwriting.[ch]: Rename + tomoe_handwriting_get_selected_candidate to ~_get_selected_tomoe_char. + * src/tomoe-window.c: Follow above changes/ + +2006-12-04 Takuro Ashie + + * src/tomoe-reading-search.[ch]: Add "selected" signal, but never emited yet. 2006-12-01 Takuro Ashie From makeinu users.sourceforge.jp Mon Dec 4 13:18:30 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 13:18:30 +0900 Subject: [Tomoe-cvs 1581] CVS update: libtomoe-gtk/src Message-ID: <20061204041830.052322AC17C@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.1 libtomoe-gtk/src/tomoe-handwriting.c:1.2 --- libtomoe-gtk/src/tomoe-handwriting.c:1.1 Fri Dec 1 14:48:06 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Mon Dec 4 13:18:29 2006 @@ -306,7 +306,7 @@ } TomoeChar * -tomoe_handwriting_get_selected_candidate (TomoeHandwriting *handwriting) +tomoe_handwriting_get_selected_tomoe_char (TomoeHandwriting *handwriting) { TomoeHandwritingPrivate *priv; Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.2 libtomoe-gtk/src/tomoe-handwriting.h:1.3 --- libtomoe-gtk/src/tomoe-handwriting.h:1.2 Fri Dec 1 15:22:40 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Mon Dec 4 13:18:29 2006 @@ -55,7 +55,7 @@ GType tomoe_handwriting_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_handwriting_new (void); GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); -TomoeChar *tomoe_handwriting_get_selected_candidate +TomoeChar *tomoe_handwriting_get_selected_tomoe_char (TomoeHandwriting *handwriting); GtkWidget *tomoe_handwriting_get_button_area (TomoeHandwriting *handwriting); Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.13 libtomoe-gtk/src/tomoe-reading-search.c:1.14 --- libtomoe-gtk/src/tomoe-reading-search.c:1.13 Mon Dec 4 11:00:39 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 4 13:18:29 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * @@ -33,9 +34,11 @@ }; enum { - CHAR_COLUMN, + TERMINATOR = -1, + UTF8_COLUMN, STROKECOUNT_COLUMN, READING_COLUMN, + CHAR_COLUMN, COLUMN_COUNT }; @@ -45,6 +48,7 @@ TomoeContext *context; GtkListStore *result_store; GtkWidget *input; + GtkWidget *treeview; }; #define TOMOE_READING_SEARCH_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_READING_SEARCH, TomoeReadingSearchPrivate)) @@ -53,10 +57,13 @@ static void dispose (GObject *object); -static void on_find_button_clicked (GtkButton *button, - gpointer user_data); -static void on_input_entry_activate (GtkEntry *entry, - gpointer *user_data); +static void on_find_button_clicked (GtkButton *button, + gpointer user_data); +static void on_input_entry_activate (GtkEntry *entry, + gpointer *user_data); +static void on_result_view_button_release_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); static guint reading_search_signals[LAST_SIGNAL] = { 0 }; @@ -133,9 +140,14 @@ gtk_widget_show (button); /* result view */ - priv->result_store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + priv->result_store = gtk_list_store_new (COLUMN_COUNT, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_OBJECT); list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->result_store)); + priv->treeview = list; result_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); gtk_tree_selection_set_mode (result_sel, GTK_SELECTION_SINGLE); @@ -152,7 +164,7 @@ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("Character"), renderer, - "text", CHAR_COLUMN, + "text", UTF8_COLUMN, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); renderer = gtk_cell_renderer_text_new (); @@ -168,11 +180,9 @@ NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); gtk_widget_set_size_request (list, 400, 320); - /* - g_signal_connect (G_OBJECT (page->char_sel), "changed", - G_CALLBACK (on_selection_changed), + g_signal_connect (G_OBJECT (list), "button-release-event", + G_CALLBACK (on_result_view_button_release_event), (gpointer) page); - */ gtk_widget_show (list); gtk_widget_show (hbox); @@ -254,10 +264,12 @@ } gtk_list_store_append (priv->result_store, &iter); gtk_list_store_set (priv->result_store, &iter, - CHAR_COLUMN, tomoe_char_get_utf8 (c), + UTF8_COLUMN, tomoe_char_get_utf8 (c), STROKECOUNT_COLUMN, strokes_text, - READING_COLUMN, readings_text, - -1); + READING_COLUMN, readings_text, + CHAR_COLUMN, c, + TERMINATOR); + g_free (readings_text); g_free (strokes_text); } @@ -266,6 +278,38 @@ g_list_free (result); } +TomoeChar * +tomoe_reading_search_get_selected_tomoe_char (TomoeReadingSearch *page) +{ + TomoeReadingSearchPrivate *priv; + GtkTreeModel *treemodel; + GtkTreePath *treepath = NULL; + GtkTreeIter iter; + TomoeChar *c = NULL; + + g_return_val_if_fail (TOMOE_IS_READING_SEARCH (page), NULL); + priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + treemodel = GTK_TREE_MODEL (priv->result_store); + + gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->treeview), &treepath, NULL); + if (!treepath) + return NULL; + if (!gtk_tree_model_get_iter (treemodel, &iter, treepath)) + return NULL; + + gtk_tree_model_get (treemodel, &iter, + CHAR_COLUMN, &c, + TERMINATOR); + + /* reference count should be increased by user */ + if (c) g_object_unref (c); + + gtk_tree_path_free (treepath); + + return c; +} + static void on_input_entry_activate (GtkEntry *entry, gpointer *user_data) { @@ -285,6 +329,19 @@ tomoe_reading_search_start_search (page); } + +static void +on_result_view_button_release_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + if (tomoe_reading_search_get_selected_tomoe_char (page)) + g_signal_emit (G_OBJECT (page), + reading_search_signals[SELECTED_SIGNAL], 0); +} /* * vi:ts=4:nowrap:ai:expandtab */ Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.2 libtomoe-gtk/src/tomoe-reading-search.h:1.3 --- libtomoe-gtk/src/tomoe-reading-search.h:1.2 Mon Dec 4 11:00:39 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Mon Dec 4 13:18:29 2006 @@ -54,6 +54,8 @@ GtkWidget *tomoe_reading_search_new (void); void tomoe_reading_search_set_context (TomoeReadingSearch *page, TomoeContext *context); +TomoeChar *tomoe_reading_search_get_selected_tomoe_char + (TomoeReadingSearch *page); G_END_DECLS Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.30 libtomoe-gtk/src/tomoe-window.c:1.31 --- libtomoe-gtk/src/tomoe-window.c:1.30 Fri Dec 1 17:34:17 2006 +++ libtomoe-gtk/src/tomoe-window.c Mon Dec 4 13:18:29 2006 @@ -63,10 +63,12 @@ static void dispose (GObject *object); static void destroy (GtkObject *object); -static void on_handwriting_candidate_selected (TomoeHandwriting *view, - gpointer user_data); -static void on_gucharmap_selected (TomoeGucharmap *gucharmap, - gpointer data); +static void on_handwriting_candidate_selected (TomoeHandwriting *view, + gpointer user_data); +static void on_reading_search_selected (TomoeReadingSearch *search, + gpointer user_data); +static void on_gucharmap_selected (TomoeGucharmap *gucharmap, + gpointer data); static guint window_signals[LAST_SIGNAL] = { 0 }; @@ -155,11 +157,9 @@ priv->reading = widget; reading_search = TOMOE_READING_SEARCH (priv->reading); tomoe_reading_search_set_context (reading_search, priv->context); -#if 0 - g_signal_connect (G_OBJECT (widget), "hoge", + g_signal_connect (G_OBJECT (widget), "selected", G_CALLBACK (on_reading_search_selected), (gpointer) window); -#endif gtk_widget_show (widget); tomoe_window_append_page (window, widget, gtk_image_new_from_file (TOMOE_SEARCHING_ICON), @@ -281,6 +281,17 @@ } static void +on_reading_search_selected (TomoeReadingSearch *search, gpointer user_data) +{ + TomoeWindow *window; + g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + + window = TOMOE_WINDOW (user_data); + g_signal_emit (G_OBJECT (window), + window_signals[SELECTED_SIGNAL], 0); +} + +static void on_gucharmap_selected (TomoeGucharmap *gucharmap, gpointer user_data) { TomoeWindow *window; @@ -304,9 +315,11 @@ page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook)); current_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num); -#warning FIX ME! +#warning FIXME! if (TOMOE_IS_HANDWRITING (current_page)) - return tomoe_handwriting_get_selected_candidate (TOMOE_HANDWRITING (priv->handwriting)); + return tomoe_handwriting_get_selected_tomoe_char (TOMOE_HANDWRITING (current_page)); + else if (TOMOE_IS_READING_SEARCH (current_page)) + return tomoe_reading_search_get_selected_tomoe_char (TOMOE_READING_SEARCH (current_page)); return NULL; } From kous users.sourceforge.jp Mon Dec 4 13:36:04 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:04 +0900 Subject: [Tomoe-cvs 1582] CVS update: tomoe/module/dict Message-ID: <20061204043604.069442AC17E@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-unihan.c diff -u /dev/null tomoe/module/dict/tomoe-unihan.c:1.1 --- /dev/null Mon Dec 4 13:36:03 2006 +++ tomoe/module/dict/tomoe-unihan.c Mon Dec 4 13:36:03 2006 @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + DO NOT EDIT! + THIS FILE IS GENERATED BY Unihan.txt: + ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip +*/ + + +#include "tomoe-unihan.h" +#include "tomoe-unihan-data.h" + +GPtrArray * +_tomoe_unihan_create (void) +{ + GPtrArray *array; + gint i, infos_size; + + infos_size = G_N_ELEMENTS (tomoe_unihan_infos); + array = g_ptr_array_sized_new (infos_size); + array->len = infos_size; + + for (i = 0; i < infos_size; i++) { + TomoeUnihanInfo info; + TomoeChar *chr; + gint j, len; + + info = tomoe_unihan_infos[i]; + + chr = tomoe_char_new (); + tomoe_char_set_utf8 (chr, info.utf8); + + if (info.n_strokes) + tomoe_char_set_n_strokes (chr, info.n_strokes); + + if (info.variants) { + len = G_N_ELEMENTS (info.variants); + for (j = 0; j < len; j++) { + tomoe_char_set_variant (chr, info.variants[j]); + } + } + + if (info.readings) { + len = G_N_ELEMENTS (info.readings); + for (j = 0; j < len; j++) { + TomoeReading *reading; + TomoeUnihanReading reading_info; + + reading_info = info.readings[j]; + reading = tomoe_reading_new (reading_info.type, + reading_info.reading); + tomoe_char_add_reading (chr, reading); + g_object_unref (reading); + } + } + + array->pdata[i] = chr; + } + + return array; +} Index: tomoe/module/dict/tomoe-unihan.h diff -u /dev/null tomoe/module/dict/tomoe-unihan.h:1.1 --- /dev/null Mon Dec 4 13:36:03 2006 +++ tomoe/module/dict/tomoe-unihan.h Mon Dec 4 13:36:03 2006 @@ -0,0 +1,38 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-unihan.h,v 1.1 2006/12/04 04:36:03 kous Exp $ + */ + +#ifndef __TOMOE_UNIHAN_H__ +#define __TOMOE_UNIHAN_H__ + +#include + +G_BEGIN_DECLS + +GPtrArray *_tomoe_unihan_create (void); + +G_END_DECLS + +#endif /* __TOMOE_UNIHAN_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ From kous users.sourceforge.jp Mon Dec 4 13:36:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:47 +0900 Subject: [Tomoe-cvs 1583] CVS update: tomoe Message-ID: <20061204043647.A04A42AC0C7@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.375 tomoe/ChangeLog:1.376 --- tomoe/ChangeLog:1.375 Mon Dec 4 12:06:17 2006 +++ tomoe/ChangeLog Mon Dec 4 13:36:47 2006 @@ -1,5 +1,21 @@ 2006-12-04 Kouhei Sutou + * module/recognizer/tomoe-recognizer-simple.c: had stroke list + dictionary. + + * lib/tomoe-recognizer.[ch] (tomoe_recognizer_search): removed + TomoeDict argument. + + * lib/tomoe-context.c: supported recognizer parameter. + + * ext/ruby/tomoe-rb-recognizer.c: supported dictionary parameter. + + * ext/ruby/tomoe-rb-dict.c: removed unused parameter for making + Unihan dictionary. + + * test/context_spec.rb, benchmark/search-by-recognizer.rb: + followed the changes. + * lib/tomoe-config.c: added Unihan dictionary backend to system dictionary. From kous users.sourceforge.jp Mon Dec 4 13:36:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:47 +0900 Subject: [Tomoe-cvs 1584] CVS update: tomoe/benchmark Message-ID: <20061204043647.D252F2AC17E@users.sourceforge.jp> Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.3 tomoe/benchmark/search-by-recognizer.rb:1.4 --- tomoe/benchmark/search-by-recognizer.rb:1.3 Thu Nov 30 18:10:12 2006 +++ tomoe/benchmark/search-by-recognizer.rb Mon Dec 4 13:36:47 2006 @@ -10,7 +10,12 @@ require 'tomoe-spec-utils' -context = Tomoe::Context.new +dict = Tomoe::Dict.new("xml", + "filename" => File.join(TomoeSpecUtils::Config.data_dir, + "all.xml"), + "editable" => false) +recognizer = Tomoe::Recognizer.new("simple", dict) +context = Tomoe::Context.new("recognizer" => recognizer) config_file = TomoeSpecUtils::Config.make_config_file context.load_config(config_file.path) From kous users.sourceforge.jp Mon Dec 4 13:36:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:48 +0900 Subject: [Tomoe-cvs 1585] CVS update: tomoe/ext/ruby Message-ID: <20061204043648.0859F2AC0C7@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.13 tomoe/ext/ruby/tomoe-rb-dict.c:1.14 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.13 Mon Dec 4 00:04:42 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Mon Dec 4 13:36:47 2006 @@ -46,13 +46,7 @@ "editable", RVAL2CBOOL(editable), NULL); } else if (strcmp(name, "unihan") == 0) { - VALUE rb_dict_name; - gchar *dict_name; - - rb_dict_name = rb_hash_aref(props, CSTR2RVAL("name")); - dict_name = NIL_P(rb_dict_name) ? NULL : RVAL2CSTR(rb_dict_name); - - dict = tomoe_dict_new(name, "name", dict_name, NULL); + dict = tomoe_dict_new(name, NULL); } else { rb_raise(rb_eArgError, "unknown dictionary type: %s", name); dict = NULL; Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.3 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.4 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.3 Wed Nov 29 11:53:11 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Mon Dec 4 13:36:47 2006 @@ -15,9 +15,17 @@ } static VALUE -tr_s_new(VALUE self, VALUE name) +tr_s_new(int argc, VALUE *argv, VALUE self) { - return GOBJ2RVAL(tomoe_recognizer_new(RVAL2CSTR(name), NULL)); + TomoeRecognizer *recognizer; + VALUE name, dict; + + rb_scan_args(argc, argv, "11", &name, &dict); + + recognizer = tomoe_recognizer_new(RVAL2CSTR(name), + "dictionary", RVAL2TDIC(dict), + NULL); + return GOBJ2RVAL(recognizer); } void @@ -30,5 +38,5 @@ rb_define_singleton_method(cTomoeRecognizer, "load", tr_s_load, 1); rb_define_singleton_method(cTomoeRecognizer, "unload", tr_s_unload, 0); - rb_define_singleton_method(cTomoeRecognizer, "new", tr_s_new, 1); + rb_define_singleton_method(cTomoeRecognizer, "new", tr_s_new, -1); } From kous users.sourceforge.jp Mon Dec 4 13:36:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:48 +0900 Subject: [Tomoe-cvs 1586] CVS update: tomoe/lib Message-ID: <20061204043648.319232AC17E@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.42 tomoe/lib/tomoe-context.c:1.43 --- tomoe/lib/tomoe-context.c:1.42 Fri Dec 1 09:39:14 2006 +++ tomoe/lib/tomoe-context.c Mon Dec 4 13:36:48 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.42 2006/12/01 00:39:14 ikezoe Exp $ + * $Id: tomoe-context.c,v 1.43 2006/12/04 04:36:48 kous Exp $ */ #include "tomoe-dict.h" @@ -30,6 +30,11 @@ #define TOMOE_CONTEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_CONTEXT, TomoeContextPrivate)) +enum { + PROP_0, + PROP_RECOGNIZER +}; + typedef struct _TomoeContextPrivate TomoeContextPrivate; struct _TomoeContextPrivate { @@ -40,7 +45,15 @@ G_DEFINE_TYPE (TomoeContext, tomoe_context, G_TYPE_OBJECT) -static void tomoe_context_dispose (GObject *object); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); static void tomoe_context_class_init (TomoeContextClass *klass) @@ -49,7 +62,19 @@ gobject_class = G_OBJECT_CLASS (klass); - gobject_class->dispose = tomoe_context_dispose; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + g_object_class_install_property ( + gobject_class, + PROP_RECOGNIZER, + g_param_spec_object ( + "recognizer", + "Recognizer", + "The recognizer of the context", + TOMOE_TYPE_RECOGNIZER, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private (gobject_class, sizeof (TomoeContextPrivate)); } @@ -82,21 +107,57 @@ } static void -tomoe_context_dispose (GObject *object) +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { TomoeContextPrivate *priv = TOMOE_CONTEXT_GET_PRIVATE (object); - if (priv->shelf) { - g_object_unref (priv->shelf); + switch (prop_id) { + case PROP_RECOGNIZER: + if (priv->recognizer) + g_object_unref (priv->recognizer); + priv->recognizer = g_value_get_object (value); + if (priv->recognizer) + g_object_ref (priv->recognizer); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } +} - if (priv->config) { - g_object_unref (priv->config); + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeContextPrivate *priv = TOMOE_CONTEXT_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_RECOGNIZER: + g_value_set_object (value, priv->recognizer); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } +} + +static void +dispose (GObject *object) +{ + TomoeContextPrivate *priv = TOMOE_CONTEXT_GET_PRIVATE (object); - if (priv->recognizer) { + if (priv->shelf) + g_object_unref (priv->shelf); + if (priv->config) + g_object_unref (priv->config); + if (priv->recognizer) g_object_unref (priv->recognizer); - } priv->shelf = NULL; priv->config = NULL; @@ -141,32 +202,29 @@ tomoe_context_search_by_strokes (TomoeContext *context, TomoeWriting *input) { TomoeContextPrivate *priv; - TomoeShelf *shelf; - GList *names, *name; GList *matched = NULL; - if (!context) return matched; + g_return_val_if_fail (context, matched); if (!input) return matched; priv = TOMOE_CONTEXT_GET_PRIVATE (context); - shelf = priv->shelf; - if (!shelf) return matched; + if (!priv->recognizer) { + TomoeShelf *shelf; + TomoeDict *dict; - names = tomoe_shelf_get_dict_names(shelf); - if (!names) return matched; + shelf = priv->shelf; + g_return_val_if_fail (shelf, matched); - if (!priv->recognizer) - priv->recognizer = tomoe_recognizer_new ("simple", NULL); + dict = tomoe_shelf_get_dict (shelf, "TOMOE Strokelist Dictionary"); + g_return_val_if_fail (dict, matched); - for (name = names; name; name = name->next) { - TomoeDict *dict; - - dict = tomoe_shelf_get_dict(shelf, name->data); - matched = g_list_concat (tomoe_recognizer_search (priv->recognizer, - dict, input), - matched); + priv->recognizer = tomoe_recognizer_new ("simple", + "dictionary", dict, + NULL); } - matched = g_list_sort (matched, _candidate_compare_func); + + matched = g_list_sort (tomoe_recognizer_search (priv->recognizer, input), + _candidate_compare_func); return matched; } Index: tomoe/lib/tomoe-context.h diff -u tomoe/lib/tomoe-context.h:1.31 tomoe/lib/tomoe-context.h:1.32 --- tomoe/lib/tomoe-context.h:1.31 Fri Dec 1 10:31:45 2006 +++ tomoe/lib/tomoe-context.h Mon Dec 4 13:36:48 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.h,v 1.31 2006/12/01 01:31:45 ikezoe Exp $ + * $Id: tomoe-context.h,v 1.32 2006/12/04 04:36:48 kous Exp $ */ #ifndef __TOMOE_CONTEXT_H__ @@ -51,9 +51,9 @@ GObjectClass parent_class; }; -GType tomoe_context_get_type (void) G_GNUC_CONST; +GType tomoe_context_get_type (void) G_GNUC_CONST; -TomoeContext *tomoe_context_new (void); +TomoeContext *tomoe_context_new (void); void tomoe_context_load_config (TomoeContext *ctx, const gchar *config_file); Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.21 tomoe/lib/tomoe-recognizer.c:1.22 --- tomoe/lib/tomoe-recognizer.c:1.21 Fri Dec 1 11:11:32 2006 +++ tomoe/lib/tomoe-recognizer.c Mon Dec 4 13:36:48 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.21 2006/12/01 02:11:32 ikezoe Exp $ + * $Id: tomoe-recognizer.c,v 1.22 2006/12/04 04:36:48 kous Exp $ */ #include @@ -86,16 +86,16 @@ /** * tomoe_recognizer_search: * @recognizer: a TomoeRecognizer object. - * @dict: a #TomoeDict object. * @input: a #TomoeWriting object for matching. * * Match strokes of TomoeChar with TomoeWriting. * - * Return value: A newly-allocated list of #TomoeCandidate. The each #TomoeCandidate should be also freed with g_object_unref. - */ + * Return value: A newly-allocated list of + * #TomoeCandidate. The each #TomoeCandidate should be also + * freed with g_object_unref. + */ GList * -tomoe_recognizer_search (TomoeRecognizer *recognizer, - TomoeDict *dict, TomoeWriting *input) +tomoe_recognizer_search (TomoeRecognizer *recognizer, TomoeWriting *input) { TomoeRecognizerClass *klass; @@ -103,7 +103,7 @@ klass = TOMOE_RECOGNIZER_GET_CLASS (recognizer); if (klass->search) - return klass->search (recognizer, dict, input); + return klass->search (recognizer, input); else return NULL; } Index: tomoe/lib/tomoe-recognizer.h diff -u tomoe/lib/tomoe-recognizer.h:1.19 tomoe/lib/tomoe-recognizer.h:1.20 --- tomoe/lib/tomoe-recognizer.h:1.19 Fri Dec 1 10:33:34 2006 +++ tomoe/lib/tomoe-recognizer.h Mon Dec 4 13:36:48 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.h,v 1.19 2006/12/01 01:33:34 ikezoe Exp $ + * $Id: tomoe-recognizer.h,v 1.20 2006/12/04 04:36:48 kous Exp $ */ #ifndef __TOMOE_RECOGNIZER_H__ @@ -50,7 +50,6 @@ GObjectClass parent_class; GList *(*search) (TomoeRecognizer *recognizer, - TomoeDict *dict, TomoeWriting *input); }; @@ -65,7 +64,6 @@ ...); GList *tomoe_recognizer_search (TomoeRecognizer *recognizer, - TomoeDict *dict, TomoeWriting *input); G_END_DECLS From kous users.sourceforge.jp Mon Dec 4 13:36:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:48 +0900 Subject: [Tomoe-cvs 1587] CVS update: tomoe/module/recognizer Message-ID: <20061204043648.55ADB2AC0C7@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.2 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.3 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.2 Thu Nov 30 15:27:19 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Mon Dec 4 13:36:48 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.2 2006/11/30 06:27:19 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.3 2006/12/04 04:36:48 kous Exp $ */ #include @@ -34,13 +34,18 @@ #define TOMOE_IS_RECOGNIZER_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_RECOGNIZER_SIMPLE)) #define TOMOE_RECOGNIZER_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_RECOGNIZER_SIMPLE, TomoeRecognizerSimpleClass)) +enum { + PROP_0, + PROP_DICTIONARY +}; typedef struct _TomoeRecognizerSimple TomoeRecognizerSimple; typedef struct _TomoeRecognizerSimpleClass TomoeRecognizerSimpleClass; struct _TomoeRecognizerSimple { - TomoeRecognizer object; + TomoeRecognizer object; + TomoeDict *dict; }; struct _TomoeRecognizerSimpleClass @@ -49,19 +54,49 @@ }; static GType tomoe_type_recognizer_simple = 0; +static GObjectClass *parent_class; -static GList *search (TomoeRecognizer *recognizer, - TomoeDict *dict, - TomoeWriting *input); +static GObject *constructor (GType type, + guint n_props, + GObjectConstructParam *props); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static GList *search (TomoeRecognizer *recognizer, + TomoeWriting *input); static void class_init (TomoeRecognizerSimpleClass *klass) { + GObjectClass *gobject_class; TomoeRecognizerClass *recognizer_class; - recognizer_class = TOMOE_RECOGNIZER_CLASS (klass); + parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->constructor = constructor; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + recognizer_class = TOMOE_RECOGNIZER_CLASS (klass); recognizer_class->search = search; + + g_object_class_install_property ( + gobject_class, + PROP_DICTIONARY, + g_param_spec_object ( + "dictionary", + "Dictionary", + "The dictionary of the recognizer", + TOMOE_TYPE_DICT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } static void @@ -110,10 +145,91 @@ first_property, var_args); } +static GObject * +constructor (GType type, guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GObjectClass *klass = G_OBJECT_CLASS (parent_class); + TomoeRecognizerSimple *recognizer; + + object = klass->constructor (type, n_props, props); + recognizer = TOMOE_RECOGNIZER_SIMPLE (object); + + if (!recognizer->dict) { + g_warning ("dictionary isn't set for TomoeRecognizerSimple."); + g_object_unref (object); + object = NULL; + } + + return object; +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeRecognizerSimple *recognizer = TOMOE_RECOGNIZER_SIMPLE (object); + + switch (prop_id) { + case PROP_DICTIONARY: + if (recognizer->dict) + g_object_unref (recognizer->dict); + recognizer->dict = g_value_get_object (value); + if (recognizer->dict) + g_object_ref (recognizer->dict); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeRecognizerSimple *recognizer = TOMOE_RECOGNIZER_SIMPLE (object); + + switch (prop_id) { + case PROP_DICTIONARY: + g_value_set_object (value, recognizer->dict); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + TomoeRecognizerSimple *recognizer; + + recognizer = TOMOE_RECOGNIZER_SIMPLE (object); + + if (recognizer->dict) + g_object_unref (recognizer->dict); + + recognizer->dict = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + static GList * -search (TomoeRecognizer *recognizer, TomoeDict *dict, TomoeWriting *input) +search (TomoeRecognizer *_recognizer, TomoeWriting *input) { - return _tomoe_recognizer_simple_get_candidates (recognizer, dict, input); + TomoeRecognizerSimple *recognizer; + + recognizer = TOMOE_RECOGNIZER_SIMPLE (_recognizer); + return _tomoe_recognizer_simple_get_candidates (_recognizer, + recognizer->dict, + input); } /* From kous users.sourceforge.jp Mon Dec 4 13:36:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:36:48 +0900 Subject: [Tomoe-cvs 1588] CVS update: tomoe/test Message-ID: <20061204043648.7AE2B2AC17E@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.19 tomoe/test/context_spec.rb:1.20 --- tomoe/test/context_spec.rb:1.19 Thu Nov 30 18:13:15 2006 +++ tomoe/test/context_spec.rb Mon Dec 4 13:36:48 2006 @@ -4,7 +4,11 @@ @@context = nil def context return @@context if @@context - @@context = Tomoe::Context.new + dict = Tomoe::Dict.new("xml", + "filename" => File.join(data_dir, "all.xml"), + "editable" => false) + recognizer = Tomoe::Recognizer.new("simple", dict) + @@context = Tomoe::Context.new("recognizer" => recognizer) @@context.load_config(@config_file.path) @@context end From kous users.sourceforge.jp Mon Dec 4 13:41:09 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 4 Dec 2006 13:41:09 +0900 Subject: [Tomoe-cvs 1589] CVS update: tomoe Message-ID: <20061204044109.2D2662AC17E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.376 tomoe/ChangeLog:1.377 --- tomoe/ChangeLog:1.376 Mon Dec 4 13:36:47 2006 +++ tomoe/ChangeLog Mon Dec 4 13:41:09 2006 @@ -2,14 +2,11 @@ * module/recognizer/tomoe-recognizer-simple.c: had stroke list dictionary. - * lib/tomoe-recognizer.[ch] (tomoe_recognizer_search): removed TomoeDict argument. * lib/tomoe-context.c: supported recognizer parameter. - * ext/ruby/tomoe-rb-recognizer.c: supported dictionary parameter. - * ext/ruby/tomoe-rb-dict.c: removed unused parameter for making Unihan dictionary. From makeinu users.sourceforge.jp Mon Dec 4 14:08:11 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:08:11 +0900 Subject: [Tomoe-cvs 1590] CVS update: libtomoe-gtk Message-ID: <20061204050811.C3C492AC181@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.213 libtomoe-gtk/ChangeLog:1.214 --- libtomoe-gtk/ChangeLog:1.213 Mon Dec 4 13:18:29 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 14:08:11 2006 @@ -1,5 +1,16 @@ 2006-12-04 Takuro Ashie + * src/tomoe-gucharma.[ch]: Add tomoe_gucharmap_get_selected_char and + tomoe_gucharmap_get_selected_tomoe_char. + * src/tomoe-handwriting.[ch]: Add tomoe_handwriting_get_selected_char. + * src/tomoe-reading-search.[ch]: + Add tomoe_reading_search_get_selected_char. + * src/tomoe-window.[ch]: Add tomoe_window_get_selected_char. + Rename tomoe_window_get_selected_tomoe_char to + tomoe_winidow_get_selected_candidate. + +2006-12-04 Takuro Ashie + * src/tomoe-reading-search.[ch]: Emit "selected" signal, and add tomoe_reading_search_get_selected_tomoe_char. * src/tomoe-handwriting.[ch]: Rename From makeinu users.sourceforge.jp Mon Dec 4 14:08:11 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:08:11 +0900 Subject: [Tomoe-cvs 1591] CVS update: libtomoe-gtk/src Message-ID: <20061204050811.0059B2AC182@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.14 libtomoe-gtk/src/tomoe-gucharmap.c:1.15 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.14 Fri Dec 1 18:03:40 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Mon Dec 4 14:08:11 2006 @@ -32,6 +32,7 @@ GtkWidget *chapters_combobox; GucharmapChapters *chapters; GucharmapCharmap *charmap; + gchar *selected; }; #define TOMOE_GUCHARMAP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_GUCHARMAP, TomoeGucharmapPrivate)) @@ -83,6 +84,8 @@ TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); GtkWidget *vbox, *hbox, *combobox, *widget; + priv->selected = NULL; + gtk_table_resize (GTK_TABLE (page), 1, 1); gtk_table_set_homogeneous (GTK_TABLE (page), FALSE); @@ -144,7 +147,14 @@ { TomoeGucharmapPrivate *priv = TOMOE_GUCHARMAP_GET_PRIVATE (object); - priv->charmap = NULL; + priv->chapters_type_combobox = NULL; + priv->chapters_combobox = NULL; + priv->chapters = NULL; + priv->charmap = NULL; + if (priv->selected) { + g_free (priv->selected); + priv->selected = NULL; + } if (G_OBJECT_CLASS(tomoe_gucharmap_parent_class)->dispose) G_OBJECT_CLASS(tomoe_gucharmap_parent_class)->dispose(object); @@ -161,18 +171,38 @@ return priv->charmap; } -gunichar -tomoe_gucharmap_get_selected (TomoeGucharmap *page) +const gchar * +tomoe_gucharmap_get_selected_char (TomoeGucharmap *page) { TomoeGucharmapPrivate *priv; GucharmapTable *table; + gunichar c; + gchar buf[7]; + gint bytes; g_return_val_if_fail (TOMOE_IS_GUCHARMAP (page), NULL); priv = TOMOE_GUCHARMAP_GET_PRIVATE (page); table = GUCHARMAP_TABLE (priv->charmap->chartable); - return gucharmap_table_get_active_character (table); + c = gucharmap_table_get_active_character (table); + bytes = g_unichar_to_utf8(c, buf); + + if (bytes > 0 && bytes < 7) { + buf[bytes] = '\0'; + g_free (priv->selected); + priv->selected = g_strdup (buf); + return priv->selected; + } + + return NULL; +} + +TomoeChar * +tomoe_gucharmap_get_selected_tomoe_char (TomoeGucharmap *page) +{ + /* not implemented yet */ + return NULL; } static void Index: libtomoe-gtk/src/tomoe-gucharmap.h diff -u libtomoe-gtk/src/tomoe-gucharmap.h:1.4 libtomoe-gtk/src/tomoe-gucharmap.h:1.5 --- libtomoe-gtk/src/tomoe-gucharmap.h:1.4 Fri Dec 1 18:03:40 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.h Mon Dec 4 14:08:11 2006 @@ -24,6 +24,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -51,11 +52,12 @@ }; -GType tomoe_gucharmap_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_gucharmap_new (void); -GucharmapCharmap * - tomoe_gucharmap_get_charmap (TomoeGucharmap *gucharmap); -gunichar tomoe_gucharmap_get_selected(TomoeGucharmap *gucharmap); +GType tomoe_gucharmap_get_type (void) G_GNUC_CONST; +GtkWidget *tomoe_gucharmap_new (void); +GucharmapCharmap *tomoe_gucharmap_get_charmap (TomoeGucharmap *gucharmap); +const gchar *tomoe_gucharmap_get_selected_char (TomoeGucharmap *gucharmap); +TomoeChar *tomoe_gucharmap_get_selected_tomoe_char + (TomoeGucharmap *gucharmap); G_END_DECLS Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.2 libtomoe-gtk/src/tomoe-handwriting.c:1.3 --- libtomoe-gtk/src/tomoe-handwriting.c:1.2 Mon Dec 4 13:18:29 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Mon Dec 4 14:08:11 2006 @@ -305,6 +305,21 @@ return priv->button_area; } +const gchar * +tomoe_handwriting_get_selected_char (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + TomoeChar *c; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + c = tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); + if (!c) return NULL; + + return tomoe_char_get_utf8 (c); +} + TomoeChar * tomoe_handwriting_get_selected_tomoe_char (TomoeHandwriting *handwriting) { Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.3 libtomoe-gtk/src/tomoe-handwriting.h:1.4 --- libtomoe-gtk/src/tomoe-handwriting.h:1.3 Mon Dec 4 13:18:29 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Mon Dec 4 14:08:11 2006 @@ -52,13 +52,15 @@ }; -GType tomoe_handwriting_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_handwriting_new (void); -GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); -TomoeChar *tomoe_handwriting_get_selected_tomoe_char - (TomoeHandwriting *handwriting); -GtkWidget *tomoe_handwriting_get_button_area - (TomoeHandwriting *handwriting); +GType tomoe_handwriting_get_type (void) G_GNUC_CONST; +GtkWidget *tomoe_handwriting_new (void); +GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); +const gchar *tomoe_handwriting_get_selected_char + (TomoeHandwriting *handwriting); +TomoeChar *tomoe_handwriting_get_selected_tomoe_char + (TomoeHandwriting *handwriting); +GtkWidget *tomoe_handwriting_get_button_area + (TomoeHandwriting *handwriting); G_END_DECLS Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.14 libtomoe-gtk/src/tomoe-reading-search.c:1.15 --- libtomoe-gtk/src/tomoe-reading-search.c:1.14 Mon Dec 4 13:18:29 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 4 14:08:11 2006 @@ -278,6 +278,21 @@ g_list_free (result); } +const gchar * +tomoe_reading_search_get_selected_char (TomoeReadingSearch *page) +{ + TomoeReadingSearchPrivate *priv; + TomoeChar *c; + + g_return_val_if_fail (TOMOE_IS_READING_SEARCH (page), NULL); + priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + c = tomoe_reading_search_get_selected_tomoe_char (page); + if (!c) return NULL; + + return tomoe_char_get_utf8 (c); +} + TomoeChar * tomoe_reading_search_get_selected_tomoe_char (TomoeReadingSearch *page) { @@ -336,7 +351,6 @@ gpointer user_data) { TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); - TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); if (tomoe_reading_search_get_selected_tomoe_char (page)) g_signal_emit (G_OBJECT (page), Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.3 libtomoe-gtk/src/tomoe-reading-search.h:1.4 --- libtomoe-gtk/src/tomoe-reading-search.h:1.3 Mon Dec 4 13:18:29 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Mon Dec 4 14:08:11 2006 @@ -50,12 +50,14 @@ }; -GType tomoe_reading_search_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_reading_search_new (void); -void tomoe_reading_search_set_context (TomoeReadingSearch *page, - TomoeContext *context); -TomoeChar *tomoe_reading_search_get_selected_tomoe_char - (TomoeReadingSearch *page); +GType tomoe_reading_search_get_type (void) G_GNUC_CONST; +GtkWidget *tomoe_reading_search_new (void); +void tomoe_reading_search_set_context (TomoeReadingSearch *page, + TomoeContext *context); +const gchar *tomoe_reading_search_get_selected_char + (TomoeReadingSearch *page); +TomoeChar *tomoe_reading_search_get_selected_tomoe_char + (TomoeReadingSearch *page); G_END_DECLS Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.31 libtomoe-gtk/src/tomoe-window.c:1.32 --- libtomoe-gtk/src/tomoe-window.c:1.31 Mon Dec 4 13:18:29 2006 +++ libtomoe-gtk/src/tomoe-window.c Mon Dec 4 14:08:11 2006 @@ -302,24 +302,47 @@ window_signals[SELECTED_SIGNAL], 0); } +const gchar * +tomoe_window_get_selected_char (TomoeWindow *window) +{ + TomoeWindowPrivate *priv; + gint page_num; + gpointer widget; + + g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); + priv = TOMOE_WINDOW_GET_PRIVATE (window); + + page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook)); + widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num); + + if (TOMOE_IS_HANDWRITING (widget)) + return tomoe_handwriting_get_selected_char (widget); + else if (TOMOE_IS_READING_SEARCH (widget)) + return tomoe_reading_search_get_selected_char (widget); + else if (TOMOE_IS_GUCHARMAP (widget)) + return tomoe_gucharmap_get_selected_char (widget); + return NULL; +} + TomoeChar * -tomoe_window_get_selected_candidate (TomoeWindow *window) +tomoe_window_get_selected_tomoe_char (TomoeWindow *window) { TomoeWindowPrivate *priv; gint page_num; - GtkWidget *current_page; + gpointer widget; g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); priv = TOMOE_WINDOW_GET_PRIVATE (window); page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook)); - current_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num); + widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num); -#warning FIXME! - if (TOMOE_IS_HANDWRITING (current_page)) - return tomoe_handwriting_get_selected_tomoe_char (TOMOE_HANDWRITING (current_page)); - else if (TOMOE_IS_READING_SEARCH (current_page)) - return tomoe_reading_search_get_selected_tomoe_char (TOMOE_READING_SEARCH (current_page)); + if (TOMOE_IS_HANDWRITING (widget)) + return tomoe_handwriting_get_selected_tomoe_char (widget); + else if (TOMOE_IS_READING_SEARCH (widget)) + return tomoe_reading_search_get_selected_tomoe_char (widget); + else if (TOMOE_IS_GUCHARMAP (widget)) + return tomoe_gucharmap_get_selected_tomoe_char (widget); return NULL; } Index: libtomoe-gtk/src/tomoe-window.h diff -u libtomoe-gtk/src/tomoe-window.h:1.12 libtomoe-gtk/src/tomoe-window.h:1.13 --- libtomoe-gtk/src/tomoe-window.h:1.12 Fri Dec 1 14:12:36 2006 +++ libtomoe-gtk/src/tomoe-window.h Mon Dec 4 14:08:11 2006 @@ -49,16 +49,17 @@ }; -GType tomoe_window_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_window_new (void); -GtkWidget *tomoe_window_get_canvas (TomoeWindow *window); -GtkWidget *tomoe_window_get_notebook(TomoeWindow *window); -void tomoe_window_append_page (TomoeWindow *window, GtkWidget *page, - GtkWidget *label, const gchar *label_text); -GtkWidget *tomoe_window_get_handwriting_page - (TomoeWindow *window); -TomoeChar *tomoe_window_get_selected_candidate - (TomoeWindow *window); +GType tomoe_window_get_type (void) G_GNUC_CONST; +GtkWidget *tomoe_window_new (void); +GtkWidget *tomoe_window_get_canvas (TomoeWindow *window); +GtkWidget *tomoe_window_get_notebook (TomoeWindow *window); +void tomoe_window_append_page (TomoeWindow *window, + GtkWidget *page, + GtkWidget *label, + const gchar *label_text); +GtkWidget *tomoe_window_get_handwriting_page (TomoeWindow *window); +const gchar *tomoe_window_get_selected_char (TomoeWindow *window); +TomoeChar *tomoe_window_get_selected_tomoe_char (TomoeWindow *window); G_END_DECLS #endif /* __TOMOE_WINDOW_H__ */ From makeinu users.sourceforge.jp Mon Dec 4 14:26:53 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:26:53 +0900 Subject: [Tomoe-cvs 1592] CVS update: libtomoe-gtk/src Message-ID: <20061204052653.D82F82AC183@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.15 libtomoe-gtk/src/tomoe-gucharmap.c:1.16 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.15 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Mon Dec 4 14:26:53 2006 @@ -48,6 +48,9 @@ static void on_gucharmap_activate (GucharmapCharmap *charmap, gunichar ch, gpointer data); +static void on_gucharmap_button_release (GtkWidget *widget, + GdkEventButton *event, + gpointer data); static guint gucharmap_signals[LAST_SIGNAL] = { 0 }; @@ -140,6 +143,10 @@ g_signal_connect (G_OBJECT (priv->charmap->chartable), "activate", G_CALLBACK (on_gucharmap_activate), (gpointer) page); + g_signal_connect (G_OBJECT (priv->charmap->chartable), + "button-release-event", + G_CALLBACK (on_gucharmap_button_release), + (gpointer) page); } static void @@ -257,3 +264,16 @@ g_signal_emit (G_OBJECT (gucharmap), gucharmap_signals[SELECTED_SIGNAL], 0); } + +static void +on_gucharmap_button_release (GtkWidget *widget, + GdkEventButton *event, + gpointer data) +{ +#if 0 + TomoeGucharmap *gucharmap = TOMOE_GUCHARMAP (data); + + g_signal_emit (G_OBJECT (gucharmap), + gucharmap_signals[SELECTED_SIGNAL], 0); +#endif +} From makeinu users.sourceforge.jp Mon Dec 4 14:33:43 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:33:43 +0900 Subject: [Tomoe-cvs 1593] CVS update: libtomoe-gtk/src Message-ID: <20061204053343.216C22AC184@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.4 libtomoe-gtk/src/tomoe-handwriting.h:1.5 --- libtomoe-gtk/src/tomoe-handwriting.h:1.4 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Mon Dec 4 14:33:42 2006 @@ -55,12 +55,12 @@ GType tomoe_handwriting_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_handwriting_new (void); GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); +GtkWidget *tomoe_handwriting_get_button_area + (TomoeHandwriting *handwriting); const gchar *tomoe_handwriting_get_selected_char (TomoeHandwriting *handwriting); TomoeChar *tomoe_handwriting_get_selected_tomoe_char (TomoeHandwriting *handwriting); -GtkWidget *tomoe_handwriting_get_button_area - (TomoeHandwriting *handwriting); G_END_DECLS From makeinu users.sourceforge.jp Mon Dec 4 14:36:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:36:00 +0900 Subject: [Tomoe-cvs 1594] CVS update: libtomoe-gtk/src Message-ID: <20061204053600.9321B2AC184@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.3 libtomoe-gtk/src/tomoe-handwriting.c:1.4 --- libtomoe-gtk/src/tomoe-handwriting.c:1.3 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Mon Dec 4 14:36:00 2006 @@ -221,6 +221,43 @@ return TOMOE_HANDWRITING_GET_PRIVATE (handwriting)->canvas; } +GtkWidget * +tomoe_handwriting_get_button_area (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + return priv->button_area; +} + +const gchar * +tomoe_handwriting_get_selected_char (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + TomoeChar *c; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + c = tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); + if (!c) return NULL; + + return tomoe_char_get_utf8 (c); +} + +TomoeChar * +tomoe_handwriting_get_selected_tomoe_char (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + return tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); +} + static void on_canvas_stroke_added (TomoeCanvas *canvas, gpointer user_data) { @@ -294,43 +331,6 @@ tomoe_handwriting_set_sensitive (handwriting); } -GtkWidget * -tomoe_handwriting_get_button_area (TomoeHandwriting *handwriting) -{ - TomoeHandwritingPrivate *priv; - - g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); - priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); - - return priv->button_area; -} - -const gchar * -tomoe_handwriting_get_selected_char (TomoeHandwriting *handwriting) -{ - TomoeHandwritingPrivate *priv; - TomoeChar *c; - - g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); - priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); - - c = tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); - if (!c) return NULL; - - return tomoe_char_get_utf8 (c); -} - -TomoeChar * -tomoe_handwriting_get_selected_tomoe_char (TomoeHandwriting *handwriting) -{ - TomoeHandwritingPrivate *priv; - - g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); - priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); - - return tomoe_char_table_get_selected (TOMOE_CHAR_TABLE (priv->candidates_view)); -} - #ifdef ENABLE_DUMPSTROKE static void on_dump_button_clicked (GtkButton *button, gpointer user_data) From makeinu users.sourceforge.jp Mon Dec 4 14:57:07 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:57:07 +0900 Subject: [Tomoe-cvs 1595] CVS update: libtomoe-gtk Message-ID: <20061204055707.E9F3A2AC18A@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.214 libtomoe-gtk/ChangeLog:1.215 --- libtomoe-gtk/ChangeLog:1.214 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 14:57:07 2006 @@ -1,5 +1,9 @@ 2006-12-04 Takuro Ashie + * src/tomoe-reading-search.[ch]: Add a "Clear" button. + +2006-12-04 Takuro Ashie + * src/tomoe-gucharma.[ch]: Add tomoe_gucharmap_get_selected_char and tomoe_gucharmap_get_selected_tomoe_char. * src/tomoe-handwriting.[ch]: Add tomoe_handwriting_get_selected_char. From makeinu users.sourceforge.jp Mon Dec 4 14:57:08 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 14:57:08 +0900 Subject: [Tomoe-cvs 1596] CVS update: libtomoe-gtk/src Message-ID: <20061204055708.212A02AC18C@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.15 libtomoe-gtk/src/tomoe-reading-search.c:1.16 --- libtomoe-gtk/src/tomoe-reading-search.c:1.15 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 4 14:57:08 2006 @@ -59,6 +59,8 @@ static void on_find_button_clicked (GtkButton *button, gpointer user_data); +static void on_clear_button_clicked (GtkButton *button, + gpointer user_data); static void on_input_entry_activate (GtkEntry *entry, gpointer *user_data); static void on_result_view_button_release_event (GtkWidget *widget, @@ -117,6 +119,8 @@ vbox = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 8); gtk_table_attach_defaults (GTK_TABLE (page), vbox, 0, 1, 0, 1); + + /* input area */ hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -139,6 +143,13 @@ (gpointer) page); gtk_widget_show (button); + button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 4); + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (on_clear_button_clicked), + (gpointer) page); + gtk_widget_show (button); + /* result view */ priv->result_store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, @@ -278,6 +289,18 @@ g_list_free (result); } +static void +tomoe_reading_search_clear (TomoeReadingSearch *page) +{ + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + g_return_if_fail (GTK_IS_LIST_STORE (priv->result_store)); + g_return_if_fail (GTK_IS_ENTRY (priv->input)); + + gtk_entry_set_text (GTK_ENTRY (priv->input), ""); + gtk_list_store_clear (priv->result_store); +} + const gchar * tomoe_reading_search_get_selected_char (TomoeReadingSearch *page) { @@ -346,6 +369,16 @@ } static void +on_clear_button_clicked (GtkButton *button, gpointer user_data) +{ + TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); + + g_return_if_fail (TOMOE_IS_READING_SEARCH (page)); + + tomoe_reading_search_clear (page); +} + +static void on_result_view_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) From makeinu users.sourceforge.jp Mon Dec 4 15:05:26 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 15:05:26 +0900 Subject: [Tomoe-cvs 1597] CVS update: libtomoe-gtk/src Message-ID: <20061204060526.9C8002AC18A@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.16 libtomoe-gtk/src/tomoe-reading-search.c:1.17 --- libtomoe-gtk/src/tomoe-reading-search.c:1.16 Mon Dec 4 14:57:08 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 4 15:05:26 2006 @@ -384,6 +384,13 @@ gpointer user_data) { TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + gboolean exist; + + exist = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->treeview), + event->x, event->y, + NULL, NULL, NULL, NULL); + if (!exist) return; if (tomoe_reading_search_get_selected_tomoe_char (page)) g_signal_emit (G_OBJECT (page), From makeinu users.sourceforge.jp Mon Dec 4 15:39:26 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 15:39:26 +0900 Subject: [Tomoe-cvs 1598] CVS update: libtomoe-gtk Message-ID: <20061204063926.B5D202AC06B@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.215 libtomoe-gtk/ChangeLog:1.216 --- libtomoe-gtk/ChangeLog:1.215 Mon Dec 4 14:57:07 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 15:39:26 2006 @@ -1,6 +1,7 @@ 2006-12-04 Takuro Ashie * src/tomoe-reading-search.[ch]: Add a "Clear" button. + Set sort column id. 2006-12-04 Takuro Ashie From makeinu users.sourceforge.jp Mon Dec 4 15:39:26 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 15:39:26 +0900 Subject: [Tomoe-cvs 1599] CVS update: libtomoe-gtk/src Message-ID: <20061204063926.E1D1F2AC0BD@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.17 libtomoe-gtk/src/tomoe-reading-search.c:1.18 --- libtomoe-gtk/src/tomoe-reading-search.c:1.17 Mon Dec 4 15:05:26 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 4 15:39:26 2006 @@ -37,6 +37,7 @@ TERMINATOR = -1, UTF8_COLUMN, STROKECOUNT_COLUMN, + STROKECOUNT_TEXT_COLUMN, READING_COLUMN, CHAR_COLUMN, COLUMN_COUNT @@ -153,6 +154,7 @@ /* result view */ priv->result_store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, + G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT); @@ -172,23 +174,31 @@ gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 4); gtk_widget_show (scrolled_window); + /* character column */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("Character"), renderer, "text", UTF8_COLUMN, NULL); + gtk_tree_view_column_set_sort_column_id (column, UTF8_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); + + /* stroke count column */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("Stroke count"), renderer, - "text", STROKECOUNT_COLUMN, + "text", STROKECOUNT_TEXT_COLUMN, NULL); + gtk_tree_view_column_set_sort_column_id (column, STROKECOUNT_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); + + /* reading column */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("Reading"), renderer, "text", READING_COLUMN, NULL); + gtk_tree_view_column_set_sort_column_id (column, READING_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); gtk_widget_set_size_request (list, 400, 320); g_signal_connect (G_OBJECT (list), "button-release-event", @@ -275,10 +285,11 @@ } gtk_list_store_append (priv->result_store, &iter); gtk_list_store_set (priv->result_store, &iter, - UTF8_COLUMN, tomoe_char_get_utf8 (c), - STROKECOUNT_COLUMN, strokes_text, - READING_COLUMN, readings_text, - CHAR_COLUMN, c, + UTF8_COLUMN, tomoe_char_get_utf8 (c), + STROKECOUNT_COLUMN, strokes, + STROKECOUNT_TEXT_COLUMN, strokes_text, + READING_COLUMN, readings_text, + CHAR_COLUMN, c, TERMINATOR); g_free (readings_text); From makeinu users.sourceforge.jp Mon Dec 4 15:54:13 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 15:54:13 +0900 Subject: [Tomoe-cvs 1600] CVS update: libtomoe-gtk Message-ID: <20061204065413.745082AC031@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.216 libtomoe-gtk/ChangeLog:1.217 --- libtomoe-gtk/ChangeLog:1.216 Mon Dec 4 15:39:26 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 15:54:13 2006 @@ -1,5 +1,10 @@ 2006-12-04 Takuro Ashie + * po/POTFILES.in, po/ja.po: Update. + * src/tomoe-gucharmap.c, src/tomoe-window.c: Minor fix. + +2006-12-04 Takuro Ashie + * src/tomoe-reading-search.[ch]: Add a "Clear" button. Set sort column id. From makeinu users.sourceforge.jp Mon Dec 4 15:54:13 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 15:54:13 +0900 Subject: [Tomoe-cvs 1601] CVS update: libtomoe-gtk/po Message-ID: <20061204065413.A209C2AC0BD@users.sourceforge.jp> Index: libtomoe-gtk/po/POTFILES.in diff -u libtomoe-gtk/po/POTFILES.in:1.4 libtomoe-gtk/po/POTFILES.in:1.5 --- libtomoe-gtk/po/POTFILES.in:1.4 Tue Nov 28 12:47:47 2006 +++ libtomoe-gtk/po/POTFILES.in Mon Dec 4 15:54:13 2006 @@ -1,9 +1,10 @@ +src/tomoe-canvas.c src/tomoe-char-table.c +src/tomoe-details.c +src/tomoe-edit-char.c src/tomoe-edit-meta.c -src/tomoe-canvas.c src/tomoe-edit-strokes.c -src/tomoe-details.c +src/tomoe-gucharmap.c +src/tomoe-handwriting.c src/tomoe-reading-search.c -src/tomoe-stroke-search.c src/tomoe-window.c -src/tomoe-edit-char.c Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.8 libtomoe-gtk/po/ja.po:1.9 --- libtomoe-gtk/po/ja.po:1.8 Wed Nov 29 12:31:50 2006 +++ libtomoe-gtk/po/ja.po Mon Dec 4 15:54:13 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-11-29 12:21+0900\n" +"POT-Creation-Date: 2006-12-04 15:50+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -10,24 +10,16 @@ "Content-Type: text/plain; charset=EUC-JP\n" "Content-Transfer-Encoding: 8bit\n" -#: src/tomoe-edit-meta.c:116 -msgid "Edit meta information" -msgstr "᥿Խ" - -#: src/tomoe-edit-strokes.c:100 src/tomoe-details.c:114 -#: src/tomoe-edit-char.c:83 +#: src/tomoe-details.c:114 src/tomoe-edit-char.c:83 +#: src/tomoe-edit-strokes.c:100 msgid "TomoeChar object" msgstr "" -#: src/tomoe-edit-strokes.c:101 src/tomoe-details.c:115 -#: src/tomoe-edit-char.c:84 +#: src/tomoe-details.c:115 src/tomoe-edit-char.c:84 +#: src/tomoe-edit-strokes.c:101 msgid "The Object of TomoeChar" msgstr "" -#: src/tomoe-edit-strokes.c:166 src/tomoe-details.c:195 -msgid "Edit Strokes" -msgstr "ȥԽ" - #: src/tomoe-details.c:122 src/tomoe-edit-char.c:91 msgid "TomoeDict object" msgstr "" @@ -44,6 +36,10 @@ msgid "Edit Character" msgstr "ʸԽ" +#: src/tomoe-details.c:195 src/tomoe-edit-strokes.c:166 +msgid "Edit Strokes" +msgstr "ȥԽ" + #: src/tomoe-details.c:203 msgid "Edit Meta" msgstr "᥿Խ" @@ -52,7 +48,7 @@ msgid "Basic information" msgstr "ܾ" -#: src/tomoe-details.c:268 src/tomoe-reading-search.c:142 +#: src/tomoe-details.c:268 src/tomoe-reading-search.c:179 msgid "Character" msgstr "ʸ" @@ -68,37 +64,61 @@ msgid "Readings" msgstr "ɤ" -#: src/tomoe-reading-search.c:105 +#: src/tomoe-edit-char.c:116 +msgid "Change character" +msgstr "ʸѹ" + +#: src/tomoe-edit-char.c:129 +msgid "New character:" +msgstr "ʸ:" + +#: src/tomoe-edit-meta.c:116 +msgid "Edit meta information" +msgstr "᥿Խ" + +#: src/tomoe-gucharmap.c:111 +msgid "Unicode block" +msgstr "Unicode֥å" + +#: src/tomoe-gucharmap.c:112 +msgid "Unicode script" +msgstr "UnicodeץȽ" + +#: src/tomoe-gucharmap.c:136 +msgid "Writing" +msgstr "" + +#: src/tomoe-handwriting.c:350 +msgid "Select the file name for dump" +msgstr "" + +#: src/tomoe-reading-search.c:128 msgid "Reading:" msgstr "ɤ:" -#: src/tomoe-reading-search.c:148 +#: src/tomoe-reading-search.c:188 msgid "Stroke count" msgstr "" -#: src/tomoe-reading-search.c:154 +#: src/tomoe-reading-search.c:197 msgid "Reading" msgstr "ɤ" -#: src/tomoe-stroke-search.c:348 -msgid "Select the file name for dump" -msgstr "" - -#: src/tomoe-window.c:88 src/tomoe-window.c:109 +#: src/tomoe-window.c:123 src/tomoe-window.c:153 msgid "Handwriting recognition" msgstr "ǧ" -#: src/tomoe-window.c:117 +#: src/tomoe-window.c:166 msgid "Search with reading " msgstr "ɤߤǸ" -#: src/tomoe-edit-char.c:116 -msgid "Change character" -msgstr "ʸѹ" - -#: src/tomoe-edit-char.c:129 -msgid "New character:" -msgstr "ʸ:" +#: src/tomoe-window.c:177 +msgid "Unicode table" +msgstr "Unicodeɽ" + +#, fuzzy +#~ msgid "Character table" +#~ msgstr "ʸξܺ" #~ msgid "Use" #~ msgstr "" From makeinu users.sourceforge.jp Mon Dec 4 15:54:13 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 15:54:13 +0900 Subject: [Tomoe-cvs 1602] CVS update: libtomoe-gtk/src Message-ID: <20061204065413.C7C392AC031@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.16 libtomoe-gtk/src/tomoe-gucharmap.c:1.17 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.16 Mon Dec 4 14:26:53 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Mon Dec 4 15:54:13 2006 @@ -17,6 +17,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H + #include +#endif + #include #include "tomoe-gucharmap.h" Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.32 libtomoe-gtk/src/tomoe-window.c:1.33 --- libtomoe-gtk/src/tomoe-window.c:1.32 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-window.c Mon Dec 4 15:54:13 2006 @@ -174,7 +174,7 @@ gtk_widget_show (widget); tomoe_window_append_page (window, widget, gtk_image_new_from_file (TOMOE_GUCHARMAP_ICON), - _("Character table")); + _("Unicode table")); } static void From makeinu users.sourceforge.jp Mon Dec 4 18:10:34 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 18:10:34 +0900 Subject: [Tomoe-cvs 1603] CVS update: libtomoe-gtk Message-ID: <20061204091034.914F12AC18A@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.217 libtomoe-gtk/ChangeLog:1.218 --- libtomoe-gtk/ChangeLog:1.217 Mon Dec 4 15:54:13 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 18:10:34 2006 @@ -1,5 +1,10 @@ 2006-12-04 Takuro Ashie + * src/tomoe-window.[ch]: Add getters for reading search page and + gucharmap page. Remove tomoe_widnow_get_canvas. + +2006-12-04 Takuro Ashie + * po/POTFILES.in, po/ja.po: Update. * src/tomoe-gucharmap.c, src/tomoe-window.c: Minor fix. From makeinu users.sourceforge.jp Mon Dec 4 18:10:34 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 18:10:34 +0900 Subject: [Tomoe-cvs 1604] CVS update: libtomoe-gtk/src Message-ID: <20061204091034.B50A42AC18B@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.33 libtomoe-gtk/src/tomoe-window.c:1.34 --- libtomoe-gtk/src/tomoe-window.c:1.33 Mon Dec 4 15:54:13 2006 +++ libtomoe-gtk/src/tomoe-window.c Mon Dec 4 18:10:34 2006 @@ -208,21 +208,6 @@ NULL)); } -GtkWidget * -tomoe_window_get_canvas (TomoeWindow *window) -{ - TomoeWindowPrivate *priv; - TomoeHandwriting *handwriting_page; - g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); - - priv = TOMOE_WINDOW_GET_PRIVATE (window); - g_return_val_if_fail (TOMOE_IS_HANDWRITING (priv->handwriting), - NULL); - - handwriting_page = TOMOE_HANDWRITING (priv->handwriting); - return tomoe_handwriting_get_canvas (handwriting_page); -} - void tomoe_window_append_page (TomoeWindow *window, GtkWidget *page, @@ -269,37 +254,20 @@ return TOMOE_WINDOW_GET_PRIVATE (window)->notebook; } -static void -on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data) +GtkWidget * +tomoe_window_get_reading_search_page (TomoeWindow *window) { - TomoeWindow *window; - g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); - window = TOMOE_WINDOW (user_data); - g_signal_emit (G_OBJECT (window), - window_signals[SELECTED_SIGNAL], 0); + return TOMOE_WINDOW_GET_PRIVATE (window)->reading; } -static void -on_reading_search_selected (TomoeReadingSearch *search, gpointer user_data) +GtkWidget * +tomoe_window_get_gucharmap_page (TomoeWindow *window) { - TomoeWindow *window; - g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); - window = TOMOE_WINDOW (user_data); - g_signal_emit (G_OBJECT (window), - window_signals[SELECTED_SIGNAL], 0); -} - -static void -on_gucharmap_selected (TomoeGucharmap *gucharmap, gpointer user_data) -{ - TomoeWindow *window; - g_return_if_fail (TOMOE_IS_WINDOW (user_data)); - - window = TOMOE_WINDOW (user_data); - g_signal_emit (G_OBJECT (window), - window_signals[SELECTED_SIGNAL], 0); + return TOMOE_WINDOW_GET_PRIVATE (window)->chartable; } const gchar * @@ -346,6 +314,39 @@ return NULL; } +static void +on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data) +{ + TomoeWindow *window; + g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + + window = TOMOE_WINDOW (user_data); + g_signal_emit (G_OBJECT (window), + window_signals[SELECTED_SIGNAL], 0); +} + +static void +on_reading_search_selected (TomoeReadingSearch *search, gpointer user_data) +{ + TomoeWindow *window; + g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + + window = TOMOE_WINDOW (user_data); + g_signal_emit (G_OBJECT (window), + window_signals[SELECTED_SIGNAL], 0); +} + +static void +on_gucharmap_selected (TomoeGucharmap *gucharmap, gpointer user_data) +{ + TomoeWindow *window; + g_return_if_fail (TOMOE_IS_WINDOW (user_data)); + + window = TOMOE_WINDOW (user_data); + g_signal_emit (G_OBJECT (window), + window_signals[SELECTED_SIGNAL], 0); +} + /* * vi:ts=4:nowrap:ai:expandtab */ Index: libtomoe-gtk/src/tomoe-window.h diff -u libtomoe-gtk/src/tomoe-window.h:1.13 libtomoe-gtk/src/tomoe-window.h:1.14 --- libtomoe-gtk/src/tomoe-window.h:1.13 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-window.h Mon Dec 4 18:10:34 2006 @@ -51,13 +51,17 @@ GType tomoe_window_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_window_new (void); -GtkWidget *tomoe_window_get_canvas (TomoeWindow *window); + GtkWidget *tomoe_window_get_notebook (TomoeWindow *window); void tomoe_window_append_page (TomoeWindow *window, GtkWidget *page, GtkWidget *label, const gchar *label_text); + GtkWidget *tomoe_window_get_handwriting_page (TomoeWindow *window); +GtkWidget *tomoe_window_get_reading_search_page (TomoeWindow *window); +GtkWidget *tomoe_window_get_gucharmap_page (TomoeWindow *window); + const gchar *tomoe_window_get_selected_char (TomoeWindow *window); TomoeChar *tomoe_window_get_selected_tomoe_char (TomoeWindow *window); G_END_DECLS From makeinu users.sourceforge.jp Mon Dec 4 18:22:06 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 18:22:06 +0900 Subject: [Tomoe-cvs 1605] CVS update: libtomoe-gtk Message-ID: <20061204092206.3FE7E2AC18B@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.218 libtomoe-gtk/ChangeLog:1.219 --- libtomoe-gtk/ChangeLog:1.218 Mon Dec 4 18:10:34 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 18:22:06 2006 @@ -1,5 +1,9 @@ 2006-12-04 Takuro Ashie + * src/tomoe-gtk.h: Add missing header files.. + +2006-12-04 Takuro Ashie + * src/tomoe-window.[ch]: Add getters for reading search page and gucharmap page. Remove tomoe_widnow_get_canvas. From makeinu users.sourceforge.jp Mon Dec 4 18:22:06 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 18:22:06 +0900 Subject: [Tomoe-cvs 1606] CVS update: libtomoe-gtk/src Message-ID: <20061204092206.691212AC18D@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gtk.h diff -u libtomoe-gtk/src/tomoe-gtk.h:1.7 libtomoe-gtk/src/tomoe-gtk.h:1.8 --- libtomoe-gtk/src/tomoe-gtk.h:1.7 Fri Dec 1 14:48:06 2006 +++ libtomoe-gtk/src/tomoe-gtk.h Mon Dec 4 18:22:06 2006 @@ -25,5 +25,7 @@ #include #include #include +#include +#include #endif /* __TOMOE_GTK_H_INCLUDED__ */ From makeinu users.sourceforge.jp Mon Dec 4 23:20:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 23:20:00 +0900 Subject: [Tomoe-cvs 1607] CVS update: libtomoe-gtk Message-ID: <20061204142000.E45A72AC0BA@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.219 libtomoe-gtk/ChangeLog:1.220 --- libtomoe-gtk/ChangeLog:1.219 Mon Dec 4 18:22:06 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 4 23:20:00 2006 @@ -1,5 +1,10 @@ 2006-12-04 Takuro Ashie + * src/tomoe-canvas.c: Call parent class's function first in + size_allocate(). + +2006-12-04 Takuro Ashie + * src/tomoe-gtk.h: Add missing header files.. 2006-12-04 Takuro Ashie From makeinu users.sourceforge.jp Mon Dec 4 23:20:01 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 23:20:01 +0900 Subject: [Tomoe-cvs 1608] CVS update: libtomoe-gtk/po Message-ID: <20061204142001.1C6062AC0E1@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.9 libtomoe-gtk/po/ja.po:1.10 --- libtomoe-gtk/po/ja.po:1.9 Mon Dec 4 15:54:13 2006 +++ libtomoe-gtk/po/ja.po Mon Dec 4 23:20:00 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-04 15:50+0900\n" +"POT-Creation-Date: 2006-12-04 20:45+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" From makeinu users.sourceforge.jp Mon Dec 4 23:20:01 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 4 Dec 2006 23:20:01 +0900 Subject: [Tomoe-cvs 1609] CVS update: libtomoe-gtk/src Message-ID: <20061204142001.77AF32AC0BA@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.41 libtomoe-gtk/src/tomoe-canvas.c:1.42 --- libtomoe-gtk/src/tomoe-canvas.c:1.41 Mon Nov 27 18:24:26 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Mon Dec 4 23:20:01 2006 @@ -314,6 +314,9 @@ { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (widget); + if (GTK_WIDGET_CLASS (tomoe_canvas_parent_class)->size_allocate) + GTK_WIDGET_CLASS (tomoe_canvas_parent_class)->size_allocate (widget, allocation); + priv->width = allocation->width; priv->height = allocation->height; priv->size = allocation->width; @@ -328,8 +331,6 @@ -1); tomoe_canvas_refresh (TOMOE_CANVAS (widget)); } - if (GTK_WIDGET_CLASS (tomoe_canvas_parent_class)->size_allocate) - GTK_WIDGET_CLASS (tomoe_canvas_parent_class)->size_allocate (widget, allocation); } static gint From makeinu users.sourceforge.jp Tue Dec 5 10:25:38 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 10:25:38 +0900 Subject: [Tomoe-cvs 1610] CVS update: libtomoe-gtk Message-ID: <20061205012538.AB99C2AC0A5@users.sourceforge.jp> Index: libtomoe-gtk/TODO diff -u libtomoe-gtk/TODO:1.8 libtomoe-gtk/TODO:1.9 --- libtomoe-gtk/TODO:1.8 Tue Nov 28 12:43:50 2006 +++ libtomoe-gtk/TODO Tue Dec 5 10:25:38 2006 @@ -4,7 +4,6 @@ * Window - Plural canvas like zaurus * Canvas (TomoeCanvas) - - Add ruled lines. - Preferences for lines: = Width and color of handwrited lines = Width, color, and type of normalized lines @@ -14,16 +13,8 @@ - Add popup window for displaying additional informations - Suppport multiple rows and columns - Page switching, add Up and Down button - - (Scrollable interface for scrolled window) - Mouse wheel support -* Commit the first candidate automatically -* Add software keybord buttons - - (Cursor) -* Input recognized letter to application - - Software keybord mode -* Add registering glyph feature * Glyph editor -* Glyph viewer * Combination of Hiragana only mode and Kana typing * Gesture * etc etc... From makeinu users.sourceforge.jp Tue Dec 5 10:28:39 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 10:28:39 +0900 Subject: [Tomoe-cvs 1611] CVS update: libtomoe-gtk Message-ID: <20061205012839.1942D2AC05D@users.sourceforge.jp> Index: libtomoe-gtk/TODO diff -u libtomoe-gtk/TODO:1.9 libtomoe-gtk/TODO:1.10 --- libtomoe-gtk/TODO:1.9 Tue Dec 5 10:25:38 2006 +++ libtomoe-gtk/TODO Tue Dec 5 10:28:38 2006 @@ -1,20 +1,24 @@ * Consider about ABI stability. * Consider about portability. * Implement meta data editing. -* Window + +* TomoeWindow - Plural canvas like zaurus -* Canvas (TomoeCanvas) +* TomoeCanvas - Preferences for lines: = Width and color of handwrited lines = Width, color, and type of normalized lines = Width, color, and type of ruled lines -* Candidates view (TomoeCharTable). + - Glyph editing mode +* TomoeCharTable - Font and color preference - Add popup window for displaying additional informations - Suppport multiple rows and columns - Page switching, add Up and Down button - Mouse wheel support -* Glyph editor -* Combination of Hiragana only mode and Kana typing +* Menu (GtkAction) +* Mode + - ASCII only mode. + - Hiragana only mode. * Gesture * etc etc... From makeinu users.sourceforge.jp Tue Dec 5 10:36:14 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 10:36:14 +0900 Subject: [Tomoe-cvs 1612] CVS update: libtomoe-gtk Message-ID: <20061205013614.1D9C22AC05D@users.sourceforge.jp> Index: libtomoe-gtk/TODO diff -u libtomoe-gtk/TODO:1.10 libtomoe-gtk/TODO:1.11 --- libtomoe-gtk/TODO:1.10 Tue Dec 5 10:28:38 2006 +++ libtomoe-gtk/TODO Tue Dec 5 10:36:13 2006 @@ -1,6 +1,8 @@ * Consider about ABI stability. * Consider about portability. -* Implement meta data editing. +* Add management tools + - Glyph viewer and editor + - Meta data editor * TomoeWindow - Plural canvas like zaurus From kous users.sourceforge.jp Tue Dec 5 12:38:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 12:38:59 +0900 Subject: [Tomoe-cvs 1613] CVS update: tomoe Message-ID: <20061205033859.A40BD2AC111@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.377 tomoe/ChangeLog:1.378 --- tomoe/ChangeLog:1.377 Mon Dec 4 13:41:09 2006 +++ tomoe/ChangeLog Tue Dec 5 12:38:59 2006 @@ -1,3 +1,8 @@ +2006-12-05 Kouhei Sutou + + * module/dict/unihan-compiler.rb: converted romaji -> hiragana + for JA_KUN and romaji -> katakana for JA_ON. + 2006-12-04 Kouhei Sutou * module/recognizer/tomoe-recognizer-simple.c: had stroke list From kous users.sourceforge.jp Tue Dec 5 12:38:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 12:38:59 +0900 Subject: [Tomoe-cvs 1614] CVS update: tomoe/module/dict Message-ID: <20061205033859.D35B22AC146@users.sourceforge.jp> Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.2 tomoe/module/dict/unihan-compiler.rb:1.3 --- tomoe/module/dict/unihan-compiler.rb:1.2 Mon Dec 4 11:45:26 2006 +++ tomoe/module/dict/unihan-compiler.rb Tue Dec 5 12:38:59 2006 @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'uconv' +require 'suikyo/suikyo' unihan_txt = ARGV.shift @@ -12,6 +13,22 @@ */ EOH + romaji_to_hiragana = Suikyo.new("romaji-kana") + hiragana_to_katakana = Suikyo.new("hiragana-katakana") + +def euc_to_utf8(euc) + Uconv.euctou8(euc) +end + +def romaji_to_hiragana(romaji) + euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) +end + +def romaji_to_katakana(romaji) + hiragana = @romaji_to_hiragana.convert("#{romaji} ") + euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) +end + def ucs4_to_utf8(ucs4) Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) end @@ -96,10 +113,14 @@ kuns = info["kJapaneseKun"] ons = info["kJapaneseOn"] if kuns - readings.concat(kuns.split.collect {|x| ["TOMOE_READING_JA_KUN", x]}) + readings.concat(kuns.split.collect do |x| + ["TOMOE_READING_JA_KUN", romaji_to_hiragana(x)] + end) end if ons - readings.concat(ons.split.collect {|x| ["TOMOE_READING_JA_ON", x]}) + readings.concat(ons.split.collect do |x| + ["TOMOE_READING_JA_ON", romaji_to_katakana(x)] + end) end unless readings.empty? From makeinu users.sourceforge.jp Tue Dec 5 13:15:37 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 13:15:37 +0900 Subject: [Tomoe-cvs 1614] CVS update: libtomoe-gtk/src Message-ID: <20061205041537.29EF92AC1A6@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.17 libtomoe-gtk/src/tomoe-gucharmap.c:1.18 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.17 Mon Dec 4 15:54:13 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Tue Dec 5 13:15:37 2006 @@ -129,12 +129,14 @@ /* Hide chapters page by default. Usually use combo box instead. */ gtk_widget_hide (GTK_WIDGET (priv->chapters)); - /* Add test page */ +#if 0 + /* CharDetails view will be here */ widget = gtk_paned_get_child2 (GTK_PANED (widget)); vbox = gtk_vbox_new (FALSE, 0); gtk_notebook_append_page (GTK_NOTEBOOK (widget), vbox, gtk_label_new (_("Writing"))); gtk_widget_show (vbox); +#endif /* setup */ setup_chapters_combo_box (page); From kous users.sourceforge.jp Tue Dec 5 13:18:08 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 13:18:08 +0900 Subject: [Tomoe-cvs 1615] CVS update: tomoe Message-ID: <20061205041808.6D2662AC10A@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.378 tomoe/ChangeLog:1.379 --- tomoe/ChangeLog:1.378 Tue Dec 5 12:38:59 2006 +++ tomoe/ChangeLog Tue Dec 5 13:18:08 2006 @@ -1,5 +1,8 @@ 2006-12-05 Kouhei Sutou + * lib/tomoe-config.c: hid tomoe_config_load(). + * lib/tomoe-context.c: removed config. + * module/dict/unihan-compiler.rb: converted romaji -> hiragana for JA_KUN and romaji -> katakana for JA_ON. From kous users.sourceforge.jp Tue Dec 5 13:18:08 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 13:18:08 +0900 Subject: [Tomoe-cvs 1616] CVS update: tomoe/lib Message-ID: <20061205041808.A671B2AC1A6@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.47 tomoe/lib/tomoe-config.c:1.48 --- tomoe/lib/tomoe-config.c:1.47 Mon Dec 4 12:06:17 2006 +++ tomoe/lib/tomoe-config.c Tue Dec 5 13:18:08 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.47 2006/12/04 03:06:17 kous Exp $ + * $Id: tomoe-config.c,v 1.48 2006/12/05 04:18:08 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -66,6 +66,7 @@ GValue *value, GParamSpec *pspec); +static void tomoe_config_load (TomoeConfig *config); static void tomoe_config_save (TomoeConfig *config); static gboolean _tomoe_config_key_file_get_boolean_value (GKeyFile *key_file, @@ -118,6 +119,8 @@ "filename", config_file, NULL); + tomoe_config_load (config); + return config; } @@ -184,7 +187,7 @@ } } -void +static void tomoe_config_load (TomoeConfig *config) { GKeyFile *key_file; Index: tomoe/lib/tomoe-config.h diff -u tomoe/lib/tomoe-config.h:1.22 tomoe/lib/tomoe-config.h:1.23 --- tomoe/lib/tomoe-config.h:1.22 Fri Dec 1 10:31:45 2006 +++ tomoe/lib/tomoe-config.h Tue Dec 5 13:18:08 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.h,v 1.22 2006/12/01 01:31:45 ikezoe Exp $ + * $Id: tomoe-config.h,v 1.23 2006/12/05 04:18:08 kous Exp $ */ #ifndef __TOMOE_CONFIG_H__ @@ -52,7 +52,6 @@ GType tomoe_config_get_type (void) G_GNUC_CONST; TomoeConfig *tomoe_config_new (const char *config_file); -void tomoe_config_load (TomoeConfig *config); const gchar *tomoe_config_get_filename (TomoeConfig *config); TomoeShelf *tomoe_config_make_shelf (TomoeConfig *config); Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.43 tomoe/lib/tomoe-context.c:1.44 --- tomoe/lib/tomoe-context.c:1.43 Mon Dec 4 13:36:48 2006 +++ tomoe/lib/tomoe-context.c Tue Dec 5 13:18:08 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.43 2006/12/04 04:36:48 kous Exp $ + * $Id: tomoe-context.c,v 1.44 2006/12/05 04:18:08 kous Exp $ */ #include "tomoe-dict.h" @@ -39,7 +39,6 @@ struct _TomoeContextPrivate { TomoeShelf *shelf; - TomoeConfig *config; TomoeRecognizer *recognizer; }; @@ -85,7 +84,6 @@ TomoeContextPrivate *priv = TOMOE_CONTEXT_GET_PRIVATE (context); priv->shelf = NULL; - priv->config = NULL; priv->recognizer = NULL; } @@ -154,13 +152,10 @@ if (priv->shelf) g_object_unref (priv->shelf); - if (priv->config) - g_object_unref (priv->config); if (priv->recognizer) g_object_unref (priv->recognizer); priv->shelf = NULL; - priv->config = NULL; priv->recognizer = NULL; G_OBJECT_CLASS (tomoe_context_parent_class)->dispose (object); @@ -182,11 +177,9 @@ g_return_if_fail (ctx); priv = TOMOE_CONTEXT_GET_PRIVATE(ctx); - priv->config = NULL; cfg = tomoe_config_new (config_file); - tomoe_config_load (cfg); priv->shelf = tomoe_config_make_shelf (cfg); - priv->config = cfg; + g_object_unref (cfg); } static gint From makeinu users.sourceforge.jp Tue Dec 5 13:29:29 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 13:29:29 +0900 Subject: [Tomoe-cvs 1617] CVS update: libtomoe-gtk Message-ID: <20061205042929.44EC62AC05D@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.220 libtomoe-gtk/ChangeLog:1.221 --- libtomoe-gtk/ChangeLog:1.220 Mon Dec 4 23:20:00 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 13:29:29 2006 @@ -1,3 +1,7 @@ +2006-12-05 Takuro Ashie + + * src/tomoe-handwriting.[ch]: Add a getter for getting TomoeCharTable. + 2006-12-04 Takuro Ashie * src/tomoe-canvas.c: Call parent class's function first in From makeinu users.sourceforge.jp Tue Dec 5 13:29:29 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 13:29:29 +0900 Subject: [Tomoe-cvs 1618] CVS update: libtomoe-gtk/src Message-ID: <20061205042929.702322AC10A@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.4 libtomoe-gtk/src/tomoe-handwriting.c:1.5 --- libtomoe-gtk/src/tomoe-handwriting.c:1.4 Mon Dec 4 14:36:00 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Tue Dec 5 13:29:29 2006 @@ -232,6 +232,17 @@ return priv->button_area; } +GtkWidget * +tomoe_handwriting_get_char_table (TomoeHandwriting *handwriting) +{ + TomoeHandwritingPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_HANDWRITING (handwriting), NULL); + priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + + return priv->candidates_view; +} + const gchar * tomoe_handwriting_get_selected_char (TomoeHandwriting *handwriting) { Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.5 libtomoe-gtk/src/tomoe-handwriting.h:1.6 --- libtomoe-gtk/src/tomoe-handwriting.h:1.5 Mon Dec 4 14:33:42 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Tue Dec 5 13:29:29 2006 @@ -57,6 +57,8 @@ GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); GtkWidget *tomoe_handwriting_get_button_area (TomoeHandwriting *handwriting); +GtkWidget *tomoe_handwriting_get_char_table + (TomoeHandwriting *handwriting); const gchar *tomoe_handwriting_get_selected_char (TomoeHandwriting *handwriting); TomoeChar *tomoe_handwriting_get_selected_tomoe_char From makeinu users.sourceforge.jp Tue Dec 5 13:59:55 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 13:59:55 +0900 Subject: [Tomoe-cvs 1619] CVS update: libtomoe-gtk Message-ID: <20061205045955.3618C2AC05D@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.221 libtomoe-gtk/ChangeLog:1.222 --- libtomoe-gtk/ChangeLog:1.221 Tue Dec 5 13:29:29 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 13:59:55 2006 @@ -1,6 +1,7 @@ 2006-12-05 Takuro Ashie * src/tomoe-handwriting.[ch]: Add a getter for getting TomoeCharTable. + * src/tomoe-char-table.[ch]: Increase default font scale to 2. 2006-12-04 Takuro Ashie From makeinu users.sourceforge.jp Tue Dec 5 13:59:55 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 13:59:55 +0900 Subject: [Tomoe-cvs 1620] CVS update: libtomoe-gtk/src Message-ID: <20061205045955.630532AC0F2@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-char-table.c diff -u libtomoe-gtk/src/tomoe-char-table.c:1.8 libtomoe-gtk/src/tomoe-char-table.c:1.9 --- libtomoe-gtk/src/tomoe-char-table.c:1.8 Tue Nov 28 15:01:53 2006 +++ libtomoe-gtk/src/tomoe-char-table.c Tue Dec 5 13:59:55 2006 @@ -27,6 +27,9 @@ #include "tomoe-canvas.h" #include "tomoe-scrollable.h" +#define DEFAULT_FONT_SCALE 2 +/*#define DEFAULT_FONT_SCALE PANGO_SCALE_XX_LARGE*/ + enum { SELECTED_SIGNAL, LAST_SIGNAL @@ -280,7 +283,7 @@ /* Set default font with large scale */ font_desc = pango_font_description_copy (widget->style->font_desc); size = pango_font_description_get_size(font_desc); - pango_font_description_set_size(font_desc, size * PANGO_SCALE_XX_LARGE); + pango_font_description_set_size(font_desc, size * DEFAULT_FONT_SCALE); gtk_widget_modify_font (widget, font_desc); pango_font_description_free (font_desc); } @@ -290,6 +293,8 @@ { TomoeCharTablePriv *priv = TOMOE_CHAR_TABLE_GET_PRIVATE (widget); + g_print ("allocate\n"); + if (GTK_WIDGET_CLASS (tomoe_char_table_parent_class)->size_allocate) GTK_WIDGET_CLASS (tomoe_char_table_parent_class)->size_allocate (widget, allocation); @@ -315,6 +320,8 @@ PangoFontMetrics *metrics; PangoContext *context; gint ascent, descent, char_width, digit_width, char_pixels; + + g_print ("request\n"); gtk_widget_ensure_style (widget); context = gtk_widget_get_pango_context (widget); From kous users.sourceforge.jp Tue Dec 5 14:07:14 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:07:14 +0900 Subject: [Tomoe-cvs 1621] CVS update: tomoe Message-ID: <20061205050714.E8DAA2AC05D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.379 tomoe/ChangeLog:1.380 --- tomoe/ChangeLog:1.379 Tue Dec 5 13:18:08 2006 +++ tomoe/ChangeLog Tue Dec 5 14:07:14 2006 @@ -1,5 +1,9 @@ 2006-12-05 Kouhei Sutou + * data/all.xml: renamed to ... + * data/handwriting.xml: ... this. + * benchmark/, test/: followed the changes. + * lib/tomoe-config.c: hid tomoe_config_load(). * lib/tomoe-context.c: removed config. From kous users.sourceforge.jp Tue Dec 5 14:07:15 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:07:15 +0900 Subject: [Tomoe-cvs 1622] CVS update: tomoe/benchmark Message-ID: <20061205050715.218362AC0FE@users.sourceforge.jp> Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.4 tomoe/benchmark/search-by-recognizer.rb:1.5 --- tomoe/benchmark/search-by-recognizer.rb:1.4 Mon Dec 4 13:36:47 2006 +++ tomoe/benchmark/search-by-recognizer.rb Tue Dec 5 14:07:14 2006 @@ -12,7 +12,7 @@ dict = Tomoe::Dict.new("xml", "filename" => File.join(TomoeSpecUtils::Config.data_dir, - "all.xml"), + "handwriting.xml"), "editable" => false) recognizer = Tomoe::Recognizer.new("simple", dict) context = Tomoe::Context.new("recognizer" => recognizer) From kous users.sourceforge.jp Tue Dec 5 14:07:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:07:17 +0900 Subject: [Tomoe-cvs 1623] CVS update: tomoe/test Message-ID: <20061205050717.E21232AC05D@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.20 tomoe/test/context_spec.rb:1.21 --- tomoe/test/context_spec.rb:1.20 Mon Dec 4 13:36:48 2006 +++ tomoe/test/context_spec.rb Tue Dec 5 14:07:17 2006 @@ -5,7 +5,7 @@ def context return @@context if @@context dict = Tomoe::Dict.new("xml", - "filename" => File.join(data_dir, "all.xml"), + "filename" => File.join(data_dir, "handwriting.xml"), "editable" => false) recognizer = Tomoe::Recognizer.new("simple", dict) @@context = Tomoe::Context.new("recognizer" => recognizer) Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.17 tomoe/test/tomoe-spec-utils.rb:1.18 --- tomoe/test/tomoe-spec-utils.rb:1.17 Mon Dec 4 00:04:42 2006 +++ tomoe/test/tomoe-spec-utils.rb Tue Dec 5 14:07:17 2006 @@ -100,7 +100,7 @@ end def dictionaries - %w(kanjidic2.xml all.xml).collect do |xml| + %w(kanjidic2.xml).collect do |xml| File.join(data_dir, xml) end end @@ -125,10 +125,9 @@ type = unihan name = Unihan -[all-dictionary] +[handwriting-dictionary] type = xml -name = all -file = #{File.join(data_dir, "all.xml")} +file = #{File.join(data_dir, "handwriting.xml")} EOC else dictionaries.each_with_index do |dictionary, i| From kous users.sourceforge.jp Tue Dec 5 14:11:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:11:03 +0900 Subject: [Tomoe-cvs 1623] CVS update: tomoe Message-ID: <20061205051103.93C2F2AC05D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.380 tomoe/ChangeLog:1.381 --- tomoe/ChangeLog:1.380 Tue Dec 5 14:07:14 2006 +++ tomoe/ChangeLog Tue Dec 5 14:11:03 2006 @@ -1,5 +1,9 @@ 2006-12-05 Kouhei Sutou + * module/recognizer/tomoe-recognizer-simple.c: loaded handwriting + dictionary by recognizer-simple. + * lib/tomoe-context.c: followed the changes. + * data/all.xml: renamed to ... * data/handwriting.xml: ... this. * benchmark/, test/: followed the changes. From kous users.sourceforge.jp Tue Dec 5 14:11:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:11:03 +0900 Subject: [Tomoe-cvs 1624] CVS update: tomoe/lib Message-ID: <20061205051103.C9BFB2AC1AC@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.44 tomoe/lib/tomoe-context.c:1.45 --- tomoe/lib/tomoe-context.c:1.44 Tue Dec 5 13:18:08 2006 +++ tomoe/lib/tomoe-context.c Tue Dec 5 14:11:03 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.44 2006/12/05 04:18:08 kous Exp $ + * $Id: tomoe-context.c,v 1.45 2006/12/05 05:11:03 kous Exp $ */ #include "tomoe-dict.h" @@ -202,18 +202,8 @@ priv = TOMOE_CONTEXT_GET_PRIVATE (context); if (!priv->recognizer) { - TomoeShelf *shelf; - TomoeDict *dict; - - shelf = priv->shelf; - g_return_val_if_fail (shelf, matched); - - dict = tomoe_shelf_get_dict (shelf, "TOMOE Strokelist Dictionary"); - g_return_val_if_fail (dict, matched); - - priv->recognizer = tomoe_recognizer_new ("simple", - "dictionary", dict, - NULL); + priv->recognizer = tomoe_recognizer_new ("simple", NULL); + g_return_val_if_fail (TOMOE_IS_RECOGNIZER (priv->recognizer), matched); } matched = g_list_sort (tomoe_recognizer_search (priv->recognizer, input), From kous users.sourceforge.jp Tue Dec 5 14:11:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:11:03 +0900 Subject: [Tomoe-cvs 1625] CVS update: tomoe/module/recognizer Message-ID: <20061205051103.EE00F2AC05D@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.3 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.4 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.3 Mon Dec 4 13:36:48 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Tue Dec 5 14:11:03 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.3 2006/12/04 04:36:48 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.4 2006/12/05 05:11:03 kous Exp $ */ #include @@ -157,6 +157,13 @@ recognizer = TOMOE_RECOGNIZER_SIMPLE (object); if (!recognizer->dict) { + recognizer->dict = + tomoe_dict_new ("xml", + "filename", DATADIR "/handwriting.xml", + NULL); + } + + if (!recognizer->dict) { g_warning ("dictionary isn't set for TomoeRecognizerSimple."); g_object_unref (object); object = NULL; From makeinu users.sourceforge.jp Tue Dec 5 14:18:19 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 14:18:19 +0900 Subject: [Tomoe-cvs 1626] CVS update: libtomoe-gtk Message-ID: <20061205051819.AE49C2AC0FE@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.222 libtomoe-gtk/ChangeLog:1.223 --- libtomoe-gtk/ChangeLog:1.222 Tue Dec 5 13:59:55 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 14:18:19 2006 @@ -1,5 +1,10 @@ 2006-12-05 Takuro Ashie + * src/tomoe-char-table.[ch]: Set the font on initializing time instead + of realizing time. Avoid needless drawing. + +2006-12-05 Takuro Ashie + * src/tomoe-handwriting.[ch]: Add a getter for getting TomoeCharTable. * src/tomoe-char-table.[ch]: Increase default font scale to 2. From makeinu users.sourceforge.jp Tue Dec 5 14:18:19 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 14:18:19 +0900 Subject: [Tomoe-cvs 1627] CVS update: libtomoe-gtk/src Message-ID: <20061205051819.D6BD02AC1AC@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-char-table.c diff -u libtomoe-gtk/src/tomoe-char-table.c:1.9 libtomoe-gtk/src/tomoe-char-table.c:1.10 --- libtomoe-gtk/src/tomoe-char-table.c:1.9 Tue Dec 5 13:59:55 2006 +++ libtomoe-gtk/src/tomoe-char-table.c Tue Dec 5 14:18:19 2006 @@ -171,6 +171,9 @@ tomoe_char_table_init (TomoeCharTable *view) { TomoeCharTablePriv *priv = TOMOE_CHAR_TABLE_GET_PRIVATE (view); + GtkWidget *widget = GTK_WIDGET (view); + PangoFontDescription *font_desc; + gint size; priv->layout = TOMOE_CHAR_TABLE_LAYOUT_SINGLE_HORIZONTAL; priv->canvas = NULL; @@ -181,6 +184,13 @@ priv->layout_list = NULL; priv->h_adj = NULL; priv->v_adj = NULL; + + /* Set default font with large scale */ + font_desc = pango_font_description_copy (widget->style->font_desc); + size = pango_font_description_get_size(font_desc); + pango_font_description_set_size(font_desc, size * DEFAULT_FONT_SCALE); + gtk_widget_modify_font (widget, font_desc); + pango_font_description_free (font_desc); } static void @@ -248,8 +258,6 @@ realize (GtkWidget *widget) { GdkWindowAttr attributes; - PangoFontDescription *font_desc; - gint size; GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); @@ -279,13 +287,6 @@ widget->style = gtk_style_attach (widget->style, widget->window); gdk_window_set_background (widget->window, &widget->style->bg [GTK_STATE_NORMAL]); - - /* Set default font with large scale */ - font_desc = pango_font_description_copy (widget->style->font_desc); - size = pango_font_description_get_size(font_desc); - pango_font_description_set_size(font_desc, size * DEFAULT_FONT_SCALE); - gtk_widget_modify_font (widget, font_desc); - pango_font_description_free (font_desc); } static void @@ -293,8 +294,6 @@ { TomoeCharTablePriv *priv = TOMOE_CHAR_TABLE_GET_PRIVATE (widget); - g_print ("allocate\n"); - if (GTK_WIDGET_CLASS (tomoe_char_table_parent_class)->size_allocate) GTK_WIDGET_CLASS (tomoe_char_table_parent_class)->size_allocate (widget, allocation); @@ -320,8 +319,6 @@ PangoFontMetrics *metrics; PangoContext *context; gint ascent, descent, char_width, digit_width, char_pixels; - - g_print ("request\n"); gtk_widget_ensure_style (widget); context = gtk_widget_get_pango_context (widget); @@ -440,12 +437,13 @@ if (GTK_WIDGET_CLASS(tomoe_char_table_parent_class)->expose_event) retval = GTK_WIDGET_CLASS(tomoe_char_table_parent_class)->expose_event (widget, event); - gdk_draw_drawable(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - priv->pixmap, - event->area.x, event->area.y, - event->area.x, event->area.y, - event->area.width, event->area.height); + if (priv->pixmap) + gdk_draw_drawable(widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + priv->pixmap, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height); return retval; } @@ -531,6 +529,8 @@ guint i; GList *node; + if (!GTK_WIDGET_VISIBLE (widget) || !priv->pixmap) return; + get_char_frame_size (view, &inner_width, &inner_height, &outer_width, &outer_height); From kous users.sourceforge.jp Tue Dec 5 14:26:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:26:01 +0900 Subject: [Tomoe-cvs 1628] CVS update: tomoe Message-ID: <20061205052601.D109C2AC05D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.381 tomoe/ChangeLog:1.382 --- tomoe/ChangeLog:1.381 Tue Dec 5 14:11:03 2006 +++ tomoe/ChangeLog Tue Dec 5 14:26:01 2006 @@ -1,5 +1,11 @@ 2006-12-05 Kouhei Sutou + * configure.in, data/Makefile.am, module/dict/Makefile.am, + module/recognizer/Makefile.am: moved directory configuration from + Makefile.am. + * module/recognizer/tomoe-recognizer-simple.c: used DICTDIR + instead of DATADIR. + * module/recognizer/tomoe-recognizer-simple.c: loaded handwriting dictionary by recognizer-simple. * lib/tomoe-context.c: followed the changes. Index: tomoe/configure.in diff -u tomoe/configure.in:1.38 tomoe/configure.in:1.39 --- tomoe/configure.in:1.38 Mon Dec 4 12:02:18 2006 +++ tomoe/configure.in Tue Dec 5 14:26:01 2006 @@ -150,16 +150,27 @@ AM_CONDITIONAL([WITH_NEON], [test "$neon_exists" = "yes"]) dnl ************************************************************** +dnl Configure for modules. +dnl ************************************************************** + +moduledir="${libdir}/\$(PACKAGE)/module" +AC_SUBST(moduledir) + +dnl ************************************************************** dnl Configure for recognizers. dnl ************************************************************** -recognizerdir="${libdir}/\$(PACKAGE)/recognizer" -AC_SUBST(recognizerdir) + +recognizer_moduledir="${moduledir}/recognizer" +AC_SUBST(recognizer_moduledir) dnl ************************************************************** dnl Configure for dictionaries. dnl ************************************************************** -dictdir="${libdir}/\$(PACKAGE)/dict" +dict_moduledir="${moduledir}/dict" +AC_SUBST(dict_moduledir) + +dictdir="${datadir}/\$(PACKAGE)" AC_SUBST(dictdir) use_unihan=yes @@ -267,7 +278,7 @@ AM_CONDITIONAL([WITH_RUBY], [test "$ruby_available" = "yes"]) dnl ************************************************************** -dnl Check for Ruby dictionary module +dnl Check for Ruby dictionary module dnl ************************************************************** AC_ARG_ENABLE(ruby_dict, [ --enable-ruby-dict Enable Ruby-dict module]) From kous users.sourceforge.jp Tue Dec 5 14:26:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:26:02 +0900 Subject: [Tomoe-cvs 1629] CVS update: tomoe/data Message-ID: <20061205052602.056912AC180@users.sourceforge.jp> Index: tomoe/data/Makefile.am diff -u tomoe/data/Makefile.am:1.18 tomoe/data/Makefile.am:1.19 --- tomoe/data/Makefile.am:1.18 Tue Dec 5 14:07:15 2006 +++ tomoe/data/Makefile.am Tue Dec 5 14:26:01 2006 @@ -20,15 +20,14 @@ CLEANFILES = *~ *.bak *.valid -dicdir = $(datadir)/$(PACKAGE) -dic_DATA = tomoe-dict.dtd handwriting.xml kanjidic2.xml +dict_DATA = tomoe-dict.dtd handwriting.xml kanjidic2.xml confdir = $(sysconfdir)/$(PACKAGE) conf_DATA = config EXTRA_DIST = \ kanjidic2-original.xml kanjidic2-original.xsl \ - $(dic_DATA) \ + $(dict_DATA) \ $(conf_DATA) kanjidic2.xml: kanjidic2-original.xsl kanjidic2-original.xml From kous users.sourceforge.jp Tue Dec 5 14:26:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:26:02 +0900 Subject: [Tomoe-cvs 1630] CVS update: tomoe/module/dict Message-ID: <20061205052602.2D1D32AC05D@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.9 tomoe/module/dict/Makefile.am:1.10 --- tomoe/module/dict/Makefile.am:1.9 Mon Dec 4 11:45:26 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 5 14:26:02 2006 @@ -24,8 +24,7 @@ -DG_LOG_DOMAIN=\"TOMOE-DICT\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATADIR=\""$(datadir)"\" \ - -DTOMOESYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ - -DTOMOEDATADIR=\""$(datadir)"/$(PACKAGE)\" \ + -DDICTDIR=\""$(dictdir)"\" \ -DRUBY_EXTDIR=\""$(RUBY_EXTDIR)"\" \ -DRUBY_LIBDIR=\""$(RUBY_LIBDIR)"\" @@ -41,26 +40,26 @@ -version-info $(LT_VERSION_INFO) \ -export-dynamic $(no_undefined) $(LIBTOOL_EXPORT_OPTIONS) -dict_LTLIBRARIES = libxml.la +dict_module_LTLIBRARIES = libxml.la libxml_la_SOURCES = tomoe-dict-xml.c if WITH_EST -dict_LTLIBRARIES += libest.la +dict_module_LTLIBRARIES += libest.la libest_la_SOURCES = tomoe-dict-est.c libest_la_LIBADD = $(EST_LIBS) endif if ENABLE_RUBY_DICT -dict_LTLIBRARIES += libruby.la +dict_module_LTLIBRARIES += libruby.la libruby_la_SOURCES = tomoe-dict-ruby.c libruby_la_LIBADD = $(RUBY_LIBS) endif if WITH_UNIHAN -dict_LTLIBRARIES += libunihan.la +dict_module_LTLIBRARIES += libunihan.la unihan_built_sources = tomoe-unihan-data.h From kous users.sourceforge.jp Tue Dec 5 14:26:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:26:02 +0900 Subject: [Tomoe-cvs 1631] CVS update: tomoe/module/recognizer Message-ID: <20061205052602.56F332AC180@users.sourceforge.jp> Index: tomoe/module/recognizer/Makefile.am diff -u tomoe/module/recognizer/Makefile.am:1.1 tomoe/module/recognizer/Makefile.am:1.2 --- tomoe/module/recognizer/Makefile.am:1.1 Wed Nov 29 15:49:39 2006 +++ tomoe/module/recognizer/Makefile.am Tue Dec 5 14:26:02 2006 @@ -24,13 +24,12 @@ -DG_LOG_DOMAIN=\"TOMOE-RECOGNIZER\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ -DDATADIR=\""$(datadir)"\" \ - -DTOMOESYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ - -DTOMOEDATADIR=\""$(datadir)"/$(PACKAGE)\" \ + -DDICTDIR=\""$(dictdir)"\" \ -I$(top_srcdir)/lib INCLUDES = $(GLIB_CFLAGS) -recognizer_LTLIBRARIES = libsimple.la +recognizer_module_LTLIBRARIES = libsimple.la libsimple_la_SOURCES = \ tomoe-recognizer-simple.c \ Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.4 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.5 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.4 Tue Dec 5 14:11:03 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Tue Dec 5 14:26:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.4 2006/12/05 05:11:03 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.5 2006/12/05 05:26:02 kous Exp $ */ #include @@ -159,14 +159,12 @@ if (!recognizer->dict) { recognizer->dict = tomoe_dict_new ("xml", - "filename", DATADIR "/handwriting.xml", + "filename", DICTDIR "/handwriting.xml", NULL); } if (!recognizer->dict) { g_warning ("dictionary isn't set for TomoeRecognizerSimple."); - g_object_unref (object); - object = NULL; } return object; From kous users.sourceforge.jp Tue Dec 5 14:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:51:42 +0900 Subject: [Tomoe-cvs 1632] CVS update: tomoe Message-ID: <20061205055142.5791C2AC05D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.382 tomoe/ChangeLog:1.383 --- tomoe/ChangeLog:1.382 Tue Dec 5 14:26:01 2006 +++ tomoe/ChangeLog Tue Dec 5 14:51:42 2006 @@ -1,10 +1,13 @@ 2006-12-05 Kouhei Sutou - * configure.in, data/Makefile.am, module/dict/Makefile.am, - module/recognizer/Makefile.am: moved directory configuration from + * configure.in, **/Makefile.am: moved directory configuration from Makefile.am. * module/recognizer/tomoe-recognizer-simple.c: used DICTDIR instead of DATADIR. + * lib/tomoe-config.c: used DICTDIR and CONFDIR instead of + TOMOESYSCONFDIR and TOMOEDATADIR. + * lib/tomoe-recognizer.c: used RECOGNIZER_MODULEDIR instead of + RECOGNIZERDIR. * module/recognizer/tomoe-recognizer-simple.c: loaded handwriting dictionary by recognizer-simple. Index: tomoe/configure.in diff -u tomoe/configure.in:1.39 tomoe/configure.in:1.40 --- tomoe/configure.in:1.39 Tue Dec 5 14:26:01 2006 +++ tomoe/configure.in Tue Dec 5 14:51:42 2006 @@ -150,6 +150,13 @@ AM_CONDITIONAL([WITH_NEON], [test "$neon_exists" = "yes"]) dnl ************************************************************** +dnl Configure for configuration. +dnl ************************************************************** + +confdir="${sysconfdir}/\$(PACKAGE)" +AC_SUBST(confdir) + +dnl ************************************************************** dnl Configure for modules. dnl ************************************************************** @@ -256,8 +263,8 @@ (default is same as ruby's one)]), [tomoe_ruby_extdir="$withval"], [tomoe_ruby_extdir="$tomoe_cv_ruby_archdir"]) - RUBY_EXTDIR="$tomoe_ruby_extdir" - AC_MSG_RESULT([$RUBY_EXTDIR]) + ruby_extdir="$tomoe_ruby_extdir" + AC_MSG_RESULT([$ruby_extdir]) AC_MSG_CHECKING([where to install Ruby scripts]) AC_CACHE_VAL([tomoe_cv_ruby_sitedir], @@ -268,11 +275,11 @@ (default is same as ruby's one)]), [tomoe_ruby_libdir="$withval"], [tomoe_ruby_libdir="$tomoe_cv_ruby_sitedir"]) - RUBY_LIBDIR="$tomoe_ruby_libdir" - AC_MSG_RESULT([$RUBY_LIBDIR]) + ruby_libdir="$tomoe_ruby_libdir" + AC_MSG_RESULT([$ruby_libdir]) - AC_SUBST(RUBY_EXTDIR) - AC_SUBST(RUBY_LIBDIR) + AC_SUBST(ruby_extdir) + AC_SUBST(ruby_libdir) fi AM_CONDITIONAL([WITH_RUBY], [test "$ruby_available" = "yes"]) @@ -284,6 +291,23 @@ Enable Ruby-dict module]) AM_CONDITIONAL(ENABLE_RUBY_DICT, test x"$enable_ruby" = "xyes") + +dnl ************************************************************** +dnl Configure for TOMOE. +dnl ************************************************************** + +TOMOE_CFLAGS=' \ + $(GLIB_CFLAGS) \ + -DCONFDIR=\""$(confdir)"\" \ + -DDICTDIR=\""$(dictdir)"\" \ + -DDICT_MODULEDIR=\""$(dict_moduledir)"\" \ + -DRECOGNIZER_MODULEDIR=\""$(recognizer_moduledir)"\" \ + -I$(top_srcdir)/lib' +AC_SUBST(TOMOE_CFLAGS) + +TOMOE_LIBS='$(GLIB_LIBS)' +AC_SUBST(TOMOE_LIBS) + AC_CONFIG_FILES([ Makefile lib/Makefile From kous users.sourceforge.jp Tue Dec 5 14:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:51:42 +0900 Subject: [Tomoe-cvs 1633] CVS update: tomoe/data Message-ID: <20061205055142.7A8502AC0FC@users.sourceforge.jp> Index: tomoe/data/Makefile.am diff -u tomoe/data/Makefile.am:1.19 tomoe/data/Makefile.am:1.20 --- tomoe/data/Makefile.am:1.19 Tue Dec 5 14:26:01 2006 +++ tomoe/data/Makefile.am Tue Dec 5 14:51:42 2006 @@ -21,8 +21,6 @@ CLEANFILES = *~ *.bak *.valid dict_DATA = tomoe-dict.dtd handwriting.xml kanjidic2.xml - -confdir = $(sysconfdir)/$(PACKAGE) conf_DATA = config EXTRA_DIST = \ From kous users.sourceforge.jp Tue Dec 5 14:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:51:42 +0900 Subject: [Tomoe-cvs 1634] CVS update: tomoe/ext/ruby Message-ID: <20061205055142.9DDC22AC05D@users.sourceforge.jp> Index: tomoe/ext/ruby/Makefile.am diff -u tomoe/ext/ruby/Makefile.am:1.10 tomoe/ext/ruby/Makefile.am:1.11 --- tomoe/ext/ruby/Makefile.am:1.10 Tue Nov 28 13:26:23 2006 +++ tomoe/ext/ruby/Makefile.am Tue Dec 5 14:51:42 2006 @@ -1,24 +1,15 @@ # -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- -rubylibdir = $(RUBY_LIBDIR) -rubylib_DATA = tomoe.rb +ruby_lib_DATA = tomoe.rb -EXTRA_DIST = \ - $(rubylib_DATA) +EXTRA_DIST = $(ruby_lib_DATA) -rubyarchdir = $(RUBY_EXTDIR) -rubyarch_HEADERS = rbtomoe.h -rubyarch_LTLIBRARIES = tomoe.la - -AM_CPPFLAGS = \ - -DTOMOESYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ - -DTOMOEDATADIR=\""$(datadir)"/$(PACKAGE)\" \ - -I$(top_srcdir)/lib - -INCLUDES = \ - $(RUBY_CFLAGS) \ - $(GLIB_CFLAGS) \ - -I$(top_srcdir)/lib +ruby_ext_HEADERS = rbtomoe.h +ruby_ext_LTLIBRARIES = tomoe.la + +INCLUDES = \ + $(TOMOE_CFLAGS) \ + $(RUBY_CFLAGS) tomoe_la_SOURCES = \ tomoe-rb.c tomoe-rb.h \ @@ -32,13 +23,13 @@ tomoe-rb-recognizer.c \ tomoe-rb-writing.c -tomoe_la_LDFLAGS = \ - -module \ - -version-info $(LT_VERSION_INFO) \ - $(RUBY_LDFLAGS) \ +tomoe_la_LDFLAGS = \ + -module \ + -version-info $(LT_VERSION_INFO) \ + $(RUBY_LDFLAGS) \ $(RUBY_EXT_LDFLAGS) -tomoe_la_LIBADD = \ - $(RUBY_LIBS) \ - $(GLIB_LIBS) \ +tomoe_la_LIBADD = \ + $(TOMOE_LIBS) \ + $(RUBY_LIBS) \ $(top_builddir)/lib/libtomoe.la From kous users.sourceforge.jp Tue Dec 5 14:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:51:42 +0900 Subject: [Tomoe-cvs 1635] CVS update: tomoe/lib Message-ID: <20061205055142.C8EC32AC0FC@users.sourceforge.jp> Index: tomoe/lib/Makefile.am diff -u tomoe/lib/Makefile.am:1.45 tomoe/lib/Makefile.am:1.46 --- tomoe/lib/Makefile.am:1.45 Thu Nov 30 11:22:31 2006 +++ tomoe/lib/Makefile.am Tue Dec 5 14:51:42 2006 @@ -20,16 +20,8 @@ CLEANFILES = *~ *.bak -AM_CPPFLAGS = \ - -DG_LOG_DOMAIN=\"TOMOE\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DTOMOESYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ - -DTOMOEDATADIR=\""$(datadir)"/$(PACKAGE)\" \ - -DRECOGNIZERDIR=\""$(recognizerdir)"\" \ - -DDICTDIR=\""$(dictdir)"\" - -INCLUDES = $(GLIB_CFLAGS) +AM_CPPFLAGS = -DG_LOG_DOMAIN=\"TOMOE\" +INCLUDES = $(TOMOE_CFLAGS) tomoe_public_h_sources = \ tomoe.h \ @@ -90,7 +82,7 @@ libtomoe_la_LD_ADD = \ -lm -libtomoe_la_LIBADD = $(GLIB_LIBS) +libtomoe_la_LIBADD = $(TOMOE_LIBS) Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.48 tomoe/lib/tomoe-config.c:1.49 --- tomoe/lib/tomoe-config.c:1.48 Tue Dec 5 13:18:08 2006 +++ tomoe/lib/tomoe-config.c Tue Dec 5 14:51:42 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.48 2006/12/05 04:18:08 kous Exp $ + * $Id: tomoe-config.c,v 1.49 2006/12/05 05:51:42 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -54,7 +54,7 @@ G_DEFINE_TYPE (TomoeConfig, tomoe_config, G_TYPE_OBJECT) -static const gchar *system_config_file = TOMOESYSCONFDIR "/config"; +static const gchar *system_config_file = CONFDIR "/config"; static void tomoe_config_dispose (GObject *object); static void tomoe_config_set_property (GObject *object, @@ -332,13 +332,13 @@ g_object_unref (dict); } - gdir = g_dir_open (TOMOEDATADIR, 0, NULL); + gdir = g_dir_open (DICTDIR, 0, NULL); while ((filename = g_dir_read_name (gdir))) { gchar *path; if (!g_str_has_suffix (filename, ".xml")) continue; - path = g_build_filename(TOMOEDATADIR, filename, NULL); + path = g_build_filename(DICTDIR, filename, NULL); if (tomoe_shelf_has_dict (shelf, path)) { g_free (path); continue; @@ -376,7 +376,7 @@ "user", TRUE); if (!user_dict) { gchar *tmp; - tmp = g_build_filename (TOMOEDATADIR, filename, NULL); + tmp = g_build_filename (DICTDIR, filename, NULL); g_free (filename); filename = tmp; } @@ -418,7 +418,7 @@ "user", TRUE); if (!user_dict) { gchar *tmp; - tmp = g_build_filename (TOMOEDATADIR, database_name, NULL); + tmp = g_build_filename (DICTDIR, database_name, NULL); g_free (database_name); database_name = tmp; } Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.22 tomoe/lib/tomoe-recognizer.c:1.23 --- tomoe/lib/tomoe-recognizer.c:1.22 Mon Dec 4 13:36:48 2006 +++ tomoe/lib/tomoe-recognizer.c Tue Dec 5 14:51:42 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.22 2006/12/04 04:36:48 kous Exp $ + * $Id: tomoe-recognizer.c,v 1.23 2006/12/05 05:51:42 kous Exp $ */ #include @@ -32,7 +32,7 @@ tomoe_recognizer_load (const gchar *base_dir) { if (!base_dir) - base_dir = RECOGNIZERDIR; + base_dir = RECOGNIZER_MODULEDIR; recognizers = g_list_concat (tomoe_module_load_modules (base_dir), recognizers); From kous users.sourceforge.jp Tue Dec 5 14:51:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:51:42 +0900 Subject: [Tomoe-cvs 1636] CVS update: tomoe/module/dict Message-ID: <20061205055142.ED6E22AC05D@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.10 tomoe/module/dict/Makefile.am:1.11 --- tomoe/module/dict/Makefile.am:1.10 Tue Dec 5 14:26:02 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 5 14:51:42 2006 @@ -22,20 +22,16 @@ AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"TOMOE-DICT\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DDICTDIR=\""$(dictdir)"\" \ - -DRUBY_EXTDIR=\""$(RUBY_EXTDIR)"\" \ - -DRUBY_LIBDIR=\""$(RUBY_LIBDIR)"\" + -DRUBY_EXTDIR=\""$(ruby_extdir)"\" \ + -DRUBY_LIBDIR=\""$(ruby_libdir)"\" INCLUDES = \ - -I$(top_srcdir)/lib \ -I$(top_srcdir)/ext/ruby \ - $(GLIB_CFLAGS) \ + $(TOMOE_CFLAGS) \ $(EST_CFLAGS) \ $(RUBY_CFLAGS) -LIBADD = $(GLIB_LIBS) +LIBADD = $(TOMOE_LIBS) LDFLAGS = \ -version-info $(LT_VERSION_INFO) \ -export-dynamic $(no_undefined) $(LIBTOOL_EXPORT_OPTIONS) Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.3 tomoe/module/dict/unihan-compiler.rb:1.4 --- tomoe/module/dict/unihan-compiler.rb:1.3 Tue Dec 5 12:38:59 2006 +++ tomoe/module/dict/unihan-compiler.rb Tue Dec 5 14:51:42 2006 @@ -47,7 +47,7 @@ case line when /^#/ # next - when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/ + when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u ucs4 = $1 key = $2 value = $3 From kous users.sourceforge.jp Tue Dec 5 14:51:43 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 14:51:43 +0900 Subject: [Tomoe-cvs 1637] CVS update: tomoe/module/recognizer Message-ID: <20061205055143.1AE9C2AC0FC@users.sourceforge.jp> Index: tomoe/module/recognizer/Makefile.am diff -u tomoe/module/recognizer/Makefile.am:1.2 tomoe/module/recognizer/Makefile.am:1.3 --- tomoe/module/recognizer/Makefile.am:1.2 Tue Dec 5 14:26:02 2006 +++ tomoe/module/recognizer/Makefile.am Tue Dec 5 14:51:42 2006 @@ -20,14 +20,8 @@ CLEANFILES = *~ *.bak -AM_CPPFLAGS = \ - -DG_LOG_DOMAIN=\"TOMOE-RECOGNIZER\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DDICTDIR=\""$(dictdir)"\" \ - -I$(top_srcdir)/lib - -INCLUDES = $(GLIB_CFLAGS) +AM_CPPFLAGS = -DG_LOG_DOMAIN=\"TOMOE-RECOGNIZER\" +INCLUDES = $(TOMOE_CFLAGS) recognizer_module_LTLIBRARIES = libsimple.la @@ -43,4 +37,4 @@ libsimple_la_LD_ADD = \ -lm -libsimple_la_LIBADD = $(GLIB_LIBS) +libsimple_la_LIBADD = $(TOMOE_LIBS) From kous users.sourceforge.jp Tue Dec 5 15:12:35 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 15:12:35 +0900 Subject: [Tomoe-cvs 1638] CVS update: tomoe Message-ID: <20061205061235.3D0042AC093@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.383 tomoe/ChangeLog:1.384 --- tomoe/ChangeLog:1.383 Tue Dec 5 14:51:42 2006 +++ tomoe/ChangeLog Tue Dec 5 15:12:35 2006 @@ -1,9 +1,15 @@ 2006-12-05 Kouhei Sutou + * configure.in, data/Makefile.am: install handwriting.xml to + $(datadir)/recognizer/ and all.xml to $(datadir)/dict/. + * lib/tomoe-recognizer.c, lib/tomoe-config.c, lib/tomoe-dict.c, + module/recognizer/tomoe-recognizer-simple.c: followed the changes. + * configure.in, **/Makefile.am: moved directory configuration from Makefile.am. * module/recognizer/tomoe-recognizer-simple.c: used DICTDIR instead of DATADIR. + * lib/tomoe-config.c: used DICTDIR and CONFDIR instead of TOMOESYSCONFDIR and TOMOEDATADIR. * lib/tomoe-recognizer.c: used RECOGNIZER_MODULEDIR instead of Index: tomoe/configure.in diff -u tomoe/configure.in:1.40 tomoe/configure.in:1.41 --- tomoe/configure.in:1.40 Tue Dec 5 14:51:42 2006 +++ tomoe/configure.in Tue Dec 5 15:12:35 2006 @@ -157,6 +157,18 @@ AC_SUBST(confdir) dnl ************************************************************** +dnl Configure for data. +dnl ************************************************************** + +datadir="${datadir}/\$(PACKAGE)" + +dict_datadir="${datadir}/dict" +AC_SUBST(dict_datadir) + +recognizer_datadir="${datadir}/recognizer" +AC_SUBST(recognizer_datadir) + +dnl ************************************************************** dnl Configure for modules. dnl ************************************************************** @@ -164,22 +176,19 @@ AC_SUBST(moduledir) dnl ************************************************************** -dnl Configure for recognizers. +dnl Configure for modules for recognizer. dnl ************************************************************** recognizer_moduledir="${moduledir}/recognizer" AC_SUBST(recognizer_moduledir) dnl ************************************************************** -dnl Configure for dictionaries. +dnl Configure for modules for dictionarie. dnl ************************************************************** dict_moduledir="${moduledir}/dict" AC_SUBST(dict_moduledir) -dictdir="${datadir}/\$(PACKAGE)" -AC_SUBST(dictdir) - use_unihan=yes AC_ARG_ENABLE(unihan, [ --disable-unihan disable Unihan detabase], @@ -299,7 +308,8 @@ TOMOE_CFLAGS=' \ $(GLIB_CFLAGS) \ -DCONFDIR=\""$(confdir)"\" \ - -DDICTDIR=\""$(dictdir)"\" \ + -DDICT_DATADIR=\""$(dict_datadir)"\" \ + -DRECOGNIZER_DATADIR=\""$(recognizer_datadir)"\" \ -DDICT_MODULEDIR=\""$(dict_moduledir)"\" \ -DRECOGNIZER_MODULEDIR=\""$(recognizer_moduledir)"\" \ -I$(top_srcdir)/lib' From kous users.sourceforge.jp Tue Dec 5 15:12:35 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 15:12:35 +0900 Subject: [Tomoe-cvs 1639] CVS update: tomoe/data Message-ID: <20061205061235.60EEF2AC0FC@users.sourceforge.jp> Index: tomoe/data/Makefile.am diff -u tomoe/data/Makefile.am:1.20 tomoe/data/Makefile.am:1.21 --- tomoe/data/Makefile.am:1.20 Tue Dec 5 14:51:42 2006 +++ tomoe/data/Makefile.am Tue Dec 5 15:12:35 2006 @@ -20,12 +20,16 @@ CLEANFILES = *~ *.bak *.valid -dict_DATA = tomoe-dict.dtd handwriting.xml kanjidic2.xml +data_DATA = tomoe-dict.dtd +dict_data_DATA = kanjidic2.xml +recognizer_data_DATA = handwriting.xml conf_DATA = config -EXTRA_DIST = \ - kanjidic2-original.xml kanjidic2-original.xsl \ - $(dict_DATA) \ +EXTRA_DIST = \ + kanjidic2-original.xml kanjidic2-original.xsl \ + $(data_DATA) \ + $(dict_data_DATA) \ + $(recognizer_data_DATA) \ $(conf_DATA) kanjidic2.xml: kanjidic2-original.xsl kanjidic2-original.xml From kous users.sourceforge.jp Tue Dec 5 15:12:35 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 15:12:35 +0900 Subject: [Tomoe-cvs 1640] CVS update: tomoe/lib Message-ID: <20061205061235.8D8452AC093@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.49 tomoe/lib/tomoe-config.c:1.50 --- tomoe/lib/tomoe-config.c:1.49 Tue Dec 5 14:51:42 2006 +++ tomoe/lib/tomoe-config.c Tue Dec 5 15:12:35 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.49 2006/12/05 05:51:42 kous Exp $ + * $Id: tomoe-config.c,v 1.50 2006/12/05 06:12:35 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -332,13 +332,13 @@ g_object_unref (dict); } - gdir = g_dir_open (DICTDIR, 0, NULL); + gdir = g_dir_open (DICT_DATADIR, 0, NULL); while ((filename = g_dir_read_name (gdir))) { gchar *path; if (!g_str_has_suffix (filename, ".xml")) continue; - path = g_build_filename(DICTDIR, filename, NULL); + path = g_build_filename(DICT_DATADIR, filename, NULL); if (tomoe_shelf_has_dict (shelf, path)) { g_free (path); continue; @@ -376,7 +376,7 @@ "user", TRUE); if (!user_dict) { gchar *tmp; - tmp = g_build_filename (DICTDIR, filename, NULL); + tmp = g_build_filename (DICT_DATADIR, filename, NULL); g_free (filename); filename = tmp; } @@ -418,7 +418,7 @@ "user", TRUE); if (!user_dict) { gchar *tmp; - tmp = g_build_filename (DICTDIR, database_name, NULL); + tmp = g_build_filename (DICT_DATADIR, database_name, NULL); g_free (database_name); database_name = tmp; } Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.129 tomoe/lib/tomoe-dict.c:1.130 --- tomoe/lib/tomoe-dict.c:1.129 Fri Dec 1 10:56:42 2006 +++ tomoe/lib/tomoe-dict.c Tue Dec 5 15:12:35 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.129 2006/12/01 01:56:42 ikezoe Exp $ + * $Id: tomoe-dict.c,v 1.130 2006/12/05 06:12:35 kous Exp $ */ #include "tomoe-dict.h" @@ -29,7 +29,7 @@ tomoe_dict_load (const gchar *base_dir) { if (!base_dir) - base_dir = DICTDIR; + base_dir = DICT_DATADIR; dicts = g_list_concat (tomoe_module_load_modules (base_dir), dicts); } From kous users.sourceforge.jp Tue Dec 5 15:12:35 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 15:12:35 +0900 Subject: [Tomoe-cvs 1641] CVS update: tomoe/module/recognizer Message-ID: <20061205061235.B1E842AC10A@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.5 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.6 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.5 Tue Dec 5 14:26:02 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Tue Dec 5 15:12:35 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.5 2006/12/05 05:26:02 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.6 2006/12/05 06:12:35 kous Exp $ */ #include @@ -159,7 +159,7 @@ if (!recognizer->dict) { recognizer->dict = tomoe_dict_new ("xml", - "filename", DICTDIR "/handwriting.xml", + "filename", RECOGNIZER_DATADIR "/handwriting.xml", NULL); } From kous users.sourceforge.jp Tue Dec 5 16:11:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 16:11:02 +0900 Subject: [Tomoe-cvs 1642] CVS update: tomoe Message-ID: <20061205071102.9B05F2AC1AF@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.384 tomoe/ChangeLog:1.385 --- tomoe/ChangeLog:1.384 Tue Dec 5 15:12:35 2006 +++ tomoe/ChangeLog Tue Dec 5 16:11:02 2006 @@ -1,5 +1,11 @@ 2006-12-05 Kouhei Sutou + * lib/tomoe-context.c, lib/tomoe-config.[ch]: supported user + dictionary. + * lib/tomoe-shelf.[ch]: renamed tomoe_shelf_add_dict() to + tomoe_shelf_register_dict() and tomoe_shelf_remove_dict() to + tomoe_shelf_unregister_dict(). + * configure.in, data/Makefile.am: install handwriting.xml to $(datadir)/recognizer/ and all.xml to $(datadir)/dict/. * lib/tomoe-recognizer.c, lib/tomoe-config.c, lib/tomoe-dict.c, Index: tomoe/configure.in diff -u tomoe/configure.in:1.41 tomoe/configure.in:1.42 --- tomoe/configure.in:1.41 Tue Dec 5 15:12:35 2006 +++ tomoe/configure.in Tue Dec 5 16:11:02 2006 @@ -308,6 +308,7 @@ TOMOE_CFLAGS=' \ $(GLIB_CFLAGS) \ -DCONFDIR=\""$(confdir)"\" \ + -DDATADIR=\""$(datadir)"\" \ -DDICT_DATADIR=\""$(dict_datadir)"\" \ -DRECOGNIZER_DATADIR=\""$(recognizer_datadir)"\" \ -DDICT_MODULEDIR=\""$(dict_moduledir)"\" \ From kous users.sourceforge.jp Tue Dec 5 16:11:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 16:11:02 +0900 Subject: [Tomoe-cvs 1643] CVS update: tomoe/lib Message-ID: <20061205071102.C95BB2AC1B2@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.50 tomoe/lib/tomoe-config.c:1.51 --- tomoe/lib/tomoe-config.c:1.50 Tue Dec 5 15:12:35 2006 +++ tomoe/lib/tomoe-config.c Tue Dec 5 16:11:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.50 2006/12/05 06:12:35 kous Exp $ + * $Id: tomoe-config.c,v 1.51 2006/12/05 07:11:02 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -35,6 +35,8 @@ #include "tomoe-config.h" #include "glib-utils.h" +#define DEFAULT_USER_DICT_NAME "user" + #define TOMOE_CONFIG_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_CONFIG, TomoeConfigPrivate)) @@ -42,6 +44,7 @@ struct _TomoeConfigPrivate { gchar *filename; + gchar *user_dict_name; GKeyFile *key_file; }; @@ -69,10 +72,14 @@ static void tomoe_config_load (TomoeConfig *config); static void tomoe_config_save (TomoeConfig *config); -static gboolean _tomoe_config_key_file_get_boolean_value (GKeyFile *key_file, - const gchar *group, - const gchar *key, - gboolean default_value); +static gboolean _tomoe_config_key_file_get_boolean (GKeyFile *key_file, + const gchar *group, + const gchar *key, + gboolean default_value); +static gchar *_tomoe_config_key_file_get_string (GKeyFile *key_file, + const gchar *group, + const gchar *key, + const gchar *default_value); static void _tomoe_config_load_system_dictionaries (TomoeConfig *config, TomoeShelf *shelf); static TomoeDict *_tomoe_config_load_dictionary (GKeyFile *key_file, @@ -107,6 +114,7 @@ TomoeConfigPrivate *priv = TOMOE_CONFIG_GET_PRIVATE (config); priv->filename = NULL; + priv->user_dict_name = NULL; priv->key_file = NULL; } @@ -135,14 +143,15 @@ tomoe_config_save (config); - if (priv->filename) { + if (priv->filename) g_free (priv->filename); - } - if (priv->key_file) { + if (priv->user_dict_name) + g_free (priv->user_dict_name); + if (priv->key_file) g_key_file_free (priv->key_file); - } priv->filename = NULL; + priv->user_dict_name = NULL; priv->key_file = NULL; if (G_OBJECT_CLASS (tomoe_config_parent_class)->dispose) @@ -215,6 +224,11 @@ } priv->key_file = key_file; + + priv->user_dict_name = + _tomoe_config_key_file_get_string (key_file, + "config", "user_dictionary", + DEFAULT_USER_DICT_NAME); } static void @@ -243,6 +257,28 @@ } } +const gchar * +tomoe_config_get_filename (TomoeConfig *config) +{ + TomoeConfigPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_CONFIG (config), NULL); + + priv = TOMOE_CONFIG_GET_PRIVATE(config); + return priv->filename; +} + +const gchar * +tomoe_config_get_user_dict_name (TomoeConfig *config) +{ + TomoeConfigPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_CONFIG (config), NULL); + + priv = TOMOE_CONFIG_GET_PRIVATE(config); + return priv->user_dict_name; +} + TomoeShelf * tomoe_config_make_shelf (TomoeConfig *config) { @@ -269,36 +305,40 @@ if (!g_str_has_suffix (dict_name, "-dictionary")) continue; - if (!_tomoe_config_key_file_get_boolean_value (key_file, dict_name, - "use", TRUE)) + if (!_tomoe_config_key_file_get_boolean (key_file, dict_name, + "use", TRUE)) continue; - type = g_key_file_get_string (key_file, dict_name, "type", NULL); - dict = _tomoe_config_load_dictionary (key_file, dict_name, - type ? type : "xml"); + type = _tomoe_config_key_file_get_string (key_file, dict_name, + "type", "xml"); + dict = _tomoe_config_load_dictionary (key_file, dict_name, type); if (dict) { - tomoe_shelf_add_dict (shelf, dict); + gchar tmp, *dictionary_suffix; + dictionary_suffix = g_strrstr (dict_name, "-dictionary"); + tmp = dict_name[dictionary_suffix - dict_name]; + dict_name[dictionary_suffix - dict_name] = '\0'; + tomoe_shelf_register_dict (shelf, dict_name, dict); + dict_name[dictionary_suffix - dict_name] = tmp; g_object_unref (dict); } g_free (type); } + g_strfreev(dicts); - if (_tomoe_config_key_file_get_boolean_value (key_file, - "config", - "use_system_dictionaries", - TRUE)) { + if (_tomoe_config_key_file_get_boolean (key_file, + "config", "use_system_dictionaries", + TRUE)) { _tomoe_config_load_system_dictionaries (config, shelf); } - g_strfreev(dicts); return shelf; } static gboolean -_tomoe_config_key_file_get_boolean_value (GKeyFile *key_file, - const gchar *group, - const gchar *key, - gboolean default_value) +_tomoe_config_key_file_get_boolean (GKeyFile *key_file, + const gchar *group, + const gchar *key, + gboolean default_value) { gboolean result; GError *error = NULL; @@ -319,6 +359,32 @@ return result; } +static gchar * +_tomoe_config_key_file_get_string (GKeyFile *key_file, + const gchar *group, + const gchar *key, + const gchar *default_value) +{ + gchar *result = NULL; + GError *error = NULL; + + result = g_key_file_get_string (key_file, group, key, &error); + if (error) { + switch (error->code) { + case G_KEY_FILE_ERROR_NOT_FOUND: + g_error_free (error); + break; + case G_KEY_FILE_ERROR_INVALID_VALUE: + TOMOE_HANDLE_ERROR (error); + break; + } + if (default_value) + result = g_strdup (default_value); + } + + return result; +} + static void _tomoe_config_load_system_dictionaries (TomoeConfig *config, TomoeShelf *shelf) { @@ -328,7 +394,7 @@ dict = tomoe_dict_new ("unihan", NULL); if (dict) { - tomoe_shelf_add_dict (shelf, dict); + tomoe_shelf_register_dict (shelf, "Unihan", dict); g_object_unref (dict); } @@ -347,7 +413,7 @@ dict = tomoe_dict_new ("xml", "filename", path, "editable", FALSE, NULL); if (dict) { - tomoe_shelf_add_dict (shelf, dict); + tomoe_shelf_register_dict (shelf, tomoe_dict_get_name (dict), dict); g_object_unref (dict); } @@ -370,9 +436,9 @@ return NULL; } - editable = _tomoe_config_key_file_get_boolean_value (key_file, dict_name, + editable = _tomoe_config_key_file_get_boolean (key_file, dict_name, "editable", TRUE); - user_dict = _tomoe_config_key_file_get_boolean_value (key_file, dict_name, + user_dict = _tomoe_config_key_file_get_boolean (key_file, dict_name, "user", TRUE); if (!user_dict) { gchar *tmp; @@ -412,9 +478,9 @@ return NULL; } - editable = _tomoe_config_key_file_get_boolean_value (key_file, dict_name, + editable = _tomoe_config_key_file_get_boolean (key_file, dict_name, "editable", TRUE); - user_dict = _tomoe_config_key_file_get_boolean_value (key_file, dict_name, + user_dict = _tomoe_config_key_file_get_boolean (key_file, dict_name, "user", TRUE); if (!user_dict) { gchar *tmp; Index: tomoe/lib/tomoe-config.h diff -u tomoe/lib/tomoe-config.h:1.23 tomoe/lib/tomoe-config.h:1.24 --- tomoe/lib/tomoe-config.h:1.23 Tue Dec 5 13:18:08 2006 +++ tomoe/lib/tomoe-config.h Tue Dec 5 16:11:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.h,v 1.23 2006/12/05 04:18:08 kous Exp $ + * $Id: tomoe-config.h,v 1.24 2006/12/05 07:11:02 kous Exp $ */ #ifndef __TOMOE_CONFIG_H__ @@ -53,6 +53,7 @@ TomoeConfig *tomoe_config_new (const char *config_file); const gchar *tomoe_config_get_filename (TomoeConfig *config); +const gchar *tomoe_config_get_user_dict_name (TomoeConfig *config); TomoeShelf *tomoe_config_make_shelf (TomoeConfig *config); G_END_DECLS Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.45 tomoe/lib/tomoe-context.c:1.46 --- tomoe/lib/tomoe-context.c:1.45 Tue Dec 5 14:11:03 2006 +++ tomoe/lib/tomoe-context.c Tue Dec 5 16:11:02 2006 @@ -17,9 +17,13 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.45 2006/12/05 05:11:03 kous Exp $ + * $Id: tomoe-context.c,v 1.46 2006/12/05 07:11:02 kous Exp $ */ +#include +#include +#include + #include "tomoe-dict.h" #include "tomoe-recognizer.h" #include "tomoe-context.h" @@ -28,6 +32,14 @@ #include "tomoe-candidate.h" #include "glib-utils.h" +#include + +#define DEFAULT_USER_DICT_CONTENT \ +"\n" \ +"\n" \ +"\n" \ +"\n" + #define TOMOE_CONTEXT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_CONTEXT, TomoeContextPrivate)) enum { @@ -40,6 +52,7 @@ { TomoeShelf *shelf; TomoeRecognizer *recognizer; + TomoeDict *user_dict; }; G_DEFINE_TYPE (TomoeContext, tomoe_context, G_TYPE_OBJECT) @@ -85,6 +98,7 @@ priv->shelf = NULL; priv->recognizer = NULL; + priv->user_dict = NULL; } /** @@ -154,13 +168,85 @@ g_object_unref (priv->shelf); if (priv->recognizer) g_object_unref (priv->recognizer); + if (priv->user_dict) + g_object_unref (priv->user_dict); priv->shelf = NULL; priv->recognizer = NULL; + priv->user_dict = NULL; G_OBJECT_CLASS (tomoe_context_parent_class)->dispose (object); } +static gchar * +ensure_user_dict_file (void) +{ + FILE *f; + gchar *tomoe_dir_name, *user_dict_filename; + const gchar *content; + + tomoe_dir_name = g_build_filename (g_get_home_dir (), ".tomoe", NULL); + + if (!g_file_test (tomoe_dir_name, G_FILE_TEST_EXISTS)) { + if (!g_mkdir (tomoe_dir_name, 0x700)) { + g_warning ("can't create %s: %s", tomoe_dir_name, strerror (errno)); + } + } + + if (!g_file_test (tomoe_dir_name, G_FILE_TEST_IS_DIR)) { + g_warning ("%s isn't directory: %s", tomoe_dir_name, strerror (errno)); + } + + user_dict_filename = g_build_filename (tomoe_dir_name, "dict.xml", NULL); + g_free (tomoe_dir_name); + + f = fopen (user_dict_filename, "wb"); + if (!f) { + g_warning ("failed to open %s: %s", + user_dict_filename, strerror (errno)); + g_free (user_dict_filename); + return NULL; + } + + content = DEFAULT_USER_DICT_CONTENT; + if (fwrite (content, strlen (content), 1, f) < 1) { + g_warning ("failed to write to %s: %s", + user_dict_filename, strerror (errno)); + g_free (user_dict_filename); + return NULL; + } + + fclose (f); + + return user_dict_filename; +} + +static TomoeDict * +ensure_user_dict (TomoeShelf *shelf, const gchar *name) +{ + TomoeDict *user_dict; + + g_return_val_if_fail (TOMOE_IS_SHELF (shelf), NULL); + + user_dict = tomoe_shelf_get_dict (shelf, name); + if (user_dict) { + g_object_ref (user_dict); + } else { + gchar *user_dict_filename; + + user_dict_filename = ensure_user_dict_file (); + if (user_dict_filename) { + user_dict = tomoe_dict_new ("xml", + "filename", user_dict_filename, + "editable", TRUE, + NULL); + g_free (user_dict_filename); + } + } + + return user_dict; +} + /** * tomoe_context_load_config: * @ctx: a #TomoeContext. @@ -169,7 +255,7 @@ * Load dictionaries into configuration file. */ void -tomoe_context_load_config (TomoeContext *ctx, const char *config_file) +tomoe_context_load_config (TomoeContext *ctx, const gchar *config_file) { TomoeContextPrivate *priv; TomoeConfig* cfg; @@ -178,7 +264,13 @@ priv = TOMOE_CONTEXT_GET_PRIVATE(ctx); cfg = tomoe_config_new (config_file); + + if (priv->shelf) + g_object_unref (priv->shelf); priv->shelf = tomoe_config_make_shelf (cfg); + priv->user_dict = ensure_user_dict (priv->shelf, + tomoe_config_get_user_dict_name (cfg)); + g_object_unref (cfg); } Index: tomoe/lib/tomoe-shelf.c diff -u tomoe/lib/tomoe-shelf.c:1.10 tomoe/lib/tomoe-shelf.c:1.11 --- tomoe/lib/tomoe-shelf.c:1.10 Mon Nov 27 16:52:03 2006 +++ tomoe/lib/tomoe-shelf.c Tue Dec 5 16:11:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-shelf.c,v 1.10 2006/11/27 07:52:03 kous Exp $ + * $Id: tomoe-shelf.c,v 1.11 2006/12/05 07:11:02 kous Exp $ */ #include "tomoe-dict.h" @@ -82,34 +82,36 @@ G_OBJECT_CLASS (tomoe_shelf_parent_class)->dispose (object); } -void -tomoe_shelf_add_dict (TomoeShelf *shelf, TomoeDict *dict) +TomoeDict * +tomoe_shelf_get_dict (TomoeShelf *shelf, const gchar *name) { TomoeShelfPrivate *priv; - g_return_if_fail (shelf); - g_return_if_fail (dict); - g_return_if_fail (tomoe_dict_get_name(dict)); + + g_return_val_if_fail(shelf, NULL); + g_return_val_if_fail(name, NULL); priv = TOMOE_SHELF_GET_PRIVATE (shelf); - g_hash_table_insert (priv->dicts, - g_strdup (tomoe_dict_get_name (dict)), - g_object_ref (dict)); + return g_hash_table_lookup(priv->dicts, name); } -TomoeDict * -tomoe_shelf_get_dict (TomoeShelf *shelf, const gchar *name) +void +tomoe_shelf_register_dict (TomoeShelf *shelf, const gchar *name, + TomoeDict *dict) { TomoeShelfPrivate *priv; - g_return_val_if_fail(shelf, NULL); - g_return_val_if_fail(name, NULL); + g_return_if_fail (TOMOE_IS_SHELF (shelf)); + g_return_if_fail (name); + g_return_if_fail (dict); priv = TOMOE_SHELF_GET_PRIVATE (shelf); - return g_hash_table_lookup(priv->dicts, name); + g_hash_table_insert (priv->dicts, + g_strdup (name), + g_object_ref (dict)); } gboolean -tomoe_shelf_remove_dict (TomoeShelf *shelf, const gchar *name) +tomoe_shelf_unregister_dict (TomoeShelf *shelf, const gchar *name) { TomoeShelfPrivate *priv; Index: tomoe/lib/tomoe-shelf.h diff -u tomoe/lib/tomoe-shelf.h:1.10 tomoe/lib/tomoe-shelf.h:1.11 --- tomoe/lib/tomoe-shelf.h:1.10 Fri Dec 1 10:40:38 2006 +++ tomoe/lib/tomoe-shelf.h Tue Dec 5 16:11:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-shelf.h,v 1.10 2006/12/01 01:40:38 ikezoe Exp $ + * $Id: tomoe-shelf.h,v 1.11 2006/12/05 07:11:02 kous Exp $ */ #ifndef __TOMOE_SHELF_H__ @@ -53,11 +53,12 @@ TomoeShelf *tomoe_shelf_new (void); -void tomoe_shelf_add_dict (TomoeShelf *shelf, - TomoeDict *dict); TomoeDict *tomoe_shelf_get_dict (TomoeShelf *shelf, const gchar *name); -gboolean tomoe_shelf_remove_dict (TomoeShelf *shelf, +void tomoe_shelf_register_dict (TomoeShelf *shelf, + const gchar *name, + TomoeDict *dict); +gboolean tomoe_shelf_unregister_dict(TomoeShelf *shelf, const gchar *name); GList *tomoe_shelf_get_dict_names (TomoeShelf *shelf); gboolean tomoe_shelf_has_dict (TomoeShelf *shelf, From makeinu users.sourceforge.jp Tue Dec 5 17:04:06 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 17:04:06 +0900 Subject: [Tomoe-cvs 1644] CVS update: tomoe Message-ID: <20061205080406.7D8192AC069@users.sourceforge.jp> Index: tomoe/configure.in diff -u tomoe/configure.in:1.42 tomoe/configure.in:1.43 --- tomoe/configure.in:1.42 Tue Dec 5 16:11:02 2006 +++ tomoe/configure.in Tue Dec 5 17:04:06 2006 @@ -305,15 +305,7 @@ dnl Configure for TOMOE. dnl ************************************************************** -TOMOE_CFLAGS=' \ - $(GLIB_CFLAGS) \ - -DCONFDIR=\""$(confdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DDICT_DATADIR=\""$(dict_datadir)"\" \ - -DRECOGNIZER_DATADIR=\""$(recognizer_datadir)"\" \ - -DDICT_MODULEDIR=\""$(dict_moduledir)"\" \ - -DRECOGNIZER_MODULEDIR=\""$(recognizer_moduledir)"\" \ - -I$(top_srcdir)/lib' +TOMOE_CFLAGS='$(GLIB_CFLAGS) -DCONFDIR=\""$(confdir)"\" -DDATADIR=\""$(datadir)"\" -DDICT_DATADIR=\""$(dict_datadir)"\" -DRECOGNIZER_DATADIR=\""$(recognizer_datadir)"\" -DDICT_MODULEDIR=\""$(dict_moduledir)"\" -DRECOGNIZER_MODULEDIR=\""$(recognizer_moduledir)"\" -I$(top_srcdir)/lib' AC_SUBST(TOMOE_CFLAGS) TOMOE_LIBS='$(GLIB_LIBS)' From kous users.sourceforge.jp Tue Dec 5 17:10:23 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:10:23 +0900 Subject: [Tomoe-cvs 1645] CVS update: tomoe Message-ID: <20061205081023.96D102AC069@users.sourceforge.jp> Index: tomoe/configure.in diff -u tomoe/configure.in:1.43 tomoe/configure.in:1.44 --- tomoe/configure.in:1.43 Tue Dec 5 17:04:06 2006 +++ tomoe/configure.in Tue Dec 5 17:10:23 2006 @@ -305,7 +305,14 @@ dnl Configure for TOMOE. dnl ************************************************************** -TOMOE_CFLAGS='$(GLIB_CFLAGS) -DCONFDIR=\""$(confdir)"\" -DDATADIR=\""$(datadir)"\" -DDICT_DATADIR=\""$(dict_datadir)"\" -DRECOGNIZER_DATADIR=\""$(recognizer_datadir)"\" -DDICT_MODULEDIR=\""$(dict_moduledir)"\" -DRECOGNIZER_MODULEDIR=\""$(recognizer_moduledir)"\" -I$(top_srcdir)/lib' +TOMOE_CFLAGS="$TOMOE_CFLAGS \$(GLIB_CFLAGS)" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DCONFDIR=\\\"\"\$(confdir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DDATADIR=\\\"\"\$(datadir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DDICT_DATADIR=\\\"\"\$(dict_datadir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DRECOGNIZER_DATADIR=\\\"\"\$(recognizer_datadir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DDICT_MODULEDIR=\\\"\"\$(dict_moduledir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DRECOGNIZER_MODULEDIR=\\\"\"\$(recognizer_moduledir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -I\$(top_srcdir)/lib" AC_SUBST(TOMOE_CFLAGS) TOMOE_LIBS='$(GLIB_LIBS)' From kous users.sourceforge.jp Tue Dec 5 17:33:05 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:33:05 +0900 Subject: [Tomoe-cvs 1646] CVS update: tomoe Message-ID: <20061205083305.2BA7E2AC066@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.385 tomoe/ChangeLog:1.386 --- tomoe/ChangeLog:1.385 Tue Dec 5 16:11:02 2006 +++ tomoe/ChangeLog Tue Dec 5 17:33:04 2006 @@ -1,7 +1,15 @@ 2006-12-05 Kouhei Sutou + * lib/tomoe-context.[ch]: added tomoe_context_{,un}register(). + * test/context_spec.rb: added tests for + tomoe_context_{,un}register(). + + * lib/glib-utils.c: fixed a boundary value related bug. + * test/data/one_stroke.data: followed the fixing. + * lib/tomoe-context.c, lib/tomoe-config.[ch]: supported user dictionary. + * lib/tomoe-shelf.[ch]: renamed tomoe_shelf_add_dict() to tomoe_shelf_register_dict() and tomoe_shelf_remove_dict() to tomoe_shelf_unregister_dict(). From kous users.sourceforge.jp Tue Dec 5 17:33:05 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:33:05 +0900 Subject: [Tomoe-cvs 1647] CVS update: tomoe/ext/ruby Message-ID: <20061205083305.6DECC2AC069@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-context.c diff -u tomoe/ext/ruby/tomoe-rb-context.c:1.12 tomoe/ext/ruby/tomoe-rb-context.c:1.13 --- tomoe/ext/ruby/tomoe-rb-context.c:1.12 Wed Nov 29 00:07:02 2006 +++ tomoe/ext/ruby/tomoe-rb-context.c Tue Dec 5 17:33:05 2006 @@ -29,6 +29,17 @@ /* RVAL2GLIST(queries))); */ /* } */ +static VALUE +tc_register(VALUE self, VALUE chr) +{ + return CBOOL2RVAL(tomoe_context_register(_SELF(self), RVAL2TCHR(chr))); +} + +static VALUE +tc_unregister(VALUE self, VALUE utf8) +{ + return CBOOL2RVAL(tomoe_context_unregister(_SELF(self), RVAL2CSTR(utf8))); +} void Init_tomoe_context(VALUE mTomoe) @@ -40,4 +51,7 @@ rb_define_method(cTomoeContext, "load_config", tc_load_config, -1); rb_define_method(cTomoeContext, "search", tc_search, 1); /* rb_define_method(cTomoeContext, "multi_search", tc_multi_search, 1); */ + + rb_define_method(cTomoeContext, "register", tc_register, 1); + rb_define_method(cTomoeContext, "unregister", tc_unregister, 1); } From kous users.sourceforge.jp Tue Dec 5 17:33:05 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:33:05 +0900 Subject: [Tomoe-cvs 1648] CVS update: tomoe/lib Message-ID: <20061205083305.A972D2AC066@users.sourceforge.jp> Index: tomoe/lib/glib-utils.c diff -u tomoe/lib/glib-utils.c:1.1 tomoe/lib/glib-utils.c:1.2 --- tomoe/lib/glib-utils.c:1.1 Mon Nov 27 17:52:01 2006 +++ tomoe/lib/glib-utils.c Tue Dec 5 17:33:05 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.c,v 1.1 2006/11/27 08:52:01 kous Exp $ + * $Id: glib-utils.c,v 1.2 2006/12/05 08:33:05 kous Exp $ */ #include @@ -28,10 +28,11 @@ GFunc func, gpointer user_data) { - guint i; + gint i; - for (i = array->len - 1; i; i--) { - func (g_ptr_array_index (array, i), user_data); + i = array->len - 1; + while (i >= 0) { + func (g_ptr_array_index (array, i--), user_data); } } Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.46 tomoe/lib/tomoe-context.c:1.47 --- tomoe/lib/tomoe-context.c:1.46 Tue Dec 5 16:11:02 2006 +++ tomoe/lib/tomoe-context.c Tue Dec 5 17:33:05 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.46 2006/12/05 07:11:02 kous Exp $ + * $Id: tomoe-context.c,v 1.47 2006/12/05 08:33:05 kous Exp $ */ #include @@ -343,6 +343,38 @@ return tomoe_context_search_by_dict (context, query); } +gboolean +tomoe_context_register (TomoeContext *context, TomoeChar *chr) +{ + TomoeContextPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_CONTEXT (context), FALSE); + + priv = TOMOE_CONTEXT_GET_PRIVATE (context); + if (!priv->user_dict) { + g_warning ("user dictionary doesn't exist"); + return FALSE; + } + + return tomoe_dict_register_char (priv->user_dict, chr); +} + +gboolean +tomoe_context_unregister (TomoeContext *context, const gchar *utf8) +{ + TomoeContextPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_CONTEXT (context), FALSE); + + priv = TOMOE_CONTEXT_GET_PRIVATE (context); + if (!priv->user_dict) { + g_warning ("user dictionary doesn't exist"); + return FALSE; + } + + return tomoe_dict_unregister_char (priv->user_dict, utf8); +} + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/lib/tomoe-context.h diff -u tomoe/lib/tomoe-context.h:1.32 tomoe/lib/tomoe-context.h:1.33 --- tomoe/lib/tomoe-context.h:1.32 Mon Dec 4 13:36:48 2006 +++ tomoe/lib/tomoe-context.h Tue Dec 5 17:33:05 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.h,v 1.32 2006/12/04 04:36:48 kous Exp $ + * $Id: tomoe-context.h,v 1.33 2006/12/05 08:33:05 kous Exp $ */ #ifndef __TOMOE_CONTEXT_H__ @@ -63,6 +63,11 @@ GList *tomoe_context_multi_search (TomoeContext *ctx, GList *queries); +gboolean tomoe_context_register (TomoeContext *ctx, + TomoeChar *chr); +gboolean tomoe_context_unregister (TomoeContext *ctx, + const gchar *utf8); + G_END_DECLS #endif /* __TOMOE_CONTEXT_H__ */ From kous users.sourceforge.jp Tue Dec 5 17:33:05 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:33:05 +0900 Subject: [Tomoe-cvs 1649] CVS update: tomoe/module/dict Message-ID: <20061205083305.D506E2AC069@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.6 tomoe/module/dict/tomoe-dict-xml.c:1.7 --- tomoe/module/dict/tomoe-dict-xml.c:1.6 Thu Nov 30 15:40:33 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Tue Dec 5 17:33:05 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.6 2006/11/30 06:40:33 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.7 2006/12/05 08:33:05 kous Exp $ */ #include @@ -286,13 +286,14 @@ } static gboolean -register_char (TomoeDict *_dict, TomoeChar *add) +register_char (TomoeDict *_dict, TomoeChar *chr) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - g_return_val_if_fail (add, FALSE); + g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); - g_ptr_array_add (dict->chars, g_object_ref (G_OBJECT (add))); + g_ptr_array_add (dict->chars, g_object_ref (G_OBJECT (chr))); g_ptr_array_sort (dict->chars, letter_compare_func); dict->modified = TRUE; From kous users.sourceforge.jp Tue Dec 5 17:33:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:33:06 +0900 Subject: [Tomoe-cvs 1650] CVS update: tomoe/test Message-ID: <20061205083306.0F7AA2AC066@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.21 tomoe/test/context_spec.rb:1.22 --- tomoe/test/context_spec.rb:1.21 Tue Dec 5 14:07:17 2006 +++ tomoe/test/context_spec.rb Tue Dec 5 17:33:05 2006 @@ -32,4 +32,44 @@ cands = context.search(query) cands.collect {|cand| cand.char.utf8}.sort.should == ["?, "??, "??].sort end + + specify "User dictionary" do + user_dict_file = Tempfile.new("tomoe-user-dict") + user_dict_file.open + user_dict_file.puts(<<-EOD) + + + + +EOD + user_dict_file.close + + config_file = Tempfile.new("tomoe-context") + config_file.open + config_file.puts(<<-EOC) +[config] +use_system_dictionaries = false +user_dictionary = user + +[user-dictionary] +type = xml +file = #{user_dict_file.path} +EOC + config_file.close + + context = Tomoe::Context.new() + context.load_config(config_file.path) + + context.search(Tomoe::Query.new).should_be_empty + + char = Tomoe::Char.new + char.utf8 = "?? + context.register(char).should + context.search(Tomoe::Query.new).collect do |cand| + cand.char.utf8 + end.should == [char.utf8] + + context.unregister(char.utf8).should + context.search(Tomoe::Query.new).should_be_empty + end end Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.18 tomoe/test/tomoe-spec-utils.rb:1.19 --- tomoe/test/tomoe-spec-utils.rb:1.18 Tue Dec 5 14:07:17 2006 +++ tomoe/test/tomoe-spec-utils.rb Tue Dec 5 17:33:05 2006 @@ -123,11 +123,6 @@ config_file.puts(<<-EOC) [unihan-dictionary] type = unihan -name = Unihan - -[handwriting-dictionary] -type = xml -file = #{File.join(data_dir, "handwriting.xml")} EOC else dictionaries.each_with_index do |dictionary, i| From kous users.sourceforge.jp Tue Dec 5 17:33:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 17:33:06 +0900 Subject: [Tomoe-cvs 1651] CVS update: tomoe/test/data Message-ID: <20061205083306.3BB912AC069@users.sourceforge.jp> Index: tomoe/test/data/one_stroke.data diff -u tomoe/test/data/one_stroke.data:1.1 tomoe/test/data/one_stroke.data:1.2 --- tomoe/test/data/one_stroke.data:1.1 Tue Nov 28 11:09:49 2006 +++ tomoe/test/data/one_stroke.data Tue Dec 5 17:33:06 2006 @@ -1,2 +1,2 @@ -?????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????? ?? ?????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????? ??????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????+?????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????? ?? ?????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????? ??????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????(^^) ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?????????? 376 183, 373 190, 373 196, 366 216, 366 222, 366 229, 366 232, 360 251, 353 270, 346 290, 343 296, 343 299, 336 319 From makeinu users.sourceforge.jp Tue Dec 5 17:48:35 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 17:48:35 +0900 Subject: [Tomoe-cvs 1652] CVS update: libtomoe-gtk Message-ID: <20061205084835.108422AC066@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.223 libtomoe-gtk/ChangeLog:1.224 --- libtomoe-gtk/ChangeLog:1.223 Tue Dec 5 14:18:19 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 17:48:34 2006 @@ -1,5 +1,9 @@ 2006-12-05 Takuro Ashie + * src/*.[ch]: Mode: C + +2006-12-05 Takuro Ashie + * src/tomoe-char-table.[ch]: Set the font on initializing time instead of realizing time. Avoid needless drawing. From makeinu users.sourceforge.jp Tue Dec 5 17:48:35 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 17:48:35 +0900 Subject: [Tomoe-cvs 1653] CVS update: libtomoe-gtk/src Message-ID: <20061205084835.5F5142AC066@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.h diff -u libtomoe-gtk/src/tomoe-canvas.h:1.9 libtomoe-gtk/src/tomoe-canvas.h:1.10 --- libtomoe-gtk/src/tomoe-canvas.h:1.9 Mon Nov 27 11:58:39 2006 +++ libtomoe-gtk/src/tomoe-canvas.h Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Copyright (C) 2006 Juernjakob Harder Index: libtomoe-gtk/src/tomoe-char-table.c diff -u libtomoe-gtk/src/tomoe-char-table.c:1.10 libtomoe-gtk/src/tomoe-char-table.c:1.11 --- libtomoe-gtk/src/tomoe-char-table.c:1.10 Tue Dec 5 14:18:19 2006 +++ libtomoe-gtk/src/tomoe-char-table.c Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Index: libtomoe-gtk/src/tomoe-char-table.h diff -u libtomoe-gtk/src/tomoe-char-table.h:1.3 libtomoe-gtk/src/tomoe-char-table.h:1.4 --- libtomoe-gtk/src/tomoe-char-table.h:1.3 Tue Nov 28 15:01:53 2006 +++ libtomoe-gtk/src/tomoe-char-table.h Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Index: libtomoe-gtk/src/tomoe-details.h diff -u libtomoe-gtk/src/tomoe-details.h:1.5 libtomoe-gtk/src/tomoe-details.h:1.6 --- libtomoe-gtk/src/tomoe-details.h:1.5 Tue Nov 21 20:17:22 2006 +++ libtomoe-gtk/src/tomoe-details.h Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-edit-char.c diff -u libtomoe-gtk/src/tomoe-edit-char.c:1.11 libtomoe-gtk/src/tomoe-edit-char.c:1.12 --- libtomoe-gtk/src/tomoe-edit-char.c:1.11 Mon Nov 27 16:20:53 2006 +++ libtomoe-gtk/src/tomoe-edit-char.c Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-edit-char.h diff -u libtomoe-gtk/src/tomoe-edit-char.h:1.5 libtomoe-gtk/src/tomoe-edit-char.h:1.6 --- libtomoe-gtk/src/tomoe-edit-char.h:1.5 Tue Nov 21 20:17:22 2006 +++ libtomoe-gtk/src/tomoe-edit-char.h Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-edit-meta.c diff -u libtomoe-gtk/src/tomoe-edit-meta.c:1.3 libtomoe-gtk/src/tomoe-edit-meta.c:1.4 --- libtomoe-gtk/src/tomoe-edit-meta.c:1.3 Thu Nov 16 15:58:42 2006 +++ libtomoe-gtk/src/tomoe-edit-meta.c Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-edit-meta.h diff -u libtomoe-gtk/src/tomoe-edit-meta.h:1.3 libtomoe-gtk/src/tomoe-edit-meta.h:1.4 --- libtomoe-gtk/src/tomoe-edit-meta.h:1.3 Tue Nov 21 15:01:21 2006 +++ libtomoe-gtk/src/tomoe-edit-meta.h Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-edit-strokes.c diff -u libtomoe-gtk/src/tomoe-edit-strokes.c:1.12 libtomoe-gtk/src/tomoe-edit-strokes.c:1.13 --- libtomoe-gtk/src/tomoe-edit-strokes.c:1.12 Fri Nov 24 11:09:25 2006 +++ libtomoe-gtk/src/tomoe-edit-strokes.c Tue Dec 5 17:48:35 2006 @@ -1,5 +1,5 @@ - -/* +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + /* * Copyright (C) 2006 Juernjakob Harder * * This library is free software; you can redistribute it and/or Index: libtomoe-gtk/src/tomoe-edit-strokes.h diff -u libtomoe-gtk/src/tomoe-edit-strokes.h:1.5 libtomoe-gtk/src/tomoe-edit-strokes.h:1.6 --- libtomoe-gtk/src/tomoe-edit-strokes.h:1.5 Tue Nov 21 20:17:22 2006 +++ libtomoe-gtk/src/tomoe-edit-strokes.h Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-gtk.h diff -u libtomoe-gtk/src/tomoe-gtk.h:1.8 libtomoe-gtk/src/tomoe-gtk.h:1.9 --- libtomoe-gtk/src/tomoe-gtk.h:1.8 Mon Dec 4 18:22:06 2006 +++ libtomoe-gtk/src/tomoe-gtk.h Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 HIGUCHI Daisuke * Copyright (C) 2006 Juernjakob Harder Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.18 libtomoe-gtk/src/tomoe-gucharmap.c:1.19 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.18 Tue Dec 5 13:15:37 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Takuro Ashie * Index: libtomoe-gtk/src/tomoe-gucharmap.h diff -u libtomoe-gtk/src/tomoe-gucharmap.h:1.5 libtomoe-gtk/src/tomoe-gucharmap.h:1.6 --- libtomoe-gtk/src/tomoe-gucharmap.h:1.5 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.h Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Copyright (C) 2006 Takuro Ashie Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.5 libtomoe-gtk/src/tomoe-handwriting.c:1.6 --- libtomoe-gtk/src/tomoe-handwriting.c:1.5 Tue Dec 5 13:29:29 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Copyright (C) 2006 Juernjakob Harder Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.6 libtomoe-gtk/src/tomoe-handwriting.h:1.7 --- libtomoe-gtk/src/tomoe-handwriting.h:1.6 Tue Dec 5 13:29:29 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Copyright (C) 2006 Juernjakob Harder Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.18 libtomoe-gtk/src/tomoe-reading-search.c:1.19 --- libtomoe-gtk/src/tomoe-reading-search.c:1.18 Mon Dec 4 15:39:26 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.4 libtomoe-gtk/src/tomoe-reading-search.h:1.5 --- libtomoe-gtk/src/tomoe-reading-search.h:1.4 Mon Dec 4 14:08:11 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Tue Dec 5 17:48:35 2006 @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * Index: libtomoe-gtk/src/tomoe-scrollable.c diff -u libtomoe-gtk/src/tomoe-scrollable.c:1.4 libtomoe-gtk/src/tomoe-scrollable.c:1.5 --- libtomoe-gtk/src/tomoe-scrollable.c:1.4 Tue Nov 21 20:11:31 2006 +++ libtomoe-gtk/src/tomoe-scrollable.c Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Takuro Ashie * Index: libtomoe-gtk/src/tomoe-scrollable.h diff -u libtomoe-gtk/src/tomoe-scrollable.h:1.1 libtomoe-gtk/src/tomoe-scrollable.h:1.2 --- libtomoe-gtk/src/tomoe-scrollable.h:1.1 Thu Nov 16 14:23:23 2006 +++ libtomoe-gtk/src/tomoe-scrollable.h Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Takuro Ashie * Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.34 libtomoe-gtk/src/tomoe-window.c:1.35 --- libtomoe-gtk/src/tomoe-window.c:1.34 Mon Dec 4 18:10:34 2006 +++ libtomoe-gtk/src/tomoe-window.c Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Copyright (C) 2006 Juernjakob Harder Index: libtomoe-gtk/src/tomoe-window.h diff -u libtomoe-gtk/src/tomoe-window.h:1.14 libtomoe-gtk/src/tomoe-window.h:1.15 --- libtomoe-gtk/src/tomoe-window.h:1.14 Mon Dec 4 18:10:34 2006 +++ libtomoe-gtk/src/tomoe-window.h Tue Dec 5 17:48:35 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2005 Takuro Ashie * Copyright (C) 2006 Juernjakob Harder From makeinu users.sourceforge.jp Tue Dec 5 17:52:21 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 17:52:21 +0900 Subject: [Tomoe-cvs 1654] CVS update: libtomoe-gtk Message-ID: <20061205085221.2F5D72AC066@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.224 libtomoe-gtk/ChangeLog:1.225 --- libtomoe-gtk/ChangeLog:1.224 Tue Dec 5 17:48:34 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 17:52:21 2006 @@ -1,6 +1,6 @@ 2006-12-05 Takuro Ashie - * src/*.[ch]: Mode: C + * src/*.[ch]: Mode: C, ts=4 2006-12-05 Takuro Ashie From makeinu users.sourceforge.jp Tue Dec 5 17:52:21 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 17:52:21 +0900 Subject: [Tomoe-cvs 1655] CVS update: libtomoe-gtk/src Message-ID: <20061205085221.7161F2AC066@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.h diff -u libtomoe-gtk/src/tomoe-canvas.h:1.10 libtomoe-gtk/src/tomoe-canvas.h:1.11 --- libtomoe-gtk/src/tomoe-canvas.h:1.10 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-canvas.h Tue Dec 5 17:52:21 2006 @@ -95,3 +95,7 @@ G_END_DECLS #endif /* __TOMOE_CANVAS_H__ */ + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-char-table.h diff -u libtomoe-gtk/src/tomoe-char-table.h:1.4 libtomoe-gtk/src/tomoe-char-table.h:1.5 --- libtomoe-gtk/src/tomoe-char-table.h:1.4 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-char-table.h Tue Dec 5 17:52:21 2006 @@ -77,3 +77,7 @@ G_END_DECLS #endif /* __TOMOE_CHAR_TABLE_H__ */ + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-details.h diff -u libtomoe-gtk/src/tomoe-details.h:1.6 libtomoe-gtk/src/tomoe-details.h:1.7 --- libtomoe-gtk/src/tomoe-details.h:1.6 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-details.h Tue Dec 5 17:52:21 2006 @@ -54,3 +54,6 @@ #endif /* __TOMOE_DETAILS_H__ */ +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-edit-char.h diff -u libtomoe-gtk/src/tomoe-edit-char.h:1.6 libtomoe-gtk/src/tomoe-edit-char.h:1.7 --- libtomoe-gtk/src/tomoe-edit-char.h:1.6 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-edit-char.h Tue Dec 5 17:52:21 2006 @@ -53,5 +53,7 @@ G_END_DECLS #endif /* __TOMOE_EDIT_CHAR_H__ */ - - + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-edit-meta.h diff -u libtomoe-gtk/src/tomoe-edit-meta.h:1.4 libtomoe-gtk/src/tomoe-edit-meta.h:1.5 --- libtomoe-gtk/src/tomoe-edit-meta.h:1.4 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-edit-meta.h Tue Dec 5 17:52:21 2006 @@ -63,5 +63,7 @@ G_END_DECLS #endif /* __TOMOE_EDIT_META_H__ */ - - + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-edit-strokes.h diff -u libtomoe-gtk/src/tomoe-edit-strokes.h:1.6 libtomoe-gtk/src/tomoe-edit-strokes.h:1.7 --- libtomoe-gtk/src/tomoe-edit-strokes.h:1.6 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-edit-strokes.h Tue Dec 5 17:52:21 2006 @@ -55,5 +55,7 @@ G_END_DECLS #endif /* __TOMOE_EDIT_STROKES_H__ */ - - + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-gtk.h diff -u libtomoe-gtk/src/tomoe-gtk.h:1.9 libtomoe-gtk/src/tomoe-gtk.h:1.10 --- libtomoe-gtk/src/tomoe-gtk.h:1.9 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-gtk.h Tue Dec 5 17:52:21 2006 @@ -29,3 +29,7 @@ #include #endif /* __TOMOE_GTK_H_INCLUDED__ */ + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-gucharmap.c diff -u libtomoe-gtk/src/tomoe-gucharmap.c:1.19 libtomoe-gtk/src/tomoe-gucharmap.c:1.20 --- libtomoe-gtk/src/tomoe-gucharmap.c:1.19 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.c Tue Dec 5 17:52:21 2006 @@ -283,3 +283,7 @@ gucharmap_signals[SELECTED_SIGNAL], 0); #endif } + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-gucharmap.h diff -u libtomoe-gtk/src/tomoe-gucharmap.h:1.6 libtomoe-gtk/src/tomoe-gucharmap.h:1.7 --- libtomoe-gtk/src/tomoe-gucharmap.h:1.6 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-gucharmap.h Tue Dec 5 17:52:21 2006 @@ -63,4 +63,7 @@ G_END_DECLS #endif /* __TOMOE_GUCHARMAP_H__ */ - + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.7 libtomoe-gtk/src/tomoe-handwriting.h:1.8 --- libtomoe-gtk/src/tomoe-handwriting.h:1.7 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Tue Dec 5 17:52:21 2006 @@ -67,3 +67,7 @@ G_END_DECLS #endif /* __TOMOE_HANDWRITING_H__ */ + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.5 libtomoe-gtk/src/tomoe-reading-search.h:1.6 --- libtomoe-gtk/src/tomoe-reading-search.h:1.5 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Tue Dec 5 17:52:21 2006 @@ -63,4 +63,7 @@ G_END_DECLS #endif /* __TOMOE_READING_SEARCH_H__ */ - + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-scrollable.h diff -u libtomoe-gtk/src/tomoe-scrollable.h:1.2 libtomoe-gtk/src/tomoe-scrollable.h:1.3 --- libtomoe-gtk/src/tomoe-scrollable.h:1.2 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-scrollable.h Tue Dec 5 17:52:21 2006 @@ -80,3 +80,7 @@ G_END_DECLS #endif /* __TOMOE_SCROLLABLE_H__ */ + +/* + * vi:ts=4:nowrap:ai:expandtab + */ Index: libtomoe-gtk/src/tomoe-window.h diff -u libtomoe-gtk/src/tomoe-window.h:1.15 libtomoe-gtk/src/tomoe-window.h:1.16 --- libtomoe-gtk/src/tomoe-window.h:1.15 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-window.h Tue Dec 5 17:52:21 2006 @@ -67,3 +67,7 @@ G_END_DECLS #endif /* __TOMOE_WINDOW_H__ */ + +/* + * vi:ts=4:nowrap:ai:expandtab + */ From kous users.sourceforge.jp Tue Dec 5 18:01:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 18:01:29 +0900 Subject: [Tomoe-cvs 1656] CVS update: tomoe Message-ID: <20061205090129.3F94F2AC069@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.386 tomoe/ChangeLog:1.387 --- tomoe/ChangeLog:1.386 Tue Dec 5 17:33:04 2006 +++ tomoe/ChangeLog Tue Dec 5 18:01:29 2006 @@ -1,5 +1,9 @@ 2006-12-05 Kouhei Sutou + * module/dict/tomoe-dict-ptr-array.[ch]: added. + * module/dict/Makefile.am, module/dict/tomoe-dict-unihan.c, + module/dict/tomoe-dict-xml.c: used tomoe-dict-ptr-array.[ch]. + * lib/tomoe-context.[ch]: added tomoe_context_{,un}register(). * test/context_spec.rb: added tests for tomoe_context_{,un}register(). From kous users.sourceforge.jp Tue Dec 5 18:01:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 5 Dec 2006 18:01:29 +0900 Subject: [Tomoe-cvs 1657] CVS update: tomoe/module/dict Message-ID: <20061205090129.760D92AC0BB@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.11 tomoe/module/dict/Makefile.am:1.12 --- tomoe/module/dict/Makefile.am:1.11 Tue Dec 5 14:51:42 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 5 18:01:29 2006 @@ -36,9 +36,13 @@ -version-info $(LT_VERSION_INFO) \ -export-dynamic $(no_undefined) $(LIBTOOL_EXPORT_OPTIONS) +ptr_array_based_dict_sources = \ + tomoe-dict-ptr-array.c \ + tomoe-dict-ptr-array.h + dict_module_LTLIBRARIES = libxml.la -libxml_la_SOURCES = tomoe-dict-xml.c +libxml_la_SOURCES = tomoe-dict-xml.c $(ptr_array_based_dict_sources) if WITH_EST dict_module_LTLIBRARIES += libest.la @@ -66,7 +70,8 @@ tomoe-dict-unihan.c \ tomoe-unihan.c \ tomoe-unihan.h \ - $(unihan_built_sources) + $(unihan_built_sources) \ + $(ptr_array_based_dict_sources) tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt $(RUBY) unihan-compiler.rb Unihan.txt > $@ Index: tomoe/module/dict/tomoe-dict-ptr-array.c diff -u /dev/null tomoe/module/dict/tomoe-dict-ptr-array.c:1.1 --- /dev/null Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.c Tue Dec 5 18:01:29 2006 @@ -0,0 +1,186 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-ptr-array.c,v 1.1 2006/12/05 09:01:29 kous Exp $ + */ + +#include + +#include "tomoe-dict-ptr-array.h" + +#include +#include + +typedef struct _TomoeDictSearchContext { + TomoeQuery *query; + GList *results; +} TomoeDictSearchContext; + +static gint +letter_compare_func (gconstpointer a, gconstpointer b) +{ + TomoeChar *ca = *(TomoeChar **) a; + TomoeChar *cb = *(TomoeChar **) b; + return tomoe_char_compare (ca, cb); +} + +void +_tomoe_dict_ptr_array_sort (GPtrArray *chars) +{ + g_ptr_array_sort (chars, letter_compare_func); +} + +gboolean +_tomoe_dict_ptr_array_register_char (GPtrArray *chars, TomoeChar *chr) +{ + g_ptr_array_add (chars, g_object_ref (G_OBJECT (chr))); + _tomoe_dict_ptr_array_sort (chars); + + return TRUE; +} + +gboolean +_tomoe_dict_ptr_array_unregister_char (GPtrArray *chars, const gchar *utf8) +{ + TomoeChar *removed = NULL; + gint i, len, index = -1; + + g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); + + len = chars->len; + for (i = 0; i < len; i++) { + TomoeChar *chr = g_ptr_array_index (chars, i); + if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { + index = i; + removed = chr; + break; + } + } + + if (index >= 0) { + g_ptr_array_remove_index (chars, index); + g_object_unref (removed); + return TRUE; + } else { + return FALSE; + } +} + +TomoeChar * +_tomoe_dict_ptr_array_get_char (GPtrArray *chars, const gchar *utf8) +{ + gint i, len; + + g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); + + len = chars->len; + for (i = 0; i < len; i++) { + TomoeChar *chr = g_ptr_array_index (chars, i); + if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { + return chr; + } + } + + return NULL; +} + +static gboolean +does_match_char_with_n_strokes (TomoeChar *chr, gint min, gint max) +{ + TomoeWriting *writing; + gint n_strokes; + + if (min < 0 && max < 0) + return TRUE; + + writing = tomoe_char_get_writing (chr); + if (!writing) + return FALSE; + + n_strokes = tomoe_writing_get_n_strokes (writing); + return ((min < 0 || min <= n_strokes) && + (max < 0 || max >= n_strokes)); +} + +static gint +compare_reading (gconstpointer a, gconstpointer b) +{ + TomoeReading *reading, *searched_reading; + + reading = TOMOE_READING(a); + searched_reading = TOMOE_READING(b); + return strcmp(tomoe_reading_get_reading(reading), + tomoe_reading_get_reading(searched_reading)); +} + +static gboolean +does_match_char_with_readings (TomoeChar *chr, TomoeReading *reading) +{ + if (!reading) + return TRUE; + + if (g_list_find_custom ((GList *)tomoe_char_get_readings (chr), + reading, compare_reading)) + return TRUE; + else + return FALSE; +} + +static void +collect_chars_by_query (gpointer data, gpointer user_data) +{ + TomoeChar *chr = data; + TomoeDictSearchContext *context = user_data; + TomoeQuery *query; + TomoeReading *reading; + gint min_n_strokes, max_n_strokes; + + query = context->query; + + min_n_strokes = tomoe_query_get_min_n_strokes (query); + max_n_strokes = tomoe_query_get_max_n_strokes (query); + if (!does_match_char_with_n_strokes (chr, min_n_strokes, max_n_strokes)) + return; + + reading = g_list_nth_data ((GList *)tomoe_query_get_readings (query), 0); + if (!does_match_char_with_readings (chr, reading)) + return; + + context->results = g_list_prepend (context->results, + tomoe_candidate_new (chr)); +} + +GList * +_tomoe_dict_ptr_array_search (GPtrArray *chars, TomoeQuery *query) +{ + TomoeDictSearchContext search_context; + + search_context.query = g_object_ref (query); + search_context.results = NULL; + + g_ptr_array_foreach_reverse (chars, collect_chars_by_query, + &search_context); + g_object_unref (search_context.query); + + return search_context.results; +} + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/module/dict/tomoe-dict-ptr-array.h diff -u /dev/null tomoe/module/dict/tomoe-dict-ptr-array.h:1.1 --- /dev/null Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.h Tue Dec 5 18:01:29 2006 @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-ptr-array.h,v 1.1 2006/12/05 09:01:29 kous Exp $ + */ + +#ifndef __TOMOE_DICT_PTR_ARRAY_H__ +#define __TOMOE_DICT_PTR_ARRAY_H__ + +#include + +G_BEGIN_DECLS + +#include + +void _tomoe_dict_ptr_array_sort (GPtrArray *chars); +gboolean _tomoe_dict_ptr_array_register_char (GPtrArray *chars, + TomoeChar *chr); +gboolean _tomoe_dict_ptr_array_unregister_char (GPtrArray *chars, + const gchar *utf8); +TomoeChar *_tomoe_dict_ptr_array_get_char (GPtrArray *chars, + const gchar *utf8); +GList *_tomoe_dict_ptr_array_search (GPtrArray *chars, + TomoeQuery *query); + +G_END_DECLS + +#endif /* __TOMOE_DICT_PTR_ARRAY_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.2 tomoe/module/dict/tomoe-dict-unihan.c:1.3 --- tomoe/module/dict/tomoe-dict-unihan.c:1.2 Mon Dec 4 12:02:45 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Tue Dec 5 18:01:29 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.2 2006/12/04 03:02:45 kous Exp $ + * $Id: tomoe-dict-unihan.c,v 1.3 2006/12/05 09:01:29 kous Exp $ */ #include @@ -34,6 +34,7 @@ #include #include "tomoe-unihan.h" +#include "tomoe-dict-ptr-array.h" #define TOMOE_TYPE_DICT_UNIHAN tomoe_type_dict_unihan #define TOMOE_DICT_UNIHAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_UNIHAN, TomoeDictUnihan)) @@ -62,11 +63,6 @@ TomoeDictClass parent_class; }; -typedef struct _TomoeDictSearchContext { - TomoeQuery *query; - GList *results; -} TomoeDictSearchContext; - static GType tomoe_type_dict_unihan = 0; static GObjectClass *parent_class; static GPtrArray *chars = NULL; @@ -281,105 +277,20 @@ get_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); - guint i; g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), NULL); - g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); - - for (i = 0; i < chars->len; i++) { - TomoeChar *chr = g_ptr_array_index (chars, i); - if (0 == strcmp(tomoe_char_get_utf8(chr), utf8)) { - return chr; - } - } - - return NULL; -} - -static gboolean -tomoe_dict_unihan_does_match_char_with_n_strokes (TomoeChar *chr, - gint min, gint max) -{ - TomoeWriting *writing; - gint n_strokes; - - if (min < 0 && max < 0) - return TRUE; - - writing = tomoe_char_get_writing (chr); - if (!writing) - return FALSE; - - n_strokes = tomoe_writing_get_n_strokes (writing); - return ((min < 0 || min <= n_strokes) && - (max < 0 || max >= n_strokes)); -} - -static gint -tomoe_dict_unihan_compare_reading (gconstpointer a, gconstpointer b) -{ - TomoeReading *reading, *searched_reading; - reading = TOMOE_READING(a); - searched_reading = TOMOE_READING(b); - return strcmp(tomoe_reading_get_reading(reading), - tomoe_reading_get_reading(searched_reading)); -} - -static gboolean -tomoe_dict_unihan_does_match_char_with_readings (TomoeChar *chr, - TomoeReading *reading) -{ - if (!reading) - return TRUE; - - if (g_list_find_custom ((GList *)tomoe_char_get_readings (chr), - reading, tomoe_dict_unihan_compare_reading)) - return TRUE; - else - return FALSE; -} - -static void -tomoe_dict_unihan_collect_chars_by_query (gpointer data, gpointer user_data) -{ - TomoeChar *chr = data; - TomoeDictSearchContext *context = user_data; - TomoeQuery *query; - TomoeReading *reading; - gint min_n_strokes, max_n_strokes; - - query = context->query; - - min_n_strokes = tomoe_query_get_min_n_strokes (query); - max_n_strokes = tomoe_query_get_max_n_strokes (query); - if (!tomoe_dict_unihan_does_match_char_with_n_strokes (chr, - min_n_strokes, - max_n_strokes)) - return; - - reading = g_list_nth_data ((GList *)tomoe_query_get_readings (query), 0); - if (!tomoe_dict_unihan_does_match_char_with_readings (chr, reading)) - return; - - context->results = g_list_prepend (context->results, - tomoe_candidate_new (chr)); + return _tomoe_dict_ptr_array_get_char (chars, utf8); } static GList * search (TomoeDict *_dict, TomoeQuery *query) { - TomoeDictSearchContext search_context; - - search_context.query = g_object_ref (query); - search_context.results = NULL; + TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); - g_ptr_array_foreach_reverse (chars, - tomoe_dict_unihan_collect_chars_by_query, - &search_context); - g_object_unref (search_context.query); + g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); - return search_context.results; + return _tomoe_dict_ptr_array_search (chars, query); } static gboolean Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.7 tomoe/module/dict/tomoe-dict-xml.c:1.8 --- tomoe/module/dict/tomoe-dict-xml.c:1.7 Tue Dec 5 17:33:05 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Tue Dec 5 18:01:29 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.7 2006/12/05 08:33:05 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.8 2006/12/05 09:01:29 kous Exp $ */ #include @@ -37,6 +37,8 @@ #include #include +#include "tomoe-dict-ptr-array.h" + #define TOMOE_TYPE_DICT_XML tomoe_type_dict_xml #define TOMOE_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXML)) #define TOMOE_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) @@ -68,11 +70,6 @@ TomoeDictClass parent_class; }; -typedef struct _TomoeDictSearchContext { - TomoeQuery *query; - GList *results; -} TomoeDictSearchContext; - static GType tomoe_type_dict_xml = 0; static GObjectClass *parent_class; @@ -100,8 +97,6 @@ static gboolean flush (TomoeDict *dict); static gboolean tomoe_dict_xml_load (TomoeDictXML *dict); static gboolean tomoe_dict_xml_save (TomoeDictXML *dict); -static gint letter_compare_func (gconstpointer a, - gconstpointer b); static void class_init (TomoeDictXMLClass *klass) @@ -293,37 +288,22 @@ g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); - g_ptr_array_add (dict->chars, g_object_ref (G_OBJECT (chr))); - g_ptr_array_sort (dict->chars, letter_compare_func); - dict->modified = TRUE; - - return TRUE; + if (_tomoe_dict_ptr_array_register_char (dict->chars, chr)) { + dict->modified = TRUE; + return TRUE; + } else { + return FALSE; + } } static gboolean unregister_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - GPtrArray *chars; - TomoeChar *removed = NULL; - guint i, index = -1; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); - chars = dict->chars; - for (i = 0; i < chars->len; i++) { - TomoeChar *chr = g_ptr_array_index (chars, i); - if (0 == strcmp(tomoe_char_get_utf8(chr), utf8)) { - index = i; - removed = chr; - break; - } - } - - if (index >= 0) { - g_ptr_array_remove_index (chars, index); - g_object_unref (removed); + if (_tomoe_dict_ptr_array_unregister_char (dict->chars, utf8)) { dict->modified = TRUE; return TRUE; } else { @@ -335,108 +315,20 @@ get_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - GPtrArray *chars; - guint i; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - g_return_val_if_fail (utf8 && *utf8 != '\0', NULL); - - chars = dict->chars; - for (i = 0; i < chars->len; i++) { - TomoeChar *chr = g_ptr_array_index (chars, i); - if (0 == strcmp(tomoe_char_get_utf8(chr), utf8)) { - return chr; - } - } - - return NULL; -} - -static gboolean -tomoe_dict_xml_does_match_char_with_n_strokes (TomoeChar *chr, - gint min, gint max) -{ - TomoeWriting *writing; - gint n_strokes; - - if (min < 0 && max < 0) - return TRUE; - - writing = tomoe_char_get_writing (chr); - if (!writing) - return FALSE; - n_strokes = tomoe_writing_get_n_strokes (writing); - return ((min < 0 || min <= n_strokes) && - (max < 0 || max >= n_strokes)); -} - -static gint -tomoe_dict_xml_compare_reading (gconstpointer a, gconstpointer b) -{ - TomoeReading *reading, *searched_reading; - - reading = TOMOE_READING(a); - searched_reading = TOMOE_READING(b); - return strcmp(tomoe_reading_get_reading(reading), - tomoe_reading_get_reading(searched_reading)); -} - -static gboolean -tomoe_dict_xml_does_match_char_with_readings (TomoeChar *chr, - TomoeReading *reading) -{ - if (!reading) - return TRUE; - - if (g_list_find_custom ((GList *)tomoe_char_get_readings (chr), - reading, tomoe_dict_xml_compare_reading)) - return TRUE; - else - return FALSE; -} - -static void -tomoe_dict_xml_collect_chars_by_query (gpointer data, gpointer user_data) -{ - TomoeChar *chr = data; - TomoeDictSearchContext *context = user_data; - TomoeQuery *query; - TomoeReading *reading; - gint min_n_strokes, max_n_strokes; - - query = context->query; - - min_n_strokes = tomoe_query_get_min_n_strokes (query); - max_n_strokes = tomoe_query_get_max_n_strokes (query); - if (!tomoe_dict_xml_does_match_char_with_n_strokes (chr, - min_n_strokes, - max_n_strokes)) - return; - - reading = g_list_nth_data ((GList *)tomoe_query_get_readings (query), 0); - if (!tomoe_dict_xml_does_match_char_with_readings (chr, reading)) - return; - - context->results = g_list_prepend (context->results, - tomoe_candidate_new (chr)); + return _tomoe_dict_ptr_array_get_char (dict->chars, utf8); } static GList * search (TomoeDict *_dict, TomoeQuery *query) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictSearchContext search_context; - search_context.query = g_object_ref (query); - search_context.results = NULL; - - g_ptr_array_foreach_reverse (dict->chars, - tomoe_dict_xml_collect_chars_by_query, - &search_context); - g_object_unref (search_context.query); + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - return search_context.results; + return _tomoe_dict_ptr_array_search (dict->chars, query); } static gboolean @@ -452,14 +344,6 @@ } } -static gint -letter_compare_func (gconstpointer a, gconstpointer b) -{ - TomoeChar *ca = *(TomoeChar **) a; - TomoeChar *cb = *(TomoeChar **) b; - return tomoe_char_compare (ca, cb); -} - static gboolean tomoe_dict_xml_load (TomoeDictXML *dict) { @@ -474,7 +358,7 @@ dict->name = g_strdup (result.name); g_free (result.name); } - g_ptr_array_sort (dict->chars, letter_compare_func); + _tomoe_dict_ptr_array_sort (dict->chars); return success; } From makeinu users.sourceforge.jp Tue Dec 5 18:14:47 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 18:14:47 +0900 Subject: [Tomoe-cvs 1658] CVS update: libtomoe-gtk/src Message-ID: <20061205091447.1EBC22AC066@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-char-table.c diff -u libtomoe-gtk/src/tomoe-char-table.c:1.11 libtomoe-gtk/src/tomoe-char-table.c:1.12 --- libtomoe-gtk/src/tomoe-char-table.c:1.11 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-char-table.c Tue Dec 5 18:14:46 2006 @@ -529,7 +529,7 @@ guint i; GList *node; - if (!GTK_WIDGET_VISIBLE (widget) || !priv->pixmap) return; + if (!priv->pixmap) return; get_char_frame_size (view, &inner_width, &inner_height, From makeinu users.sourceforge.jp Tue Dec 5 21:55:31 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 21:55:31 +0900 Subject: [Tomoe-cvs 1659] CVS update: libtomoe-gtk Message-ID: <20061205125531.CE4BA2AC07B@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.225 libtomoe-gtk/ChangeLog:1.226 --- libtomoe-gtk/ChangeLog:1.225 Tue Dec 5 17:52:21 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 21:55:31 2006 @@ -1,5 +1,11 @@ 2006-12-05 Takuro Ashie + * src/tomoe-canvas.[ch]: Add "tomoe-context" property and remove + needless functions. + * src/tomoe-handwriting.c: Fix indent. + +2006-12-05 Takuro Ashie + * src/*.[ch]: Mode: C, ts=4 2006-12-05 Takuro Ashie From makeinu users.sourceforge.jp Tue Dec 5 21:55:32 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 21:55:32 +0900 Subject: [Tomoe-cvs 1660] CVS update: libtomoe-gtk/src Message-ID: <20061205125532.0D77D2AC0BE@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.42 libtomoe-gtk/src/tomoe-canvas.c:1.43 --- libtomoe-gtk/src/tomoe-canvas.c:1.42 Mon Dec 4 23:20:01 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Tue Dec 5 21:55:31 2006 @@ -24,6 +24,7 @@ #include #include +#include #include "tomoe-canvas.h" @@ -39,6 +40,11 @@ LAST_SIGNAL, }; +enum { + PROP_0, + PROP_TOMOE_CONTEXT +}; + typedef struct _TomoeCanvasPriv TomoeCanvasPriv; struct _TomoeCanvasPriv { @@ -66,8 +72,18 @@ #define TOMOE_CANVAS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_CANVAS, TomoeCanvasPriv)) G_DEFINE_TYPE (TomoeCanvas, tomoe_canvas, GTK_TYPE_WIDGET) + /* virtual functions for GtkObject class */ static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + /* virtual functions for GtkWidget class */ static void realize (GtkWidget *widget); static void size_allocate (GtkWidget *widget, @@ -95,6 +111,7 @@ static void tomoe_canvas_draw_background (TomoeCanvas *canvas, gboolean draw); static void tomoe_canvas_draw_axis (TomoeCanvas *canvas); +static void tomoe_canvas_refresh (TomoeCanvas *canvas); static void tomoe_canvas_resize_writing (TomoeCanvas *canvas, gdouble x_rate, gdouble y_rate); @@ -124,6 +141,23 @@ { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GParamSpec *spec; + + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + widget_class->realize = realize; + widget_class->size_allocate = size_allocate; + widget_class->expose_event = expose_event; + widget_class->button_press_event = button_press_event; + widget_class->button_release_event = button_release_event; + widget_class->motion_notify_event = motion_notify_event; + + klass->find = tomoe_canvas_real_find; + klass->clear = tomoe_canvas_real_clear; + klass->normalize = tomoe_canvas_real_normalize; + klass->stroke_added = NULL; + klass->stroke_reverted = NULL; canvas_signals[FIND_SIGNAL] = g_signal_new ("find", @@ -166,19 +200,12 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gobject_class->dispose = dispose; - widget_class->realize = realize; - widget_class->size_allocate = size_allocate; - widget_class->expose_event = expose_event; - widget_class->button_press_event = button_press_event; - widget_class->button_release_event = button_release_event; - widget_class->motion_notify_event = motion_notify_event; - - klass->find = tomoe_canvas_real_find; - klass->clear = tomoe_canvas_real_clear; - klass->normalize = tomoe_canvas_real_normalize; - klass->stroke_added = NULL; - klass->stroke_reverted = NULL; + spec = g_param_spec_object ("tomoe-context", + N_("Tomoe context"), + N_("A tomoe context which stores handwriting dictionaries."), + TOMOE_TYPE_CONTEXT, + G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); g_type_class_add_private (gobject_class, sizeof(TomoeCanvasPriv)); } @@ -249,6 +276,11 @@ priv->candidates = NULL; } + if (priv->context) { + g_object_unref (priv->context); + priv->context = NULL; + } + if (priv->writing) { g_object_unref (priv->writing); priv->writing = NULL; @@ -263,6 +295,46 @@ G_OBJECT_CLASS(tomoe_canvas_parent_class)->dispose(object); } +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeCanvas *canvas = TOMOE_CANVAS (object); + + switch (prop_id) { + case PROP_TOMOE_CONTEXT: + { + TomoeContext *ctx = TOMOE_CONTEXT (g_value_get_object (value)); + tomoe_canvas_set_context (canvas, ctx); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeCanvas *canvas = TOMOE_CANVAS (object); + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + switch (prop_id) { + case PROP_TOMOE_CONTEXT: + g_value_set_object (value, G_OBJECT (priv->context)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + GtkWidget * tomoe_canvas_new (void) { @@ -270,6 +342,24 @@ NULL)); } +void +tomoe_canvas_set_context (TomoeCanvas *canvas, TomoeContext *context) +{ + TomoeCanvasPriv *priv; + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + if (priv->context) + g_object_unref (priv->context); + if (context) + g_object_ref (context); + priv->context = context; + + g_object_notify (G_OBJECT (canvas), "tomoe-context"); +} + static void realize (GtkWidget *widget) { @@ -367,8 +457,6 @@ priv->auto_find_id = 0; } - /* tomoe_canvas_refresh (canvas); */ - if (event->button == 1) { priv->drawing = TRUE; tomoe_writing_move_to (priv->writing, (gint) event->x, (gint) event->y); @@ -719,44 +807,12 @@ } } -void -tomoe_canvas_refresh (TomoeCanvas *canvas) +const GList * +tomoe_canvas_get_candidates (TomoeCanvas *canvas) { - TomoeCanvasPriv *priv; - GtkWidget *widget; - guint i; - const GList *strokes, *list; - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - _init_gc (canvas); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - widget = GTK_WIDGET (canvas); - - gdk_draw_rectangle (priv->pixmap, - widget->style->white_gc, - TRUE, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - tomoe_canvas_draw_axis (canvas); - - if (priv->writing) { - strokes = tomoe_writing_get_strokes (priv->writing); - for (list = strokes, i = 1; list; list = g_list_next (list), i++) { - GList *points = (GList *) list->data; - draw_stroke (points, canvas, i); - } - } + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - gdk_draw_drawable(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - priv->pixmap, - 0, 0, - 0, 0, - widget->allocation.width, widget->allocation.height); + return priv->candidates; } void @@ -808,23 +864,6 @@ return (tomoe_writing_get_n_strokes (priv->writing) > 0); } -void -tomoe_canvas_set_size (TomoeCanvas *canvas, guint size) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - priv->width = size; - priv->height = size; - - gtk_widget_set_size_request (GTK_WIDGET (canvas), size, size); - gtk_widget_queue_resize (GTK_WIDGET (canvas)); - if (GTK_WIDGET_REALIZED (GTK_WIDGET (canvas))) - tomoe_canvas_refresh (canvas); -} - static void tomoe_canvas_gc_set_foreground (GdkGC *gc, GdkColor *color) { @@ -911,15 +950,6 @@ return priv->auto_find_time; } -void -tomoe_canvas_set_context (TomoeCanvas *canvas, TomoeContext *context) -{ - TomoeCanvasPriv *priv; - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - priv->context = context; -} - static void tomoe_canvas_append_point (TomoeCanvas *canvas, gint x, gint y) { @@ -1030,6 +1060,46 @@ } static void +tomoe_canvas_refresh (TomoeCanvas *canvas) +{ + TomoeCanvasPriv *priv; + GtkWidget *widget; + guint i; + const GList *strokes, *list; + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + _init_gc (canvas); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + widget = GTK_WIDGET (canvas); + + gdk_draw_rectangle (priv->pixmap, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width, + widget->allocation.height); + + tomoe_canvas_draw_axis (canvas); + + if (priv->writing) { + strokes = tomoe_writing_get_strokes (priv->writing); + for (list = strokes, i = 1; list; list = g_list_next (list), i++) { + GList *points = (GList *) list->data; + draw_stroke (points, canvas, i); + } + } + + gdk_draw_drawable(widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + priv->pixmap, + 0, 0, + 0, 0, + widget->allocation.width, widget->allocation.height); +} + +static void _init_gc (TomoeCanvas *canvas) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); @@ -1130,13 +1200,6 @@ g_free (buffer); g_object_unref (layout); } -const GList * -tomoe_canvas_get_candidates (TomoeCanvas *canvas) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - return priv->candidates; -} /* * vi:ts=4:nowrap:ai:expandtab Index: libtomoe-gtk/src/tomoe-canvas.h diff -u libtomoe-gtk/src/tomoe-canvas.h:1.11 libtomoe-gtk/src/tomoe-canvas.h:1.12 --- libtomoe-gtk/src/tomoe-canvas.h:1.11 Tue Dec 5 17:52:21 2006 +++ libtomoe-gtk/src/tomoe-canvas.h Tue Dec 5 21:55:31 2006 @@ -58,18 +58,19 @@ GType tomoe_canvas_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_canvas_new (void); +void tomoe_canvas_set_context (TomoeCanvas *canvas, + TomoeContext *context); + void tomoe_canvas_find (TomoeCanvas *canvas); -TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, - guint nth); guint tomoe_canvas_get_number_of_candidates (TomoeCanvas *canvas); -void tomoe_canvas_refresh (TomoeCanvas *canvas); +TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, + guint nth); +const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); void tomoe_canvas_revert (TomoeCanvas *canvas); void tomoe_canvas_clear (TomoeCanvas *canvas); void tomoe_canvas_normalize (TomoeCanvas *canvas); gboolean tomoe_canvas_has_stroke (TomoeCanvas *canvas); -void tomoe_canvas_set_size (TomoeCanvas *canvas, - guint size); void tomoe_canvas_set_handwrite_line_color (TomoeCanvas *canvas, GdkColor *color); @@ -83,14 +84,11 @@ void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, gint time_msec); gint tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas); -void tomoe_canvas_set_context (TomoeCanvas *canvas, - TomoeContext *context); TomoeWriting *tomoe_canvas_get_writing (TomoeCanvas *canvas); void tomoe_canvas_set_writing (TomoeCanvas *canvas, TomoeWriting *writing); void tomoe_canvas_lock (TomoeCanvas *canvas, gboolean lock); -const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); G_END_DECLS Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.6 libtomoe-gtk/src/tomoe-handwriting.c:1.7 --- libtomoe-gtk/src/tomoe-handwriting.c:1.6 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Tue Dec 5 21:55:31 2006 @@ -49,7 +49,7 @@ G_DEFINE_TYPE (TomoeHandwriting, tomoe_handwriting, GTK_TYPE_TABLE) -static void tomoe_handwriting_set_sensitive (TomoeHandwriting *handwriting); +static void tomoe_handwriting_set_sensitive (TomoeHandwriting *handwriting); /* callbacks for child widgets */ static void on_canvas_stroke_added (TomoeCanvas *canvas, From makeinu users.sourceforge.jp Tue Dec 5 23:04:13 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 23:04:13 +0900 Subject: [Tomoe-cvs 1661] CVS update: libtomoe-gtk Message-ID: <20061205140413.B7DC82AC0E8@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.226 libtomoe-gtk/ChangeLog:1.227 --- libtomoe-gtk/ChangeLog:1.226 Tue Dec 5 21:55:31 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 23:04:13 2006 @@ -1,5 +1,10 @@ 2006-12-05 Takuro Ashie + * src/tomoe-canvas.[ch]: Add "writing" property. Plug a memory leak. + Fix indent. + +2006-12-05 Takuro Ashie + * src/tomoe-canvas.[ch]: Add "tomoe-context" property and remove needless functions. * src/tomoe-handwriting.c: Fix indent. From makeinu users.sourceforge.jp Tue Dec 5 23:04:13 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 23:04:13 +0900 Subject: [Tomoe-cvs 1662] CVS update: libtomoe-gtk/src Message-ID: <20061205140413.E42E72AC1BC@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.43 libtomoe-gtk/src/tomoe-canvas.c:1.44 --- libtomoe-gtk/src/tomoe-canvas.c:1.43 Tue Dec 5 21:55:31 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Tue Dec 5 23:04:13 2006 @@ -42,7 +42,8 @@ enum { PROP_0, - PROP_TOMOE_CONTEXT + PROP_TOMOE_CONTEXT, + PROP_WRITING }; typedef struct _TomoeCanvasPriv TomoeCanvasPriv; @@ -200,13 +201,22 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - spec = g_param_spec_object ("tomoe-context", - N_("Tomoe context"), - N_("A tomoe context which stores handwriting dictionaries."), - TOMOE_TYPE_CONTEXT, - G_PARAM_WRITABLE); + spec = g_param_spec_object ( + "tomoe-context", + N_("Tomoe context"), + N_("A tomoe context which stores handwriting dictionaries."), + TOMOE_TYPE_CONTEXT, + G_PARAM_WRITABLE); g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); + spec = g_param_spec_object ( + "writing", + N_("Tomoe writing"), + N_("Strokes of a character to show on this canvas."), + TOMOE_TYPE_WRITING, + G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, PROP_WRITING, spec); + g_type_class_add_private (gobject_class, sizeof(TomoeCanvasPriv)); } @@ -310,6 +320,12 @@ tomoe_canvas_set_context (canvas, ctx); break; } + case PROP_WRITING: + { + TomoeWriting *writing = TOMOE_WRITING (g_value_get_object (value)); + tomoe_canvas_set_writing (canvas, writing); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -329,6 +345,13 @@ case PROP_TOMOE_CONTEXT: g_value_set_object (value, G_OBJECT (priv->context)); break; + case PROP_WRITING: + { + TomoeWriting *writing = tomoe_canvas_get_writing (canvas); + g_value_set_object (value, G_OBJECT (priv->context)); + g_object_unref (writing); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -386,17 +409,19 @@ GDK_LEAVE_NOTIFY_MASK; widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, - GDK_WA_X | GDK_WA_Y | - GDK_WA_COLORMAP | - GDK_WA_VISUAL); + &attributes, + GDK_WA_X | GDK_WA_Y | + GDK_WA_COLORMAP | + GDK_WA_VISUAL); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); - gdk_window_set_background (widget->window, &widget->style->bg [GTK_STATE_NORMAL]); + gdk_window_set_background (widget->window, + &widget->style->bg [GTK_STATE_NORMAL]); font_desc = pango_font_description_from_string ("Sans 12"); gtk_widget_modify_font (widget, font_desc); + pango_font_description_free (font_desc); } static void @@ -482,8 +507,7 @@ if (priv->locked) return retval; if (!priv->drawing) return retval; - /* tomoe_writing_line_to (priv->writing, (gint) event->x, (gint) event->y); */ - /* draw_annotate (points, canvas, tomoe_writing_get_n_strokes (priv->writing) + 1); */ + /* FIXME: draw annotate */ priv->drawing = FALSE; @@ -581,9 +605,10 @@ priv->candidates = NULL; } - writing = _tomoe_writing_new_scale_writing (priv->writing, - (gdouble) TOMOE_WRITING_WIDTH / priv->width, - (gdouble) TOMOE_WRITING_WIDTH / priv->height); + writing = _tomoe_writing_new_scale_writing ( + priv->writing, + (gdouble) TOMOE_WRITING_WIDTH / priv->width, + (gdouble) TOMOE_WRITING_WIDTH / priv->height); query = tomoe_query_new (); tomoe_query_set_writing (query, writing); @@ -624,16 +649,19 @@ TomoeWriting * tomoe_canvas_get_writing (TomoeCanvas *canvas) { - TomoeWriting *writing; + TomoeWriting *writing = NULL; TomoeCanvasPriv *priv; g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), NULL); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - writing = _tomoe_writing_new_scale_writing (priv->writing, - (gdouble) TOMOE_WRITING_WIDTH / priv->width, - (gdouble) TOMOE_WRITING_WIDTH / priv->height); + if (priv->writing) + writing = _tomoe_writing_new_scale_writing ( + priv->writing, + (gdouble) TOMOE_WRITING_WIDTH / priv->width, + (gdouble) TOMOE_WRITING_WIDTH / priv->height); + return writing; } @@ -648,10 +676,13 @@ if (priv->writing) g_object_unref (priv->writing); +#warning FIXME: should be resized priv->writing = writing; if (GTK_WIDGET_REALIZED (GTK_WIDGET (canvas))) tomoe_canvas_refresh (canvas); + + g_object_notify (G_OBJECT (canvas), "writing"); } void @@ -700,13 +731,16 @@ } static void -tomoe_canvas_resize_writing (TomoeCanvas *canvas, gdouble x_rate, gdouble y_rate) +tomoe_canvas_resize_writing (TomoeCanvas *canvas, + gdouble x_rate, gdouble y_rate) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); TomoeWriting *new_writing; - new_writing = _tomoe_writing_new_scale_writing (priv->writing, x_rate, y_rate); + new_writing = _tomoe_writing_new_scale_writing (priv->writing, + x_rate, y_rate); +#warning FIXME: should not use tomoe_canvas_set_writing () tomoe_canvas_set_writing (canvas, new_writing); } @@ -741,6 +775,7 @@ new_writing = _tomoe_writing_new_move_writing (priv->writing, dx, dy); +#warning FIXME: should not use tomoe_canvas_set_writing () tomoe_canvas_set_writing (canvas, new_writing); } @@ -753,10 +788,8 @@ gint dx, dy; get_char_size (canvas, &char_size); - x_rate = (priv->size * TOMOE_CANVAS_DEFAULT_RATE) - / char_size.width; - y_rate = (priv->size * TOMOE_CANVAS_DEFAULT_RATE) - / char_size.height; + x_rate = (priv->size * TOMOE_CANVAS_DEFAULT_RATE) / char_size.width; + y_rate = (priv->size * TOMOE_CANVAS_DEFAULT_RATE) / char_size.height; tomoe_canvas_resize_writing (canvas, x_rate, y_rate); From makeinu users.sourceforge.jp Tue Dec 5 23:39:13 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 23:39:13 +0900 Subject: [Tomoe-cvs 1663] CVS update: libtomoe-gtk Message-ID: <20061205143913.E1F722AC10B@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.227 libtomoe-gtk/ChangeLog:1.228 --- libtomoe-gtk/ChangeLog:1.227 Tue Dec 5 23:04:13 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 5 23:39:13 2006 @@ -1,5 +1,14 @@ 2006-12-05 Takuro Ashie + * src/tomoe-canvas.[ch]: Reorder functions. + tomoe_canvas_revert () -> tomoe_canvas_revert_stroke (). + tomoe_canvas_lock () -> tomoe_canvas_set_locked (). + Add tomoe_canvas_is_locked (). + * src/tomoe-handwriting.c, src/tomoe-edit-strokes.c, + src/tomoe-details.c: Follow the change. + +2006-12-05 Takuro Ashie + * src/tomoe-canvas.[ch]: Add "writing" property. Plug a memory leak. Fix indent. From makeinu users.sourceforge.jp Tue Dec 5 23:39:14 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 5 Dec 2006 23:39:14 +0900 Subject: [Tomoe-cvs 1664] CVS update: libtomoe-gtk/src Message-ID: <20061205143914.170852AC1B7@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.44 libtomoe-gtk/src/tomoe-canvas.c:1.45 --- libtomoe-gtk/src/tomoe-canvas.c:1.44 Tue Dec 5 23:04:13 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Tue Dec 5 23:39:13 2006 @@ -365,24 +365,6 @@ NULL)); } -void -tomoe_canvas_set_context (TomoeCanvas *canvas, TomoeContext *context) -{ - TomoeCanvasPriv *priv; - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - if (priv->context) - g_object_unref (priv->context); - if (context) - g_object_ref (context); - priv->context = context; - - g_object_notify (G_OBJECT (canvas), "tomoe-context"); -} - static void realize (GtkWidget *widget) { @@ -646,6 +628,24 @@ tomoe_canvas_refresh (canvas); } +void +tomoe_canvas_set_context (TomoeCanvas *canvas, TomoeContext *context) +{ + TomoeCanvasPriv *priv; + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + if (priv->context) + g_object_unref (priv->context); + if (context) + g_object_ref (context); + priv->context = context; + + g_object_notify (G_OBJECT (canvas), "tomoe-context"); +} + TomoeWriting * tomoe_canvas_get_writing (TomoeCanvas *canvas) { @@ -686,12 +686,113 @@ } void -tomoe_canvas_lock (TomoeCanvas *canvas, gboolean lock) +tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, gint time_msec) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + if (time_msec < 0) + priv->auto_find_time = -1; + else + priv->auto_find_time = time_msec; +} + +void +tomoe_canvas_set_locked (TomoeCanvas *canvas, gboolean lock) +{ + TomoeCanvasPriv *priv; + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); priv->locked = lock; } +gint +tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas) +{ + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), -1); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + return priv->auto_find_time; +} + +gboolean +tomoe_canvas_is_locked (TomoeCanvas *canvas) +{ + TomoeCanvasPriv *priv; + + g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), FALSE); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + return priv->locked; +} + +static void +tomoe_canvas_gc_set_foreground (GdkGC *gc, GdkColor *color) +{ + GdkColor default_color = { 0, 0x0000, 0x0000, 0x0000 }; + + if (color) { + gdk_colormap_alloc_color (gdk_colormap_get_system (), color, + TRUE, TRUE); + gdk_gc_set_foreground (gc, color); + } else { + gdk_colormap_alloc_color (gdk_colormap_get_system (), &default_color, + TRUE, TRUE); + gdk_gc_set_foreground (gc, &default_color); + } +} + +void +tomoe_canvas_set_handwrite_line_color (TomoeCanvas *canvas, GdkColor *color) +{ + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + tomoe_canvas_gc_set_foreground (priv->handwrite_line_gc, color); +} + +void +tomoe_canvas_set_adjust_line_color (TomoeCanvas *canvas, GdkColor *color) +{ + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + tomoe_canvas_gc_set_foreground (priv->adjust_line_gc, color); +} + +void +tomoe_canvas_set_annotate_color (TomoeCanvas *canvas, GdkColor *color) +{ + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + tomoe_canvas_gc_set_foreground (priv->annotate_gc, color); +} + +void +tomoe_canvas_set_axis_color (TomoeCanvas *canvas, GdkColor *color) +{ + TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + tomoe_canvas_gc_set_foreground (priv->axis_gc, color); +} + static void get_rectangle_for_stroke (GList *points, GdkRectangle *rect) { @@ -849,28 +950,28 @@ } void -tomoe_canvas_revert (TomoeCanvas *canvas) +tomoe_canvas_revert_stroke (TomoeCanvas *canvas) { TomoeCanvasPriv *priv; - gboolean reverted = TRUE; + gint n; g_return_if_fail (TOMOE_IS_CANVAS (canvas)); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + n = tomoe_writing_get_n_strokes (priv->writing); + if (n <= 0) return; + /* remove last line */ tomoe_writing_remove_last_stroke (priv->writing); - /* reverted = tomoe_writing_remove_last_stroke (priv->writing); */ - if (reverted) { - tomoe_canvas_refresh (canvas); - - g_signal_emit (G_OBJECT (canvas), - canvas_signals[STROKE_REVERTED_SIGNAL], 0); + tomoe_canvas_refresh (canvas); - if (tomoe_writing_get_n_strokes (priv->writing) == 0) - g_signal_emit (G_OBJECT (canvas), canvas_signals[CLEAR_SIGNAL], 0); + /* emit signal */ + g_signal_emit (G_OBJECT (canvas), + canvas_signals[STROKE_REVERTED_SIGNAL], 0); + if (tomoe_writing_get_n_strokes (priv->writing) == 0) + g_signal_emit (G_OBJECT (canvas), canvas_signals[CLEAR_SIGNAL], 0); - } } void @@ -898,92 +999,6 @@ } static void -tomoe_canvas_gc_set_foreground (GdkGC *gc, GdkColor *color) -{ - GdkColor default_color = { 0, 0x0000, 0x0000, 0x0000 }; - - if (color) { - gdk_colormap_alloc_color (gdk_colormap_get_system (), color, - TRUE, TRUE); - gdk_gc_set_foreground (gc, color); - } else { - gdk_colormap_alloc_color (gdk_colormap_get_system (), &default_color, - TRUE, TRUE); - gdk_gc_set_foreground (gc, &default_color); - } -} - -void -tomoe_canvas_set_handwrite_line_color (TomoeCanvas *canvas, GdkColor *color) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->handwrite_line_gc, color); -} - -void -tomoe_canvas_set_adjust_line_color (TomoeCanvas *canvas, GdkColor *color) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->adjust_line_gc, color); -} - -void -tomoe_canvas_set_annotate_color (TomoeCanvas *canvas, GdkColor *color) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->annotate_gc, color); -} - -void -tomoe_canvas_set_axis_color (TomoeCanvas *canvas, GdkColor *color) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->axis_gc, color); -} - -void -tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, gint time_msec) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - if (time_msec < 0) - priv->auto_find_time = -1; - else - priv->auto_find_time = time_msec; -} - -gint -tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas) -{ - TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), -1); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - - return priv->auto_find_time; -} - -static void tomoe_canvas_append_point (TomoeCanvas *canvas, gint x, gint y) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); Index: libtomoe-gtk/src/tomoe-canvas.h diff -u libtomoe-gtk/src/tomoe-canvas.h:1.12 libtomoe-gtk/src/tomoe-canvas.h:1.13 --- libtomoe-gtk/src/tomoe-canvas.h:1.12 Tue Dec 5 21:55:31 2006 +++ libtomoe-gtk/src/tomoe-canvas.h Tue Dec 5 23:39:13 2006 @@ -58,19 +58,18 @@ GType tomoe_canvas_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_canvas_new (void); +/* setters/getters */ void tomoe_canvas_set_context (TomoeCanvas *canvas, TomoeContext *context); - -void tomoe_canvas_find (TomoeCanvas *canvas); -guint tomoe_canvas_get_number_of_candidates - (TomoeCanvas *canvas); -TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, - guint nth); -const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); -void tomoe_canvas_revert (TomoeCanvas *canvas); -void tomoe_canvas_clear (TomoeCanvas *canvas); -void tomoe_canvas_normalize (TomoeCanvas *canvas); -gboolean tomoe_canvas_has_stroke (TomoeCanvas *canvas); +void tomoe_canvas_set_writing (TomoeCanvas *canvas, + TomoeWriting *writing); +TomoeWriting *tomoe_canvas_get_writing (TomoeCanvas *canvas); +void tomoe_canvas_set_locked (TomoeCanvas *canvas, + gboolean lock); +gboolean tomoe_canvas_is_locked (TomoeCanvas *canvas); +void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, + gint time_msec); +gint tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas); void tomoe_canvas_set_handwrite_line_color (TomoeCanvas *canvas, GdkColor *color); @@ -81,14 +80,18 @@ GdkColor *color); void tomoe_canvas_set_axis_color (TomoeCanvas *canvas, GdkColor *color); -void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, - gint time_msec); -gint tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas); -TomoeWriting *tomoe_canvas_get_writing (TomoeCanvas *canvas); -void tomoe_canvas_set_writing (TomoeCanvas *canvas, - TomoeWriting *writing); -void tomoe_canvas_lock (TomoeCanvas *canvas, - gboolean lock); + +/* editing/searching */ +void tomoe_canvas_find (TomoeCanvas *canvas); +guint tomoe_canvas_get_number_of_candidates + (TomoeCanvas *canvas); +TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, + guint nth); +const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); +void tomoe_canvas_revert_stroke (TomoeCanvas *canvas); +void tomoe_canvas_clear (TomoeCanvas *canvas); +void tomoe_canvas_normalize (TomoeCanvas *canvas); +gboolean tomoe_canvas_has_stroke (TomoeCanvas *canvas); G_END_DECLS Index: libtomoe-gtk/src/tomoe-details.c diff -u libtomoe-gtk/src/tomoe-details.c:1.25 libtomoe-gtk/src/tomoe-details.c:1.26 --- libtomoe-gtk/src/tomoe-details.c:1.25 Tue Nov 28 19:24:58 2006 +++ libtomoe-gtk/src/tomoe-details.c Tue Dec 5 23:39:13 2006 @@ -218,7 +218,7 @@ canvas = tomoe_canvas_new (); priv->canvas = canvas; - tomoe_canvas_lock (TOMOE_CANVAS (canvas), TRUE); + tomoe_canvas_set_locked (TOMOE_CANVAS (canvas), TRUE); gtk_container_add (GTK_CONTAINER (frame), canvas); gtk_widget_set_size_request (canvas, 100, 100); /* Index: libtomoe-gtk/src/tomoe-edit-strokes.c diff -u libtomoe-gtk/src/tomoe-edit-strokes.c:1.13 libtomoe-gtk/src/tomoe-edit-strokes.c:1.14 --- libtomoe-gtk/src/tomoe-edit-strokes.c:1.13 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-edit-strokes.c Tue Dec 5 23:39:13 2006 @@ -285,7 +285,7 @@ g_return_if_fail (TOMOE_IS_EDIT_STROKES (dialog)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - tomoe_canvas_revert (TOMOE_CANVAS (priv->canvas)); + tomoe_canvas_revert_stroke (TOMOE_CANVAS (priv->canvas)); tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); tomoe_edit_strokes_set_sensitive (dialog); } Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.7 libtomoe-gtk/src/tomoe-handwriting.c:1.8 --- libtomoe-gtk/src/tomoe-handwriting.c:1.7 Tue Dec 5 21:55:31 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Tue Dec 5 23:39:13 2006 @@ -298,7 +298,7 @@ g_return_if_fail (TOMOE_IS_HANDWRITING (handwriting)); g_return_if_fail (TOMOE_IS_CANVAS (priv->canvas)); - tomoe_canvas_revert (TOMOE_CANVAS (priv->canvas)); + tomoe_canvas_revert_stroke (TOMOE_CANVAS (priv->canvas)); tomoe_canvas_find (TOMOE_CANVAS (priv->canvas)); tomoe_handwriting_set_sensitive (handwriting); } From makeinu users.sourceforge.jp Wed Dec 6 10:55:09 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 10:55:09 +0900 Subject: [Tomoe-cvs 1665] CVS update: libtomoe-gtk Message-ID: <20061206015509.2A8422AC1C4@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.228 libtomoe-gtk/ChangeLog:1.229 --- libtomoe-gtk/ChangeLog:1.228 Tue Dec 5 23:39:13 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 10:55:08 2006 @@ -1,3 +1,8 @@ +2006-12-06 Takuro Ashie + + * src/tomoe-canvas.[ch]: Add "locked" and "auto-find-time" properties. + Reorder some functions. + 2006-12-05 Takuro Ashie * src/tomoe-canvas.[ch]: Reorder functions. From makeinu users.sourceforge.jp Wed Dec 6 10:55:09 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 10:55:09 +0900 Subject: [Tomoe-cvs 1666] CVS update: libtomoe-gtk/src Message-ID: <20061206015509.5992D2AC1C5@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.45 libtomoe-gtk/src/tomoe-canvas.c:1.46 --- libtomoe-gtk/src/tomoe-canvas.c:1.45 Tue Dec 5 23:39:13 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 10:55:09 2006 @@ -43,7 +43,13 @@ enum { PROP_0, PROP_TOMOE_CONTEXT, - PROP_WRITING + PROP_LOCKED, + PROP_WRITING, + PROP_AUTO_FIND_TIME, + PROP_HANDWRITING_LINE_COLOR, + PROP_ADJUST_LINE_COLOR, + PROP_ANNOTATE_COLOR, + PROP_AXIS_COLOR }; typedef struct _TomoeCanvasPriv TomoeCanvasPriv; @@ -180,7 +186,7 @@ g_signal_new ("normalize", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (TomoeCanvasClass, normalize), + G_STRUCT_OFFSET (TomoeCanvasClass, normalize), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -209,14 +215,31 @@ G_PARAM_WRITABLE); g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); + spec = g_param_spec_boolean ( + "locked", + N_("Locked"), + N_("Whether the canvas is locked drawing or not."), + G_TYPE_BOOLEAN, + G_PARAM_READABLE | G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, PROP_LOCKED, spec); + spec = g_param_spec_object ( "writing", N_("Tomoe writing"), N_("Strokes of a character to show on this canvas."), TOMOE_TYPE_WRITING, - G_PARAM_WRITABLE); + G_PARAM_READABLE | G_PARAM_WRITABLE); g_object_class_install_property (gobject_class, PROP_WRITING, spec); + spec = g_param_spec_int ( + "auto-find-time", + N_("Auto find time"), + N_("Delay time from releasing mouse button to starting auto finding. " + "Set 0 to find immediatly. Set -1 to disable auto finding."), + -1, G_MAXINT32, 0, + G_PARAM_READABLE | G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, PROP_AUTO_FIND_TIME, spec); + g_type_class_add_private (gobject_class, sizeof(TomoeCanvasPriv)); } @@ -320,12 +343,22 @@ tomoe_canvas_set_context (canvas, ctx); break; } + case PROP_LOCKED: + { + tomoe_canvas_set_locked (canvas, g_value_get_boolean (value)); + break; + } case PROP_WRITING: { TomoeWriting *writing = TOMOE_WRITING (g_value_get_object (value)); tomoe_canvas_set_writing (canvas, writing); break; } + case PROP_AUTO_FIND_TIME: + { + tomoe_canvas_set_auto_find_time (canvas, g_value_get_int (value)); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -345,6 +378,11 @@ case PROP_TOMOE_CONTEXT: g_value_set_object (value, G_OBJECT (priv->context)); break; + case PROP_LOCKED: + { + g_value_set_boolean (value, priv->locked); + break; + } case PROP_WRITING: { TomoeWriting *writing = tomoe_canvas_get_writing (canvas); @@ -352,6 +390,11 @@ g_object_unref (writing); break; } + case PROP_AUTO_FIND_TIME: + { + g_value_set_int (value, priv->auto_find_time); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -646,23 +689,28 @@ g_object_notify (G_OBJECT (canvas), "tomoe-context"); } -TomoeWriting * -tomoe_canvas_get_writing (TomoeCanvas *canvas) +void +tomoe_canvas_set_locked (TomoeCanvas *canvas, gboolean lock) { - TomoeWriting *writing = NULL; TomoeCanvasPriv *priv; - g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), NULL); + g_return_if_fail (TOMOE_IS_CANVAS (canvas)); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + priv->locked = lock; - if (priv->writing) - writing = _tomoe_writing_new_scale_writing ( - priv->writing, - (gdouble) TOMOE_WRITING_WIDTH / priv->width, - (gdouble) TOMOE_WRITING_WIDTH / priv->height); + g_object_notify (G_OBJECT (canvas), "locked"); +} - return writing; +gboolean +tomoe_canvas_is_locked (TomoeCanvas *canvas) +{ + TomoeCanvasPriv *priv; + + g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), FALSE); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + return priv->locked; } void @@ -685,6 +733,25 @@ g_object_notify (G_OBJECT (canvas), "writing"); } +TomoeWriting * +tomoe_canvas_get_writing (TomoeCanvas *canvas) +{ + TomoeWriting *writing = NULL; + TomoeCanvasPriv *priv; + + g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), NULL); + + priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + + if (priv->writing) + writing = _tomoe_writing_new_scale_writing ( + priv->writing, + (gdouble) TOMOE_WRITING_WIDTH / priv->width, + (gdouble) TOMOE_WRITING_WIDTH / priv->height); + + return writing; +} + void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, gint time_msec) { @@ -697,17 +764,8 @@ priv->auto_find_time = -1; else priv->auto_find_time = time_msec; -} -void -tomoe_canvas_set_locked (TomoeCanvas *canvas, gboolean lock) -{ - TomoeCanvasPriv *priv; - - g_return_if_fail (TOMOE_IS_CANVAS (canvas)); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - priv->locked = lock; + g_object_notify (G_OBJECT (canvas), "auto-find-time"); } gint @@ -722,17 +780,6 @@ return priv->auto_find_time; } -gboolean -tomoe_canvas_is_locked (TomoeCanvas *canvas) -{ - TomoeCanvasPriv *priv; - - g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), FALSE); - - priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - return priv->locked; -} - static void tomoe_canvas_gc_set_foreground (GdkGC *gc, GdkColor *color) { From makeinu users.sourceforge.jp Wed Dec 6 11:03:41 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:03:41 +0900 Subject: [Tomoe-cvs 1667] CVS update: libtomoe-gtk Message-ID: <20061206020341.71D592AC1C4@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.229 libtomoe-gtk/ChangeLog:1.230 --- libtomoe-gtk/ChangeLog:1.229 Wed Dec 6 10:55:08 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 11:03:41 2006 @@ -1,7 +1,7 @@ 2006-12-06 Takuro Ashie * src/tomoe-canvas.[ch]: Add "locked" and "auto-find-time" properties. - Reorder some functions. + Reorder some functions. Don't use tomoe_canvas_set_writing() internally. 2006-12-05 Takuro Ashie From makeinu users.sourceforge.jp Wed Dec 6 11:03:41 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:03:41 +0900 Subject: [Tomoe-cvs 1668] CVS update: libtomoe-gtk/src Message-ID: <20061206020341.9C1C42AC1C5@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.46 libtomoe-gtk/src/tomoe-canvas.c:1.47 --- libtomoe-gtk/src/tomoe-canvas.c:1.46 Wed Dec 6 10:55:09 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 11:03:41 2006 @@ -888,8 +888,12 @@ new_writing = _tomoe_writing_new_scale_writing (priv->writing, x_rate, y_rate); -#warning FIXME: should not use tomoe_canvas_set_writing () - tomoe_canvas_set_writing (canvas, new_writing); + if (priv->writing) + g_object_unref (priv->writing); + priv->writing = new_writing; + + if (GTK_WIDGET_REALIZED (GTK_WIDGET (canvas))) + tomoe_canvas_refresh (canvas); } static TomoeWriting * @@ -923,8 +927,12 @@ new_writing = _tomoe_writing_new_move_writing (priv->writing, dx, dy); -#warning FIXME: should not use tomoe_canvas_set_writing () - tomoe_canvas_set_writing (canvas, new_writing); + if (priv->writing) + g_object_unref (priv->writing); + priv->writing = new_writing; + + if (GTK_WIDGET_REALIZED (GTK_WIDGET (canvas))) + tomoe_canvas_refresh (canvas); } static void From makeinu users.sourceforge.jp Wed Dec 6 11:42:28 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:42:28 +0900 Subject: [Tomoe-cvs 1669] CVS update: libtomoe-gtk Message-ID: <20061206024228.8B8F62AC1C7@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.230 libtomoe-gtk/ChangeLog:1.231 --- libtomoe-gtk/ChangeLog:1.230 Wed Dec 6 11:03:41 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 11:42:28 2006 @@ -1,5 +1,11 @@ 2006-12-06 Takuro Ashie + * src/tomoe-canvas.[ch]: Add remaining properties. + tomoe_canvas_get_number_of_candidaets () -> ~_n_candidates (). + * src/tomoe-char-table.c: Follow the change. + +2006-12-06 Takuro Ashie + * src/tomoe-canvas.[ch]: Add "locked" and "auto-find-time" properties. Reorder some functions. Don't use tomoe_canvas_set_writing() internally. From makeinu users.sourceforge.jp Wed Dec 6 11:42:28 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:42:28 +0900 Subject: [Tomoe-cvs 1670] CVS update: libtomoe-gtk/src Message-ID: <20061206024228.B65482AC1C9@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.47 libtomoe-gtk/src/tomoe-canvas.c:1.48 --- libtomoe-gtk/src/tomoe-canvas.c:1.47 Wed Dec 6 11:03:41 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 11:42:28 2006 @@ -47,8 +47,8 @@ PROP_WRITING, PROP_AUTO_FIND_TIME, PROP_HANDWRITING_LINE_COLOR, - PROP_ADJUST_LINE_COLOR, - PROP_ANNOTATE_COLOR, + PROP_ADJUSTED_LINE_COLOR, + PROP_ANNOTATION_COLOR, PROP_AXIS_COLOR }; @@ -59,9 +59,9 @@ gint width; gint height; - GdkGC *handwrite_line_gc; - GdkGC *adjust_line_gc; - GdkGC *annotate_gc; + GdkGC *handwriting_line_gc; + GdkGC *adjusted_line_gc; + GdkGC *annotation_gc; GdkGC *axis_gc; GdkPixmap *pixmap; @@ -130,7 +130,7 @@ static void draw_stroke (GList *points, TomoeCanvas *canvas, guint index); -static void draw_annotate (GList *points, +static void draw_annotation (GList *points, TomoeCanvas *canvas, guint index); @@ -240,6 +240,41 @@ G_PARAM_READABLE | G_PARAM_WRITABLE); g_object_class_install_property (gobject_class, PROP_AUTO_FIND_TIME, spec); + spec = g_param_spec_boxed ( + "handwriting-line-color", + N_("Handwriting line color"), + N_("The color of handwriting lines."), + GDK_TYPE_COLOR, + /*G_PARAM_READABLE |*/ G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, + PROP_HANDWRITING_LINE_COLOR, spec); + + spec = g_param_spec_boxed ( + "adjusted-line-color", + N_("Adjusted line color"), + N_("The color of adjusted handwriting lines."), + GDK_TYPE_COLOR, + /*G_PARAM_READABLE |*/ G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, + PROP_ADJUSTED_LINE_COLOR, spec); + + spec = g_param_spec_boxed ( + "annotation-color", + N_("Annotation color"), + N_("The color of annotation strings."), + GDK_TYPE_COLOR, + /*G_PARAM_READABLE |*/ G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, + PROP_ANNOTATION_COLOR, spec); + + spec = g_param_spec_boxed ( + "axis-color", + N_("Axis color"), + N_("The color of axis lines."), + GDK_TYPE_COLOR, + /*G_PARAM_READABLE |*/ G_PARAM_WRITABLE); + g_object_class_install_property (gobject_class, PROP_AXIS_COLOR, spec); + g_type_class_add_private (gobject_class, sizeof(TomoeCanvasPriv)); } @@ -248,25 +283,25 @@ { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - priv->size = TOMOE_CANVAS_DEFAULT_SIZE; - priv->width = TOMOE_CANVAS_DEFAULT_SIZE; - priv->height = TOMOE_CANVAS_DEFAULT_SIZE; - - priv->handwrite_line_gc = NULL; - priv->adjust_line_gc = NULL; - priv->annotate_gc = NULL; - priv->axis_gc = NULL; - - priv->pixmap = NULL; - priv->drawing = FALSE; - - priv->context = NULL; - priv->writing = tomoe_writing_new (); - priv->candidates = NULL; - - priv->auto_find_time = 0; - priv->auto_find_id = 0; - priv->locked = FALSE; + priv->size = TOMOE_CANVAS_DEFAULT_SIZE; + priv->width = TOMOE_CANVAS_DEFAULT_SIZE; + priv->height = TOMOE_CANVAS_DEFAULT_SIZE; + + priv->handwriting_line_gc = NULL; + priv->adjusted_line_gc = NULL; + priv->annotation_gc = NULL; + priv->axis_gc = NULL; + + priv->pixmap = NULL; + priv->drawing = FALSE; + + priv->context = NULL; + priv->writing = tomoe_writing_new (); + priv->candidates = NULL; + + priv->auto_find_time = 0; + priv->auto_find_id = 0; + priv->locked = FALSE; instance_list = g_list_append (instance_list, (gpointer) canvas); } @@ -279,19 +314,19 @@ instance_list = g_list_remove (instance_list, (gpointer) canvas); - if (priv->handwrite_line_gc) { - g_object_unref (priv->handwrite_line_gc); - priv->handwrite_line_gc = NULL; + if (priv->handwriting_line_gc) { + g_object_unref (priv->handwriting_line_gc); + priv->handwriting_line_gc = NULL; } - if (priv->adjust_line_gc) { - g_object_unref (priv->adjust_line_gc); - priv->adjust_line_gc = NULL; + if (priv->adjusted_line_gc) { + g_object_unref (priv->adjusted_line_gc); + priv->adjusted_line_gc = NULL; } - if (priv->annotate_gc) { - g_object_unref (priv->annotate_gc); - priv->annotate_gc = NULL; + if (priv->annotation_gc) { + g_object_unref (priv->annotation_gc); + priv->annotation_gc = NULL; } if (priv->axis_gc) { @@ -359,6 +394,30 @@ tomoe_canvas_set_auto_find_time (canvas, g_value_get_int (value)); break; } + case PROP_HANDWRITING_LINE_COLOR: + { + GdkColor *color = g_value_get_boxed (value); + tomoe_canvas_set_handwriting_line_color (canvas, color); + break; + } + case PROP_ADJUSTED_LINE_COLOR: + { + GdkColor *color = g_value_get_boxed (value); + tomoe_canvas_set_adjusted_line_color (canvas, color); + break; + } + case PROP_ANNOTATION_COLOR: + { + GdkColor *color = g_value_get_boxed (value); + tomoe_canvas_set_annotation_color (canvas, color); + break; + } + case PROP_AXIS_COLOR: + { + GdkColor *color = g_value_get_boxed (value); + tomoe_canvas_set_axis_color (canvas, color); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -395,6 +454,18 @@ g_value_set_int (value, priv->auto_find_time); break; } + case PROP_HANDWRITING_LINE_COLOR: + /* FIXME */ + break; + case PROP_ADJUSTED_LINE_COLOR: + /* FIXME */ + break; + case PROP_ANNOTATION_COLOR: + /* FIXME */ + break; + case PROP_AXIS_COLOR: + /* FIXME */ + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -532,7 +603,7 @@ if (priv->locked) return retval; if (!priv->drawing) return retval; - /* FIXME: draw annotate */ + /* FIXME: draw annotation */ priv->drawing = FALSE; @@ -622,7 +693,7 @@ for (list = strokes, i = 1; list; list = g_list_next (list), i++) { GList *points = (GList *) list->data; - draw_annotate (points, canvas, i); + draw_annotation (points, canvas, i); } if (priv->candidates) { @@ -797,36 +868,36 @@ } void -tomoe_canvas_set_handwrite_line_color (TomoeCanvas *canvas, GdkColor *color) +tomoe_canvas_set_handwriting_line_color (TomoeCanvas *canvas, GdkColor *color) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); g_return_if_fail (TOMOE_IS_CANVAS (canvas)); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->handwrite_line_gc, color); + tomoe_canvas_gc_set_foreground (priv->handwriting_line_gc, color); } void -tomoe_canvas_set_adjust_line_color (TomoeCanvas *canvas, GdkColor *color) +tomoe_canvas_set_adjusted_line_color (TomoeCanvas *canvas, GdkColor *color) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); g_return_if_fail (TOMOE_IS_CANVAS (canvas)); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->adjust_line_gc, color); + tomoe_canvas_gc_set_foreground (priv->adjusted_line_gc, color); } void -tomoe_canvas_set_annotate_color (TomoeCanvas *canvas, GdkColor *color) +tomoe_canvas_set_annotation_color (TomoeCanvas *canvas, GdkColor *color) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); g_return_if_fail (TOMOE_IS_CANVAS (canvas)); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - tomoe_canvas_gc_set_foreground (priv->annotate_gc, color); + tomoe_canvas_gc_set_foreground (priv->annotation_gc, color); } void @@ -967,7 +1038,7 @@ } guint -tomoe_canvas_get_number_of_candidates (TomoeCanvas *canvas) +tomoe_canvas_get_n_candidates (TomoeCanvas *canvas) { TomoeCanvasPriv *priv; @@ -1077,7 +1148,7 @@ _init_gc (canvas); tomoe_canvas_draw_line (canvas, &pp, &p, - priv->handwrite_line_gc, + priv->handwriting_line_gc, TRUE); tomoe_writing_line_to (priv->writing, x, y); @@ -1208,30 +1279,30 @@ TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); GtkWidget *widget = GTK_WIDGET (canvas); - if (!priv->adjust_line_gc) { + if (!priv->adjusted_line_gc) { GdkColor color = { 0, 0x8000, 0x0000, 0x0000 }; - priv->adjust_line_gc = gdk_gc_new (widget->window); - tomoe_canvas_set_adjust_line_color (canvas, &color); - gdk_gc_set_line_attributes (priv->adjust_line_gc, 1, + priv->adjusted_line_gc = gdk_gc_new (widget->window); + tomoe_canvas_set_adjusted_line_color (canvas, &color); + gdk_gc_set_line_attributes (priv->adjusted_line_gc, 1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_BEVEL); } - if (!priv->handwrite_line_gc) { + if (!priv->handwriting_line_gc) { GdkColor color = { 0, 0x0000, 0x0000, 0x0000 }; - priv->handwrite_line_gc = gdk_gc_new (widget->window); - tomoe_canvas_set_handwrite_line_color (canvas, &color); - gdk_gc_set_line_attributes (priv->handwrite_line_gc, 4, + priv->handwriting_line_gc = gdk_gc_new (widget->window); + tomoe_canvas_set_handwriting_line_color (canvas, &color); + gdk_gc_set_line_attributes (priv->handwriting_line_gc, 4, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); } - if (!priv->annotate_gc) { + if (!priv->annotation_gc) { GdkColor color = { 0, 0x8000, 0x0000, 0x0000 }; - priv->annotate_gc = gdk_gc_new (widget->window); - tomoe_canvas_set_annotate_color (canvas, &color); + priv->annotation_gc = gdk_gc_new (widget->window); + tomoe_canvas_set_annotation_color (canvas, &color); } } @@ -1253,14 +1324,14 @@ p2 = (TomoePoint *) next->data; tomoe_canvas_draw_line (canvas, p1, p2, - priv->handwrite_line_gc, + priv->handwriting_line_gc, FALSE); } - draw_annotate (points, canvas, index); + draw_annotation (points, canvas, index); } static void -draw_annotate (GList *points, TomoeCanvas *canvas, guint index) +draw_annotation (GList *points, TomoeCanvas *canvas, guint index) { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); GtkWidget *widget = GTK_WIDGET (canvas); @@ -1297,7 +1368,7 @@ y += (0.5 + (0.5 * r * dy / dl) - (sign * 0.5 * r * dx / dl) - (height / 2)); gdk_draw_layout (priv->pixmap, - priv->annotate_gc, + priv->annotation_gc, x, y, layout); g_free (buffer); Index: libtomoe-gtk/src/tomoe-canvas.h diff -u libtomoe-gtk/src/tomoe-canvas.h:1.13 libtomoe-gtk/src/tomoe-canvas.h:1.14 --- libtomoe-gtk/src/tomoe-canvas.h:1.13 Tue Dec 5 23:39:13 2006 +++ libtomoe-gtk/src/tomoe-canvas.h Wed Dec 6 11:42:28 2006 @@ -70,21 +70,21 @@ void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, gint time_msec); gint tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas); -void tomoe_canvas_set_handwrite_line_color +void tomoe_canvas_set_handwriting_line_color (TomoeCanvas *canvas, GdkColor *color); -void tomoe_canvas_set_adjust_line_color +void tomoe_canvas_set_adjusted_line_color (TomoeCanvas *canvas, GdkColor *color); -void tomoe_canvas_set_annotate_color (TomoeCanvas *canvas, +void tomoe_canvas_set_annotation_color + (TomoeCanvas *canvas, GdkColor *color); void tomoe_canvas_set_axis_color (TomoeCanvas *canvas, GdkColor *color); /* editing/searching */ void tomoe_canvas_find (TomoeCanvas *canvas); -guint tomoe_canvas_get_number_of_candidates - (TomoeCanvas *canvas); +guint tomoe_canvas_get_n_candidates (TomoeCanvas *canvas); TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, guint nth); const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); Index: libtomoe-gtk/src/tomoe-char-table.c diff -u libtomoe-gtk/src/tomoe-char-table.c:1.12 libtomoe-gtk/src/tomoe-char-table.c:1.13 --- libtomoe-gtk/src/tomoe-char-table.c:1.12 Tue Dec 5 18:14:46 2006 +++ libtomoe-gtk/src/tomoe-char-table.c Wed Dec 6 11:42:28 2006 @@ -778,7 +778,7 @@ priv->prelighted = -1; if (priv->canvas) - n_candidates = tomoe_canvas_get_number_of_candidates (priv->canvas); + n_candidates = tomoe_canvas_get_n_candidates (priv->canvas); for (i = 0; i < n_candidates; i++) { PangoLayout *layout; From makeinu users.sourceforge.jp Wed Dec 6 11:44:22 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:44:22 +0900 Subject: [Tomoe-cvs 1671] CVS update: libtomoe-gtk/src Message-ID: <20061206024422.E96A42AC0D0@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.48 libtomoe-gtk/src/tomoe-canvas.c:1.49 --- libtomoe-gtk/src/tomoe-canvas.c:1.48 Wed Dec 6 11:42:28 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 11:44:22 2006 @@ -876,6 +876,8 @@ priv = TOMOE_CANVAS_GET_PRIVATE (canvas); tomoe_canvas_gc_set_foreground (priv->handwriting_line_gc, color); + + g_object_notify (G_OBJECT (canvas), "handwriting-line-color"); } void @@ -887,6 +889,8 @@ priv = TOMOE_CANVAS_GET_PRIVATE (canvas); tomoe_canvas_gc_set_foreground (priv->adjusted_line_gc, color); + + g_object_notify (G_OBJECT (canvas), "adjusted-line-color"); } void @@ -898,6 +902,8 @@ priv = TOMOE_CANVAS_GET_PRIVATE (canvas); tomoe_canvas_gc_set_foreground (priv->annotation_gc, color); + + g_object_notify (G_OBJECT (canvas), "annotation-color"); } void @@ -909,6 +915,8 @@ priv = TOMOE_CANVAS_GET_PRIVATE (canvas); tomoe_canvas_gc_set_foreground (priv->axis_gc, color); + + g_object_notify (G_OBJECT (canvas), "axis-color"); } static void From makeinu users.sourceforge.jp Wed Dec 6 11:56:10 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:56:10 +0900 Subject: [Tomoe-cvs 1672] CVS update: libtomoe-gtk Message-ID: <20061206025610.375D22AC06A@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.231 libtomoe-gtk/ChangeLog:1.232 --- libtomoe-gtk/ChangeLog:1.231 Wed Dec 6 11:42:28 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 11:56:10 2006 @@ -1,5 +1,10 @@ 2006-12-06 Takuro Ashie + * src/tomoe-canvas.[ch]: Remove priv->size. + Resize provided writing to internal size in tomoe_canvas_set_writing(). + +2006-12-06 Takuro Ashie + * src/tomoe-canvas.[ch]: Add remaining properties. tomoe_canvas_get_number_of_candidaets () -> ~_n_candidates (). * src/tomoe-char-table.c: Follow the change. From makeinu users.sourceforge.jp Wed Dec 6 11:56:10 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 11:56:10 +0900 Subject: [Tomoe-cvs 1673] CVS update: libtomoe-gtk/src Message-ID: <20061206025610.59C822AC0A2@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.49 libtomoe-gtk/src/tomoe-canvas.c:1.50 --- libtomoe-gtk/src/tomoe-canvas.c:1.49 Wed Dec 6 11:44:22 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 11:56:10 2006 @@ -283,7 +283,6 @@ { TomoeCanvasPriv *priv = TOMOE_CANVAS_GET_PRIVATE (canvas); - priv->size = TOMOE_CANVAS_DEFAULT_SIZE; priv->width = TOMOE_CANVAS_DEFAULT_SIZE; priv->height = TOMOE_CANVAS_DEFAULT_SIZE; @@ -530,7 +529,6 @@ priv->width = allocation->width; priv->height = allocation->height; - priv->size = allocation->width; if (GTK_WIDGET_REALIZED (widget)) { if (priv->pixmap) @@ -703,8 +701,8 @@ writing = _tomoe_writing_new_scale_writing ( priv->writing, - (gdouble) TOMOE_WRITING_WIDTH / priv->width, - (gdouble) TOMOE_WRITING_WIDTH / priv->height); + (gdouble) TOMOE_WRITING_WIDTH / priv->width, + (gdouble) TOMOE_WRITING_HEIGHT / priv->height); query = tomoe_query_new (); tomoe_query_set_writing (query, writing); @@ -788,15 +786,21 @@ tomoe_canvas_set_writing (TomoeCanvas *canvas, TomoeWriting *writing) { TomoeCanvasPriv *priv; + TomoeWriting *new_writing = NULL; g_return_if_fail (TOMOE_IS_CANVAS (canvas)); priv = TOMOE_CANVAS_GET_PRIVATE (canvas); + if (writing) + new_writing = _tomoe_writing_new_scale_writing ( + writing, + (gdouble) priv->width / TOMOE_WRITING_WIDTH, + (gdouble) priv->height / TOMOE_WRITING_HEIGHT); + if (priv->writing) g_object_unref (priv->writing); -#warning FIXME: should be resized - priv->writing = writing; + priv->writing = new_writing; if (GTK_WIDGET_REALIZED (GTK_WIDGET (canvas))) tomoe_canvas_refresh (canvas); @@ -817,8 +821,8 @@ if (priv->writing) writing = _tomoe_writing_new_scale_writing ( priv->writing, - (gdouble) TOMOE_WRITING_WIDTH / priv->width, - (gdouble) TOMOE_WRITING_WIDTH / priv->height); + (gdouble) TOMOE_WRITING_WIDTH / priv->width, + (gdouble) TOMOE_WRITING_HEIGHT / priv->height); return writing; } @@ -1023,14 +1027,14 @@ gint dx, dy; get_char_size (canvas, &char_size); - x_rate = (priv->size * TOMOE_CANVAS_DEFAULT_RATE) / char_size.width; - y_rate = (priv->size * TOMOE_CANVAS_DEFAULT_RATE) / char_size.height; + x_rate = (priv->width * TOMOE_CANVAS_DEFAULT_RATE) / char_size.width; + y_rate = (priv->height * TOMOE_CANVAS_DEFAULT_RATE) / char_size.height; tomoe_canvas_resize_writing (canvas, x_rate, y_rate); get_char_size (canvas, &char_size); - dx = ((priv->size - char_size.width) / 2) - char_size.x; - dy = ((priv->size - char_size.height) / 2) - char_size.y; + dx = ((priv->width - char_size.width) / 2) - char_size.x; + dy = ((priv->height - char_size.height) / 2) - char_size.y; tomoe_canvas_move_writing (canvas, dx, dy); @@ -1234,11 +1238,11 @@ } gdk_draw_line (priv->pixmap, priv->axis_gc, - (priv->size / 2), 0, - (priv->size / 2), priv->size); + (priv->width / 2), 0, + (priv->width / 2), priv->height); gdk_draw_line (priv->pixmap, priv->axis_gc, - 0, (priv->size / 2), - priv->size, (priv->size / 2)); + 0, (priv->height / 2), + priv->width, (priv->height / 2)); } static void From makeinu users.sourceforge.jp Wed Dec 6 12:06:25 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 12:06:25 +0900 Subject: [Tomoe-cvs 1674] CVS update: libtomoe-gtk/src Message-ID: <20061206030625.B0F732AC0A2@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.50 libtomoe-gtk/src/tomoe-canvas.c:1.51 --- libtomoe-gtk/src/tomoe-canvas.c:1.50 Wed Dec 6 11:56:10 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 12:06:25 2006 @@ -210,7 +210,9 @@ spec = g_param_spec_object ( "tomoe-context", N_("Tomoe context"), - N_("A tomoe context which stores handwriting dictionaries."), + N_("A tomoe context which stores handwriting dictionaries. " + "TomoeCanvas doesn't always require TomoeContext. " + "For example it isn't needed on viewer mode."), TOMOE_TYPE_CONTEXT, G_PARAM_WRITABLE); g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); From makeinu users.sourceforge.jp Wed Dec 6 12:07:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 12:07:00 +0900 Subject: [Tomoe-cvs 1675] CVS update: libtomoe-gtk/src Message-ID: <20061206030700.D32642AC0A2@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.51 libtomoe-gtk/src/tomoe-canvas.c:1.52 --- libtomoe-gtk/src/tomoe-canvas.c:1.51 Wed Dec 6 12:06:25 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 12:07:00 2006 @@ -210,7 +210,7 @@ spec = g_param_spec_object ( "tomoe-context", N_("Tomoe context"), - N_("A tomoe context which stores handwriting dictionaries. " + N_("A TomoeContext which stores handwriting dictionaries. " "TomoeCanvas doesn't always require TomoeContext. " "For example it isn't needed on viewer mode."), TOMOE_TYPE_CONTEXT, From kous users.sourceforge.jp Wed Dec 6 12:08:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 12:08:46 +0900 Subject: [Tomoe-cvs 1676] CVS update: tomoe Message-ID: <20061206030846.B91CE2AC0A2@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.387 tomoe/ChangeLog:1.388 --- tomoe/ChangeLog:1.387 Tue Dec 5 18:01:29 2006 +++ tomoe/ChangeLog Wed Dec 6 12:08:46 2006 @@ -1,3 +1,23 @@ +2006-12-06 Kouhei Sutou + + * lib/tomoe-char.h (TOMOE_CHAR_PRIVATE_USE_AREA_START, + TOMOE_CHAR_PRIVATE_USE_AREA_END): added. + * lib/tomoe-dict.[ch] (tomoe_dict_is_editable, + tomoe_dict_get_available_private_utf8): added. + * lib/tomoe-dict.c (tomoe_dict_register_char): supported + registering GAIJI. + * module/dict/tomoe-dict-ptr-array.[ch] + (_tomoe_dict_ptr_array_get_available_private_utf8): added. + * module/dict/tomoe-dict-unihan.c, module/dict/tomoe-dict-xml.c: + supported is_editable and get_available_private_utf8 interfaces. + + * ext/ruby/tomoe-rb-char.c (Tomoe::Char::PRIVATE_USE_AREA_START, + Tomoe::Char::PRIVATE_USE_AREA_END): added. + + * test/context_spec.rb: added tests for registering character + without UTF8 value. + * test/tomoe-spec-utils.rb: added Unicode related utils. + 2006-12-05 Kouhei Sutou * module/dict/tomoe-dict-ptr-array.[ch]: added. From kous users.sourceforge.jp Wed Dec 6 12:08:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 12:08:46 +0900 Subject: [Tomoe-cvs 1677] CVS update: tomoe/ext/ruby Message-ID: <20061206030846.DB78E2AC0D0@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-char.c diff -u tomoe/ext/ruby/tomoe-rb-char.c:1.10 tomoe/ext/ruby/tomoe-rb-char.c:1.11 --- tomoe/ext/ruby/tomoe-rb-char.c:1.10 Thu Nov 30 12:03:32 2006 +++ tomoe/ext/ruby/tomoe-rb-char.c Wed Dec 6 12:08:46 2006 @@ -84,6 +84,12 @@ VALUE cTomoeChar; cTomoeChar = G_DEF_CLASS(TOMOE_TYPE_CHAR, "Char", mTomoe); + + rb_define_const(cTomoeChar, "PRIVATE_USE_AREA_START", + INT2NUM(TOMOE_CHAR_PRIVATE_USE_AREA_START)); + rb_define_const(cTomoeChar, "PRIVATE_USE_AREA_END", + INT2NUM(TOMOE_CHAR_PRIVATE_USE_AREA_END)); + rb_include_module(cTomoeChar, rb_mComparable); rb_define_method(cTomoeChar, "initialize", tc_initialize, -1); From kous users.sourceforge.jp Wed Dec 6 12:08:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 12:08:47 +0900 Subject: [Tomoe-cvs 1678] CVS update: tomoe/lib Message-ID: <20061206030847.16B982AC0A2@users.sourceforge.jp> Index: tomoe/lib/tomoe-char.h diff -u tomoe/lib/tomoe-char.h:1.54 tomoe/lib/tomoe-char.h:1.55 --- tomoe/lib/tomoe-char.h:1.54 Fri Dec 1 10:35:42 2006 +++ tomoe/lib/tomoe-char.h Wed Dec 6 12:08:46 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-char.h,v 1.54 2006/12/01 01:35:42 ikezoe Exp $ + * $Id: tomoe-char.h,v 1.55 2006/12/06 03:08:46 kous Exp $ */ #ifndef __TOMOE_CHAR_H__ @@ -31,6 +31,9 @@ #include "tomoe-reading.h" #include "tomoe-writing.h" +#define TOMOE_CHAR_PRIVATE_USE_AREA_START 0xE000 +#define TOMOE_CHAR_PRIVATE_USE_AREA_END 0xF8FF + #define TOMOE_TYPE_CHAR (tomoe_char_get_type ()) #define TOMOE_CHAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_CHAR, TomoeChar)) #define TOMOE_CHAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_CHAR, TomoeCharClass)) @@ -80,10 +83,10 @@ void tomoe_char_register_meta_data (TomoeChar *chr, const gchar *key, const gchar *value); -gboolean tomoe_char_has_meta_data (TomoeChar* chr); -void tomoe_char_meta_data_foreach (TomoeChar* chr, - GHFunc func, - gpointer user_data); +gboolean tomoe_char_has_meta_data (TomoeChar *chr); +void tomoe_char_meta_data_foreach (TomoeChar *chr, + GHFunc func, + gpointer user_data); gint tomoe_char_compare (const TomoeChar *a, const TomoeChar *b); Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.130 tomoe/lib/tomoe-dict.c:1.131 --- tomoe/lib/tomoe-dict.c:1.130 Tue Dec 5 15:12:35 2006 +++ tomoe/lib/tomoe-dict.c Wed Dec 6 12:08:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.130 2006/12/05 06:12:35 kous Exp $ + * $Id: tomoe-dict.c,v 1.131 2006/12/06 03:08:46 kous Exp $ */ #include "tomoe-dict.h" @@ -52,6 +52,9 @@ klass->unregister_char = NULL; klass->get_char = NULL; klass->search = NULL; + klass->flush = NULL; + klass->is_editable = NULL; + klass->get_available_private_utf8 = NULL; } static void @@ -120,11 +123,33 @@ g_return_val_if_fail (TOMOE_IS_DICT (dict), FALSE); + if (!tomoe_dict_is_editable (dict)) { + g_warning ("the dictionary isn't editable."); + return FALSE; + } + klass = TOMOE_DICT_GET_CLASS (dict); - if (klass->register_char) - return klass->register_char (dict, chr); - else + if (klass->register_char) { + gboolean need_to_set_utf8, success; + + need_to_set_utf8 = !tomoe_char_get_utf8 (chr); + if (need_to_set_utf8) { + gchar *utf8; + utf8 = tomoe_dict_get_available_private_utf8 (dict); + if (!utf8) { + g_warning ("there is no available PUA(Private Use Area)"); + return FALSE; + } + tomoe_char_set_utf8 (chr, utf8); + g_free (utf8); + } + success = klass->register_char (dict, chr); + if (!success && need_to_set_utf8) + tomoe_char_set_utf8 (chr, NULL); + return success; + } else { return FALSE; + } } /** @@ -143,6 +168,11 @@ g_return_val_if_fail (TOMOE_IS_DICT (dict), FALSE); + if (!tomoe_dict_is_editable (dict)) { + g_warning ("the dictionary isn't editable."); + return FALSE; + } + klass = TOMOE_DICT_GET_CLASS (dict); if (klass->unregister_char) return klass->unregister_char (dict, utf8); @@ -201,6 +231,34 @@ return FALSE; } +gboolean +tomoe_dict_is_editable (TomoeDict *dict) +{ + TomoeDictClass *klass; + + g_return_val_if_fail (TOMOE_IS_DICT (dict), FALSE); + + klass = TOMOE_DICT_GET_CLASS (dict); + if (klass->is_editable) + return klass->is_editable (dict); + else + return FALSE; +} + +gchar * +tomoe_dict_get_available_private_utf8 (TomoeDict *dict) +{ + TomoeDictClass *klass; + + g_return_val_if_fail (TOMOE_IS_DICT (dict), NULL); + + klass = TOMOE_DICT_GET_CLASS (dict); + if (klass->get_available_private_utf8) + return klass->get_available_private_utf8 (dict); + else + return NULL; +} + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/lib/tomoe-dict.h diff -u tomoe/lib/tomoe-dict.h:1.55 tomoe/lib/tomoe-dict.h:1.56 --- tomoe/lib/tomoe-dict.h:1.55 Fri Dec 1 10:54:44 2006 +++ tomoe/lib/tomoe-dict.h Wed Dec 6 12:08:46 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.h,v 1.55 2006/12/01 01:54:44 ikezoe Exp $ + * $Id: tomoe-dict.h,v 1.56 2006/12/06 03:08:46 kous Exp $ */ #ifndef __TOMOE_DICT_H__ @@ -63,6 +63,8 @@ GList *(*search) (TomoeDict *dict, TomoeQuery *query); gboolean (*flush) (TomoeDict *dict); + gboolean (*is_editable) (TomoeDict *dict); + gchar *(*get_available_private_utf8) (TomoeDict *dict); }; GType tomoe_dict_get_type (void) G_GNUC_CONST; @@ -77,7 +79,6 @@ const gchar *tomoe_dict_get_name (TomoeDict *dict); /* Editable methods */ - gboolean tomoe_dict_register_char (TomoeDict *dict, TomoeChar *chr); @@ -93,6 +94,11 @@ gboolean tomoe_dict_flush (TomoeDict *dict); + +gboolean tomoe_dict_is_editable (TomoeDict *dict); + +gchar *tomoe_dict_get_available_private_utf8 (TomoeDict *dict); + G_END_DECLS #endif /* __TOMOE_DICT_H__ */ From kous users.sourceforge.jp Wed Dec 6 12:08:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 12:08:47 +0900 Subject: [Tomoe-cvs 1679] CVS update: tomoe/module/dict Message-ID: <20061206030847.4D0692AC0D0@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-ptr-array.c diff -u tomoe/module/dict/tomoe-dict-ptr-array.c:1.1 tomoe/module/dict/tomoe-dict-ptr-array.c:1.2 --- tomoe/module/dict/tomoe-dict-ptr-array.c:1.1 Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.c Wed Dec 6 12:08:47 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ptr-array.c,v 1.1 2006/12/05 09:01:29 kous Exp $ + * $Id: tomoe-dict-ptr-array.c,v 1.2 2006/12/06 03:08:47 kous Exp $ */ #include @@ -33,7 +33,7 @@ } TomoeDictSearchContext; static gint -letter_compare_func (gconstpointer a, gconstpointer b) +char_compare_func (gconstpointer a, gconstpointer b) { TomoeChar *ca = *(TomoeChar **) a; TomoeChar *cb = *(TomoeChar **) b; @@ -43,7 +43,7 @@ void _tomoe_dict_ptr_array_sort (GPtrArray *chars) { - g_ptr_array_sort (chars, letter_compare_func); + g_ptr_array_sort (chars, char_compare_func); } gboolean @@ -109,11 +109,14 @@ if (min < 0 && max < 0) return TRUE; - writing = tomoe_char_get_writing (chr); - if (!writing) - return FALSE; + n_strokes = tomoe_char_get_n_strokes (chr); + if (n_strokes < 0) { + writing = tomoe_char_get_writing (chr); + if (!writing) + return FALSE; + n_strokes = tomoe_writing_get_n_strokes (writing); + } - n_strokes = tomoe_writing_get_n_strokes (writing); return ((min < 0 || min <= n_strokes) && (max < 0 || max >= n_strokes)); } @@ -181,6 +184,36 @@ return search_context.results; } +gchar * +_tomoe_dict_ptr_array_get_available_private_utf8 (GPtrArray *chars) +{ + gint i, len, result_len; + gchar *result; + gunichar result_ucs = TOMOE_CHAR_PRIVATE_USE_AREA_START; + + len = chars->len; + for (i = 0; i < len; i++) { + TomoeChar *chr; + gunichar ucs; + + chr = chars->pdata[i]; + ucs = g_utf8_get_char (tomoe_char_get_utf8 (chr)); + if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_START) { + if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_END) { + return NULL; + } else { + result_ucs = ucs + 1; + } + } + } + + result_len = g_unichar_to_utf8 (result_ucs, NULL); + result = g_new (gchar, result_len + 1); + g_unichar_to_utf8 (result_ucs, result); + result[result_len] = '\0'; + return result; +} + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/module/dict/tomoe-dict-ptr-array.h diff -u tomoe/module/dict/tomoe-dict-ptr-array.h:1.1 tomoe/module/dict/tomoe-dict-ptr-array.h:1.2 --- tomoe/module/dict/tomoe-dict-ptr-array.h:1.1 Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.h Wed Dec 6 12:08:47 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ptr-array.h,v 1.1 2006/12/05 09:01:29 kous Exp $ + * $Id: tomoe-dict-ptr-array.h,v 1.2 2006/12/06 03:08:47 kous Exp $ */ #ifndef __TOMOE_DICT_PTR_ARRAY_H__ @@ -29,15 +29,16 @@ #include -void _tomoe_dict_ptr_array_sort (GPtrArray *chars); -gboolean _tomoe_dict_ptr_array_register_char (GPtrArray *chars, - TomoeChar *chr); -gboolean _tomoe_dict_ptr_array_unregister_char (GPtrArray *chars, - const gchar *utf8); -TomoeChar *_tomoe_dict_ptr_array_get_char (GPtrArray *chars, - const gchar *utf8); -GList *_tomoe_dict_ptr_array_search (GPtrArray *chars, - TomoeQuery *query); +void _tomoe_dict_ptr_array_sort (GPtrArray *chars); +gboolean _tomoe_dict_ptr_array_register_char (GPtrArray *chars, + TomoeChar *chr); +gboolean _tomoe_dict_ptr_array_unregister_char (GPtrArray *chars, + const gchar *utf8); +TomoeChar *_tomoe_dict_ptr_array_get_char (GPtrArray *chars, + const gchar *utf8); +GList *_tomoe_dict_ptr_array_search (GPtrArray *chars, + TomoeQuery *query); +gchar *_tomoe_dict_ptr_array_get_available_private_utf8 (GPtrArray *chars); G_END_DECLS Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.3 tomoe/module/dict/tomoe-dict-unihan.c:1.4 --- tomoe/module/dict/tomoe-dict-unihan.c:1.3 Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Wed Dec 6 12:08:47 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.3 2006/12/05 09:01:29 kous Exp $ + * $Id: tomoe-dict-unihan.c,v 1.4 2006/12/06 03:08:47 kous Exp $ */ #include @@ -80,15 +80,13 @@ GValue *value, GParamSpec *pspec); static const gchar *get_name (TomoeDict *dict); -static gboolean register_char (TomoeDict *dict, - TomoeChar *chr); -static gboolean unregister_char (TomoeDict *dict, +static TomoeChar *get_char (TomoeDict *dict, const gchar *utf8); -static TomoeChar *get_char (TomoeDict *dict, - const gchar *utf8); -static GList *search (TomoeDict *dict, +static GList *search (TomoeDict *dict, TomoeQuery *query); -static gboolean flush (TomoeDict *dict); +static gboolean flush (TomoeDict *dict); +static gboolean is_editable (TomoeDict *dict); +static gchar *get_available_private_utf8 (TomoeDict *dict); static void class_init (TomoeDictUnihanClass *klass) @@ -107,11 +105,11 @@ dict_class = TOMOE_DICT_CLASS (klass); dict_class->get_name = get_name; - dict_class->register_char = register_char; - dict_class->unregister_char = unregister_char; dict_class->get_char = get_char; dict_class->search = search; dict_class->flush = flush; + dict_class->is_editable = is_editable; + dict_class->get_available_private_utf8 = get_available_private_utf8; g_object_class_install_property ( gobject_class, @@ -249,30 +247,6 @@ return dict->name ? dict->name : DEFAULT_NAME; } -static gboolean -register_char (TomoeDict *_dict, TomoeChar *chr) -{ - TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); - g_return_val_if_fail (chr, FALSE); - - g_warning ("TomoeDictUnihan doesn't support register_char()"); - return FALSE; -} - -static gboolean -unregister_char (TomoeDict *_dict, const gchar *utf8) -{ - TomoeDictUnihan *dict = TOMOE_DICT_UNIHAN (_dict); - - g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); - g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); - - g_warning ("TomoeDictUnihan doesn't support register_char()"); - return FALSE; -} - static TomoeChar * get_char (TomoeDict *_dict, const gchar *utf8) { @@ -299,6 +273,18 @@ return TRUE; } +static gboolean +is_editable (TomoeDict *_dict) +{ + return FALSE; +} + +static gchar * +get_available_private_utf8 (TomoeDict *_dict) +{ + return NULL; +} + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.8 tomoe/module/dict/tomoe-dict-xml.c:1.9 --- tomoe/module/dict/tomoe-dict-xml.c:1.8 Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Wed Dec 6 12:08:47 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.8 2006/12/05 09:01:29 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.9 2006/12/06 03:08:47 kous Exp $ */ #include @@ -90,13 +90,15 @@ TomoeChar *chr); static gboolean unregister_char (TomoeDict *dict, const gchar *utf8); -static TomoeChar *get_char (TomoeDict *dict, +static TomoeChar *get_char (TomoeDict *dict, const gchar *utf8); -static GList *search (TomoeDict *dict, +static GList *search (TomoeDict *dict, TomoeQuery *query); -static gboolean flush (TomoeDict *dict); -static gboolean tomoe_dict_xml_load (TomoeDictXML *dict); -static gboolean tomoe_dict_xml_save (TomoeDictXML *dict); +static gboolean flush (TomoeDict *dict); +static gboolean is_editable (TomoeDict *dict); +static gchar *get_available_private_utf8 (TomoeDict *dict); +static gboolean tomoe_dict_xml_load (TomoeDictXML *dict); +static gboolean tomoe_dict_xml_save (TomoeDictXML *dict); static void class_init (TomoeDictXMLClass *klass) @@ -120,6 +122,9 @@ dict_class->get_char = get_char; dict_class->search = search; dict_class->flush = flush; + dict_class->is_editable = is_editable; + dict_class->get_available_private_utf8 = get_available_private_utf8; + g_object_class_install_property ( gobject_class, @@ -336,6 +341,8 @@ { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); + if (dict->editable && dict->modified) { dict->modified = FALSE; return tomoe_dict_xml_save (dict); @@ -345,6 +352,26 @@ } static gboolean +is_editable (TomoeDict *_dict) +{ + TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); + + return dict->editable; +} + +static gchar * +get_available_private_utf8 (TomoeDict *_dict) +{ + TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); + + return _tomoe_dict_ptr_array_get_available_private_utf8 (dict->chars); +} + +static gboolean tomoe_dict_xml_load (TomoeDictXML *dict) { gboolean success = TRUE; From kous users.sourceforge.jp Wed Dec 6 12:08:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 12:08:47 +0900 Subject: [Tomoe-cvs 1680] CVS update: tomoe/test Message-ID: <20061206030847.732EC2AC0A2@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.22 tomoe/test/context_spec.rb:1.23 --- tomoe/test/context_spec.rb:1.22 Tue Dec 5 17:33:05 2006 +++ tomoe/test/context_spec.rb Wed Dec 6 12:08:47 2006 @@ -13,6 +13,35 @@ @@context end + setup do + setup_user_dict + end + + def setup_user_dict + @user_dict_file = Tempfile.new("tomoe-user-dict") + @user_dict_file.open + @user_dict_file.puts(<<-EOD) + + + + +EOD + @user_dict_file.close + + @user_dict_config_file = Tempfile.new("tomoe-context") + @user_dict_config_file.open + @user_dict_config_file.puts(<<-EOC) +[config] +use_system_dictionaries = false +user_dictionary = user + +[user-dictionary] +type = xml +file = #{@user_dict_file.path} +EOC + @user_dict_config_file.close + end + TomoeSpecUtils::Config.test_data_files.each do |file| base = File.basename(file) specify "Search by strokes for #{base}" do @@ -34,31 +63,8 @@ end specify "User dictionary" do - user_dict_file = Tempfile.new("tomoe-user-dict") - user_dict_file.open - user_dict_file.puts(<<-EOD) - - - - -EOD - user_dict_file.close - - config_file = Tempfile.new("tomoe-context") - config_file.open - config_file.puts(<<-EOC) -[config] -use_system_dictionaries = false -user_dictionary = user - -[user-dictionary] -type = xml -file = #{user_dict_file.path} -EOC - config_file.close - context = Tomoe::Context.new() - context.load_config(config_file.path) + context.load_config(@user_dict_config_file.path) context.search(Tomoe::Query.new).should_be_empty @@ -72,4 +78,36 @@ context.unregister(char.utf8).should context.search(Tomoe::Query.new).should_be_empty end + + specify "should assign available UTF8 encoded code point " \ + "when a character is registered without UTF8 value" do + context = Tomoe::Context.new() + context.load_config(@user_dict_config_file.path) + + n_strokes = 8 + query = Tomoe::Query.new + query.min_n_strokes = n_strokes + query.max_n_strokes = n_strokes + + context.search(query).should_be_empty + + char = Tomoe::Char.new + char.n_strokes = n_strokes + context.register(char).should + char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) + + context.search(query).collect do |cand| + cand.char.utf8 + end.should == [char.utf8] + + + char2 = Tomoe::Char.new + char2.n_strokes = n_strokes + context.register(char2).should + char2.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START + 1) + + context.search(query).collect do |cand| + cand.char.utf8 + end.sort.should == [char.utf8, char2.utf8].sort + end end Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.19 tomoe/test/tomoe-spec-utils.rb:1.20 --- tomoe/test/tomoe-spec-utils.rb:1.19 Tue Dec 5 17:33:05 2006 +++ tomoe/test/tomoe-spec-utils.rb Wed Dec 6 12:08:47 2006 @@ -1,5 +1,6 @@ require 'tempfile' require 'fileutils' +require 'uconv' require 'tomoe' @@ -43,6 +44,7 @@ base.class_eval do include Base include Config + include Unicode end end @@ -181,6 +183,12 @@ point end end + + module Unicode + def ucs4_to_utf8(ucs4) + Uconv.u4tou8([ucs4].pack("I*")) + end + end end Tomoe::Dict.unload From makeinu users.sourceforge.jp Wed Dec 6 12:11:28 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 12:11:28 +0900 Subject: [Tomoe-cvs 1681] CVS update: libtomoe-gtk/src Message-ID: <20061206031128.EA6102AC06A@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.52 libtomoe-gtk/src/tomoe-canvas.c:1.53 --- libtomoe-gtk/src/tomoe-canvas.c:1.52 Wed Dec 6 12:07:00 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Dec 6 12:11:28 2006 @@ -221,7 +221,7 @@ "locked", N_("Locked"), N_("Whether the canvas is locked drawing or not."), - G_TYPE_BOOLEAN, + FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE); g_object_class_install_property (gobject_class, PROP_LOCKED, spec); @@ -477,6 +477,7 @@ tomoe_canvas_new (void) { return GTK_WIDGET(g_object_new (TOMOE_TYPE_CANVAS, + "tomoe-context", NULL, NULL)); } From ikezoe users.sourceforge.jp Wed Dec 6 12:33:41 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Wed, 6 Dec 2006 12:33:41 +0900 Subject: [Tomoe-cvs 1682] CVS update: tomoe Message-ID: <20061206033341.DBB902AC054@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.388 tomoe/ChangeLog:1.389 --- tomoe/ChangeLog:1.388 Wed Dec 6 12:08:46 2006 +++ tomoe/ChangeLog Wed Dec 6 12:33:41 2006 @@ -1,3 +1,8 @@ +2006-12-06 Hiroyuki Ikezoe + + * module/recognizer/tomoe-recognizer-simple.c: Use g_build_filename() + for constructing the path name of dictionary. + 2006-12-06 Kouhei Sutou * lib/tomoe-char.h (TOMOE_CHAR_PRIVATE_USE_AREA_START, From ikezoe users.sourceforge.jp Wed Dec 6 12:33:42 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Wed, 6 Dec 2006 12:33:42 +0900 Subject: [Tomoe-cvs 1683] CVS update: tomoe/module/recognizer Message-ID: <20061206033342.149752AC0DB@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.6 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.7 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.6 Tue Dec 5 15:12:35 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Wed Dec 6 12:33:41 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.6 2006/12/05 06:12:35 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.7 2006/12/06 03:33:41 ikezoe Exp $ */ #include @@ -157,10 +157,14 @@ recognizer = TOMOE_RECOGNIZER_SIMPLE (object); if (!recognizer->dict) { + gchar *filename = g_build_filename (RECOGNIZER_DATADIR, + "handwriting.xml", + NULL); recognizer->dict = tomoe_dict_new ("xml", - "filename", RECOGNIZER_DATADIR "/handwriting.xml", + "filename", filename, NULL); + g_free(filename); } if (!recognizer->dict) { From kous users.sourceforge.jp Wed Dec 6 13:01:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 13:01:47 +0900 Subject: [Tomoe-cvs 1684] CVS update: tomoe Message-ID: <20061206040147.0F7832AC1CA@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.389 tomoe/ChangeLog:1.390 --- tomoe/ChangeLog:1.389 Wed Dec 6 12:33:41 2006 +++ tomoe/ChangeLog Wed Dec 6 13:01:46 2006 @@ -1,3 +1,7 @@ +2006-12-06 Kouhei Sutou + + * lib/tomoe-context.c: fixed a bug related user dictionary. + 2006-12-06 Hiroyuki Ikezoe * module/recognizer/tomoe-recognizer-simple.c: Use g_build_filename() From kous users.sourceforge.jp Wed Dec 6 13:01:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 13:01:47 +0900 Subject: [Tomoe-cvs 1685] CVS update: tomoe/lib Message-ID: <20061206040147.3C3872AC1CC@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.47 tomoe/lib/tomoe-context.c:1.48 --- tomoe/lib/tomoe-context.c:1.47 Tue Dec 5 17:33:05 2006 +++ tomoe/lib/tomoe-context.c Wed Dec 6 13:01:47 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.47 2006/12/05 08:33:05 kous Exp $ + * $Id: tomoe-context.c,v 1.48 2006/12/06 04:01:47 kous Exp $ */ #include @@ -178,12 +178,37 @@ G_OBJECT_CLASS (tomoe_context_parent_class)->dispose (object); } +static gboolean +ensure_user_dict_file_content (const gchar *user_dict_filename) +{ + if (!g_file_test (user_dict_filename, G_FILE_TEST_EXISTS)) { + FILE *f; + const gchar *content; + + f = fopen (user_dict_filename, "wb"); + if (!f) { + g_warning ("failed to open %s: %s", + user_dict_filename, strerror (errno)); + return FALSE; + } + + content = DEFAULT_USER_DICT_CONTENT; + if (fwrite (content, strlen (content), 1, f) < 1) { + g_warning ("failed to write to %s: %s", + user_dict_filename, strerror (errno)); + return FALSE; + } + + fclose (f); + } + + return TRUE; +} + static gchar * ensure_user_dict_file (void) { - FILE *f; gchar *tomoe_dir_name, *user_dict_filename; - const gchar *content; tomoe_dir_name = g_build_filename (g_get_home_dir (), ".tomoe", NULL); @@ -200,24 +225,11 @@ user_dict_filename = g_build_filename (tomoe_dir_name, "dict.xml", NULL); g_free (tomoe_dir_name); - f = fopen (user_dict_filename, "wb"); - if (!f) { - g_warning ("failed to open %s: %s", - user_dict_filename, strerror (errno)); + if (!ensure_user_dict_file_content (user_dict_filename)) { g_free (user_dict_filename); return NULL; } - content = DEFAULT_USER_DICT_CONTENT; - if (fwrite (content, strlen (content), 1, f) < 1) { - g_warning ("failed to write to %s: %s", - user_dict_filename, strerror (errno)); - g_free (user_dict_filename); - return NULL; - } - - fclose (f); - return user_dict_filename; } From makeinu users.sourceforge.jp Wed Dec 6 13:07:56 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 13:07:56 +0900 Subject: [Tomoe-cvs 1686] CVS update: libtomoe-gtk Message-ID: <20061206040756.C36BA2AC0A2@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.232 libtomoe-gtk/ChangeLog:1.233 --- libtomoe-gtk/ChangeLog:1.232 Wed Dec 6 11:56:10 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 13:07:56 2006 @@ -1,5 +1,11 @@ 2006-12-06 Takuro Ashie + * src/tomoe-handwriting.[ch]: Add a "tomoe-context" property as + construct only. + * src/tomoe-window.c: Follow the change. + +2006-12-06 Takuro Ashie + * src/tomoe-canvas.[ch]: Remove priv->size. Resize provided writing to internal size in tomoe_canvas_set_writing(). From makeinu users.sourceforge.jp Wed Dec 6 13:07:56 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 13:07:56 +0900 Subject: [Tomoe-cvs 1687] CVS update: libtomoe-gtk/src Message-ID: <20061206040756.E8CBD2AC0EC@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.8 libtomoe-gtk/src/tomoe-handwriting.c:1.9 --- libtomoe-gtk/src/tomoe-handwriting.c:1.8 Tue Dec 5 23:39:13 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Wed Dec 6 13:07:56 2006 @@ -33,9 +33,16 @@ LAST_SIGNAL }; +enum { + PROP_0, + PROP_TOMOE_CONTEXT +}; + typedef struct _TomoeHandwritingPrivate TomoeHandwritingPrivate; struct _TomoeHandwritingPrivate { + TomoeContext *context; + GtkWidget *canvas; GtkWidget *button_area; GtkWidget *find_button; @@ -49,25 +56,35 @@ G_DEFINE_TYPE (TomoeHandwriting, tomoe_handwriting, GTK_TYPE_TABLE) +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + static void tomoe_handwriting_set_sensitive (TomoeHandwriting *handwriting); /* callbacks for child widgets */ -static void on_canvas_stroke_added (TomoeCanvas *canvas, - gpointer user_data); -static void on_find_button_clicked (GtkButton *button, - gpointer user_data); -static void on_go_back_button_clicked (GtkButton *button, - gpointer user_data); -static void on_clear_button_clicked (GtkButton *button, - gpointer user_data); -static void on_normalize_button_clicked (GtkButton *button, - gpointer user_data); +static void on_canvas_stroke_added (TomoeCanvas *canvas, + gpointer user_data); +static void on_find_button_clicked (GtkButton *button, + gpointer user_data); +static void on_go_back_button_clicked (GtkButton *button, + gpointer user_data); +static void on_clear_button_clicked (GtkButton *button, + gpointer user_data); +static void on_normalize_button_clicked (GtkButton *button, + gpointer user_data); #ifdef ENABLE_DUMPSTROKE -static void on_dump_button_clicked (GtkButton *button, - gpointer user_data); +static void on_dump_button_clicked (GtkButton *button, + gpointer user_data); #endif -static void on_candidate_selected (TomoeCharTable *table, - gpointer user_data); +static void on_candidate_selected (TomoeCharTable *table, + gpointer user_data); static guint handwriting_signals[LAST_SIGNAL] = { 0 }; @@ -75,6 +92,12 @@ tomoe_handwriting_class_init (TomoeHandwritingClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *spec; + + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + klass->selected = NULL; handwriting_signals[SELECTED_SIGNAL] = g_signal_new ("selected", @@ -85,7 +108,13 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - klass->selected = NULL; + spec = g_param_spec_object ( + "tomoe-context", + N_("Tomoe context"), + N_("A TomoeContext which stores handwriting dictionaries. "), + TOMOE_TYPE_CONTEXT, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); g_type_class_add_private (gobject_class, sizeof (TomoeHandwritingPrivate)); } @@ -97,6 +126,8 @@ GtkWidget *canvas, *button, *table; TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); + priv->context = NULL; + gtk_table_resize (GTK_TABLE (handwriting), 1, 1); gtk_table_set_homogeneous (GTK_TABLE (handwriting), TRUE); @@ -195,6 +226,67 @@ } static void +dispose (GObject *object) +{ + TomoeHandwriting *hw = TOMOE_HANDWRITING (object); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (hw); + + if (priv->context) { + g_object_unref (priv->context); + priv->context = NULL; + } + + if (G_OBJECT_CLASS(tomoe_handwriting_parent_class)->dispose) + G_OBJECT_CLASS(tomoe_handwriting_parent_class)->dispose(object); +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeHandwriting *hw = TOMOE_HANDWRITING (object); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (hw); + + switch (prop_id) { + case PROP_TOMOE_CONTEXT: + { + TomoeContext *ctx = TOMOE_CONTEXT (g_value_get_object (value)); + if (priv->context) + g_object_unref (priv->context); + if (ctx) + g_object_ref (ctx); + priv->context = ctx; + tomoe_canvas_set_context (TOMOE_CANVAS (priv->canvas), ctx); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeHandwriting *hw = TOMOE_HANDWRITING (object); + TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (hw); + + switch (prop_id) { + case PROP_TOMOE_CONTEXT: + g_value_set_object (value, G_OBJECT (priv->context)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void tomoe_handwriting_set_sensitive (TomoeHandwriting *handwriting) { TomoeHandwritingPrivate *priv = TOMOE_HANDWRITING_GET_PRIVATE (handwriting); @@ -207,9 +299,11 @@ } GtkWidget * -tomoe_handwriting_new (void) +tomoe_handwriting_new (TomoeContext *context) { + g_return_val_if_fail (TOMOE_IS_CONTEXT (context), NULL); return GTK_WIDGET(g_object_new (TOMOE_TYPE_HANDWRITING, + "tomoe-context", context, NULL)); } Index: libtomoe-gtk/src/tomoe-handwriting.h diff -u libtomoe-gtk/src/tomoe-handwriting.h:1.8 libtomoe-gtk/src/tomoe-handwriting.h:1.9 --- libtomoe-gtk/src/tomoe-handwriting.h:1.8 Tue Dec 5 17:52:21 2006 +++ libtomoe-gtk/src/tomoe-handwriting.h Wed Dec 6 13:07:56 2006 @@ -25,6 +25,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -53,7 +54,7 @@ GType tomoe_handwriting_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_handwriting_new (void); +GtkWidget *tomoe_handwriting_new (TomoeContext *context); GtkWidget *tomoe_handwriting_get_canvas (TomoeHandwriting *handwriting); GtkWidget *tomoe_handwriting_get_button_area (TomoeHandwriting *handwriting); Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.35 libtomoe-gtk/src/tomoe-window.c:1.36 --- libtomoe-gtk/src/tomoe-window.c:1.35 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-window.c Wed Dec 6 13:07:56 2006 @@ -99,7 +99,6 @@ TomoeHandwriting *handwriting_page; TomoeReadingSearch *reading_search; GtkWidget *widget, *notebook, *vbox; - TomoeCanvas *canvas; TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); #ifdef ENABLE_NLS @@ -139,11 +138,9 @@ gtk_widget_show (notebook); /* handwriting page */ - widget = tomoe_handwriting_new (); + widget = tomoe_handwriting_new (priv->context); priv->handwriting = widget; handwriting_page = TOMOE_HANDWRITING (widget); - canvas = TOMOE_CANVAS (tomoe_handwriting_get_canvas (handwriting_page)); - tomoe_canvas_set_context (canvas, priv->context); g_signal_connect (G_OBJECT (widget), "selected", G_CALLBACK (on_handwriting_candidate_selected), (gpointer) window); From kous users.sourceforge.jp Wed Dec 6 13:09:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 13:09:16 +0900 Subject: [Tomoe-cvs 1687] CVS update: tomoe Message-ID: <20061206040916.B51D72AC0A2@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.390 tomoe/ChangeLog:1.391 --- tomoe/ChangeLog:1.390 Wed Dec 6 13:01:46 2006 +++ tomoe/ChangeLog Wed Dec 6 13:09:16 2006 @@ -1,5 +1,7 @@ 2006-12-06 Kouhei Sutou + * lib/tomoe-dict.c (tomoe_dict_load): fixed a typo. + * lib/tomoe-context.c: fixed a bug related user dictionary. 2006-12-06 Hiroyuki Ikezoe From kous users.sourceforge.jp Wed Dec 6 13:09:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 13:09:16 +0900 Subject: [Tomoe-cvs 1688] CVS update: tomoe/lib Message-ID: <20061206040916.E15D82AC0EC@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.131 tomoe/lib/tomoe-dict.c:1.132 --- tomoe/lib/tomoe-dict.c:1.131 Wed Dec 6 12:08:46 2006 +++ tomoe/lib/tomoe-dict.c Wed Dec 6 13:09:16 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.131 2006/12/06 03:08:46 kous Exp $ + * $Id: tomoe-dict.c,v 1.132 2006/12/06 04:09:16 kous Exp $ */ #include "tomoe-dict.h" @@ -29,7 +29,7 @@ tomoe_dict_load (const gchar *base_dir) { if (!base_dir) - base_dir = DICT_DATADIR; + base_dir = DICT_MODULEDIR; dicts = g_list_concat (tomoe_module_load_modules (base_dir), dicts); } From ikezoe users.sourceforge.jp Wed Dec 6 13:19:43 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Wed, 6 Dec 2006 13:19:43 +0900 Subject: [Tomoe-cvs 1689] CVS update: tomoe/module/dict Message-ID: <20061206041943.A94962AC0A2@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.4 tomoe/module/dict/tomoe-dict-unihan.c:1.5 --- tomoe/module/dict/tomoe-dict-unihan.c:1.4 Wed Dec 6 12:08:47 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Wed Dec 6 13:19:43 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.4 2006/12/06 03:08:47 kous Exp $ + * $Id: tomoe-dict-unihan.c,v 1.5 2006/12/06 04:19:43 ikezoe Exp $ */ #include @@ -264,7 +264,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_UNIHAN (dict), FALSE); - return _tomoe_dict_ptr_array_search (chars, query); + return _tomoe_dict_ptr_array_search (chars, query); } static gboolean From kous users.sourceforge.jp Wed Dec 6 14:09:52 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 14:09:52 +0900 Subject: [Tomoe-cvs 1690] CVS update: tomoe Message-ID: <20061206050952.EB8CF2AC1CD@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.391 tomoe/ChangeLog:1.392 --- tomoe/ChangeLog:1.391 Wed Dec 6 13:09:16 2006 +++ tomoe/ChangeLog Wed Dec 6 14:09:52 2006 @@ -1,5 +1,8 @@ 2006-12-06 Kouhei Sutou + * module/dict/tomoe-unihan.c, module/dict/unihan-compiler.rb: + fixed a bug that readings and variants aren't set. + * lib/tomoe-dict.c (tomoe_dict_load): fixed a typo. * lib/tomoe-context.c: fixed a bug related user dictionary. From kous users.sourceforge.jp Wed Dec 6 14:09:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 14:09:53 +0900 Subject: [Tomoe-cvs 1691] CVS update: tomoe/module/dict Message-ID: <20061206050953.2454A2AC1CE@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-unihan.c diff -u tomoe/module/dict/tomoe-unihan.c:1.1 tomoe/module/dict/tomoe-unihan.c:1.2 --- tomoe/module/dict/tomoe-unihan.c:1.1 Mon Dec 4 13:36:03 2006 +++ tomoe/module/dict/tomoe-unihan.c Wed Dec 6 14:09:53 2006 @@ -32,25 +32,21 @@ if (info.n_strokes) tomoe_char_set_n_strokes (chr, info.n_strokes); - if (info.variants) { - len = G_N_ELEMENTS (info.variants); - for (j = 0; j < len; j++) { - tomoe_char_set_variant (chr, info.variants[j]); - } + len = info.variants_size; + for (j = 0; j < len; j++) { + tomoe_char_set_variant (chr, info.variants[j]); } - if (info.readings) { - len = G_N_ELEMENTS (info.readings); - for (j = 0; j < len; j++) { - TomoeReading *reading; - TomoeUnihanReading reading_info; + len = info.readings_size; + for (j = 0; j < len; j++) { + TomoeReading *reading; + TomoeUnihanReading reading_info; - reading_info = info.readings[j]; - reading = tomoe_reading_new (reading_info.type, - reading_info.reading); - tomoe_char_add_reading (chr, reading); - g_object_unref (reading); - } + reading_info = info.readings[j]; + reading = tomoe_reading_new (reading_info.type, + reading_info.reading); + tomoe_char_add_reading (chr, reading); + g_object_unref (reading); } array->pdata[i] = chr; Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.4 tomoe/module/dict/unihan-compiler.rb:1.5 --- tomoe/module/dict/unihan-compiler.rb:1.4 Tue Dec 5 14:51:42 2006 +++ tomoe/module/dict/unihan-compiler.rb Wed Dec 6 14:09:53 2006 @@ -92,7 +92,9 @@ gchar *utf8; gint n_strokes; gchar **variants; + gint variants_size; TomoeUnihanReading *readings; + gint readings_size; }; EOH @@ -137,10 +139,19 @@ infos.each_with_index do |(ucs4, info), i| info["utf8"] = utf8 = Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) n_strokes = info["kTotalStrokes"] || -1 - variants = info["have_variants"] ? "#{prefix}variant_#{ucs4}" : "NULL" - readings = info["have_readings"] ? "#{prefix}reading_#{ucs4}" : "NULL" + variants = readings = "NULL" + variants_size = readings_size = "0" + if info["have_variants"] + variants = "#{prefix}variant_#{ucs4}" + variants_size = "G_N_ELEMENTS(#{variants})" + end + if info["have_readings"] + readings = "#{prefix}reading_#{ucs4}" + readings_size = "G_N_ELEMENTS(#{readings})" + end - puts(" {\"#{utf8}\", #{n_strokes}, #{variants}, #{readings}},") + puts(" {\"#{utf8}\", #{n_strokes}, #{variants}, #{variants_size}, " \ + "#{readings}, #{readings_size}},") end puts("};") end From makeinu users.sourceforge.jp Wed Dec 6 14:28:58 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 14:28:58 +0900 Subject: [Tomoe-cvs 1692] CVS update: libtomoe-gtk Message-ID: <20061206052858.CAC7B2AC110@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.233 libtomoe-gtk/ChangeLog:1.234 --- libtomoe-gtk/ChangeLog:1.233 Wed Dec 6 13:07:56 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 14:28:58 2006 @@ -1,5 +1,9 @@ 2006-12-06 Takuro Ashie + * src/tomoe-windows.c: Make window as resizable. + +2006-12-06 Takuro Ashie + * src/tomoe-handwriting.[ch]: Add a "tomoe-context" property as construct only. * src/tomoe-window.c: Follow the change. From makeinu users.sourceforge.jp Wed Dec 6 14:28:59 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 14:28:59 +0900 Subject: [Tomoe-cvs 1693] CVS update: libtomoe-gtk/src Message-ID: <20061206052859.0B1682AC1C8@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.36 libtomoe-gtk/src/tomoe-window.c:1.37 --- libtomoe-gtk/src/tomoe-window.c:1.36 Wed Dec 6 13:07:56 2006 +++ libtomoe-gtk/src/tomoe-window.c Wed Dec 6 14:28:58 2006 @@ -121,9 +121,6 @@ gtk_window_set_title (GTK_WINDOW (window), _("Handwriting recognition")); - /* FIXME! */ - gtk_window_set_resizable (GTK_WINDOW (window), FALSE); - vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); From makeinu users.sourceforge.jp Wed Dec 6 14:31:26 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 14:31:26 +0900 Subject: [Tomoe-cvs 1694] CVS update: libtomoe-gtk Message-ID: <20061206053126.430A02AC026@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.234 libtomoe-gtk/ChangeLog:1.235 --- libtomoe-gtk/ChangeLog:1.234 Wed Dec 6 14:28:58 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 14:31:26 2006 @@ -1,6 +1,7 @@ 2006-12-06 Takuro Ashie * src/tomoe-windows.c: Make window as resizable. + * src/tomoe-handwriting.c: Add remaining properties. 2006-12-06 Takuro Ashie From makeinu users.sourceforge.jp Wed Dec 6 14:31:26 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 14:31:26 +0900 Subject: [Tomoe-cvs 1695] CVS update: libtomoe-gtk/src Message-ID: <20061206053126.9AFC02AC026@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.9 libtomoe-gtk/src/tomoe-handwriting.c:1.10 --- libtomoe-gtk/src/tomoe-handwriting.c:1.9 Wed Dec 6 13:07:56 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Wed Dec 6 14:31:26 2006 @@ -35,7 +35,10 @@ enum { PROP_0, - PROP_TOMOE_CONTEXT + PROP_TOMOE_CONTEXT, + PROP_CANVAS, + PROP_BUTTON_AREA, + PROP_CHAR_TABLE }; typedef struct _TomoeHandwritingPrivate TomoeHandwritingPrivate; @@ -111,11 +114,31 @@ spec = g_param_spec_object ( "tomoe-context", N_("Tomoe context"), - N_("A TomoeContext which stores handwriting dictionaries. "), - TOMOE_TYPE_CONTEXT, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); + N_("A TomoeContext which stores handwriting dictionaries."), + TOMOE_TYPE_CONTEXT, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); + spec = g_param_spec_object ( + "canvas", + N_("TomoeCanvas"), + N_("The TomoeCavas widget inside of the TomoeHandwriting container."), + GTK_TYPE_WIDGET, G_PARAM_READABLE); + g_object_class_install_property (gobject_class, PROP_CANVAS, spec); + + spec = g_param_spec_object ( + "button-area", + N_("ButtonArea"), + N_("The button area widget inside of the TomoeHandwriting container."), + GTK_TYPE_WIDGET, G_PARAM_READABLE); + g_object_class_install_property (gobject_class, PROP_BUTTON_AREA, spec); + + spec = g_param_spec_object ( + "char-table", + N_("CharTable"), + N_("A candidates view widget inside of the TomoeHandwriting container."), + GTK_TYPE_WIDGET, G_PARAM_READABLE); + g_object_class_install_property (gobject_class, PROP_CHAR_TABLE, spec); + g_type_class_add_private (gobject_class, sizeof (TomoeHandwritingPrivate)); } @@ -280,6 +303,15 @@ case PROP_TOMOE_CONTEXT: g_value_set_object (value, G_OBJECT (priv->context)); break; + case PROP_CANVAS: + g_value_set_object (value, G_OBJECT (priv->canvas)); + break; + case PROP_BUTTON_AREA: + g_value_set_object (value, G_OBJECT (priv->button_area)); + break; + case PROP_CHAR_TABLE: + g_value_set_object (value, G_OBJECT (priv->candidates_view)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; From kous users.sourceforge.jp Wed Dec 6 14:46:13 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 14:46:13 +0900 Subject: [Tomoe-cvs 1696] CVS update: tomoe Message-ID: <20061206054613.3862C2AC026@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.392 tomoe/ChangeLog:1.393 --- tomoe/ChangeLog:1.392 Wed Dec 6 14:09:52 2006 +++ tomoe/ChangeLog Wed Dec 6 14:46:13 2006 @@ -1,5 +1,8 @@ 2006-12-06 Kouhei Sutou + * lib/tomoe-context.c (ensure_user_dict): added user dictionary to + shelf. + * module/dict/tomoe-unihan.c, module/dict/unihan-compiler.rb: fixed a bug that readings and variants aren't set. From kous users.sourceforge.jp Wed Dec 6 14:46:13 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 14:46:13 +0900 Subject: [Tomoe-cvs 1697] CVS update: tomoe/lib Message-ID: <20061206054613.653342AC108@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.48 tomoe/lib/tomoe-context.c:1.49 --- tomoe/lib/tomoe-context.c:1.48 Wed Dec 6 13:01:47 2006 +++ tomoe/lib/tomoe-context.c Wed Dec 6 14:46:13 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.48 2006/12/06 04:01:47 kous Exp $ + * $Id: tomoe-context.c,v 1.49 2006/12/06 05:46:13 kous Exp $ */ #include @@ -254,6 +254,8 @@ NULL); g_free (user_dict_filename); } + + tomoe_shelf_register_dict (shelf, name, user_dict); } return user_dict; From makeinu users.sourceforge.jp Wed Dec 6 15:12:28 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:12:28 +0900 Subject: [Tomoe-cvs 1698] CVS update: libtomoe-gtk Message-ID: <20061206061228.F10B82AC026@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.235 libtomoe-gtk/ChangeLog:1.236 --- libtomoe-gtk/ChangeLog:1.235 Wed Dec 6 14:31:26 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 15:12:28 2006 @@ -1,5 +1,11 @@ 2006-12-06 Takuro Ashie + * src/tomoe-reading-search.[ch]: Add a "tomoe-context" property like as + TomoeHandwriting. + * src/tomoe-window.c: Follow the change. + +2006-12-06 Takuro Ashie + * src/tomoe-windows.c: Make window as resizable. * src/tomoe-handwriting.c: Add remaining properties. From makeinu users.sourceforge.jp Wed Dec 6 15:12:29 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:12:29 +0900 Subject: [Tomoe-cvs 1699] CVS update: libtomoe-gtk/src Message-ID: <20061206061229.28E052AC02E@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.19 libtomoe-gtk/src/tomoe-reading-search.c:1.20 --- libtomoe-gtk/src/tomoe-reading-search.c:1.19 Tue Dec 5 17:48:35 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Wed Dec 6 15:12:29 2006 @@ -34,6 +34,11 @@ }; enum { + PROP_0, + PROP_TOMOE_CONTEXT +}; + +enum { TERMINATOR = -1, UTF8_COLUMN, STROKECOUNT_COLUMN, @@ -56,7 +61,15 @@ G_DEFINE_TYPE (TomoeReadingSearch, tomoe_reading_search, GTK_TYPE_TABLE) -static void dispose (GObject *object); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); static void on_find_button_clicked (GtkButton *button, gpointer user_data); @@ -71,23 +84,32 @@ static guint reading_search_signals[LAST_SIGNAL] = { 0 }; GtkWidget * -tomoe_reading_search_new (void) +tomoe_reading_search_new (TomoeContext *context) { return GTK_WIDGET(g_object_new (TOMOE_TYPE_READING_SEARCH, + "tomoe-context", context, NULL)); } +#if 0 void tomoe_reading_search_set_context (TomoeReadingSearch *page, TomoeContext *context) { TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); priv->context = g_object_ref (context); } +#endif static void tomoe_reading_search_class_init (TomoeReadingSearchClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *spec; + + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + klass->selected = NULL; reading_search_signals[SELECTED_SIGNAL] = g_signal_new ("selected", @@ -98,8 +120,12 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gobject_class->dispose = dispose; - klass->selected = NULL; + spec = g_param_spec_object ( + "tomoe-context", + N_("Tomoe context"), + N_("A TomoeContext which stores handwriting dictionaries."), + TOMOE_TYPE_CONTEXT, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (gobject_class, PROP_TOMOE_CONTEXT, spec); g_type_class_add_private (gobject_class, sizeof (TomoeReadingSearchPrivate)); } @@ -229,6 +255,51 @@ } static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeReadingSearch *page = TOMOE_READING_SEARCH (object); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + switch (prop_id) { + case PROP_TOMOE_CONTEXT: + { + TomoeContext *ctx = TOMOE_CONTEXT (g_value_get_object (value)); + if (priv->context) + g_object_unref (priv->context); + if (ctx) + g_object_ref (ctx); + priv->context = ctx; + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeReadingSearch *page = TOMOE_READING_SEARCH (object); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + switch (prop_id) { + case PROP_TOMOE_CONTEXT: + g_value_set_object (value, G_OBJECT (priv->context)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void tomoe_reading_search_start_search (TomoeReadingSearch *page) { GList *result, *list; Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.6 libtomoe-gtk/src/tomoe-reading-search.h:1.7 --- libtomoe-gtk/src/tomoe-reading-search.h:1.6 Tue Dec 5 17:52:21 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Wed Dec 6 15:12:29 2006 @@ -52,9 +52,9 @@ GType tomoe_reading_search_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_reading_search_new (void); +GtkWidget *tomoe_reading_search_new (TomoeContext *context); void tomoe_reading_search_set_context (TomoeReadingSearch *page, - TomoeContext *context); + TomoeContext *context); const gchar *tomoe_reading_search_get_selected_char (TomoeReadingSearch *page); TomoeChar *tomoe_reading_search_get_selected_tomoe_char Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.37 libtomoe-gtk/src/tomoe-window.c:1.38 --- libtomoe-gtk/src/tomoe-window.c:1.37 Wed Dec 6 14:28:58 2006 +++ libtomoe-gtk/src/tomoe-window.c Wed Dec 6 15:12:29 2006 @@ -97,8 +97,7 @@ tomoe_window_init (TomoeWindow *window) { TomoeHandwriting *handwriting_page; - TomoeReadingSearch *reading_search; - GtkWidget *widget, *notebook, *vbox; + GtkWidget *widget, *notebook, *vbox; TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); #ifdef ENABLE_NLS @@ -147,17 +146,15 @@ _("Handwriting recognition")); /* reading search page */ - widget = tomoe_reading_search_new (); + widget = tomoe_reading_search_new (priv->context); priv->reading = widget; - reading_search = TOMOE_READING_SEARCH (priv->reading); - tomoe_reading_search_set_context (reading_search, priv->context); g_signal_connect (G_OBJECT (widget), "selected", G_CALLBACK (on_reading_search_selected), (gpointer) window); gtk_widget_show (widget); tomoe_window_append_page (window, widget, gtk_image_new_from_file (TOMOE_SEARCHING_ICON), - _("Search with reading ")); + _("Search with reading")); /* gucharmap page */ widget = tomoe_gucharmap_new (); From makeinu users.sourceforge.jp Wed Dec 6 15:20:24 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:20:24 +0900 Subject: [Tomoe-cvs 1700] CVS update: libtomoe-gtk Message-ID: <20061206062024.0F9612AC026@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.236 libtomoe-gtk/ChangeLog:1.237 --- libtomoe-gtk/ChangeLog:1.236 Wed Dec 6 15:12:28 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 15:20:23 2006 @@ -1,7 +1,7 @@ 2006-12-06 Takuro Ashie * src/tomoe-reading-search.[ch]: Add a "tomoe-context" property like as - TomoeHandwriting. + TomoeHandwriting. Remove tomoe_reading_search_set_context(). * src/tomoe-window.c: Follow the change. 2006-12-06 Takuro Ashie From makeinu users.sourceforge.jp Wed Dec 6 15:20:24 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:20:24 +0900 Subject: [Tomoe-cvs 1701] CVS update: libtomoe-gtk/src Message-ID: <20061206062024.3C1402AC085@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.20 libtomoe-gtk/src/tomoe-reading-search.c:1.21 --- libtomoe-gtk/src/tomoe-reading-search.c:1.20 Wed Dec 6 15:12:29 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Wed Dec 6 15:20:24 2006 @@ -91,15 +91,6 @@ NULL)); } -#if 0 -void -tomoe_reading_search_set_context (TomoeReadingSearch *page, TomoeContext *context) -{ - TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); - priv->context = g_object_ref (context); -} -#endif - static void tomoe_reading_search_class_init (TomoeReadingSearchClass *klass) { Index: libtomoe-gtk/src/tomoe-reading-search.h diff -u libtomoe-gtk/src/tomoe-reading-search.h:1.7 libtomoe-gtk/src/tomoe-reading-search.h:1.8 --- libtomoe-gtk/src/tomoe-reading-search.h:1.7 Wed Dec 6 15:12:29 2006 +++ libtomoe-gtk/src/tomoe-reading-search.h Wed Dec 6 15:20:24 2006 @@ -53,8 +53,6 @@ GType tomoe_reading_search_get_type (void) G_GNUC_CONST; GtkWidget *tomoe_reading_search_new (TomoeContext *context); -void tomoe_reading_search_set_context (TomoeReadingSearch *page, - TomoeContext *context); const gchar *tomoe_reading_search_get_selected_char (TomoeReadingSearch *page); TomoeChar *tomoe_reading_search_get_selected_tomoe_char From makeinu users.sourceforge.jp Wed Dec 6 15:26:03 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:26:03 +0900 Subject: [Tomoe-cvs 1702] CVS update: libtomoe-gtk/src Message-ID: <20061206062603.ECA5D2AC1C8@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-canvas.h diff -u libtomoe-gtk/src/tomoe-canvas.h:1.14 libtomoe-gtk/src/tomoe-canvas.h:1.15 --- libtomoe-gtk/src/tomoe-canvas.h:1.14 Wed Dec 6 11:42:28 2006 +++ libtomoe-gtk/src/tomoe-canvas.h Wed Dec 6 15:26:03 2006 @@ -55,43 +55,42 @@ }; -GType tomoe_canvas_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_canvas_new (void); +GType tomoe_canvas_get_type (void) G_GNUC_CONST; +GtkWidget *tomoe_canvas_new (void); /* setters/getters */ -void tomoe_canvas_set_context (TomoeCanvas *canvas, - TomoeContext *context); -void tomoe_canvas_set_writing (TomoeCanvas *canvas, - TomoeWriting *writing); -TomoeWriting *tomoe_canvas_get_writing (TomoeCanvas *canvas); -void tomoe_canvas_set_locked (TomoeCanvas *canvas, - gboolean lock); -gboolean tomoe_canvas_is_locked (TomoeCanvas *canvas); -void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, - gint time_msec); -gint tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas); +void tomoe_canvas_set_context (TomoeCanvas *canvas, + TomoeContext *context); +void tomoe_canvas_set_writing (TomoeCanvas *canvas, + TomoeWriting *writing); +TomoeWriting *tomoe_canvas_get_writing (TomoeCanvas *canvas); +void tomoe_canvas_set_locked (TomoeCanvas *canvas, + gboolean lock); +gboolean tomoe_canvas_is_locked (TomoeCanvas *canvas); +void tomoe_canvas_set_auto_find_time (TomoeCanvas *canvas, + gint time_msec); +gint tomoe_canvas_get_auto_find_time (TomoeCanvas *canvas); void tomoe_canvas_set_handwriting_line_color - (TomoeCanvas *canvas, - GdkColor *color); + (TomoeCanvas *canvas, + GdkColor *color); void tomoe_canvas_set_adjusted_line_color - (TomoeCanvas *canvas, - GdkColor *color); -void tomoe_canvas_set_annotation_color - (TomoeCanvas *canvas, - GdkColor *color); -void tomoe_canvas_set_axis_color (TomoeCanvas *canvas, - GdkColor *color); + (TomoeCanvas *canvas, + GdkColor *color); +void tomoe_canvas_set_annotation_color (TomoeCanvas *canvas, + GdkColor *color); +void tomoe_canvas_set_axis_color (TomoeCanvas *canvas, + GdkColor *color); /* editing/searching */ -void tomoe_canvas_find (TomoeCanvas *canvas); -guint tomoe_canvas_get_n_candidates (TomoeCanvas *canvas); -TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, - guint nth); -const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); -void tomoe_canvas_revert_stroke (TomoeCanvas *canvas); -void tomoe_canvas_clear (TomoeCanvas *canvas); -void tomoe_canvas_normalize (TomoeCanvas *canvas); -gboolean tomoe_canvas_has_stroke (TomoeCanvas *canvas); +void tomoe_canvas_find (TomoeCanvas *canvas); +guint tomoe_canvas_get_n_candidates (TomoeCanvas *canvas); +TomoeChar *tomoe_canvas_get_nth_candidate (TomoeCanvas *canvas, + guint nth); +const GList *tomoe_canvas_get_candidates (TomoeCanvas *canvas); +void tomoe_canvas_revert_stroke (TomoeCanvas *canvas); +void tomoe_canvas_clear (TomoeCanvas *canvas); +void tomoe_canvas_normalize (TomoeCanvas *canvas); +gboolean tomoe_canvas_has_stroke (TomoeCanvas *canvas); G_END_DECLS From kous users.sourceforge.jp Wed Dec 6 15:28:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 15:28:36 +0900 Subject: [Tomoe-cvs 1703] CVS update: tomoe Message-ID: <20061206062836.709FD2AC110@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.393 tomoe/ChangeLog:1.394 --- tomoe/ChangeLog:1.393 Wed Dec 6 14:46:13 2006 +++ tomoe/ChangeLog Wed Dec 6 15:28:36 2006 @@ -1,5 +1,11 @@ 2006-12-06 Kouhei Sutou + * lib/tomoe-context.[ch] (tomoe_context_get_char): added. + * ext/ruby/tomoe-rb-context.c: added Tomoe::Context#[]. + * test/context_spec.rb: added tests for tomoe_context_get_char(). + + * ext/ruby/: fixed memory leaks. + * lib/tomoe-context.c (ensure_user_dict): added user dictionary to shelf. From kous users.sourceforge.jp Wed Dec 6 15:28:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 15:28:36 +0900 Subject: [Tomoe-cvs 1704] CVS update: tomoe/ext/ruby Message-ID: <20061206062836.B92792AC110@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-context.c diff -u tomoe/ext/ruby/tomoe-rb-context.c:1.13 tomoe/ext/ruby/tomoe-rb-context.c:1.14 --- tomoe/ext/ruby/tomoe-rb-context.c:1.13 Tue Dec 5 17:33:05 2006 +++ tomoe/ext/ruby/tomoe-rb-context.c Wed Dec 6 15:28:36 2006 @@ -41,6 +41,12 @@ return CBOOL2RVAL(tomoe_context_unregister(_SELF(self), RVAL2CSTR(utf8))); } +static VALUE +tc_get_char(VALUE self, VALUE utf8) +{ + return GOBJ2RVALU(tomoe_context_get_char(_SELF(self), RVAL2CSTR(utf8))); +} + void Init_tomoe_context(VALUE mTomoe) { @@ -54,4 +60,6 @@ rb_define_method(cTomoeContext, "register", tc_register, 1); rb_define_method(cTomoeContext, "unregister", tc_unregister, 1); + + rb_define_method(cTomoeContext, "[]", tc_get_char, 1); } Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.14 tomoe/ext/ruby/tomoe-rb-dict.c:1.15 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.14 Mon Dec 4 13:36:47 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Wed Dec 6 15:28:36 2006 @@ -52,13 +52,13 @@ dict = NULL; } - return GOBJ2RVAL(dict); + return GOBJ2RVALU(dict); } static VALUE td_get_char(VALUE self, VALUE utf8) { - return GOBJ2RVAL(tomoe_dict_get_char(_SELF(self), RVAL2CSTR(utf8))); + return GOBJ2RVALU(tomoe_dict_get_char(_SELF(self), RVAL2CSTR(utf8))); } static VALUE Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.4 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.5 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.4 Mon Dec 4 13:36:47 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Wed Dec 6 15:28:36 2006 @@ -25,7 +25,7 @@ recognizer = tomoe_recognizer_new(RVAL2CSTR(name), "dictionary", RVAL2TDIC(dict), NULL); - return GOBJ2RVAL(recognizer); + return GOBJ2RVALU(recognizer); } void Index: tomoe/ext/ruby/tomoe-rb.c diff -u tomoe/ext/ruby/tomoe-rb.c:1.4 tomoe/ext/ruby/tomoe-rb.c:1.5 --- tomoe/ext/ruby/tomoe-rb.c:1.4 Wed Nov 22 18:04:47 2006 +++ tomoe/ext/ruby/tomoe-rb.c Wed Dec 6 15:28:36 2006 @@ -2,6 +2,17 @@ #include "tomoe-rb.h" +#ifndef HAVE_GOBJ2RVALU +VALUE +_tomoe_ruby_object_from_instance_with_unref(gpointer instance) +{ + VALUE result = rbgobj_ruby_object_from_instance(instance); + if (!NIL_P(result)) + g_object_unref(instance); + return result; +} +#endif + void Init_tomoe(void) { Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.8 tomoe/ext/ruby/tomoe-rb.h:1.9 --- tomoe/ext/ruby/tomoe-rb.h:1.8 Tue Nov 28 13:26:23 2006 +++ tomoe/ext/ruby/tomoe-rb.h Wed Dec 6 15:28:36 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.8 2006/11/28 04:26:23 kous Exp $ + * $Id: tomoe-rb.h,v 1.9 2006/12/06 06:28:36 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -27,6 +27,15 @@ G_BEGIN_DECLS +#if GOBJ2RVALU +# define HAVE_GOBJ2RVALU +#endif + +#ifndef HAVE_GOBJ2RVALU +# define GOBJ2RVALU(gobj) (_tomoe_ruby_object_from_instance_with_unref(gobj)) +VALUE _tomoe_ruby_object_from_instance_with_unref(gpointer instance); +#endif + void Init_tomoe(void); void Init_tomoe_candidate(VALUE mTomoe); void Init_tomoe_char(VALUE mTomoe); From kous users.sourceforge.jp Wed Dec 6 15:28:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 15:28:36 +0900 Subject: [Tomoe-cvs 1705] CVS update: tomoe/lib Message-ID: <20061206062836.E04CA2AC12D@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.49 tomoe/lib/tomoe-context.c:1.50 --- tomoe/lib/tomoe-context.c:1.49 Wed Dec 6 14:46:13 2006 +++ tomoe/lib/tomoe-context.c Wed Dec 6 15:28:36 2006 @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2006 Juernjakob Harder * @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.49 2006/12/06 05:46:13 kous Exp $ + * $Id: tomoe-context.c,v 1.50 2006/12/06 06:28:36 kous Exp $ */ #include @@ -389,6 +389,37 @@ return tomoe_dict_unregister_char (priv->user_dict, utf8); } +TomoeChar * +tomoe_context_get_char (TomoeContext *context, const gchar *utf8) +{ + TomoeContextPrivate *priv; + TomoeShelf *shelf; + TomoeChar *chr = NULL; + GList *names, *node; + + g_return_val_if_fail (TOMOE_IS_CONTEXT (context), chr); + + priv = TOMOE_CONTEXT_GET_PRIVATE (context); + + shelf = priv->shelf; + if (!shelf) return chr; + + names = tomoe_shelf_get_dict_names (shelf); + if (!names) return chr; + + for (node = names; node; node = g_list_next (node)) { + const gchar *name = node->data; + TomoeDict *dict; + + dict = tomoe_shelf_get_dict (shelf, name); + chr = tomoe_dict_get_char (dict, utf8); + if (chr) + break; + } + + return chr; +} + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/lib/tomoe-context.h diff -u tomoe/lib/tomoe-context.h:1.33 tomoe/lib/tomoe-context.h:1.34 --- tomoe/lib/tomoe-context.h:1.33 Tue Dec 5 17:33:05 2006 +++ tomoe/lib/tomoe-context.h Wed Dec 6 15:28:36 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.h,v 1.33 2006/12/05 08:33:05 kous Exp $ + * $Id: tomoe-context.h,v 1.34 2006/12/06 06:28:36 kous Exp $ */ #ifndef __TOMOE_CONTEXT_H__ @@ -63,6 +63,9 @@ GList *tomoe_context_multi_search (TomoeContext *ctx, GList *queries); +TomoeChar *tomoe_context_get_char (TomoeContext *ctx, + const gchar *utf8); + gboolean tomoe_context_register (TomoeContext *ctx, TomoeChar *chr); gboolean tomoe_context_unregister (TomoeContext *ctx, From kous users.sourceforge.jp Wed Dec 6 15:28:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 15:28:37 +0900 Subject: [Tomoe-cvs 1706] CVS update: tomoe/module/dict Message-ID: <20061206062837.0F3A02AC110@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-ptr-array.c diff -u tomoe/module/dict/tomoe-dict-ptr-array.c:1.2 tomoe/module/dict/tomoe-dict-ptr-array.c:1.3 --- tomoe/module/dict/tomoe-dict-ptr-array.c:1.2 Wed Dec 6 12:08:47 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.c Wed Dec 6 15:28:36 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ptr-array.c,v 1.2 2006/12/06 03:08:47 kous Exp $ + * $Id: tomoe-dict-ptr-array.c,v 1.3 2006/12/06 06:28:36 kous Exp $ */ #include @@ -93,7 +93,7 @@ for (i = 0; i < len; i++) { TomoeChar *chr = g_ptr_array_index (chars, i); if (g_str_equal (tomoe_char_get_utf8(chr), utf8)) { - return chr; + return g_object_ref (chr); } } From kous users.sourceforge.jp Wed Dec 6 15:28:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 15:28:37 +0900 Subject: [Tomoe-cvs 1707] CVS update: tomoe/test Message-ID: <20061206062837.3327A2AC12D@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.23 tomoe/test/context_spec.rb:1.24 --- tomoe/test/context_spec.rb:1.23 Wed Dec 6 12:08:47 2006 +++ tomoe/test/context_spec.rb Wed Dec 6 15:28:37 2006 @@ -110,4 +110,19 @@ cand.char.utf8 end.sort.should == [char.utf8, char2.utf8].sort end + + specify "should get character by UTF8" do + context = Tomoe::Context.new() + context.load_config(@user_dict_config_file.path) + + context[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)].should_nil + + char = Tomoe::Char.new + char.n_strokes = 8 + context.register(char).should + char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) + + retrieved_char = context[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)] + retrieved_char.n_strokes.should == char.n_strokes + end end From makeinu users.sourceforge.jp Wed Dec 6 15:48:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:48:00 +0900 Subject: [Tomoe-cvs 1708] CVS update: libtomoe-gtk Message-ID: <20061206064800.88DF82AC1CD@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.237 libtomoe-gtk/ChangeLog:1.238 --- libtomoe-gtk/ChangeLog:1.237 Wed Dec 6 15:20:23 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 15:48:00 2006 @@ -1,5 +1,9 @@ 2006-12-06 Takuro Ashie + * src/tomoe-window.c: Don't call gtk_main_quit() from here. + +2006-12-06 Takuro Ashie + * src/tomoe-reading-search.[ch]: Add a "tomoe-context" property like as TomoeHandwriting. Remove tomoe_reading_search_set_context(). * src/tomoe-window.c: Follow the change. From makeinu users.sourceforge.jp Wed Dec 6 15:48:00 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:48:00 +0900 Subject: [Tomoe-cvs 1709] CVS update: libtomoe-gtk/src Message-ID: <20061206064800.B2B392AC1D0@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.38 libtomoe-gtk/src/tomoe-window.c:1.39 --- libtomoe-gtk/src/tomoe-window.c:1.38 Wed Dec 6 15:12:29 2006 +++ libtomoe-gtk/src/tomoe-window.c Wed Dec 6 15:48:00 2006 @@ -60,8 +60,7 @@ G_DEFINE_TYPE (TomoeWindow, tomoe_window, GTK_TYPE_WINDOW) -static void dispose (GObject *object); -static void destroy (GtkObject *object); +static void dispose (GObject *object); static void on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data); @@ -78,6 +77,8 @@ GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + gobject_class->dispose = dispose; + window_signals[SELECTED_SIGNAL] = g_signal_new ("selected", G_TYPE_FROM_CLASS (klass), @@ -87,9 +88,6 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gobject_class->dispose = dispose; - object_class->destroy = destroy; - g_type_class_add_private (gobject_class, sizeof (TomoeWindowPrivate)); } @@ -184,14 +182,6 @@ G_OBJECT_CLASS(tomoe_window_parent_class)->dispose(object); } -static void -destroy (GtkObject *object) -{ - GTK_OBJECT_CLASS (tomoe_window_parent_class)->destroy (object); - - gtk_main_quit(); -} - GtkWidget * tomoe_window_new (void) { From makeinu users.sourceforge.jp Wed Dec 6 15:48:57 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:48:57 +0900 Subject: [Tomoe-cvs 1710] CVS update: uim-tomoe-gtk Message-ID: <20061206064857.55DA12AC0A2@users.sourceforge.jp> Index: uim-tomoe-gtk/ChangeLog diff -u uim-tomoe-gtk/ChangeLog:1.18 uim-tomoe-gtk/ChangeLog:1.19 --- uim-tomoe-gtk/ChangeLog:1.18 Wed Nov 29 12:35:06 2006 +++ uim-tomoe-gtk/ChangeLog Wed Dec 6 15:48:57 2006 @@ -1,3 +1,7 @@ +2006-12-06 Takuro Ashie + + * src/uim-tomoe-gtk.c: Follow libtomoe-gtk. + 2006-11-29 Takuro Ashie * Version-0.4.0. From makeinu users.sourceforge.jp Wed Dec 6 15:48:57 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 15:48:57 +0900 Subject: [Tomoe-cvs 1711] CVS update: uim-tomoe-gtk/src Message-ID: <20061206064857.80D0A2AC1CD@users.sourceforge.jp> Index: uim-tomoe-gtk/src/uim-tomoe-gtk.c diff -u uim-tomoe-gtk/src/uim-tomoe-gtk.c:1.13 uim-tomoe-gtk/src/uim-tomoe-gtk.c:1.14 --- uim-tomoe-gtk/src/uim-tomoe-gtk.c:1.13 Tue Nov 28 13:26:46 2006 +++ uim-tomoe-gtk/src/uim-tomoe-gtk.c Wed Dec 6 15:48:57 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: uim-tomoe-gtk.c,v 1.13 2006/11/28 04:26:46 makeinu Exp $ + * $Id: uim-tomoe-gtk.c,v 1.14 2006/12/06 06:48:57 makeinu Exp $ */ #ifdef HAVE_CONFIG_H @@ -84,18 +84,12 @@ /* * main */ -static void -quit (void) -{ - gtk_exit (0); -} - int main (int argc, char *argv[]) { GtkWidget *window; TomoeWindow *tomoe; - TomoeStrokeSearch *page; + TomoeHandwriting *page; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -110,16 +104,14 @@ window = tomoe_window_new (); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_widget_show (window); - g_signal_connect (G_OBJECT (window), "response", - G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (GTK_OBJECT (window), "destroy", - G_CALLBACK (quit), NULL); + G_CALLBACK (gtk_main_quit), NULL); /* add hooks */ tomoe = TOMOE_WINDOW (window); - page = TOMOE_STROKE_SEARCH (tomoe_window_get_handwriting_page (tomoe)); - g_signal_connect (G_OBJECT (tomoe_stroke_search_get_candidates_view (page)), + page = TOMOE_HANDWRITING (tomoe_window_get_handwriting_page (tomoe)); + g_signal_connect (G_OBJECT (tomoe_handwriting_get_char_table (page)), "selected", G_CALLBACK (char_clicked_cb), (gpointer) tomoe); From makeinu users.sourceforge.jp Wed Dec 6 16:13:08 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 16:13:08 +0900 Subject: [Tomoe-cvs 1712] CVS update: libtomoe-gtk Message-ID: <20061206071308.90C822AC0A2@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.238 libtomoe-gtk/ChangeLog:1.239 --- libtomoe-gtk/ChangeLog:1.238 Wed Dec 6 15:48:00 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 16:13:08 2006 @@ -1,6 +1,7 @@ 2006-12-06 Takuro Ashie * src/tomoe-window.c: Don't call gtk_main_quit() from here. + * src/testtomoegtk.c: Call gtk_main_quit(). 2006-12-06 Takuro Ashie From makeinu users.sourceforge.jp Wed Dec 6 16:13:08 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 16:13:08 +0900 Subject: [Tomoe-cvs 1713] CVS update: libtomoe-gtk/test Message-ID: <20061206071308.C46742AC1D0@users.sourceforge.jp> Index: libtomoe-gtk/test/testtomoegtk.c diff -u libtomoe-gtk/test/testtomoegtk.c:1.4 libtomoe-gtk/test/testtomoegtk.c:1.5 --- libtomoe-gtk/test/testtomoegtk.c:1.4 Fri Dec 1 14:03:37 2006 +++ libtomoe-gtk/test/testtomoegtk.c Wed Dec 6 16:13:08 2006 @@ -9,6 +9,8 @@ /*g_setenv ("TOMOE_CONFIG_FILE", "./test-config.xml", FALSE);*/ gtk_init (&argc, &argv); win = tomoe_window_new (); + g_signal_connect (G_OBJECT (win), "destroy", + G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show (win); gtk_main (); return 0; From kous users.sourceforge.jp Wed Dec 6 16:13:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 16:13:42 +0900 Subject: [Tomoe-cvs 1714] CVS update: tomoe/benchmark Message-ID: <20061206071342.E7B552AC0A2@users.sourceforge.jp> Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.5 tomoe/benchmark/search-by-recognizer.rb:1.6 --- tomoe/benchmark/search-by-recognizer.rb:1.5 Tue Dec 5 14:07:14 2006 +++ tomoe/benchmark/search-by-recognizer.rb Wed Dec 6 16:13:42 2006 @@ -10,10 +10,17 @@ require 'tomoe-spec-utils' -dict = Tomoe::Dict.new("xml", - "filename" => File.join(TomoeSpecUtils::Config.data_dir, - "handwriting.xml"), - "editable" => false) +data_dir = TomoeSpecUtils::Config.data_dir +use_est = false +if use_est + dict = Tomoe::Dict.new("est", + "database_name" => File.join(data_dir, "handwriting"), + "editable" => false) +else + dict = Tomoe::Dict.new("xml", + "filename" => File.join(data_dir, "handwriting.xml"), + "editable" => false) +end recognizer = Tomoe::Recognizer.new("simple", dict) context = Tomoe::Context.new("recognizer" => recognizer) config_file = TomoeSpecUtils::Config.make_config_file From kous users.sourceforge.jp Wed Dec 6 16:13:43 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 16:13:43 +0900 Subject: [Tomoe-cvs 1715] CVS update: tomoe Message-ID: <20061206071343.1B33B2AC1D0@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.394 tomoe/ChangeLog:1.395 --- tomoe/ChangeLog:1.394 Wed Dec 6 15:28:36 2006 +++ tomoe/ChangeLog Wed Dec 6 16:13:42 2006 @@ -1,5 +1,7 @@ 2006-12-06 Kouhei Sutou + * benchmark/search-by-recognizer.rb: supported est backend. + * lib/tomoe-context.[ch] (tomoe_context_get_char): added. * ext/ruby/tomoe-rb-context.c: added Tomoe::Context#[]. * test/context_spec.rb: added tests for tomoe_context_get_char(). From kous users.sourceforge.jp Wed Dec 6 16:14:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 16:14:25 +0900 Subject: [Tomoe-cvs 1716] CVS update: tomoe/module/dict Message-ID: <20061206071425.4D5AC2AC1D3@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.5 tomoe/module/dict/tomoe-dict-est.c:1.6 --- tomoe/module/dict/tomoe-dict-est.c:1.5 Fri Dec 1 14:27:16 2006 +++ tomoe/module/dict/tomoe-dict-est.c Wed Dec 6 16:14:25 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.5 2006/12/01 05:27:16 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.6 2006/12/06 07:14:25 kous Exp $ */ #include @@ -99,6 +99,7 @@ static GList *search (TomoeDict *dict, TomoeQuery *query); static gboolean flush (TomoeDict *dict); +static gboolean is_editable (TomoeDict *dict); static gboolean tomoe_dict_est_open (TomoeDictEst *dict); static gboolean tomoe_dict_est_close (TomoeDictEst *dict); @@ -124,6 +125,7 @@ dict_class->get_char = get_char; dict_class->search = search; dict_class->flush = flush; + dict_class->is_editable = is_editable; g_object_class_install_property ( gobject_class, @@ -505,6 +507,16 @@ } static gboolean +is_editable (TomoeDict *_dict) +{ + TomoeDictEst *dict = TOMOE_DICT_EST (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), FALSE); + + return dict->editable; +} + +static gboolean tomoe_dict_est_open (TomoeDictEst *dict) { gboolean success = TRUE; From kous users.sourceforge.jp Wed Dec 6 16:14:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 16:14:25 +0900 Subject: [Tomoe-cvs 1717] CVS update: tomoe Message-ID: <20061206071425.70E7F2AC1D4@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.395 tomoe/ChangeLog:1.396 --- tomoe/ChangeLog:1.395 Wed Dec 6 16:13:42 2006 +++ tomoe/ChangeLog Wed Dec 6 16:14:25 2006 @@ -1,5 +1,7 @@ 2006-12-06 Kouhei Sutou + * module/dict/tomoe-dict-est.c: supported is_editable. + * benchmark/search-by-recognizer.rb: supported est backend. * lib/tomoe-context.[ch] (tomoe_context_get_char): added. From makeinu users.sourceforge.jp Wed Dec 6 16:22:49 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 16:22:49 +0900 Subject: [Tomoe-cvs 1718] CVS update: libtomoe-gtk Message-ID: <20061206072249.460552AC1D3@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.239 libtomoe-gtk/ChangeLog:1.240 --- libtomoe-gtk/ChangeLog:1.239 Wed Dec 6 16:13:08 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 16:22:49 2006 @@ -1,5 +1,9 @@ 2006-12-06 Takuro Ashie + * src/tomoe-window.c: Add getters for getting inside widgets. + +2006-12-06 Takuro Ashie + * src/tomoe-window.c: Don't call gtk_main_quit() from here. * src/testtomoegtk.c: Call gtk_main_quit(). From makeinu users.sourceforge.jp Wed Dec 6 16:22:49 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 16:22:49 +0900 Subject: [Tomoe-cvs 1719] CVS update: libtomoe-gtk/src Message-ID: <20061206072249.72C4B2AC1D4@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.39 libtomoe-gtk/src/tomoe-window.c:1.40 --- libtomoe-gtk/src/tomoe-window.c:1.39 Wed Dec 6 15:48:00 2006 +++ libtomoe-gtk/src/tomoe-window.c Wed Dec 6 16:22:49 2006 @@ -43,6 +43,13 @@ LAST_SIGNAL }; +enum { + PROP_0, + PROP_HANDWRITING_PAGE, + PROP_READING_SEARCH_PAGE, + PROP_GUCHARMAP_PAGE +}; + typedef struct _TomoeWindowPrivate TomoeWindowPrivate; struct _TomoeWindowPrivate { @@ -53,7 +60,7 @@ /* child pages */ GtkWidget *handwriting; GtkWidget *reading; - GtkWidget *chartable; + GtkWidget *gucharmap; }; #define TOMOE_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_WINDOW, TomoeWindowPrivate)) @@ -61,6 +68,14 @@ G_DEFINE_TYPE (TomoeWindow, tomoe_window, GTK_TYPE_WINDOW) static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); static void on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data); @@ -75,9 +90,11 @@ tomoe_window_class_init (TomoeWindowClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GParamSpec *spec; - gobject_class->dispose = dispose; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; window_signals[SELECTED_SIGNAL] = g_signal_new ("selected", @@ -88,6 +105,30 @@ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + spec = g_param_spec_object ( + "handwriting-page", + N_("TomoeHandwriting"), + N_("The TomoeHandwriting widget inside of the TomoeWindow."), + GTK_TYPE_WIDGET, G_PARAM_READABLE); + g_object_class_install_property (gobject_class, + PROP_HANDWRITING_PAGE, spec); + + spec = g_param_spec_object ( + "reading-search-page", + N_("TomoeReadingSearch"), + N_("The TomoeReadingSearch widget inside of the TomoeWindow."), + GTK_TYPE_WIDGET, G_PARAM_READABLE); + g_object_class_install_property (gobject_class, + PROP_READING_SEARCH_PAGE, spec); + + spec = g_param_spec_object ( + "gucharmap-page", + N_("TomoeGucharmap"), + N_("The TomoeGucharmap widget inside of the TomoeWindow."), + GTK_TYPE_WIDGET, G_PARAM_READABLE); + g_object_class_install_property (gobject_class, + PROP_GUCHARMAP_PAGE, spec); + g_type_class_add_private (gobject_class, sizeof (TomoeWindowPrivate)); } @@ -156,7 +197,7 @@ /* gucharmap page */ widget = tomoe_gucharmap_new (); - priv->chartable = widget; + priv->gucharmap = widget; g_signal_connect (G_OBJECT (widget), "selected", G_CALLBACK (on_gucharmap_selected), (gpointer) window); @@ -189,6 +230,49 @@ NULL)); } +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ +#if 0 + TomoeWindow *window = TOMOE_WINDOW (object); + TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); +#endif + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeWindow *window = TOMOE_WINDOW (object); + TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); + + switch (prop_id) { + case PROP_HANDWRITING_PAGE: + g_value_set_object (value, priv->handwriting); + break; + case PROP_READING_SEARCH_PAGE: + g_value_set_object (value, priv->reading); + break; + case PROP_GUCHARMAP_PAGE: + g_value_set_object (value, priv->gucharmap); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + void tomoe_window_append_page (TomoeWindow *window, GtkWidget *page, @@ -248,7 +332,7 @@ { g_return_val_if_fail (TOMOE_IS_WINDOW (window), NULL); - return TOMOE_WINDOW_GET_PRIVATE (window)->chartable; + return TOMOE_WINDOW_GET_PRIVATE (window)->gucharmap; } const gchar * From makeinu users.sourceforge.jp Wed Dec 6 17:37:14 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 17:37:14 +0900 Subject: [Tomoe-cvs 1720] CVS update: libtomoe-gtk Message-ID: <20061206083714.8A4672AC0F3@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.240 libtomoe-gtk/ChangeLog:1.241 --- libtomoe-gtk/ChangeLog:1.240 Wed Dec 6 16:22:49 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 17:37:14 2006 @@ -1,5 +1,10 @@ 2006-12-06 Takuro Ashie + * test/testtomoegtkedit.c: Added. + * test/Makefile.am: Ditto. + +2006-12-06 Takuro Ashie + * src/tomoe-window.c: Add getters for getting inside widgets. 2006-12-06 Takuro Ashie From makeinu users.sourceforge.jp Wed Dec 6 17:37:14 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 17:37:14 +0900 Subject: [Tomoe-cvs 1721] CVS update: libtomoe-gtk/test Message-ID: <20061206083714.B68D02AC120@users.sourceforge.jp> Index: libtomoe-gtk/test/Makefile.am diff -u libtomoe-gtk/test/Makefile.am:1.5 libtomoe-gtk/test/Makefile.am:1.6 --- libtomoe-gtk/test/Makefile.am:1.5 Tue Nov 28 12:48:36 2006 +++ libtomoe-gtk/test/Makefile.am Wed Dec 6 17:37:14 2006 @@ -38,7 +38,10 @@ @TOMOE_LIBS@ \ $(top_builddir)/src/libtomoe-gtk.la -noinst_PROGRAMS = testtomoegtk +noinst_PROGRAMS = testtomoegtk testtomoegtkedit testtomoegtk_LDADD = $(LDADDS) testtomoegtk_SOURCES = testtomoegtk.c + +testtomoegtkedit_LDADD = $(LDADDS) +testtomoegtkedit_SOURCES = testtomoegtkedit.c Index: libtomoe-gtk/test/testtomoegtkedit.c diff -u /dev/null libtomoe-gtk/test/testtomoegtkedit.c:1.1 --- /dev/null Wed Dec 6 17:37:14 2006 +++ libtomoe-gtk/test/testtomoegtkedit.c Wed Dec 6 17:37:14 2006 @@ -0,0 +1,17 @@ +#include +#include "tomoe-gtk.h" + +int +main (int argc, char *argv[]) +{ + GtkWidget *win; + + gtk_init (&argc, &argv); + /* will be replaced to TomoeDetails or something */ + win = tomoe_window_new (); + g_signal_connect (G_OBJECT (win), "destroy", + G_CALLBACK (gtk_main_quit), NULL); + gtk_widget_show (win); + gtk_main (); + return 0; +} From makeinu users.sourceforge.jp Wed Dec 6 17:50:32 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 17:50:32 +0900 Subject: [Tomoe-cvs 1722] CVS update: libtomoe-gtk Message-ID: <20061206085032.1ECE42AC0B3@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.241 libtomoe-gtk/ChangeLog:1.242 --- libtomoe-gtk/ChangeLog:1.241 Wed Dec 6 17:37:14 2006 +++ libtomoe-gtk/ChangeLog Wed Dec 6 17:50:31 2006 @@ -1,5 +1,9 @@ 2006-12-06 Takuro Ashie + * src/tomoe-gtk.h: Add missing files. + +2006-12-06 Takuro Ashie + * test/testtomoegtkedit.c: Added. * test/Makefile.am: Ditto. From makeinu users.sourceforge.jp Wed Dec 6 17:50:32 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Wed, 6 Dec 2006 17:50:32 +0900 Subject: [Tomoe-cvs 1723] CVS update: libtomoe-gtk/src Message-ID: <20061206085032.4790B2AC0F1@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-gtk.h diff -u libtomoe-gtk/src/tomoe-gtk.h:1.10 libtomoe-gtk/src/tomoe-gtk.h:1.11 --- libtomoe-gtk/src/tomoe-gtk.h:1.10 Tue Dec 5 17:52:21 2006 +++ libtomoe-gtk/src/tomoe-gtk.h Wed Dec 6 17:50:32 2006 @@ -28,6 +28,12 @@ #include #include +/* editors */ +#include +#include +#include +#include + #endif /* __TOMOE_GTK_H_INCLUDED__ */ /* From kous users.sourceforge.jp Wed Dec 6 18:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:00:59 +0900 Subject: [Tomoe-cvs 1724] CVS update: tomoe Message-ID: <20061206090059.C71362AC1CD@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.396 tomoe/ChangeLog:1.397 --- tomoe/ChangeLog:1.396 Wed Dec 6 16:14:25 2006 +++ tomoe/ChangeLog Wed Dec 6 18:00:59 2006 @@ -1,5 +1,13 @@ 2006-12-06 Kouhei Sutou + * module/dict/unihan-compiler.rb, module/dict/tomoe-unihan.c, + module/dict/Makefile.am: supported merging kanjidic2.xml to + Unihan.txt. + * data/Makefile.am: don't install kanjidic2.xml to dictionary data + directory. We don't need it on runtime! + + * ext/ruby/tomoe-rb-char.c: added Tomoe::Char#each. + * module/dict/tomoe-dict-est.c: supported is_editable. * benchmark/search-by-recognizer.rb: supported est backend. Index: tomoe/Makefile.am diff -u tomoe/Makefile.am:1.18 tomoe/Makefile.am:1.19 --- tomoe/Makefile.am:1.18 Wed Nov 29 15:49:38 2006 +++ tomoe/Makefile.am Wed Dec 6 18:00:59 2006 @@ -18,7 +18,7 @@ ## Free Software Foundation, Inc., 59 Temple Place, Suite 330, ## Boston, MA 02111-1307 USA -SUBDIRS = lib module data ext test benchmark doc +SUBDIRS = lib ext module data test benchmark doc EXTRA_DIST = autogen.sh tomoe.pc From kous users.sourceforge.jp Wed Dec 6 18:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:00:59 +0900 Subject: [Tomoe-cvs 1725] CVS update: tomoe/data Message-ID: <20061206090059.EBE872AC1D4@users.sourceforge.jp> Index: tomoe/data/Makefile.am diff -u tomoe/data/Makefile.am:1.21 tomoe/data/Makefile.am:1.22 --- tomoe/data/Makefile.am:1.21 Tue Dec 5 15:12:35 2006 +++ tomoe/data/Makefile.am Wed Dec 6 18:00:59 2006 @@ -21,12 +21,13 @@ CLEANFILES = *~ *.bak *.valid data_DATA = tomoe-dict.dtd -dict_data_DATA = kanjidic2.xml +dict_data_DATA = recognizer_data_DATA = handwriting.xml conf_DATA = config EXTRA_DIST = \ kanjidic2-original.xml kanjidic2-original.xsl \ + kanjidic2.xml \ $(data_DATA) \ $(dict_data_DATA) \ $(recognizer_data_DATA) \ From kous users.sourceforge.jp Wed Dec 6 18:01:00 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:01:00 +0900 Subject: [Tomoe-cvs 1726] CVS update: tomoe/ext/ruby Message-ID: <20061206090100.1AE8D2AC1CD@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-char.c diff -u tomoe/ext/ruby/tomoe-rb-char.c:1.11 tomoe/ext/ruby/tomoe-rb-char.c:1.12 --- tomoe/ext/ruby/tomoe-rb-char.c:1.11 Wed Dec 6 12:08:46 2006 +++ tomoe/ext/ruby/tomoe-rb-char.c Wed Dec 6 18:00:59 2006 @@ -55,6 +55,22 @@ return Qnil; } +static void +yield_meta_data(gpointer _key, gpointer _value, gpointer user_data) +{ + gchar *key = _key; + gchar *value = _value; + + rb_yield_values(2, CSTR2RVAL(key), CSTR2RVAL(value)); +} + +static VALUE +tc_meta_data_foreach(VALUE self) +{ + tomoe_char_meta_data_foreach(_SELF(self), yield_meta_data, NULL); + return Qnil; +} + static VALUE tc_to_xml(VALUE self) { @@ -91,6 +107,7 @@ INT2NUM(TOMOE_CHAR_PRIVATE_USE_AREA_END)); rb_include_module(cTomoeChar, rb_mComparable); + rb_include_module(cTomoeChar, rb_mEnumerable); rb_define_method(cTomoeChar, "initialize", tc_initialize, -1); @@ -101,5 +118,7 @@ rb_define_method(cTomoeChar, "radicals", tc_get_radicals, 0); rb_define_method(cTomoeChar, "add_radical", tc_add_radical, 1); + rb_define_method(cTomoeChar, "each", tc_meta_data_foreach, 0); + rb_define_method(cTomoeChar, "to_xml", tc_to_xml, 0); } From kous users.sourceforge.jp Wed Dec 6 18:01:00 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:01:00 +0900 Subject: [Tomoe-cvs 1727] CVS update: tomoe/module/dict Message-ID: <20061206090100.420142AC1D6@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.12 tomoe/module/dict/Makefile.am:1.13 --- tomoe/module/dict/Makefile.am:1.12 Tue Dec 5 18:01:29 2006 +++ tomoe/module/dict/Makefile.am Wed Dec 6 18:01:00 2006 @@ -73,8 +73,10 @@ $(unihan_built_sources) \ $(ptr_array_based_dict_sources) -tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt - $(RUBY) unihan-compiler.rb Unihan.txt > $@ +tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml + $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ + -I$(top_srcdir)/test unihan-compiler.rb \ + Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@ Unihan.txt: Unihan.zip $(UNZIP) Unihan.zip Index: tomoe/module/dict/tomoe-unihan.c diff -u tomoe/module/dict/tomoe-unihan.c:1.2 tomoe/module/dict/tomoe-unihan.c:1.3 --- tomoe/module/dict/tomoe-unihan.c:1.2 Wed Dec 6 14:09:53 2006 +++ tomoe/module/dict/tomoe-unihan.c Wed Dec 6 18:01:00 2006 @@ -32,11 +32,6 @@ if (info.n_strokes) tomoe_char_set_n_strokes (chr, info.n_strokes); - len = info.variants_size; - for (j = 0; j < len; j++) { - tomoe_char_set_variant (chr, info.variants[j]); - } - len = info.readings_size; for (j = 0; j < len; j++) { TomoeReading *reading; @@ -49,6 +44,24 @@ g_object_unref (reading); } + len = info.radicals_size; + for (j = 0; j < len; j++) { + tomoe_char_add_radical (chr, info.radicals[j]); + } + + len = info.variants_size; + for (j = 0; j < len; j++) { + tomoe_char_set_variant (chr, info.variants[j]); + } + + len = info.meta_data_size; + for (j = 0; j < len; j++) { + TomoeUnihanMetaData meta_data; + + meta_data = info.meta_data[j]; + tomoe_char_register_meta_data (chr, meta_data.key, meta_data.value); + } + array->pdata[i] = chr; } Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.5 tomoe/module/dict/unihan-compiler.rb:1.6 --- tomoe/module/dict/unihan-compiler.rb:1.5 Wed Dec 6 14:09:53 2006 +++ tomoe/module/dict/unihan-compiler.rb Wed Dec 6 18:01:00 2006 @@ -1,9 +1,12 @@ #!/usr/bin/env ruby +require 'tomoe-spec-utils' + require 'uconv' require 'suikyo/suikyo' unihan_txt = ARGV.shift +kanjidic2_xml = ARGV.shift DO_NOT_EDIT_HEADER = <<-EOH /* @@ -16,57 +19,133 @@ @romaji_to_hiragana = Suikyo.new("romaji-kana") @hiragana_to_katakana = Suikyo.new("hiragana-katakana") +def kcode(code) + old_kcode = $KCODE + $KCODE = code + yield +ensure + $KCODE = old_kcode +end + def euc_to_utf8(euc) Uconv.euctou8(euc) end def romaji_to_hiragana(romaji) - euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) + kcode("e") do + euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) + end end def romaji_to_katakana(romaji) - hiragana = @romaji_to_hiragana.convert("#{romaji} ") - euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) + kcode("e") do + hiragana = @romaji_to_hiragana.convert("#{romaji} ") + euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) + end end def ucs4_to_utf8(ucs4) Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) end -def parse_unihan_txt(unihan_txt) - cache = "#{unihan_txt}.cache" - if File.exists?(cache) and (File.mtime(cache) > File.mtime(unihan_txt)) +def utf8_to_ucs4(utf8) + "%X" % Uconv.u8tou4(utf8).unpack("I*")[0] +end + +def cache(filename) + cache = "#{filename}.cache" + if File.exists?(cache) and (File.mtime(cache) > File.mtime(filename)) begin return Marshal.load(File.read(cache)) rescue ArgumentError end end - infos = {} - File.open(unihan_txt).each do |line| - case line - when /^#/ # - next - when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u - ucs4 = $1 - key = $2 - value = $3 - - infos[ucs4] ||= {} - infos[ucs4][key] = value - else - STDERR.puts "Unknown line: #{line}" - end + result = yield + File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} + result +end + +def parse_unihan_entry(key, value) + case key + when "kCompatibilityVariant" + [:variants, value.split.collect {|v| ucs4_to_utf8(v.sub(/^U\+2?/, ''))}] + when "kJapaneseKun" + [:ja_kuns, value.split.collect {|k| romaji_to_hiragana(k)}] + when "kJapaneseOn" + [:ja_ons, value.split.collect {|o| romaji_to_katakana(o)}] + when "kTotalStrokes" + [:n_strokes, value] + else + [key, value] end +end - result = infos.collect do |ucs4, info| - [ucs4, info] - end.sort_by do |ucs4, info| - ucs4 +def parse_unihan_txt(unihan_txt) + cache(unihan_txt) do + infos = {} + File.open(unihan_txt).each do |line| + case line + when /^#/ # + next + when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u + ucs4 = $1.upcase + key = $2 + value = $3 + + infos[ucs4] ||= {} + key, value = parse_unihan_entry(key, value) + infos[ucs4][key] = value + else + STDERR.puts "Unknown line: #{line}" + end + end + infos end +end - File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} - result +def merge_kanjidic2_xml(kanjidic2_xml, infos) + dict = Tomoe::Dict.new("xml", + "filename" => kanjidic2_xml, + "editable" => false) + dict.search(Tomoe::Query.new).each do |cand| + char = cand.char + ucs4 = utf8_to_ucs4(char.utf8) + info = infos[ucs4] || {} + + info[:n_strokes] ||= char.n_strokes + + info[:ja_ons] ||= [] + info[:ja_kuns] ||= [] + char.readings.each do |reading| + case reading.type + when Tomoe::Reading::JA_ON + info[:ja_ons] << reading.reading + when Tomoe::Reading::JA_KUN + info[:ja_kuns] << reading.reading + end + end + info[:ja_ons].uniq! + info[:ja_kuns].uniq! + + info[:radicals] ||= [] + info[:radicals].concat(char.radicals) + info[:radicals].uniq! + + if char.variant + info[:variants] ||= [] + info[:variants] << char.variant + info[:variants].uniq! + end + + info[:meta_data] ||= {} + char.each do |key, value| + info[:meta_data][key] = value + end + + infos[ucs4] = info + end + infos end def generate_header(infos) @@ -81,6 +160,7 @@ #include typedef struct _TomoeUnihanReading TomoeUnihanReading; +typedef struct _TomoeUnihanMetaData TomoeUnihanMetaData; typedef struct _TomoeUnihanInfo TomoeUnihanInfo; struct _TomoeUnihanReading { @@ -88,73 +168,111 @@ gchar *reading; }; +struct _TomoeUnihanMetaData { + gchar *key; + gchar *value; +}; + struct _TomoeUnihanInfo { - gchar *utf8; - gint n_strokes; - gchar **variants; - gint variants_size; - TomoeUnihanReading *readings; - gint readings_size; + gchar *utf8; + gint n_strokes; + TomoeUnihanReading *readings; + gint readings_size; + gchar **radicals; + gint radicals_size; + gchar **variants; + gint variants_size; + TomoeUnihanMetaData *meta_data; + gint meta_data_size; }; EOH infos.each_with_index do |(ucs4, info), i| - variants = info["kCompatibilityVariant"] - if variants - info["have_variants"] = true - puts("static gchar *#{prefix}variant_#{ucs4}[] = {") - variants.split.each do |variant| - utf8_variant = ucs4_to_utf8(variant.sub(/^U\+2?/, '')) - puts(" \"#{utf8_variant}\",") - end - puts("};"); - end - readings = [] - kuns = info["kJapaneseKun"] - ons = info["kJapaneseOn"] + kuns = info[:ja_kuns] + ons = info[:ja_ons] if kuns - readings.concat(kuns.split.collect do |x| - ["TOMOE_READING_JA_KUN", romaji_to_hiragana(x)] - end) + readings.concat(kuns.collect {|x| ["TOMOE_READING_JA_KUN", x]}) end if ons - readings.concat(ons.split.collect do |x| - ["TOMOE_READING_JA_ON", romaji_to_katakana(x)] - end) + readings.concat(ons.collect {|x| ["TOMOE_READING_JA_ON", x]}) end unless readings.empty? - info["have_readings"] = true - puts("static TomoeUnihanReading #{prefix}reading_#{ucs4}[] = {") + info[:have_readings] = true + puts("static TomoeUnihanReading #{prefix}readings_#{ucs4}[] = {") readings.each do |type, reading| puts(" {#{type}, \"#{reading}\"},") end puts("};") end + + radicals = info[:radicals] || [] + unless radicals.empty? + info[:have_radicals] = true + puts("static gchar *#{prefix}radicals_#{ucs4}[] = {") + radicals.each do |radical| + puts(" \"#{radical}\",") + end + puts("};"); + end + + variants = info[:variants] || [] + unless variants.empty? + info[:have_variants] = true + puts("static gchar *#{prefix}variants_#{ucs4}[] = {") + variants.each do |variant| + puts(" \"#{variant}\",") + end + puts("};"); + end + + meta_data = info[:meta_data] || [] + unless meta_data.empty? + info[:have_meta_data] = true + puts("static TomoeUnihanMetaData #{prefix}meta_data_#{ucs4}[] = {") + meta_data.each do |key, value| + puts(" {\"#{key}\", \"#{value.gsub(/\"/, '\"')}\"},") + end + puts("};") + end end puts("static TomoeUnihanInfo #{prefix}infos[] = {") infos.each_with_index do |(ucs4, info), i| - info["utf8"] = utf8 = Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) - n_strokes = info["kTotalStrokes"] || -1 - variants = readings = "NULL" - variants_size = readings_size = "0" - if info["have_variants"] - variants = "#{prefix}variant_#{ucs4}" + utf8 = ucs4_to_utf8(ucs4) + n_strokes = info[:n_strokes] || -1 + readings = radicals = variants = meta_data = "NULL" + readings_size = radicals_size = variants_size = meta_data_size = "0" + if info[:have_readings] + readings = "#{prefix}readings_#{ucs4}" + readings_size = "G_N_ELEMENTS(#{readings})" + end + if info[:have_radicals] + radicals = "#{prefix}radicals_#{ucs4}" + radicals_size = "G_N_ELEMENTS(#{radicals})" + end + if info[:have_variants] + variants = "#{prefix}variants_#{ucs4}" variants_size = "G_N_ELEMENTS(#{variants})" end - if info["have_readings"] - readings = "#{prefix}reading_#{ucs4}" - readings_size = "G_N_ELEMENTS(#{readings})" + if info[:have_meta_data] + meta_data = "#{prefix}meta_data_#{ucs4}" + meta_data_size = "G_N_ELEMENTS(#{meta_data})" end - puts(" {\"#{utf8}\", #{n_strokes}, #{variants}, #{variants_size}, " \ - "#{readings}, #{readings_size}},") + puts(" {\"#{utf8}\", #{n_strokes}, #{readings}, #{readings_size},") + puts(" #{radicals}, #{radicals_size}, #{variants}, #{variants_size},") + puts(" #{meta_data}, #{meta_data_size}},") end puts("};") end infos = parse_unihan_txt(unihan_txt) +infos = merge_kanjidic2_xml(kanjidic2_xml, infos).collect do |ucs4, info| + [ucs4, info] +end.sort_by do |ucs4, info| + ucs4 +end generate_header(infos) From kous users.sourceforge.jp Wed Dec 6 18:05:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:05:36 +0900 Subject: [Tomoe-cvs 1728] CVS update: tomoe Message-ID: <20061206090536.2A5492AC0B3@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.397 tomoe/ChangeLog:1.398 --- tomoe/ChangeLog:1.397 Wed Dec 6 18:00:59 2006 +++ tomoe/ChangeLog Wed Dec 6 18:05:36 2006 @@ -1,5 +1,9 @@ 2006-12-06 Kouhei Sutou + * lib/tomoe-config.c: made name parameter optional for Unihan + backend. + * test/tomoe-spec-utils.rb: used Unihan backend by default. + * module/dict/unihan-compiler.rb, module/dict/tomoe-unihan.c, module/dict/Makefile.am: supported merging kanjidic2.xml to Unihan.txt. From kous users.sourceforge.jp Wed Dec 6 18:05:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:05:36 +0900 Subject: [Tomoe-cvs 1729] CVS update: tomoe/lib Message-ID: <20061206090536.5C5B12AC0F1@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.51 tomoe/lib/tomoe-config.c:1.52 --- tomoe/lib/tomoe-config.c:1.51 Tue Dec 5 16:11:02 2006 +++ tomoe/lib/tomoe-config.c Wed Dec 6 18:05:36 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.51 2006/12/05 07:11:02 kous Exp $ + * $Id: tomoe-config.c,v 1.52 2006/12/06 09:05:36 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -505,19 +505,13 @@ load_unihan_dictionary (GKeyFile *key_file, const gchar *dict_name) { TomoeDict *dict; - GError *error = NULL; gchar *name; - name = g_key_file_get_string (key_file, dict_name, "name", &error); - if (error) { - TOMOE_HANDLE_ERROR (error); - return NULL; - } - + name = _tomoe_config_key_file_get_string (key_file, dict_name, + "name", NULL); dict = tomoe_dict_new ("unihan", "name", name, NULL); - g_free (name); return dict; From kous users.sourceforge.jp Wed Dec 6 18:05:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:05:36 +0900 Subject: [Tomoe-cvs 1730] CVS update: tomoe/test Message-ID: <20061206090536.7F3A72AC0B3@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.20 tomoe/test/tomoe-spec-utils.rb:1.21 --- tomoe/test/tomoe-spec-utils.rb:1.20 Wed Dec 6 12:08:47 2006 +++ tomoe/test/tomoe-spec-utils.rb Wed Dec 6 18:05:36 2006 @@ -111,7 +111,7 @@ Dir.glob(File.join(test_data_dir, "*.data")) end - def make_config_file(name=nil, dict_type=:xml) + def make_config_file(name=nil, dict_type=:unihan) name ||= "tomoe" config_file = Tempfile.new(name) config_file.open From kous users.sourceforge.jp Wed Dec 6 18:12:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 18:12:41 +0900 Subject: [Tomoe-cvs 1731] CVS update: tomoe Message-ID: <20061206091241.62FAD2AC0F1@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.398 tomoe/ChangeLog:1.399 --- tomoe/ChangeLog:1.398 Wed Dec 6 18:05:36 2006 +++ tomoe/ChangeLog Wed Dec 6 18:12:41 2006 @@ -1,5 +1,7 @@ 2006-12-06 Kouhei Sutou + * TODO: updated. + * lib/tomoe-config.c: made name parameter optional for Unihan backend. * test/tomoe-spec-utils.rb: used Unihan backend by default. Index: tomoe/TODO diff -u tomoe/TODO:1.12 tomoe/TODO:1.13 --- tomoe/TODO:1.12 Fri Dec 1 11:23:38 2006 +++ tomoe/TODO Wed Dec 6 18:12:41 2006 @@ -1,7 +1,6 @@ * Merge same characters of different dictionaries in search output. * Transformation of reading search pattern, e.g. ka > ?? ??> ?? ??> ka should be language independent. -* Add "register_char" function into TomoeContext. * Implement advanced searching. * Add modulized dictionary types. - QDBM? @@ -13,3 +12,4 @@ * Prepare character data base. * HMM! HMM! * Write document. +* Implement partial mutch searching. From ikezoe users.sourceforge.jp Wed Dec 6 20:26:16 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Wed, 6 Dec 2006 20:26:16 +0900 Subject: [Tomoe-cvs 1732] CVS update: tomoe Message-ID: <20061206112616.D267A2AC0FD@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.399 tomoe/ChangeLog:1.400 --- tomoe/ChangeLog:1.399 Wed Dec 6 18:12:41 2006 +++ tomoe/ChangeLog Wed Dec 6 20:26:16 2006 @@ -38,6 +38,7 @@ * module/recognizer/tomoe-recognizer-simple.c: Use g_build_filename() for constructing the path name of dictionary. + * module/dict/tomoe-dict-est.c: Plugged memory leaks. 2006-12-06 Kouhei Sutou From ikezoe users.sourceforge.jp Wed Dec 6 20:26:17 2006 From: ikezoe users.sourceforge.jp (Hiroyuki Ikezoe) Date: Wed, 6 Dec 2006 20:26:17 +0900 Subject: [Tomoe-cvs 1733] CVS update: tomoe/module/dict Message-ID: <20061206112617.0A9862AC1C8@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.6 tomoe/module/dict/tomoe-dict-est.c:1.7 --- tomoe/module/dict/tomoe-dict-est.c:1.6 Wed Dec 6 16:14:25 2006 +++ tomoe/module/dict/tomoe-dict-est.c Wed Dec 6 20:26:16 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.6 2006/12/06 07:14:25 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.7 2006/12/06 11:26:16 ikezoe Exp $ */ #include @@ -387,6 +387,7 @@ } } g_free (results); + est_cond_delete (cond); return success; } @@ -443,6 +444,7 @@ if (chr) break; } g_free (results); + est_cond_delete (cond); return chr; } @@ -494,6 +496,7 @@ tomoe_candidate_new (chr)); } g_free (results); + est_cond_delete (cond); return candidates; } From kous users.sourceforge.jp Wed Dec 6 21:43:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 21:43:11 +0900 Subject: [Tomoe-cvs 1734] CVS update: tomoe/module/dict Message-ID: <20061206124311.E4C5E2AC10D@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.13 tomoe/module/dict/Makefile.am:1.14 --- tomoe/module/dict/Makefile.am:1.13 Wed Dec 6 18:01:00 2006 +++ tomoe/module/dict/Makefile.am Wed Dec 6 21:43:11 2006 @@ -66,6 +66,8 @@ CLEANFILES += Unihan.txt Unihan.txt.cache BUILT_SOURCES = $(unihan_built_sources) Unihan.zip +EXTRA_DIST = unihan-schemer.rb + libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ tomoe-unihan.c \ @@ -73,9 +75,9 @@ $(unihan_built_sources) \ $(ptr_array_based_dict_sources) -tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml +tomoe-unihan-data.h: unihan-schemer.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ - -I$(top_srcdir)/test unihan-compiler.rb \ + -I$(top_srcdir)/test unihan-schemer.rb \ Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@ Unihan.txt: Unihan.zip Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.6 tomoe/module/dict/unihan-compiler.rb:removed --- tomoe/module/dict/unihan-compiler.rb:1.6 Wed Dec 6 18:01:00 2006 +++ tomoe/module/dict/unihan-compiler.rb Wed Dec 6 21:43:11 2006 @@ -1,278 +0,0 @@ -#!/usr/bin/env ruby - -require 'tomoe-spec-utils' - -require 'uconv' -require 'suikyo/suikyo' - -unihan_txt = ARGV.shift -kanjidic2_xml = ARGV.shift - -DO_NOT_EDIT_HEADER = <<-EOH -/* - DO NOT EDIT! - THIS FILE IS GENERATED FROM Unihan.txt: - ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip -*/ -EOH - - romaji_to_hiragana = Suikyo.new("romaji-kana") - hiragana_to_katakana = Suikyo.new("hiragana-katakana") - -def kcode(code) - old_kcode = $KCODE - $KCODE = code - yield -ensure - $KCODE = old_kcode -end - -def euc_to_utf8(euc) - Uconv.euctou8(euc) -end - -def romaji_to_hiragana(romaji) - kcode("e") do - euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) - end -end - -def romaji_to_katakana(romaji) - kcode("e") do - hiragana = @romaji_to_hiragana.convert("#{romaji} ") - euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) - end -end - -def ucs4_to_utf8(ucs4) - Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) -end - -def utf8_to_ucs4(utf8) - "%X" % Uconv.u8tou4(utf8).unpack("I*")[0] -end - -def cache(filename) - cache = "#{filename}.cache" - if File.exists?(cache) and (File.mtime(cache) > File.mtime(filename)) - begin - return Marshal.load(File.read(cache)) - rescue ArgumentError - end - end - - result = yield - File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} - result -end - -def parse_unihan_entry(key, value) - case key - when "kCompatibilityVariant" - [:variants, value.split.collect {|v| ucs4_to_utf8(v.sub(/^U\+2?/, ''))}] - when "kJapaneseKun" - [:ja_kuns, value.split.collect {|k| romaji_to_hiragana(k)}] - when "kJapaneseOn" - [:ja_ons, value.split.collect {|o| romaji_to_katakana(o)}] - when "kTotalStrokes" - [:n_strokes, value] - else - [key, value] - end -end - -def parse_unihan_txt(unihan_txt) - cache(unihan_txt) do - infos = {} - File.open(unihan_txt).each do |line| - case line - when /^#/ # - next - when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u - ucs4 = $1.upcase - key = $2 - value = $3 - - infos[ucs4] ||= {} - key, value = parse_unihan_entry(key, value) - infos[ucs4][key] = value - else - STDERR.puts "Unknown line: #{line}" - end - end - infos - end -end - -def merge_kanjidic2_xml(kanjidic2_xml, infos) - dict = Tomoe::Dict.new("xml", - "filename" => kanjidic2_xml, - "editable" => false) - dict.search(Tomoe::Query.new).each do |cand| - char = cand.char - ucs4 = utf8_to_ucs4(char.utf8) - info = infos[ucs4] || {} - - info[:n_strokes] ||= char.n_strokes - - info[:ja_ons] ||= [] - info[:ja_kuns] ||= [] - char.readings.each do |reading| - case reading.type - when Tomoe::Reading::JA_ON - info[:ja_ons] << reading.reading - when Tomoe::Reading::JA_KUN - info[:ja_kuns] << reading.reading - end - end - info[:ja_ons].uniq! - info[:ja_kuns].uniq! - - info[:radicals] ||= [] - info[:radicals].concat(char.radicals) - info[:radicals].uniq! - - if char.variant - info[:variants] ||= [] - info[:variants] << char.variant - info[:variants].uniq! - end - - info[:meta_data] ||= {} - char.each do |key, value| - info[:meta_data][key] = value - end - - infos[ucs4] = info - end - infos -end - -def generate_header(infos) - prefix = "tomoe_unihan_" - - puts <<-EOH -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#{DO_NOT_EDIT_HEADER} - -#include "tomoe-unihan.h" - -#include - -typedef struct _TomoeUnihanReading TomoeUnihanReading; -typedef struct _TomoeUnihanMetaData TomoeUnihanMetaData; -typedef struct _TomoeUnihanInfo TomoeUnihanInfo; - -struct _TomoeUnihanReading { - TomoeReadingType type; - gchar *reading; -}; - -struct _TomoeUnihanMetaData { - gchar *key; - gchar *value; -}; - -struct _TomoeUnihanInfo { - gchar *utf8; - gint n_strokes; - TomoeUnihanReading *readings; - gint readings_size; - gchar **radicals; - gint radicals_size; - gchar **variants; - gint variants_size; - TomoeUnihanMetaData *meta_data; - gint meta_data_size; -}; - -EOH - - infos.each_with_index do |(ucs4, info), i| - readings = [] - kuns = info[:ja_kuns] - ons = info[:ja_ons] - if kuns - readings.concat(kuns.collect {|x| ["TOMOE_READING_JA_KUN", x]}) - end - if ons - readings.concat(ons.collect {|x| ["TOMOE_READING_JA_ON", x]}) - end - - unless readings.empty? - info[:have_readings] = true - puts("static TomoeUnihanReading #{prefix}readings_#{ucs4}[] = {") - readings.each do |type, reading| - puts(" {#{type}, \"#{reading}\"},") - end - puts("};") - end - - radicals = info[:radicals] || [] - unless radicals.empty? - info[:have_radicals] = true - puts("static gchar *#{prefix}radicals_#{ucs4}[] = {") - radicals.each do |radical| - puts(" \"#{radical}\",") - end - puts("};"); - end - - variants = info[:variants] || [] - unless variants.empty? - info[:have_variants] = true - puts("static gchar *#{prefix}variants_#{ucs4}[] = {") - variants.each do |variant| - puts(" \"#{variant}\",") - end - puts("};"); - end - - meta_data = info[:meta_data] || [] - unless meta_data.empty? - info[:have_meta_data] = true - puts("static TomoeUnihanMetaData #{prefix}meta_data_#{ucs4}[] = {") - meta_data.each do |key, value| - puts(" {\"#{key}\", \"#{value.gsub(/\"/, '\"')}\"},") - end - puts("};") - end - end - - puts("static TomoeUnihanInfo #{prefix}infos[] = {") - infos.each_with_index do |(ucs4, info), i| - utf8 = ucs4_to_utf8(ucs4) - n_strokes = info[:n_strokes] || -1 - readings = radicals = variants = meta_data = "NULL" - readings_size = radicals_size = variants_size = meta_data_size = "0" - if info[:have_readings] - readings = "#{prefix}readings_#{ucs4}" - readings_size = "G_N_ELEMENTS(#{readings})" - end - if info[:have_radicals] - radicals = "#{prefix}radicals_#{ucs4}" - radicals_size = "G_N_ELEMENTS(#{radicals})" - end - if info[:have_variants] - variants = "#{prefix}variants_#{ucs4}" - variants_size = "G_N_ELEMENTS(#{variants})" - end - if info[:have_meta_data] - meta_data = "#{prefix}meta_data_#{ucs4}" - meta_data_size = "G_N_ELEMENTS(#{meta_data})" - end - - puts(" {\"#{utf8}\", #{n_strokes}, #{readings}, #{readings_size},") - puts(" #{radicals}, #{radicals_size}, #{variants}, #{variants_size},") - puts(" #{meta_data}, #{meta_data_size}},") - end - puts("};") -end - -infos = parse_unihan_txt(unihan_txt) -infos = merge_kanjidic2_xml(kanjidic2_xml, infos).collect do |ucs4, info| - [ucs4, info] -end.sort_by do |ucs4, info| - ucs4 -end -generate_header(infos) Index: tomoe/module/dict/unihan-schemer.rb diff -u /dev/null tomoe/module/dict/unihan-schemer.rb:1.1 --- /dev/null Wed Dec 6 21:43:11 2006 +++ tomoe/module/dict/unihan-schemer.rb Wed Dec 6 21:43:11 2006 @@ -0,0 +1,278 @@ +#!/usr/bin/env ruby + +require 'tomoe-spec-utils' + +require 'uconv' +require 'suikyo/suikyo' + +unihan_txt = ARGV.shift +kanjidic2_xml = ARGV.shift + +DO_NOT_EDIT_HEADER = <<-EOH +/* + DO NOT EDIT! + THIS FILE IS GENERATED FROM Unihan.txt: + ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip +*/ +EOH + + romaji_to_hiragana = Suikyo.new("romaji-kana") + hiragana_to_katakana = Suikyo.new("hiragana-katakana") + +def kcode(code) + old_kcode = $KCODE + $KCODE = code + yield +ensure + $KCODE = old_kcode +end + +def euc_to_utf8(euc) + Uconv.euctou8(euc) +end + +def romaji_to_hiragana(romaji) + kcode("e") do + euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) + end +end + +def romaji_to_katakana(romaji) + kcode("e") do + hiragana = @romaji_to_hiragana.convert("#{romaji} ") + euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) + end +end + +def ucs4_to_utf8(ucs4) + Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) +end + +def utf8_to_ucs4(utf8) + "%X" % Uconv.u8tou4(utf8).unpack("I*")[0] +end + +def cache(filename) + cache = "#{filename}.cache" + if File.exists?(cache) and (File.mtime(cache) > File.mtime(filename)) + begin + return Marshal.load(File.read(cache)) + rescue ArgumentError + end + end + + result = yield + File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} + result +end + +def parse_unihan_entry(key, value) + case key + when "kCompatibilityVariant" + [:variants, value.split.collect {|v| ucs4_to_utf8(v.sub(/^U\+2?/, ''))}] + when "kJapaneseKun" + [:ja_kuns, value.split.collect {|k| romaji_to_hiragana(k)}] + when "kJapaneseOn" + [:ja_ons, value.split.collect {|o| romaji_to_katakana(o)}] + when "kTotalStrokes" + [:n_strokes, value] + else + [key, value] + end +end + +def parse_unihan_txt(unihan_txt) + cache(unihan_txt) do + infos = {} + File.open(unihan_txt).each do |line| + case line + when /^#/ # + next + when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u + ucs4 = $1.upcase + key = $2 + value = $3 + + infos[ucs4] ||= {} + key, value = parse_unihan_entry(key, value) + infos[ucs4][key] = value + else + STDERR.puts "Unknown line: #{line}" + end + end + infos + end +end + +def merge_kanjidic2_xml(kanjidic2_xml, infos) + dict = Tomoe::Dict.new("xml", + "filename" => kanjidic2_xml, + "editable" => false) + dict.search(Tomoe::Query.new).each do |cand| + char = cand.char + ucs4 = utf8_to_ucs4(char.utf8) + info = infos[ucs4] || {} + + info[:n_strokes] ||= char.n_strokes + + info[:ja_ons] ||= [] + info[:ja_kuns] ||= [] + char.readings.each do |reading| + case reading.type + when Tomoe::Reading::JA_ON + info[:ja_ons] << reading.reading + when Tomoe::Reading::JA_KUN + info[:ja_kuns] << reading.reading + end + end + info[:ja_ons].uniq! + info[:ja_kuns].uniq! + + info[:radicals] ||= [] + info[:radicals].concat(char.radicals) + info[:radicals].uniq! + + if char.variant + info[:variants] ||= [] + info[:variants] << char.variant + info[:variants].uniq! + end + + info[:meta_data] ||= {} + char.each do |key, value| + info[:meta_data][key] = value + end + + infos[ucs4] = info + end + infos +end + +def generate_header(infos) + prefix = "tomoe_unihan_" + + puts <<-EOH +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#{DO_NOT_EDIT_HEADER} + +#include "tomoe-unihan.h" + +#include + +typedef struct _TomoeUnihanReading TomoeUnihanReading; +typedef struct _TomoeUnihanMetaData TomoeUnihanMetaData; +typedef struct _TomoeUnihanInfo TomoeUnihanInfo; + +struct _TomoeUnihanReading { + TomoeReadingType type; + gchar *reading; +}; + +struct _TomoeUnihanMetaData { + gchar *key; + gchar *value; +}; + +struct _TomoeUnihanInfo { + gchar *utf8; + gint n_strokes; + TomoeUnihanReading *readings; + gint readings_size; + gchar **radicals; + gint radicals_size; + gchar **variants; + gint variants_size; + TomoeUnihanMetaData *meta_data; + gint meta_data_size; +}; + +EOH + + infos.each_with_index do |(ucs4, info), i| + readings = [] + kuns = info[:ja_kuns] + ons = info[:ja_ons] + if kuns + readings.concat(kuns.collect {|x| ["TOMOE_READING_JA_KUN", x]}) + end + if ons + readings.concat(ons.collect {|x| ["TOMOE_READING_JA_ON", x]}) + end + + unless readings.empty? + info[:have_readings] = true + puts("static TomoeUnihanReading #{prefix}readings_#{ucs4}[] = {") + readings.each do |type, reading| + puts(" {#{type}, \"#{reading}\"},") + end + puts("};") + end + + radicals = info[:radicals] || [] + unless radicals.empty? + info[:have_radicals] = true + puts("static gchar *#{prefix}radicals_#{ucs4}[] = {") + radicals.each do |radical| + puts(" \"#{radical}\",") + end + puts("};"); + end + + variants = info[:variants] || [] + unless variants.empty? + info[:have_variants] = true + puts("static gchar *#{prefix}variants_#{ucs4}[] = {") + variants.each do |variant| + puts(" \"#{variant}\",") + end + puts("};"); + end + + meta_data = info[:meta_data] || [] + unless meta_data.empty? + info[:have_meta_data] = true + puts("static TomoeUnihanMetaData #{prefix}meta_data_#{ucs4}[] = {") + meta_data.each do |key, value| + puts(" {\"#{key}\", \"#{value.gsub(/\"/, '\"')}\"},") + end + puts("};") + end + end + + puts("static TomoeUnihanInfo #{prefix}infos[] = {") + infos.each_with_index do |(ucs4, info), i| + utf8 = ucs4_to_utf8(ucs4) + n_strokes = info[:n_strokes] || -1 + readings = radicals = variants = meta_data = "NULL" + readings_size = radicals_size = variants_size = meta_data_size = "0" + if info[:have_readings] + readings = "#{prefix}readings_#{ucs4}" + readings_size = "G_N_ELEMENTS(#{readings})" + end + if info[:have_radicals] + radicals = "#{prefix}radicals_#{ucs4}" + radicals_size = "G_N_ELEMENTS(#{radicals})" + end + if info[:have_variants] + variants = "#{prefix}variants_#{ucs4}" + variants_size = "G_N_ELEMENTS(#{variants})" + end + if info[:have_meta_data] + meta_data = "#{prefix}meta_data_#{ucs4}" + meta_data_size = "G_N_ELEMENTS(#{meta_data})" + end + + puts(" {\"#{utf8}\", #{n_strokes}, #{readings}, #{readings_size},") + puts(" #{radicals}, #{radicals_size}, #{variants}, #{variants_size},") + puts(" #{meta_data}, #{meta_data_size}},") + end + puts("};") +end + +infos = parse_unihan_txt(unihan_txt) +infos = merge_kanjidic2_xml(kanjidic2_xml, infos).collect do |ucs4, info| + [ucs4, info] +end.sort_by do |ucs4, info| + ucs4 +end +generate_header(infos) From kous users.sourceforge.jp Wed Dec 6 21:43:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 6 Dec 2006 21:43:11 +0900 Subject: [Tomoe-cvs 1735] CVS update: tomoe Message-ID: <20061206124311.8D73B2AC0C3@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.400 tomoe/ChangeLog:1.401 --- tomoe/ChangeLog:1.400 Wed Dec 6 20:26:16 2006 +++ tomoe/ChangeLog Wed Dec 6 21:43:11 2006 @@ -1,5 +1,8 @@ 2006-12-06 Kouhei Sutou + * module/dict/unihan-schemer.rb: renamed from unihan-compiler.rb. + * module/dict/Makefile.am: followed the change. + * TODO: updated. * lib/tomoe-config.c: made name parameter optional for Unihan From kous users.sourceforge.jp Thu Dec 7 10:31:31 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 10:31:31 +0900 Subject: [Tomoe-cvs 1736] CVS update: tomoe Message-ID: <20061207013131.D17D22AC096@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.401 tomoe/ChangeLog:1.402 --- tomoe/ChangeLog:1.401 Wed Dec 6 21:43:11 2006 +++ tomoe/ChangeLog Thu Dec 7 10:31:31 2006 @@ -1,3 +1,9 @@ +2006-12-07 Kouhei Sutou + + * module/dict/tomoe-dict-xml.[ch]: split definitions of + TomoeDictXML to tomoe-dict-xml.h from tomoe-dict-xml.c. + * module/dict/Makefile.am: followed the change. + 2006-12-06 Kouhei Sutou * module/dict/unihan-schemer.rb: renamed from unihan-compiler.rb. From kous users.sourceforge.jp Thu Dec 7 10:31:32 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 10:31:32 +0900 Subject: [Tomoe-cvs 1737] CVS update: tomoe/module/dict Message-ID: <20061207013132.067A02AC100@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.14 tomoe/module/dict/Makefile.am:1.15 --- tomoe/module/dict/Makefile.am:1.14 Wed Dec 6 21:43:11 2006 +++ tomoe/module/dict/Makefile.am Thu Dec 7 10:31:31 2006 @@ -42,7 +42,9 @@ dict_module_LTLIBRARIES = libxml.la -libxml_la_SOURCES = tomoe-dict-xml.c $(ptr_array_based_dict_sources) +libxml_la_SOURCES = \ + tomoe-dict-xml.c tomoe-dict-xml.h \ + $(ptr_array_based_dict_sources) if WITH_EST dict_module_LTLIBRARIES += libest.la Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.9 tomoe/module/dict/tomoe-dict-xml.c:1.10 --- tomoe/module/dict/tomoe-dict-xml.c:1.9 Wed Dec 6 12:08:47 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Thu Dec 7 10:31:31 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.9 2006/12/06 03:08:47 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.10 2006/12/07 01:31:31 kous Exp $ */ #include @@ -38,25 +38,14 @@ #include #include "tomoe-dict-ptr-array.h" +#include "tomoe-dict-xml.h" -#define TOMOE_TYPE_DICT_XML tomoe_type_dict_xml -#define TOMOE_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXML)) -#define TOMOE_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) -#define TOMOE_IS_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_XML)) -#define TOMOE_IS_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_XML)) -#define TOMOE_DICT_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) +#define TOMOE_DICT_XML_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXMLPrivate)) -enum { - PROP_0, - PROP_FILENAME, - PROP_EDITABLE -}; - -typedef struct _TomoeDictXML TomoeDictXML; -typedef struct _TomoeDictXMLClass TomoeDictXMLClass; -struct _TomoeDictXML +typedef struct _TomoeDictXMLPrivate TomoeDictXMLPrivate; +struct _TomoeDictXMLPrivate { - TomoeDict object; gchar *filename; gchar *name; GPtrArray *chars; @@ -65,9 +54,10 @@ gboolean modified; }; -struct _TomoeDictXMLClass -{ - TomoeDictClass parent_class; +enum { + PROP_0, + PROP_FILENAME, + PROP_EDITABLE }; static GType tomoe_type_dict_xml = 0; @@ -100,6 +90,12 @@ static gboolean tomoe_dict_xml_load (TomoeDictXML *dict); static gboolean tomoe_dict_xml_save (TomoeDictXML *dict); +GType +tomoe_dict_xml_get_type (void) +{ + return tomoe_type_dict_xml; +} + static void class_init (TomoeDictXMLClass *klass) { @@ -144,16 +140,20 @@ "Editable flag", TRUE, G_PARAM_READWRITE)); + + g_type_class_add_private (gobject_class, sizeof (TomoeDictXMLPrivate)); } static void init (TomoeDictXML *dict) { - dict->filename = NULL; - dict->name = NULL; - dict->chars = g_ptr_array_new(); - dict->modified = FALSE; - dict->editable = FALSE; + TomoeDictXMLPrivate *priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + + priv->filename = NULL; + priv->name = NULL; + priv->chars = g_ptr_array_new(); + priv->modified = FALSE; + priv->editable = FALSE; } static void @@ -218,15 +218,17 @@ GParamSpec *pspec) { TomoeDictXML *dict = TOMOE_DICT_XML (object); + TomoeDictXMLPrivate *priv; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); switch (prop_id) { - case PROP_FILENAME: - dict->filename = g_value_dup_string (value); + case PROP_FILENAME: + priv->filename = g_value_dup_string (value); break; - case PROP_EDITABLE: - dict->editable = g_value_get_boolean (value); + case PROP_EDITABLE: + priv->editable = g_value_get_boolean (value); break; - default: + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } @@ -240,15 +242,17 @@ GParamSpec *pspec) { TomoeDictXML *dict = TOMOE_DICT_XML (object); + TomoeDictXMLPrivate *priv; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); switch (prop_id) { - case PROP_FILENAME: - g_value_set_string (value, dict->filename); + case PROP_FILENAME: + g_value_set_string (value, priv->filename); break; - case PROP_EDITABLE: - g_value_set_boolean (value, dict->editable); + case PROP_EDITABLE: + g_value_set_boolean (value, priv->editable); break; - default: + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } @@ -258,21 +262,23 @@ dispose (GObject *object) { TomoeDictXML *dict; + TomoeDictXMLPrivate *priv; dict = TOMOE_DICT_XML(object); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); flush (TOMOE_DICT (dict)); - if (dict->name) - g_free (dict->name); - if (dict->filename) - g_free (dict->filename); - if (dict->chars) - TOMOE_PTR_ARRAY_FREE_ALL(dict->chars, g_object_unref); - - dict->name = NULL; - dict->filename = NULL; - dict->chars = NULL; + if (priv->name) + g_free (priv->name); + if (priv->filename) + g_free (priv->filename); + if (priv->chars) + TOMOE_PTR_ARRAY_FREE_ALL(priv->chars, g_object_unref); + + priv->name = NULL; + priv->filename = NULL; + priv->chars = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -281,20 +287,25 @@ get_name (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; + g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - return dict->name; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + return priv->name; } static gboolean register_char (TomoeDict *_dict, TomoeChar *chr) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); - if (_tomoe_dict_ptr_array_register_char (dict->chars, chr)) { - dict->modified = TRUE; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + if (_tomoe_dict_ptr_array_register_char (priv->chars, chr)) { + priv->modified = TRUE; return TRUE; } else { return FALSE; @@ -305,11 +316,13 @@ unregister_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - if (_tomoe_dict_ptr_array_unregister_char (dict->chars, utf8)) { - dict->modified = TRUE; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + if (_tomoe_dict_ptr_array_unregister_char (priv->chars, utf8)) { + priv->modified = TRUE; return TRUE; } else { return FALSE; @@ -320,31 +333,37 @@ get_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - return _tomoe_dict_ptr_array_get_char (dict->chars, utf8); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + return _tomoe_dict_ptr_array_get_char (priv->chars, utf8); } static GList * search (TomoeDict *_dict, TomoeQuery *query) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - return _tomoe_dict_ptr_array_search (dict->chars, query); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + return _tomoe_dict_ptr_array_search (priv->chars, query); } static gboolean flush (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - if (dict->editable && dict->modified) { - dict->modified = FALSE; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + if (priv->editable && priv->modified) { + priv->modified = FALSE; return tomoe_dict_xml_save (dict); } else { return TRUE; @@ -355,20 +374,24 @@ is_editable (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - return dict->editable; + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + return priv->editable; } static gchar * get_available_private_utf8 (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); + TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - return _tomoe_dict_ptr_array_get_available_private_utf8 (dict->chars); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + return _tomoe_dict_ptr_array_get_available_private_utf8 (priv->chars); } static gboolean @@ -376,16 +399,19 @@ { gboolean success = TRUE; TomoeXMLParsedData result; + TomoeDictXMLPrivate *priv; + + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); result.name = NULL; - result.chars = dict->chars; - success = _tomoe_xml_parser_parse_dictionary_file (dict->filename, &result); + result.chars = priv->chars; + success = _tomoe_xml_parser_parse_dictionary_file (priv->filename, &result); if (result.name) { - g_free (dict->name); - dict->name = g_strdup (result.name); + g_free (priv->name); + priv->name = g_strdup (result.name); g_free (result.name); } - _tomoe_dict_ptr_array_sort (dict->chars); + _tomoe_dict_ptr_array_sort (priv->chars); return success; } @@ -393,15 +419,19 @@ static gboolean tomoe_dict_xml_save (TomoeDictXML *dict) { + TomoeDictXMLPrivate *priv; FILE *f; gchar *head; const gchar *foot = "\n"; guint i; + g_return_val_if_fail (TOMOE_IS_DICT (dict), FALSE); - if (!dict->editable) return FALSE; - f = fopen (dict->filename, "wb"); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + if (!priv->editable) return FALSE; + + f = fopen (priv->filename, "wb"); g_return_val_if_fail (f, FALSE); /* write the header */ @@ -411,18 +441,18 @@ if (fwrite (head, strlen (head), 1, f) < 1) goto ERROR; g_free (head); - if (dict->name) + if (priv->name) head = g_markup_printf_escaped ("\n", - dict->name); + priv->name); else head = g_strdup ("\n"); if (fwrite (head, strlen (head), 1, f) < 1) goto ERROR; /* write each characters */ - for (i = 0; i < dict->chars->len; i++) { + for (i = 0; i < priv->chars->len; i++) { gchar *xml; gboolean failed; - TomoeChar* chr = (TomoeChar*)g_ptr_array_index (dict->chars, i); + TomoeChar* chr = (TomoeChar*)g_ptr_array_index (priv->chars, i); xml = tomoe_char_to_xml (chr); if (!xml) goto ERROR; @@ -438,12 +468,12 @@ /* clean */ g_free (head); fclose (f); - dict->modified = FALSE; + priv->modified = FALSE; return TRUE; ERROR: g_free (head); - g_warning ("Faild to write %s.", dict->filename); + g_warning ("Faild to write %s.", priv->filename); fclose (f); return FALSE; } Index: tomoe/module/dict/tomoe-dict-xml.h diff -u /dev/null tomoe/module/dict/tomoe-dict-xml.h:1.1 --- /dev/null Thu Dec 7 10:31:31 2006 +++ tomoe/module/dict/tomoe-dict-xml.h Thu Dec 7 10:31:31 2006 @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-xml.h,v 1.1 2006/12/07 01:31:31 kous Exp $ + */ + +#ifndef __TOMOE_DICT_XML_H__ +#define __TOMOE_DICT_XML_H__ + +#include + +G_BEGIN_DECLS + +#include "tomoe-char.h" +#include "tomoe-query.h" + +#define TOMOE_TYPE_DICT_XML tomoe_type_dict_xml +#define TOMOE_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXML)) +#define TOMOE_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) +#define TOMOE_IS_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_XML)) +#define TOMOE_IS_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_XML)) +#define TOMOE_DICT_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) + +typedef struct _TomoeDictXML TomoeDictXML; +typedef struct _TomoeDictXMLClass TomoeDictXMLClass; +struct _TomoeDictXML +{ + TomoeDict object; +}; + +struct _TomoeDictXMLClass +{ + TomoeDictClass parent_class; +}; + +GType tomoe_dict_xml_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __TOMOE_DICT_XML_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ From makeinu users.sourceforge.jp Thu Dec 7 10:35:40 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 10:35:40 +0900 Subject: [Tomoe-cvs 1738] CVS update: libtomoe-gtk/src Message-ID: <20061207013540.39CD52AC096@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.21 libtomoe-gtk/src/tomoe-reading-search.c:1.22 --- libtomoe-gtk/src/tomoe-reading-search.c:1.21 Wed Dec 6 15:20:24 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 7 10:35:40 2006 @@ -193,28 +193,28 @@ /* character column */ renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Character"), - renderer, - "text", UTF8_COLUMN, - NULL); + column = gtk_tree_view_column_new_with_attributes ( + _("Character"), renderer, + "text", UTF8_COLUMN, + NULL); gtk_tree_view_column_set_sort_column_id (column, UTF8_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); /* stroke count column */ renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Stroke count"), - renderer, - "text", STROKECOUNT_TEXT_COLUMN, - NULL); + column = gtk_tree_view_column_new_with_attributes ( + _("Stroke count"), renderer, + "text", STROKECOUNT_TEXT_COLUMN, + NULL); gtk_tree_view_column_set_sort_column_id (column, STROKECOUNT_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); /* reading column */ renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Reading"), - renderer, - "text", READING_COLUMN, - NULL); + column = gtk_tree_view_column_new_with_attributes ( + _("Reading"), renderer, + "text", READING_COLUMN, + NULL); gtk_tree_view_column_set_sort_column_id (column, READING_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); gtk_widget_set_size_request (list, 400, 320); @@ -337,7 +337,8 @@ str_array = g_new0 (gchar *, reading_num + 1); str_array[reading_num] = NULL; for (i = 0; i < reading_num; i++) { - TomoeReading *reading = TOMOE_READING (g_list_nth_data ((GList *) readings, i)); + TomoeReading *reading + = TOMOE_READING (g_list_nth_data ((GList *) readings, i)); str_array[i] = (gchar *) tomoe_reading_get_reading (reading); } readings_text = g_strjoinv (" ", str_array); From kous users.sourceforge.jp Thu Dec 7 10:38:05 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 10:38:05 +0900 Subject: [Tomoe-cvs 1739] CVS update: tomoe Message-ID: <20061207013805.E43882AC096@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.402 tomoe/ChangeLog:1.403 --- tomoe/ChangeLog:1.402 Thu Dec 7 10:31:31 2006 +++ tomoe/ChangeLog Thu Dec 7 10:38:05 2006 @@ -1,5 +1,8 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-est.c: fixed a reference count related + bug. + * module/dict/tomoe-dict-xml.[ch]: split definitions of TomoeDictXML to tomoe-dict-xml.h from tomoe-dict-xml.c. * module/dict/Makefile.am: followed the change. From kous users.sourceforge.jp Thu Dec 7 10:38:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 10:38:06 +0900 Subject: [Tomoe-cvs 1740] CVS update: tomoe/module/dict Message-ID: <20061207013806.241E82AC100@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.7 tomoe/module/dict/tomoe-dict-est.c:1.8 --- tomoe/module/dict/tomoe-dict-est.c:1.7 Wed Dec 6 20:26:16 2006 +++ tomoe/module/dict/tomoe-dict-est.c Thu Dec 7 10:38:05 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.7 2006/12/06 11:26:16 ikezoe Exp $ + * $Id: tomoe-dict-est.c,v 1.8 2006/12/07 01:38:05 kous Exp $ */ #include @@ -413,7 +413,7 @@ chr = tomoe_char_new_from_xml_data (est_doc_hidden_texts (doc), -1); if (chr) - g_hash_table_insert (dict->cache, g_strdup (utf8), chr); + g_hash_table_insert (dict->cache, g_strdup (utf8), g_object_ref (chr)); est_doc_delete (doc); From kous users.sourceforge.jp Thu Dec 7 10:38:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 10:38:06 +0900 Subject: [Tomoe-cvs 1741] CVS update: tomoe/test Message-ID: <20061207013806.4EC422AC096@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.13 tomoe/test/dict_spec.rb:1.14 --- tomoe/test/dict_spec.rb:1.13 Mon Dec 4 00:04:42 2006 +++ tomoe/test/dict_spec.rb Thu Dec 7 10:38:06 2006 @@ -24,7 +24,6 @@ dict = Tomoe::Dict.new("est", "database_name" => est_db, "editable" => true) - return if dict.nil? a = dict[@utf8] a.writing.strokes.should == @strokes ensure From kous users.sourceforge.jp Thu Dec 7 10:39:20 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 10:39:20 +0900 Subject: [Tomoe-cvs 1742] CVS update: tomoe Message-ID: <20061207013920.CA6772AC1E5@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.403 tomoe/ChangeLog:1.404 --- tomoe/ChangeLog:1.403 Thu Dec 7 10:38:05 2006 +++ tomoe/ChangeLog Thu Dec 7 10:39:20 2006 @@ -1,5 +1,7 @@ 2006-12-07 Kouhei Sutou + * NEWS: updated. + * module/dict/tomoe-dict-est.c: fixed a reference count related bug. Index: tomoe/NEWS diff -u tomoe/NEWS:1.6 tomoe/NEWS:1.7 --- tomoe/NEWS:1.6 Fri Dec 1 11:23:38 2006 +++ tomoe/NEWS Thu Dec 7 10:39:20 2006 @@ -2,6 +2,7 @@ ============================================================== * New modulized dictionarys: - Hyper Estraier + - Unihan database Overview of Changes from libtomoe-0.3.0 to libtomoe-0.4.0 ============================================================== From makeinu users.sourceforge.jp Thu Dec 7 11:11:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:11:20 +0900 Subject: [Tomoe-cvs 1743] CVS update: libtomoe-gtk Message-ID: <20061207021120.97B5A2AC1E9@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.242 libtomoe-gtk/ChangeLog:1.243 --- libtomoe-gtk/ChangeLog:1.242 Wed Dec 6 17:50:31 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 11:11:20 2006 @@ -1,3 +1,8 @@ +2006-12-07 Takuro Ashie + + * src/tomoe-reading-search.c: Add stroke count spin button. + * po/ja.po: Update. + 2006-12-06 Takuro Ashie * src/tomoe-gtk.h: Add missing files. From makeinu users.sourceforge.jp Thu Dec 7 11:11:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:11:20 +0900 Subject: [Tomoe-cvs 1744] CVS update: libtomoe-gtk/po Message-ID: <20061207021120.C55522AC1EB@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.10 libtomoe-gtk/po/ja.po:1.11 --- libtomoe-gtk/po/ja.po:1.10 Mon Dec 4 23:20:00 2006 +++ libtomoe-gtk/po/ja.po Thu Dec 7 11:11:20 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-04 20:45+0900\n" +"POT-Creation-Date: 2006-12-07 10:52+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -10,21 +10,91 @@ "Content-Type: text/plain; charset=EUC-JP\n" "Content-Transfer-Encoding: 8bit\n" -#: src/tomoe-details.c:114 src/tomoe-edit-char.c:83 +#: src/tomoe-canvas.c:212 src/tomoe-handwriting.c:116 +#: src/tomoe-reading-search.c:118 +msgid "Tomoe context" +msgstr "" + +#: src/tomoe-canvas.c:213 +msgid "" +"A TomoeContext which stores handwriting dictionaries. TomoeCanvas doesn't " +"always require TomoeContext. For example it isn't needed on viewer mode." +msgstr "" + +#: src/tomoe-canvas.c:222 +msgid "Locked" +msgstr "" + +#: src/tomoe-canvas.c:223 +msgid "Whether the canvas is locked drawing or not." +msgstr "" + +#: src/tomoe-canvas.c:230 +msgid "Tomoe writing" +msgstr "" + +#: src/tomoe-canvas.c:231 +msgid "Strokes of a character to show on this canvas." +msgstr "" + +#: src/tomoe-canvas.c:238 +msgid "Auto find time" +msgstr "" + +#: src/tomoe-canvas.c:239 +msgid "" +"Delay time from releasing mouse button to starting auto finding. Set 0 to " +"find immediatly. Set -1 to disable auto finding." +msgstr "" + +#: src/tomoe-canvas.c:247 +#, fuzzy +msgid "Handwriting line color" +msgstr "ǧ" + +#: src/tomoe-canvas.c:248 +msgid "The color of handwriting lines." +msgstr "" + +#: src/tomoe-canvas.c:256 +msgid "Adjusted line color" +msgstr "" + +#: src/tomoe-canvas.c:257 +msgid "The color of adjusted handwriting lines." +msgstr "" + +#: src/tomoe-canvas.c:265 +msgid "Annotation color" +msgstr "" + +#: src/tomoe-canvas.c:266 +msgid "The color of annotation strings." +msgstr "" + +#: src/tomoe-canvas.c:274 +msgid "Axis color" +msgstr "" + +#: src/tomoe-canvas.c:275 +msgid "The color of axis lines." +msgstr "" + +#: src/tomoe-details.c:114 src/tomoe-edit-char.c:84 #: src/tomoe-edit-strokes.c:100 msgid "TomoeChar object" msgstr "" -#: src/tomoe-details.c:115 src/tomoe-edit-char.c:84 +#: src/tomoe-details.c:115 src/tomoe-edit-char.c:85 #: src/tomoe-edit-strokes.c:101 msgid "The Object of TomoeChar" msgstr "" -#: src/tomoe-details.c:122 src/tomoe-edit-char.c:91 +#: src/tomoe-details.c:122 src/tomoe-edit-char.c:92 msgid "TomoeDict object" msgstr "" -#: src/tomoe-details.c:123 src/tomoe-edit-char.c:92 +#: src/tomoe-details.c:123 src/tomoe-edit-char.c:93 msgid "The Object of TomoeDict" msgstr "" @@ -48,7 +118,7 @@ msgid "Basic information" msgstr "ܾ" -#: src/tomoe-details.c:268 src/tomoe-reading-search.c:179 +#: src/tomoe-details.c:268 src/tomoe-reading-search.c:230 msgid "Character" msgstr "ʸ" @@ -64,15 +134,15 @@ msgid "Readings" msgstr "ɤ" -#: src/tomoe-edit-char.c:116 +#: src/tomoe-edit-char.c:117 msgid "Change character" msgstr "ʸѹ" -#: src/tomoe-edit-char.c:129 +#: src/tomoe-edit-char.c:130 msgid "New character:" msgstr "ʸ:" -#: src/tomoe-edit-meta.c:116 +#: src/tomoe-edit-meta.c:117 msgid "Edit meta information" msgstr "᥿Խ" @@ -84,42 +154,104 @@ msgid "Unicode script" msgstr "UnicodeץȽ" -#: src/tomoe-gucharmap.c:136 +#: src/tomoe-gucharmap.c:137 msgid "Writing" msgstr "" -#: src/tomoe-handwriting.c:350 +#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:119 +msgid "A TomoeContext which stores handwriting dictionaries." +msgstr "" + +#: src/tomoe-handwriting.c:123 +msgid "TomoeCanvas" +msgstr "" + +#: src/tomoe-handwriting.c:124 +msgid "The TomoeCavas widget inside of the TomoeHandwriting container." +msgstr "" + +#: src/tomoe-handwriting.c:130 +msgid "ButtonArea" +msgstr "" + +#: src/tomoe-handwriting.c:131 +msgid "The button area widget inside of the TomoeHandwriting container." +msgstr "" + +#: src/tomoe-handwriting.c:137 +#, fuzzy +msgid "CharTable" +msgstr "ʸξܺ" + +#: src/tomoe-handwriting.c:138 +msgid "A candidates view widget inside of the TomoeHandwriting container." +msgstr "" + +#: src/tomoe-handwriting.c:487 msgid "Select the file name for dump" msgstr "" -#: src/tomoe-reading-search.c:128 +#: src/tomoe-reading-search.c:149 msgid "Reading:" msgstr "ɤ:" -#: src/tomoe-reading-search.c:188 +#: src/tomoe-reading-search.c:180 +msgid "Stroke count:" +msgstr ":" + +#: src/tomoe-reading-search.c:184 +msgid "Minimum" +msgstr "Ǿ" + +#: src/tomoe-reading-search.c:194 +msgid "Maximum" +msgstr "" + +#: src/tomoe-reading-search.c:239 msgid "Stroke count" msgstr "" -#: src/tomoe-reading-search.c:197 +#: src/tomoe-reading-search.c:248 msgid "Reading" msgstr "ɤ" -#: src/tomoe-window.c:123 src/tomoe-window.c:153 +#: src/tomoe-window.c:110 +msgid "TomoeHandwriting" +msgstr "" + +#: src/tomoe-window.c:111 +msgid "The TomoeHandwriting widget inside of the TomoeWindow." +msgstr "" + +#: src/tomoe-window.c:118 +msgid "TomoeReadingSearch" +msgstr "" + +#: src/tomoe-window.c:119 +msgid "The TomoeReadingSearch widget inside of the TomoeWindow." +msgstr "" + +#: src/tomoe-window.c:126 +msgid "TomoeGucharmap" +msgstr "" + +#: src/tomoe-window.c:127 +msgid "The TomoeGucharmap widget inside of the TomoeWindow." +msgstr "" + +#: src/tomoe-window.c:160 src/tomoe-window.c:185 msgid "Handwriting recognition" msgstr "ǧ" -#: src/tomoe-window.c:166 -msgid "Search with reading " +#: src/tomoe-window.c:196 +#, fuzzy +msgid "Search with reading" msgstr "ɤߤǸ" -#: src/tomoe-window.c:177 +#: src/tomoe-window.c:207 msgid "Unicode table" msgstr "Unicodeɽ" -#, fuzzy -#~ msgid "Character table" -#~ msgstr "ʸξܺ" - #~ msgid "Use" #~ msgstr "" From makeinu users.sourceforge.jp Thu Dec 7 11:11:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:11:20 +0900 Subject: [Tomoe-cvs 1745] CVS update: libtomoe-gtk/src Message-ID: <20061207021120.EE6EC2AC1E9@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.22 libtomoe-gtk/src/tomoe-reading-search.c:1.23 --- libtomoe-gtk/src/tomoe-reading-search.c:1.22 Thu Dec 7 10:35:40 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 7 11:11:20 2006 @@ -54,6 +54,8 @@ TomoeContext *context; GtkListStore *result_store; GtkWidget *input; + GtkWidget *min_strokes_spin; + GtkWidget *max_strokes_spin; GtkWidget *treeview; }; @@ -124,12 +126,13 @@ static void tomoe_reading_search_init (TomoeReadingSearch *page) { - GtkWidget *hbox, *vbox, *input, *button, *list, *label; + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + GtkWidget *hbox, *vbox, *input, *button, *list, *label, *spin; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *result_sel; GtkWidget *scrolled_window; - TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + GtkObject *adj; gtk_table_resize (GTK_TABLE (page), 1, 1); gtk_table_set_homogeneous (GTK_TABLE (page), FALSE); @@ -141,6 +144,7 @@ /* input area */ hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); label = gtk_label_new (_("Reading:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); @@ -168,6 +172,35 @@ (gpointer) page); gtk_widget_show (button); + /* stroke count area */ + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + label = gtk_label_new (_("Stroke count:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); + gtk_widget_show (label); + + label = gtk_label_new (_("Minimum")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); + gtk_widget_show (label); + + adj = gtk_adjustment_new (1.0, 1.0, 200.0, 1.0, 5.0, 5.0); + spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0.0, 0); + priv->min_strokes_spin = spin; + gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 4); + gtk_widget_show (spin); + + label = gtk_label_new (_("Maximum")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); + gtk_widget_show (label); + + adj = gtk_adjustment_new (20.0, 1.0, 200.0, 1.0, 5.0, 5.0); + spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0.0, 0); + priv->max_strokes_spin = spin; + gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 4); + gtk_widget_show (spin); + /* result view */ priv->result_store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, @@ -223,7 +256,6 @@ (gpointer) page); gtk_widget_show (list); - gtk_widget_show (hbox); gtk_widget_show (vbox); } @@ -295,6 +327,8 @@ { GList *result, *list; const gchar *reading_text; + gint min, max; + GtkSpinButton *min_spin, *max_spin; TomoeQuery *query; TomoeReading *reading; TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); @@ -304,14 +338,29 @@ gtk_list_store_clear (priv->result_store); + query = tomoe_query_new (); + reading_text = gtk_entry_get_text (GTK_ENTRY (priv->input)); + if (reading_text && *reading_text) { + reading = tomoe_reading_new (TOMOE_READING_UNKNOWN, reading_text); + tomoe_query_add_reading (query, reading); + g_object_unref (reading); + } + + min_spin = GTK_SPIN_BUTTON (priv->min_strokes_spin); + if (GTK_WIDGET_VISIBLE (min_spin)) { + min = gtk_spin_button_get_value (min_spin); + tomoe_query_set_min_n_strokes (query, min); + } + + max_spin = GTK_SPIN_BUTTON (priv->max_strokes_spin); + if (GTK_WIDGET_VISIBLE (max_spin)) { + max = gtk_spin_button_get_value (max_spin); + tomoe_query_set_max_n_strokes (query, max); + } - reading = tomoe_reading_new (TOMOE_READING_UNKNOWN, reading_text); - query = tomoe_query_new (); - tomoe_query_add_reading (query, reading); result = tomoe_context_search (priv->context, query); g_object_unref (query); - g_object_unref (reading); for (list = result; list; list = g_list_next (list)) { TomoeCandidate *cand = TOMOE_CANDIDATE (list->data); From makeinu users.sourceforge.jp Thu Dec 7 11:25:07 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:25:07 +0900 Subject: [Tomoe-cvs 1746] CVS update: libtomoe-gtk Message-ID: <20061207022507.573062AC157@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.243 libtomoe-gtk/ChangeLog:1.244 --- libtomoe-gtk/ChangeLog:1.243 Thu Dec 7 11:11:20 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 11:25:07 2006 @@ -1,5 +1,9 @@ 2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Add expander to hide additional options. + +2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Add stroke count spin button. * po/ja.po: Update. From makeinu users.sourceforge.jp Thu Dec 7 11:25:07 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:25:07 +0900 Subject: [Tomoe-cvs 1747] CVS update: libtomoe-gtk/src Message-ID: <20061207022507.844B82AC15D@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.23 libtomoe-gtk/src/tomoe-reading-search.c:1.24 --- libtomoe-gtk/src/tomoe-reading-search.c:1.23 Thu Dec 7 11:11:20 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 7 11:25:07 2006 @@ -127,7 +127,7 @@ tomoe_reading_search_init (TomoeReadingSearch *page) { TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); - GtkWidget *hbox, *vbox, *input, *button, *list, *label, *spin; + GtkWidget *hbox, *vbox, *input, *button, *list, *label, *spin, *expander; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *result_sel; @@ -173,8 +173,12 @@ gtk_widget_show (button); /* stroke count area */ + expander = gtk_expander_new_with_mnemonic (_("More options")); + gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0); + gtk_widget_show (expander); + hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_container_add (GTK_CONTAINER (expander), hbox); gtk_widget_show (hbox); label = gtk_label_new (_("Stroke count:")); From makeinu users.sourceforge.jp Thu Dec 7 11:35:03 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:35:03 +0900 Subject: [Tomoe-cvs 1748] CVS update: libtomoe-gtk Message-ID: <20061207023505.2E6062AC1E5@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.244 libtomoe-gtk/ChangeLog:1.245 --- libtomoe-gtk/ChangeLog:1.244 Thu Dec 7 11:25:07 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 11:35:02 2006 @@ -1,6 +1,7 @@ 2006-12-07 Takuro Ashie * src/tomoe-reading-search.c: Add expander to hide additional options. + * po/ja.po: Update. 2006-12-07 Takuro Ashie From makeinu users.sourceforge.jp Thu Dec 7 11:35:05 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:35:05 +0900 Subject: [Tomoe-cvs 1749] CVS update: libtomoe-gtk/po Message-ID: <20061207023505.5F05F2AC157@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.11 libtomoe-gtk/po/ja.po:1.12 --- libtomoe-gtk/po/ja.po:1.11 Thu Dec 7 11:11:20 2006 +++ libtomoe-gtk/po/ja.po Thu Dec 7 11:35:05 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-07 10:52+0900\n" +"POT-Creation-Date: 2006-12-07 11:25+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -118,7 +118,7 @@ msgid "Basic information" msgstr "ܾ" -#: src/tomoe-details.c:268 src/tomoe-reading-search.c:230 +#: src/tomoe-details.c:268 src/tomoe-reading-search.c:234 msgid "Character" msgstr "ʸ" @@ -195,23 +195,28 @@ msgid "Reading:" msgstr "ɤ:" -#: src/tomoe-reading-search.c:180 +#. stroke count area +#: src/tomoe-reading-search.c:176 +msgid "More options" +msgstr "¾θ" + +#: src/tomoe-reading-search.c:184 msgid "Stroke count:" msgstr ":" -#: src/tomoe-reading-search.c:184 +#: src/tomoe-reading-search.c:188 msgid "Minimum" msgstr "Ǿ" -#: src/tomoe-reading-search.c:194 +#: src/tomoe-reading-search.c:198 msgid "Maximum" msgstr "" -#: src/tomoe-reading-search.c:239 +#: src/tomoe-reading-search.c:243 msgid "Stroke count" msgstr "" -#: src/tomoe-reading-search.c:248 +#: src/tomoe-reading-search.c:252 msgid "Reading" msgstr "ɤ" From makeinu users.sourceforge.jp Thu Dec 7 11:35:05 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:35:05 +0900 Subject: [Tomoe-cvs 1750] CVS update: libtomoe-gtk/src Message-ID: <20061207023505.972352AC1E5@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.24 libtomoe-gtk/src/tomoe-reading-search.c:1.25 --- libtomoe-gtk/src/tomoe-reading-search.c:1.24 Thu Dec 7 11:25:07 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 7 11:35:05 2006 @@ -56,6 +56,7 @@ GtkWidget *input; GtkWidget *min_strokes_spin; GtkWidget *max_strokes_spin; + GtkWidget *expander; GtkWidget *treeview; }; @@ -174,6 +175,7 @@ /* stroke count area */ expander = gtk_expander_new_with_mnemonic (_("More options")); + priv->expander = expander; gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0); gtk_widget_show (expander); @@ -352,13 +354,13 @@ } min_spin = GTK_SPIN_BUTTON (priv->min_strokes_spin); - if (GTK_WIDGET_VISIBLE (min_spin)) { + if (gtk_expander_get_expanded (GTK_EXPANDER (priv->expander))) { min = gtk_spin_button_get_value (min_spin); tomoe_query_set_min_n_strokes (query, min); } max_spin = GTK_SPIN_BUTTON (priv->max_strokes_spin); - if (GTK_WIDGET_VISIBLE (max_spin)) { + if (gtk_expander_get_expanded (GTK_EXPANDER (priv->expander))) { max = gtk_spin_button_get_value (max_spin); tomoe_query_set_max_n_strokes (query, max); } From makeinu users.sourceforge.jp Thu Dec 7 11:46:25 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:46:25 +0900 Subject: [Tomoe-cvs 1751] CVS update: libtomoe-gtk Message-ID: <20061207024625.375712AC157@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.245 libtomoe-gtk/ChangeLog:1.246 --- libtomoe-gtk/ChangeLog:1.245 Thu Dec 7 11:35:02 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 11:46:25 2006 @@ -1,5 +1,9 @@ 2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Validate max & min stroke count. + +2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Add expander to hide additional options. * po/ja.po: Update. From makeinu users.sourceforge.jp Thu Dec 7 11:46:25 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 11:46:25 +0900 Subject: [Tomoe-cvs 1752] CVS update: libtomoe-gtk/src Message-ID: <20061207024625.633632AC159@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.25 libtomoe-gtk/src/tomoe-reading-search.c:1.26 --- libtomoe-gtk/src/tomoe-reading-search.c:1.25 Thu Dec 7 11:35:05 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 7 11:46:25 2006 @@ -80,6 +80,10 @@ gpointer user_data); static void on_input_entry_activate (GtkEntry *entry, gpointer *user_data); +static void on_min_strokes_spin_button_changed (GtkSpinButton *spinbutton, + gpointer user_data); +static void on_max_strokes_spin_button_changed (GtkSpinButton *spinbutton, + gpointer user_data); static void on_result_view_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); @@ -194,6 +198,9 @@ adj = gtk_adjustment_new (1.0, 1.0, 200.0, 1.0, 5.0, 5.0); spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0.0, 0); priv->min_strokes_spin = spin; + g_signal_connect (G_OBJECT (spin), "value-changed", + G_CALLBACK (on_min_strokes_spin_button_changed), + page); gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 4); gtk_widget_show (spin); @@ -204,6 +211,9 @@ adj = gtk_adjustment_new (20.0, 1.0, 200.0, 1.0, 5.0, 5.0); spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0.0, 0); priv->max_strokes_spin = spin; + g_signal_connect (G_OBJECT (spin), "value-changed", + G_CALLBACK (on_max_strokes_spin_button_changed), + page); gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 4); gtk_widget_show (spin); @@ -421,6 +431,7 @@ static void tomoe_reading_search_clear (TomoeReadingSearch *page) { + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); g_return_if_fail (GTK_IS_LIST_STORE (priv->result_store)); @@ -488,6 +499,40 @@ } static void +on_min_strokes_spin_button_changed (GtkSpinButton *spinbutton, + gpointer user_data) +{ + gint min, max; + + TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->min_strokes_spin)); + max = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->max_strokes_spin)); + + if (min > max) + gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->max_strokes_spin), + min); +} + +static void +on_max_strokes_spin_button_changed (GtkSpinButton *spinbutton, + gpointer user_data) +{ + gint min, max; + + TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + min = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->min_strokes_spin)); + max = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->max_strokes_spin)); + + if (max < min) + gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->min_strokes_spin), + max); +} + +static void on_find_button_clicked (GtkButton *button, gpointer user_data) { TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); From makeinu users.sourceforge.jp Thu Dec 7 12:01:43 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:01:43 +0900 Subject: [Tomoe-cvs 1753] CVS update: libtomoe-gtk Message-ID: <20061207030143.A1AE32AC01E@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.246 libtomoe-gtk/ChangeLog:1.247 --- libtomoe-gtk/ChangeLog:1.246 Thu Dec 7 11:46:25 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 12:01:43 2006 @@ -1,5 +1,10 @@ 2006-12-07 Takuro Ashie + * src/tomoe-window.c: Plug a memory leak. + * po/ja.po: Fix a typo. + +2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Validate max & min stroke count. 2006-12-07 Takuro Ashie From makeinu users.sourceforge.jp Thu Dec 7 12:01:43 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:01:43 +0900 Subject: [Tomoe-cvs 1754] CVS update: libtomoe-gtk/po Message-ID: <20061207030143.CDFF02AC159@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.12 libtomoe-gtk/po/ja.po:1.13 --- libtomoe-gtk/po/ja.po:1.12 Thu Dec 7 11:35:05 2006 +++ libtomoe-gtk/po/ja.po Thu Dec 7 12:01:43 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-07 11:25+0900\n" +"POT-Creation-Date: 2006-12-07 11:48+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -11,7 +11,7 @@ "Content-Transfer-Encoding: 8bit\n" #: src/tomoe-canvas.c:212 src/tomoe-handwriting.c:116 -#: src/tomoe-reading-search.c:118 +#: src/tomoe-reading-search.c:123 msgid "Tomoe context" msgstr "" @@ -118,7 +118,7 @@ msgid "Basic information" msgstr "ܾ" -#: src/tomoe-details.c:268 src/tomoe-reading-search.c:234 +#: src/tomoe-details.c:268 src/tomoe-reading-search.c:246 msgid "Character" msgstr "ʸ" @@ -158,7 +158,7 @@ msgid "Writing" msgstr "" -#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:119 +#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:124 msgid "A TomoeContext which stores handwriting dictionaries." msgstr "" @@ -191,32 +191,32 @@ msgid "Select the file name for dump" msgstr "" -#: src/tomoe-reading-search.c:149 +#: src/tomoe-reading-search.c:154 msgid "Reading:" msgstr "ɤ:" #. stroke count area -#: src/tomoe-reading-search.c:176 +#: src/tomoe-reading-search.c:181 msgid "More options" msgstr "¾θ" -#: src/tomoe-reading-search.c:184 +#: src/tomoe-reading-search.c:190 msgid "Stroke count:" msgstr ":" -#: src/tomoe-reading-search.c:188 +#: src/tomoe-reading-search.c:194 msgid "Minimum" msgstr "Ǿ" -#: src/tomoe-reading-search.c:198 +#: src/tomoe-reading-search.c:207 msgid "Maximum" msgstr "" -#: src/tomoe-reading-search.c:243 +#: src/tomoe-reading-search.c:255 msgid "Stroke count" msgstr "" -#: src/tomoe-reading-search.c:252 +#: src/tomoe-reading-search.c:264 msgid "Reading" msgstr "ɤ" @@ -249,7 +249,6 @@ msgstr "ǧ" #: src/tomoe-window.c:196 -#, fuzzy msgid "Search with reading" msgstr "ɤߤǸ" From makeinu users.sourceforge.jp Thu Dec 7 12:01:44 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:01:44 +0900 Subject: [Tomoe-cvs 1755] CVS update: libtomoe-gtk/src Message-ID: <20061207030144.055502AC01E@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.40 libtomoe-gtk/src/tomoe-window.c:1.41 --- libtomoe-gtk/src/tomoe-window.c:1.40 Wed Dec 6 16:22:49 2006 +++ libtomoe-gtk/src/tomoe-window.c Thu Dec 7 12:01:43 2006 @@ -61,6 +61,7 @@ GtkWidget *handwriting; GtkWidget *reading; GtkWidget *gucharmap; + GtkTooltips *tooltips; }; #define TOMOE_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_WINDOW, TomoeWindowPrivate)) @@ -163,6 +164,11 @@ gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); + // tooltips + priv->tooltips = gtk_tooltips_new (); + g_object_ref (G_OBJECT (priv->tooltips)); + gtk_object_sink (GTK_OBJECT (priv->tooltips)); + /* create search pages view notebook */ notebook = gtk_notebook_new (); priv->notebook = notebook; @@ -216,7 +222,12 @@ g_object_unref (priv->context); priv->context = NULL; } - + + if (priv->tooltips) { + g_object_unref (priv->tooltips); + priv->tooltips = NULL; + } + tomoe_quit (); if (G_OBJECT_CLASS(tomoe_window_parent_class)->dispose) @@ -280,7 +291,6 @@ const gchar *label_text) { TomoeWindowPrivate *priv; - GtkTooltips *tip; GtkWidget *event_box = NULL; g_return_if_fail (TOMOE_IS_WINDOW (window)); @@ -297,10 +307,8 @@ gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, event_box); - if (label_text) { - tip = gtk_tooltips_new (); - gtk_tooltips_set_tip (tip, event_box, label_text, NULL); - } + if (label_text) + gtk_tooltips_set_tip (priv->tooltips, event_box, label_text, NULL); } GtkWidget * From makeinu users.sourceforge.jp Thu Dec 7 12:32:15 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:32:15 +0900 Subject: [Tomoe-cvs 1756] CVS update: libtomoe-gtk Message-ID: <20061207033215.509972AC01E@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.247 libtomoe-gtk/ChangeLog:1.248 --- libtomoe-gtk/ChangeLog:1.247 Thu Dec 7 12:01:43 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 12:32:15 2006 @@ -1,5 +1,9 @@ 2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Fix initial size. + +2006-12-07 Takuro Ashie + * src/tomoe-window.c: Plug a memory leak. * po/ja.po: Fix a typo. From makeinu users.sourceforge.jp Thu Dec 7 12:32:15 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:32:15 +0900 Subject: [Tomoe-cvs 1757] CVS update: libtomoe-gtk/src Message-ID: <20061207033215.7C9332AC159@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.26 libtomoe-gtk/src/tomoe-reading-search.c:1.27 --- libtomoe-gtk/src/tomoe-reading-search.c:1.26 Thu Dec 7 11:46:25 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 7 12:32:15 2006 @@ -266,7 +266,7 @@ NULL); gtk_tree_view_column_set_sort_column_id (column, READING_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - gtk_widget_set_size_request (list, 400, 320); + gtk_widget_set_size_request (list, 300, 250); g_signal_connect (G_OBJECT (list), "button-release-event", G_CALLBACK (on_result_view_button_release_event), (gpointer) page); From makeinu users.sourceforge.jp Thu Dec 7 12:49:19 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:49:19 +0900 Subject: [Tomoe-cvs 1758] CVS update: libtomoe-gtk Message-ID: <20061207034919.E3F8C2AC1EA@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.248 libtomoe-gtk/ChangeLog:1.249 --- libtomoe-gtk/ChangeLog:1.248 Thu Dec 7 12:32:15 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 7 12:49:19 2006 @@ -1,5 +1,9 @@ 2006-12-07 Takuro Ashie + * src/tomoe-window.c: Set the window title automatically. + +2006-12-07 Takuro Ashie + * src/tomoe-reading-search.c: Fix initial size. 2006-12-07 Takuro Ashie From makeinu users.sourceforge.jp Thu Dec 7 12:49:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 7 Dec 2006 12:49:20 +0900 Subject: [Tomoe-cvs 1759] CVS update: libtomoe-gtk/src Message-ID: <20061207034920.1D4E32AC1EC@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.41 libtomoe-gtk/src/tomoe-window.c:1.42 --- libtomoe-gtk/src/tomoe-window.c:1.41 Thu Dec 7 12:01:43 2006 +++ libtomoe-gtk/src/tomoe-window.c Thu Dec 7 12:49:19 2006 @@ -78,6 +78,10 @@ GValue *value, GParamSpec *pspec); +static void on_notebook_switch_page (GtkNotebook *notebook, + GtkNotebookPage *page, + guint page_num, + gpointer user_data); static void on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data); static void on_reading_search_selected (TomoeReadingSearch *search, @@ -175,6 +179,8 @@ gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_LEFT); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE); gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE); + g_signal_connect (G_OBJECT (notebook), "switch-page", + G_CALLBACK (on_notebook_switch_page), window); gtk_container_add (GTK_CONTAINER (vbox), notebook); gtk_widget_show (notebook); @@ -299,6 +305,9 @@ priv = TOMOE_WINDOW_GET_PRIVATE (window); + g_object_set_data_full (G_OBJECT (page), "TomoeWindow::page-title", + g_strdup (label_text), (GDestroyNotify) g_free); + event_box = gtk_event_box_new (); gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE); gtk_container_add (GTK_CONTAINER (event_box), label); @@ -388,6 +397,21 @@ } static void +on_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, + guint page_num, gpointer user_data) +{ + TomoeWindow *window = TOMOE_WINDOW (user_data); + GtkWidget *widget = gtk_notebook_get_nth_page (notebook, page_num); + + const gchar *title = g_object_get_data (G_OBJECT (widget), + "TomoeWindow::page-title"); + if (title && *title) + gtk_window_set_title (GTK_WINDOW (window), title); + else + gtk_window_set_title (GTK_WINDOW (window), _("Tomoe")); +} + +static void on_handwriting_candidate_selected (TomoeHandwriting *view, gpointer user_data) { TomoeWindow *window; From kous users.sourceforge.jp Thu Dec 7 13:05:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:05:47 +0900 Subject: [Tomoe-cvs 1760] CVS update: tomoe Message-ID: <20061207040547.64EB12AC01D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.404 tomoe/ChangeLog:1.405 --- tomoe/ChangeLog:1.404 Thu Dec 7 10:39:20 2006 +++ tomoe/ChangeLog Thu Dec 7 13:05:47 2006 @@ -1,5 +1,7 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-xml.h: fixed a typo. + * NEWS: updated. * module/dict/tomoe-dict-est.c: fixed a reference count related From kous users.sourceforge.jp Thu Dec 7 13:05:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:05:47 +0900 Subject: [Tomoe-cvs 1761] CVS update: tomoe/module/dict Message-ID: <20061207040547.903482AC02F@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-xml.h diff -u tomoe/module/dict/tomoe-dict-xml.h:1.1 tomoe/module/dict/tomoe-dict-xml.h:1.2 --- tomoe/module/dict/tomoe-dict-xml.h:1.1 Thu Dec 7 10:31:31 2006 +++ tomoe/module/dict/tomoe-dict-xml.h Thu Dec 7 13:05:47 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.h,v 1.1 2006/12/07 01:31:31 kous Exp $ + * $Id: tomoe-dict-xml.h,v 1.2 2006/12/07 04:05:47 kous Exp $ */ #ifndef __TOMOE_DICT_XML_H__ @@ -30,7 +30,7 @@ #include "tomoe-char.h" #include "tomoe-query.h" -#define TOMOE_TYPE_DICT_XML tomoe_type_dict_xml +#define TOMOE_TYPE_DICT_XML (tomoe_dict_xml_get_type ()) #define TOMOE_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXML)) #define TOMOE_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) #define TOMOE_IS_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_XML)) From kous users.sourceforge.jp Thu Dec 7 13:17:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:17:30 +0900 Subject: [Tomoe-cvs 1762] CVS update: tomoe Message-ID: <20061207041730.9FD102AC01E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.405 tomoe/ChangeLog:1.406 --- tomoe/ChangeLog:1.405 Thu Dec 7 13:05:47 2006 +++ tomoe/ChangeLog Thu Dec 7 13:17:30 2006 @@ -1,5 +1,7 @@ 2006-12-07 Kouhei Sutou + * lib/tomoe-module.c: don't load module until it's needed. + * module/dict/tomoe-dict-xml.h: fixed a typo. * NEWS: updated. Index: tomoe/configure.in diff -u tomoe/configure.in:1.44 tomoe/configure.in:1.45 --- tomoe/configure.in:1.44 Tue Dec 5 17:10:23 2006 +++ tomoe/configure.in Thu Dec 7 13:17:30 2006 @@ -176,19 +176,23 @@ AC_SUBST(moduledir) dnl ************************************************************** -dnl Configure for modules for recognizer. +dnl Configure for recognizer modules. dnl ************************************************************** recognizer_moduledir="${moduledir}/recognizer" AC_SUBST(recognizer_moduledir) dnl ************************************************************** -dnl Configure for modules for dictionarie. +dnl Configure for dictionary modules. dnl ************************************************************** dict_moduledir="${moduledir}/dict" AC_SUBST(dict_moduledir) +dnl ************************************************************** +dnl Configure for Unihan dictionary. +dnl ************************************************************** + use_unihan=yes AC_ARG_ENABLE(unihan, [ --disable-unihan disable Unihan detabase], @@ -199,6 +203,61 @@ AC_PATH_PROG(UNZIP, unzip, unzip-not-found) dnl ************************************************************** +dnl Configure for Subverion dictionary. +dnl ************************************************************** + +PKG_CHECK_MODULES(APR, apr-1, [use_svn=yes], [use_svn=no]) + +svn_includes="/usr/local/include /usr/include" +AC_ARG_WITH(svn-include, + [ --with-svn-include=DIR Use the given path to the subversion headers.], + [if test "$withval" != "yes" -a "$withval" != ""; then + svn_includes=$withval + fi]) +AC_MSG_CHECKING([for Subversion headers]) +svn_include="" +for value in $svn_includes ; do + if test -f $value/subversion-1/svn_types.h ; then + svn_include=$value + break + fi +done +if test "x$svn_include" != "x" ; then + AC_MSG_RESULT([$svn_include]) +else + AC_MSG_RESULT([not found]) + use_svn="no" +fi +SVN_CFLAGS="\$(APR_CFLAGS) -I$svn_include/subversion-1" + +svn_libs="/usr/local/lib /usr/lib" +AC_ARG_WITH(svn-lib, + [ --with-svn-lib=DIR Use the given path to the subversion libraries.], + [if test "$withval" != "yes" -a "$withval" != ""; then + SVN_LIBS=$withval + fi]) +AC_MSG_CHECKING([for Subversion libraries]) +svn_lib="" +for value in $svn_libs ; do + if ls $value/libsvn_client-1.* >/dev/null 2>&1; then + svn_lib=$value + break + fi +done +if test "x$svn_lib" != "x" ; then + AC_MSG_RESULT([$svn_lib]) +else + AC_MSG_RESULT([not found]) + use_svn="no" +fi +SVN_LIBS="\$(APR_LIBS) -L$svn_lib -lsvn_client-1 -lsvn_subr-1" + +AC_SUBST(SVN_CFLAGS) +AC_SUBST(SVN_LIBS) + +AM_CONDITIONAL([WITH_SVN], [test "$use_svn" = "yes"]) + +dnl ************************************************************** dnl Bindings: Check for Ruby. dnl ************************************************************** ruby_available="no" From kous users.sourceforge.jp Thu Dec 7 13:17:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:17:30 +0900 Subject: [Tomoe-cvs 1763] CVS update: tomoe/ext/ruby Message-ID: <20061207041730.C75582AC076@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.15 tomoe/ext/ruby/tomoe-rb-dict.c:1.16 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.15 Wed Dec 6 15:28:36 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Thu Dec 7 13:17:30 2006 @@ -47,6 +47,18 @@ NULL); } else if (strcmp(name, "unihan") == 0) { dict = tomoe_dict_new(name, NULL); + } else if (strcmp(name, "svn") == 0) { + VALUE filename, editable, repository, working_copy; + filename = rb_hash_aref(props, CSTR2RVAL("filename")); + editable = rb_hash_aref(props, CSTR2RVAL("editable")); + repository = rb_hash_aref(props, CSTR2RVAL("repository")); + working_copy = rb_hash_aref(props, CSTR2RVAL("working_copy")); + dict = tomoe_dict_new(name, + "filename", RVAL2CSTR(filename), + "editable", RVAL2CBOOL(editable), + "repository", RVAL2CSTR(repository), + "working_copy", RVAL2CSTR(working_copy), + NULL); } else { rb_raise(rb_eArgError, "unknown dictionary type: %s", name); dict = NULL; From kous users.sourceforge.jp Thu Dec 7 13:17:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:17:30 +0900 Subject: [Tomoe-cvs 1764] CVS update: tomoe/lib Message-ID: <20061207041730.EA0562AC01E@users.sourceforge.jp> Index: tomoe/lib/tomoe-module.c diff -u tomoe/lib/tomoe-module.c:1.5 tomoe/lib/tomoe-module.c:1.6 --- tomoe/lib/tomoe-module.c:1.5 Thu Nov 30 13:21:54 2006 +++ tomoe/lib/tomoe-module.c Thu Dec 7 13:17:30 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.c,v 1.5 2006/11/30 04:21:54 kous Exp $ + * $Id: tomoe-module.c,v 1.6 2006/12/07 04:17:30 kous Exp $ */ #include @@ -54,7 +54,7 @@ static gboolean _tomoe_module_load_func (GModule *module, const gchar *func_name, gpointer *symbol); -static gboolean _tomoe_module_match_name (GModule *module, +static gboolean _tomoe_module_match_name (const gchar *mod_path, const gchar *name); static void @@ -167,11 +167,10 @@ TomoeModulePrivate *priv; priv = TOMOE_MODULE_GET_PRIVATE (module); - if (g_type_module_use (G_TYPE_MODULE (module))) { + if (_tomoe_module_match_name (priv->mod_path, name) && + g_type_module_use (G_TYPE_MODULE (module))) { GObject *object = NULL; - if (_tomoe_module_match_name (priv->library, name)) { - object = priv->instantiate (first_property, var_args); - } + object = priv->instantiate (first_property, var_args); g_type_module_unuse (G_TYPE_MODULE (module)); if (object) return object; @@ -260,12 +259,12 @@ } static gboolean -_tomoe_module_match_name (GModule *module, const gchar *name) +_tomoe_module_match_name (const gchar *mod_path, const gchar *name) { gboolean matched; gchar *module_base_name, *normalized_matched_name; - module_base_name = g_path_get_basename (g_module_name (module)); + module_base_name = g_path_get_basename (mod_path); normalized_matched_name = g_module_build_path (NULL, name); matched = (0 == strcmp (module_base_name, normalized_matched_name)); From kous users.sourceforge.jp Thu Dec 7 13:17:31 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:17:31 +0900 Subject: [Tomoe-cvs 1765] CVS update: tomoe/module/dict Message-ID: <20061207041731.18E5A2AC076@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.15 tomoe/module/dict/Makefile.am:1.16 --- tomoe/module/dict/Makefile.am:1.15 Thu Dec 7 10:31:31 2006 +++ tomoe/module/dict/Makefile.am Thu Dec 7 13:17:30 2006 @@ -29,6 +29,7 @@ -I$(top_srcdir)/ext/ruby \ $(TOMOE_CFLAGS) \ $(EST_CFLAGS) \ + $(SVN_CFLAGS) \ $(RUBY_CFLAGS) LIBADD = $(TOMOE_LIBS) @@ -90,3 +91,10 @@ Unihan.zip: $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > $@ endif + +if WITH_SVN +dict_module_LTLIBRARIES += libsvn.la + +libsvn_la_SOURCES = tomoe-dict-svn.c tomoe-dict-xml.h +libsvn_la_LIBADD = $(SVN_LIBS) libxml.la +endif Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.10 tomoe/module/dict/tomoe-dict-xml.c:1.11 --- tomoe/module/dict/tomoe-dict-xml.c:1.10 Thu Dec 7 10:31:31 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Thu Dec 7 13:17:30 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.10 2006/12/07 01:31:31 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.11 2006/12/07 04:17:30 kous Exp $ */ #include @@ -220,7 +220,7 @@ TomoeDictXML *dict = TOMOE_DICT_XML (object); TomoeDictXMLPrivate *priv; - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); switch (prop_id) { case PROP_FILENAME: priv->filename = g_value_dup_string (value); @@ -244,7 +244,7 @@ TomoeDictXML *dict = TOMOE_DICT_XML (object); TomoeDictXMLPrivate *priv; - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); + priv = TOMOE_DICT_XML_GET_PRIVATE (dict); switch (prop_id) { case PROP_FILENAME: g_value_set_string (value, priv->filename); From kous users.sourceforge.jp Thu Dec 7 13:18:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:18:46 +0900 Subject: [Tomoe-cvs 1766] CVS update: tomoe Message-ID: <20061207041846.952122AC076@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.406 tomoe/ChangeLog:1.407 --- tomoe/ChangeLog:1.406 Thu Dec 7 13:17:30 2006 +++ tomoe/ChangeLog Thu Dec 7 13:18:46 2006 @@ -1,5 +1,8 @@ 2006-12-07 Kouhei Sutou + * configure.in, module/dict/tomoe-dict-svn.c: added Subversion + backend. + * lib/tomoe-module.c: don't load module until it's needed. * module/dict/tomoe-dict-xml.h: fixed a typo. From kous users.sourceforge.jp Thu Dec 7 13:18:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:18:46 +0900 Subject: [Tomoe-cvs 1767] CVS update: tomoe/module/dict Message-ID: <20061207041846.BFBBA2AC1E5@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-svn.c diff -u /dev/null tomoe/module/dict/tomoe-dict-svn.c:1.1 --- /dev/null Thu Dec 7 13:18:46 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Thu Dec 7 13:18:46 2006 @@ -0,0 +1,474 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-svn.c,v 1.1 2006/12/07 04:18:46 kous Exp $ + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "tomoe-dict-ptr-array.h" +#include "tomoe-dict-xml.h" + +#define TOMOE_TYPE_DICT_SVN tomoe_type_dict_svn +#define TOMOE_DICT_SVN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_SVN, TomoeDictSvn)) +#define TOMOE_DICT_SVN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_SVN, TomoeDictSvnClass)) +#define TOMOE_IS_DICT_SVN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_SVN)) +#define TOMOE_IS_DICT_SVN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_SVN)) +#define TOMOE_DICT_SVN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_SVN, TomoeDictSvnClass)) + +enum { + PROP_0, + PROP_REPOSITORY, + PROP_WORKING_COPY +}; + +typedef struct _TomoeDictSvn TomoeDictSvn; +typedef struct _TomoeDictSvnClass TomoeDictSvnClass; +struct _TomoeDictSvn +{ + TomoeDictXML object; + gchar *repository; + gchar *working_copy; + + apr_pool_t *pool; + svn_client_ctx_t *ctx; +}; + +struct _TomoeDictSvnClass +{ + TomoeDictXMLClass parent_class; +}; + +static GType tomoe_type_dict_svn = 0; +static GObjectClass *parent_class; + +static apr_pool_t *pool; + +static GObject *constructor (GType type, + guint n_props, + GObjectConstructParam *props); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static const gchar *get_name (TomoeDict *dict); +static gboolean register_char (TomoeDict *dict, + TomoeChar *chr); +static gboolean unregister_char (TomoeDict *dict, + const gchar *utf8); +static TomoeChar *get_char (TomoeDict *dict, + const gchar *utf8); +static GList *search (TomoeDict *dict, + TomoeQuery *query); +static gboolean flush (TomoeDict *dict); +static gboolean is_editable (TomoeDict *dict); +static gchar *get_available_private_utf8 (TomoeDict *dict); + +static void tomoe_dict_svn_init_wc (TomoeDictSvn *dict); +static gboolean tomoe_dict_svn_update (TomoeDictSvn *dict); +static gboolean tomoe_dict_svn_commit (TomoeDictSvn *dict); + +static void +class_init (TomoeDictSvnClass *klass) +{ + GObjectClass *gobject_class; + TomoeDictClass *dict_class; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->constructor = constructor; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + dict_class = TOMOE_DICT_CLASS (klass); + dict_class->get_name = get_name; + dict_class->register_char = register_char; + dict_class->unregister_char = unregister_char; + dict_class->get_char = get_char; + dict_class->search = search; + dict_class->flush = flush; + dict_class->is_editable = is_editable; + dict_class->get_available_private_utf8 = get_available_private_utf8; + + g_object_class_install_property ( + gobject_class, + PROP_REPOSITORY, + g_param_spec_string ( + "repository", + "Repository", + "The repository name of the dictionary", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property ( + gobject_class, + PROP_WORKING_COPY, + g_param_spec_string ( + "working-copy", + "Working copy", + "The working copy directory of the dictionary", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} + +static void +init (TomoeDictSvn *dict) +{ + svn_error_t *err; + + dict->repository = NULL; + dict->working_copy = NULL; + dict->pool = svn_pool_create (NULL); + err = svn_client_create_context (&dict->ctx, dict->pool); + + if (err) { + g_warning ("create context: %s", err->message); + svn_error_clear (err); + } +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (TomoeDictSvnClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (TomoeDictSvn), + 0, + (GInstanceInitFunc) init, + }; + + tomoe_type_dict_svn = g_type_module_register_type (type_module, + TOMOE_TYPE_DICT_XML, + "TomoeDictSvn", + &info, 0); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + apr_status_t status; + + status = apr_initialize (); + if (status) { + char buf[1024]; + apr_strerror (status, buf, sizeof(buf) - 1); + g_warning ("cannot initialize APR: %s", buf); + return; + } + + pool = svn_pool_create (NULL); + svn_utf_initialize (pool); + + register_type (type_module); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_EXIT (void) +{ + apr_pool_destroy (pool); +} + +G_MODULE_EXPORT GObject * +TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist (TOMOE_TYPE_DICT_SVN, first_property, var_args); +} + +static GObject * +constructor (GType type, guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GObjectClass *klass = G_OBJECT_CLASS (parent_class); + TomoeDictSvn *dict; + + object = klass->constructor (type, n_props, props); + dict = TOMOE_DICT_SVN (object); + + tomoe_dict_svn_init_wc (dict); + + return object; +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (object); + + switch (prop_id) { + case PROP_REPOSITORY: + g_free (dict->repository); + dict->repository = g_value_dup_string (value); + break; + case PROP_WORKING_COPY: + g_free (dict->working_copy); + dict->working_copy = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (object); + + switch (prop_id) { + case PROP_REPOSITORY: + g_value_set_string (value, dict->repository); + break; + case PROP_WORKING_COPY: + g_value_set_string (value, dict->working_copy); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + TomoeDictSvn *dict; + + dict = TOMOE_DICT_SVN (object); + + tomoe_dict_svn_commit (dict); + + if (dict->repository) + g_free (dict->repository); + if (dict->working_copy) + g_free (dict->working_copy); + if (dict->pool) + apr_pool_destroy (dict->pool); + + dict->repository = NULL; + dict->working_copy = NULL; + dict->pool = NULL; + dict->ctx = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static const gchar* +get_name (TomoeDict *_dict) +{ + return TOMOE_DICT_CLASS (parent_class)->get_name (_dict); +} + +static gboolean +register_char (TomoeDict *_dict, TomoeChar *chr) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + + return (tomoe_dict_svn_update (dict) && + TOMOE_DICT_CLASS (parent_class)->register_char (_dict, chr) && + tomoe_dict_svn_commit (dict)); +} + +static gboolean +unregister_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + + return (tomoe_dict_svn_update (dict) && + TOMOE_DICT_CLASS (parent_class)->unregister_char (_dict, utf8) && + tomoe_dict_svn_commit (dict)); +} + +static TomoeChar * +get_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); + + if (tomoe_dict_svn_update (dict)) + return TOMOE_DICT_CLASS (parent_class)->get_char (_dict, utf8); + else + return NULL; +} + +static GList * +search (TomoeDict *_dict, TomoeQuery *query) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); + + if (tomoe_dict_svn_update (dict)) + return TOMOE_DICT_CLASS (parent_class)->search (_dict, query); + else + return NULL; +} + +static gboolean +flush (TomoeDict *_dict) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + + return (tomoe_dict_svn_update (dict) && + TOMOE_DICT_CLASS (parent_class)->flush (_dict) && + tomoe_dict_svn_commit (dict)); +} + +static gboolean +is_editable (TomoeDict *_dict) +{ + return TOMOE_DICT_CLASS (parent_class)->is_editable (_dict); +} + +static gchar * +get_available_private_utf8 (TomoeDict *_dict) +{ + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); + + if (tomoe_dict_svn_update (dict)) + return TOMOE_DICT_CLASS (parent_class)->get_available_private_utf8 (_dict); + else + return NULL; +} + + +static void +tomoe_dict_svn_init_wc (TomoeDictSvn *dict) +{ + svn_error_t *err; + svn_opt_revision_t revision; + apr_pool_t *sub_pool; + + g_return_if_fail (dict->working_copy); + + if (g_file_test (dict->working_copy, G_FILE_TEST_EXISTS)) + return; + + g_return_if_fail (dict->ctx); + g_return_if_fail (dict->repository); + + sub_pool = svn_pool_create (dict->pool); + revision.kind = svn_opt_revision_head; + err = svn_client_checkout (NULL, dict->repository, dict->working_copy, + &revision, TRUE, dict->ctx, sub_pool); + apr_pool_destroy (sub_pool); + + if (err) { + g_warning ("failed to checkout: %s", err->message); + svn_error_clear (err); + } +} + +static gboolean +tomoe_dict_svn_update (TomoeDictSvn *dict) +{ + svn_error_t *err; + svn_opt_revision_t revision; + apr_pool_t *sub_pool; + + g_return_val_if_fail (dict->working_copy, FALSE); + g_return_val_if_fail (g_file_test (dict->working_copy, G_FILE_TEST_EXISTS), + FALSE); + + g_return_val_if_fail (dict->ctx, FALSE); + + sub_pool = svn_pool_create (dict->pool); + revision.kind = svn_opt_revision_head; + err = svn_client_update (NULL, dict->working_copy, &revision, TRUE, + dict->ctx, sub_pool); + apr_pool_destroy (sub_pool); + + if (err) { + g_warning ("failed to update: %s", err->message); + svn_error_clear (err); + return FALSE; + } else { + return TRUE; + } +} + +static gboolean +tomoe_dict_svn_commit (TomoeDictSvn *dict) +{ + svn_error_t *err; + apr_array_header_t *targets; + apr_pool_t *sub_pool; + + g_return_val_if_fail (dict->working_copy, FALSE); + g_return_val_if_fail (g_file_test (dict->working_copy, G_FILE_TEST_EXISTS), + FALSE); + + g_return_val_if_fail (dict->ctx, FALSE); + + sub_pool = svn_pool_create (dict->pool); + targets = apr_array_make (sub_pool, 1, sizeof(gchar *)); + APR_ARRAY_IDX(targets, 0, gchar *) = dict->working_copy; + err = svn_client_commit (NULL, targets, FALSE, dict->ctx, sub_pool); + apr_pool_destroy (sub_pool); + + if (err) { + g_warning ("failed to commit: %s", err->message); + svn_error_clear (err); + return FALSE; + } else { + return TRUE; + } +} + +/* +vi:ts=4:nowrap:ai:expandtab +*/ From kous users.sourceforge.jp Thu Dec 7 13:59:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:59:07 +0900 Subject: [Tomoe-cvs 1768] CVS update: tomoe Message-ID: <20061207045907.1F3DE2AC076@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.407 tomoe/ChangeLog:1.408 --- tomoe/ChangeLog:1.407 Thu Dec 7 13:18:46 2006 +++ tomoe/ChangeLog Thu Dec 7 13:59:06 2006 @@ -1,5 +1,9 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-svn.c, module/dict/Makefile.am: used + delegate instead of inheritance. + * test/dict_spec.rb: added tests for TomoeDictSvn. + * configure.in, module/dict/tomoe-dict-svn.c: added Subversion backend. From kous users.sourceforge.jp Thu Dec 7 13:59:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:59:07 +0900 Subject: [Tomoe-cvs 1769] CVS update: tomoe/ext/ruby Message-ID: <20061207045907.4B2902AC1EA@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.16 tomoe/ext/ruby/tomoe-rb-dict.c:1.17 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.16 Thu Dec 7 13:17:30 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Thu Dec 7 13:59:07 2006 @@ -48,14 +48,12 @@ } else if (strcmp(name, "unihan") == 0) { dict = tomoe_dict_new(name, NULL); } else if (strcmp(name, "svn") == 0) { - VALUE filename, editable, repository, working_copy; - filename = rb_hash_aref(props, CSTR2RVAL("filename")); - editable = rb_hash_aref(props, CSTR2RVAL("editable")); + VALUE dictionary, repository, working_copy; + dictionary = rb_hash_aref(props, CSTR2RVAL("dictionary")); repository = rb_hash_aref(props, CSTR2RVAL("repository")); working_copy = rb_hash_aref(props, CSTR2RVAL("working_copy")); dict = tomoe_dict_new(name, - "filename", RVAL2CSTR(filename), - "editable", RVAL2CBOOL(editable), + "dictionary", RVAL2TDIC(dictionary), "repository", RVAL2CSTR(repository), "working_copy", RVAL2CSTR(working_copy), NULL); From kous users.sourceforge.jp Thu Dec 7 13:59:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:59:07 +0900 Subject: [Tomoe-cvs 1770] CVS update: tomoe/module/dict Message-ID: <20061207045907.6FA5A2AC076@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.16 tomoe/module/dict/Makefile.am:1.17 --- tomoe/module/dict/Makefile.am:1.16 Thu Dec 7 13:17:30 2006 +++ tomoe/module/dict/Makefile.am Thu Dec 7 13:59:07 2006 @@ -95,6 +95,6 @@ if WITH_SVN dict_module_LTLIBRARIES += libsvn.la -libsvn_la_SOURCES = tomoe-dict-svn.c tomoe-dict-xml.h -libsvn_la_LIBADD = $(SVN_LIBS) libxml.la +libsvn_la_SOURCES = tomoe-dict-svn.c +libsvn_la_LIBADD = $(SVN_LIBS) endif Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.1 tomoe/module/dict/tomoe-dict-svn.c:1.2 --- tomoe/module/dict/tomoe-dict-svn.c:1.1 Thu Dec 7 13:18:46 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Thu Dec 7 13:59:07 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.1 2006/12/07 04:18:46 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.2 2006/12/07 04:59:07 kous Exp $ */ #include @@ -33,7 +33,6 @@ #include #include "tomoe-dict-ptr-array.h" -#include "tomoe-dict-xml.h" #define TOMOE_TYPE_DICT_SVN tomoe_type_dict_svn #define TOMOE_DICT_SVN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_SVN, TomoeDictSvn)) @@ -44,6 +43,7 @@ enum { PROP_0, + PROP_DICTIONARY, PROP_REPOSITORY, PROP_WORKING_COPY }; @@ -52,17 +52,19 @@ typedef struct _TomoeDictSvnClass TomoeDictSvnClass; struct _TomoeDictSvn { - TomoeDictXML object; + TomoeDict object; gchar *repository; gchar *working_copy; + TomoeDict *sub_dict; + apr_pool_t *pool; svn_client_ctx_t *ctx; }; struct _TomoeDictSvnClass { - TomoeDictXMLClass parent_class; + TomoeDictClass parent_class; }; static GType tomoe_type_dict_svn = 0; @@ -126,6 +128,15 @@ g_object_class_install_property ( gobject_class, + PROP_DICTIONARY, + g_param_spec_object ( + "dictionary", + "Dictionary", + "The dictionary to delegate of the dictionary", + TOMOE_TYPE_DICT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property ( + gobject_class, PROP_REPOSITORY, g_param_spec_string ( "repository", @@ -151,6 +162,7 @@ dict->repository = NULL; dict->working_copy = NULL; + dict->sub_dict = NULL; dict->pool = svn_pool_create (NULL); err = svn_client_create_context (&dict->ctx, dict->pool); @@ -177,7 +189,7 @@ }; tomoe_type_dict_svn = g_type_module_register_type (type_module, - TOMOE_TYPE_DICT_XML, + TOMOE_TYPE_DICT, "TomoeDictSvn", &info, 0); } @@ -214,8 +226,7 @@ } static GObject * -constructor (GType type, guint n_props, - GObjectConstructParam *props) +constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *object; GObjectClass *klass = G_OBJECT_CLASS (parent_class); @@ -238,6 +249,13 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (object); switch (prop_id) { + case PROP_DICTIONARY: + if (dict->sub_dict) + g_object_unref (dict->sub_dict); + dict->sub_dict = g_value_get_object (value); + if (dict->sub_dict) + g_object_ref (dict->sub_dict); + break; case PROP_REPOSITORY: g_free (dict->repository); dict->repository = g_value_dup_string (value); @@ -262,6 +280,9 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (object); switch (prop_id) { + case PROP_DICTIONARY: + g_value_set_object (value, dict->sub_dict); + break; case PROP_REPOSITORY: g_value_set_string (value, dict->repository); break; @@ -281,17 +302,20 @@ dict = TOMOE_DICT_SVN (object); - tomoe_dict_svn_commit (dict); + /* tomoe_dict_svn_commit (dict); */ if (dict->repository) g_free (dict->repository); if (dict->working_copy) g_free (dict->working_copy); + if (dict->sub_dict) + g_object_unref (dict->sub_dict); if (dict->pool) apr_pool_destroy (dict->pool); dict->repository = NULL; dict->working_copy = NULL; + dict->sub_dict = NULL; dict->pool = NULL; dict->ctx = NULL; @@ -301,7 +325,12 @@ static const gchar* get_name (TomoeDict *_dict) { - return TOMOE_DICT_CLASS (parent_class)->get_name (_dict); + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), NULL); + + return tomoe_dict_get_name (dict->sub_dict); } static gboolean @@ -310,9 +339,10 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); return (tomoe_dict_svn_update (dict) && - TOMOE_DICT_CLASS (parent_class)->register_char (_dict, chr) && + tomoe_dict_register_char (dict->sub_dict, chr) && tomoe_dict_svn_commit (dict)); } @@ -322,9 +352,10 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); return (tomoe_dict_svn_update (dict) && - TOMOE_DICT_CLASS (parent_class)->unregister_char (_dict, utf8) && + tomoe_dict_unregister_char (dict->sub_dict, utf8) && tomoe_dict_svn_commit (dict)); } @@ -334,9 +365,10 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), NULL); if (tomoe_dict_svn_update (dict)) - return TOMOE_DICT_CLASS (parent_class)->get_char (_dict, utf8); + return tomoe_dict_get_char (dict->sub_dict, utf8); else return NULL; } @@ -347,9 +379,10 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), NULL); if (tomoe_dict_svn_update (dict)) - return TOMOE_DICT_CLASS (parent_class)->search (_dict, query); + return tomoe_dict_search (dict->sub_dict, query); else return NULL; } @@ -360,16 +393,22 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); return (tomoe_dict_svn_update (dict) && - TOMOE_DICT_CLASS (parent_class)->flush (_dict) && + tomoe_dict_flush (dict->sub_dict) && tomoe_dict_svn_commit (dict)); } static gboolean is_editable (TomoeDict *_dict) { - return TOMOE_DICT_CLASS (parent_class)->is_editable (_dict); + TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); + + return tomoe_dict_is_editable (dict->sub_dict); } static gchar * @@ -378,9 +417,10 @@ TomoeDictSvn *dict = TOMOE_DICT_SVN (_dict); g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); + g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); if (tomoe_dict_svn_update (dict)) - return TOMOE_DICT_CLASS (parent_class)->get_available_private_utf8 (_dict); + return tomoe_dict_get_available_private_utf8 (dict->sub_dict); else return NULL; } @@ -445,6 +485,7 @@ tomoe_dict_svn_commit (TomoeDictSvn *dict) { svn_error_t *err; + svn_client_commit_info_t *info; apr_array_header_t *targets; apr_pool_t *sub_pool; @@ -455,9 +496,9 @@ g_return_val_if_fail (dict->ctx, FALSE); sub_pool = svn_pool_create (dict->pool); - targets = apr_array_make (sub_pool, 1, sizeof(gchar *)); - APR_ARRAY_IDX(targets, 0, gchar *) = dict->working_copy; - err = svn_client_commit (NULL, targets, FALSE, dict->ctx, sub_pool); + targets = apr_array_make (sub_pool, 1, sizeof(gchar)); + APR_ARRAY_PUSH(targets, gchar *) = dict->working_copy; + err = svn_client_commit (&info, targets, FALSE, dict->ctx, sub_pool); apr_pool_destroy (sub_pool); if (err) { From kous users.sourceforge.jp Thu Dec 7 13:59:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 13:59:07 +0900 Subject: [Tomoe-cvs 1771] CVS update: tomoe/test Message-ID: <20061207045907.947B12AC1EA@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.14 tomoe/test/dict_spec.rb:1.15 --- tomoe/test/dict_spec.rb:1.14 Thu Dec 7 10:38:06 2006 +++ tomoe/test/dict_spec.rb Thu Dec 7 13:59:07 2006 @@ -31,6 +31,43 @@ end end + specify "should load Subverion dictionary" do + begin + repos = File.join(tmp_dir, "svn.repos") + repos_url = "file://#{repos}" + wc = File.join(tmp_dir, "svn.wc") + dict_file = File.join(wc, "dict.xml") + + `svnadmin create #{repos.dump}` + `svn co #{repos_url.dump} #{wc.dump}` + FileUtils.cp(@dict_file.path, dict_file) + `svn add #{dict_file.dump}` + + `svnlook youngest #{repos.dump}`.chomp.should == "0" + `svn ci -m '' #{wc.dump}` + `svnlook youngest #{repos.dump}`.chomp.should == "1" + + xml_dict = Tomoe::Dict.new("xml", + "filename" => dict_file, + "editable" => true) + dict = Tomoe::Dict.new("svn", + "dictionary" => xml_dict, + "repository" => repos_url, + "working_copy" => wc) + a = dict[@utf8] + a.writing.strokes.should == @strokes + + `svnlook youngest #{repos.dump}`.chomp.should == "1" + dict.register(Tomoe::Char.new) + `svnlook youngest #{repos.dump}`.chomp.should == "1" + dict.flush + `svnlook youngest #{repos.dump}`.chomp.should == "2" + ensure + FileUtils.rm_rf(repos) + FileUtils.rm_rf(wc) + end + end + def setup_strokes @strokes = [ [ From kous users.sourceforge.jp Thu Dec 7 14:07:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:07:25 +0900 Subject: [Tomoe-cvs 1772] CVS update: tomoe Message-ID: <20061207050725.1223E2AC076@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.408 tomoe/ChangeLog:1.409 --- tomoe/ChangeLog:1.408 Thu Dec 7 13:59:06 2006 +++ tomoe/ChangeLog Thu Dec 7 14:07:24 2006 @@ -1,5 +1,8 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-xml.[ch], module/dict/Makefile.am: + reverted. merged tomoe-dict-xml.c with tomoe-dict-xml.h. + * module/dict/tomoe-dict-svn.c, module/dict/Makefile.am: used delegate instead of inheritance. * test/dict_spec.rb: added tests for TomoeDictSvn. From kous users.sourceforge.jp Thu Dec 7 14:07:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:07:25 +0900 Subject: [Tomoe-cvs 1773] CVS update: tomoe/module/dict Message-ID: <20061207050725.421CA2AC094@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.11 tomoe/module/dict/tomoe-dict-xml.c:1.12 --- tomoe/module/dict/tomoe-dict-xml.c:1.11 Thu Dec 7 13:17:30 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Thu Dec 7 14:07:25 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.11 2006/12/07 04:17:30 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.12 2006/12/07 05:07:25 kous Exp $ */ #include @@ -38,14 +38,25 @@ #include #include "tomoe-dict-ptr-array.h" -#include "tomoe-dict-xml.h" -#define TOMOE_DICT_XML_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXMLPrivate)) +#define TOMOE_TYPE_DICT_XML tomoe_type_dict_xml +#define TOMOE_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXML)) +#define TOMOE_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) +#define TOMOE_IS_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_XML)) +#define TOMOE_IS_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_XML)) +#define TOMOE_DICT_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) -typedef struct _TomoeDictXMLPrivate TomoeDictXMLPrivate; -struct _TomoeDictXMLPrivate +enum { + PROP_0, + PROP_FILENAME, + PROP_EDITABLE +}; + +typedef struct _TomoeDictXML TomoeDictXML; +typedef struct _TomoeDictXMLClass TomoeDictXMLClass; +struct _TomoeDictXML { + TomoeDict object; gchar *filename; gchar *name; GPtrArray *chars; @@ -54,10 +65,9 @@ gboolean modified; }; -enum { - PROP_0, - PROP_FILENAME, - PROP_EDITABLE +struct _TomoeDictXMLClass +{ + TomoeDictClass parent_class; }; static GType tomoe_type_dict_xml = 0; @@ -90,12 +100,6 @@ static gboolean tomoe_dict_xml_load (TomoeDictXML *dict); static gboolean tomoe_dict_xml_save (TomoeDictXML *dict); -GType -tomoe_dict_xml_get_type (void) -{ - return tomoe_type_dict_xml; -} - static void class_init (TomoeDictXMLClass *klass) { @@ -140,20 +144,16 @@ "Editable flag", TRUE, G_PARAM_READWRITE)); - - g_type_class_add_private (gobject_class, sizeof (TomoeDictXMLPrivate)); } static void init (TomoeDictXML *dict) { - TomoeDictXMLPrivate *priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - - priv->filename = NULL; - priv->name = NULL; - priv->chars = g_ptr_array_new(); - priv->modified = FALSE; - priv->editable = FALSE; + dict->filename = NULL; + dict->name = NULL; + dict->chars = g_ptr_array_new(); + dict->modified = FALSE; + dict->editable = FALSE; } static void @@ -218,17 +218,15 @@ GParamSpec *pspec) { TomoeDictXML *dict = TOMOE_DICT_XML (object); - TomoeDictXMLPrivate *priv; - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); switch (prop_id) { - case PROP_FILENAME: - priv->filename = g_value_dup_string (value); + case PROP_FILENAME: + dict->filename = g_value_dup_string (value); break; - case PROP_EDITABLE: - priv->editable = g_value_get_boolean (value); + case PROP_EDITABLE: + dict->editable = g_value_get_boolean (value); break; - default: + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } @@ -242,17 +240,15 @@ GParamSpec *pspec) { TomoeDictXML *dict = TOMOE_DICT_XML (object); - TomoeDictXMLPrivate *priv; - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); switch (prop_id) { - case PROP_FILENAME: - g_value_set_string (value, priv->filename); + case PROP_FILENAME: + g_value_set_string (value, dict->filename); break; - case PROP_EDITABLE: - g_value_set_boolean (value, priv->editable); + case PROP_EDITABLE: + g_value_set_boolean (value, dict->editable); break; - default: + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } @@ -262,23 +258,21 @@ dispose (GObject *object) { TomoeDictXML *dict; - TomoeDictXMLPrivate *priv; dict = TOMOE_DICT_XML(object); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); flush (TOMOE_DICT (dict)); - if (priv->name) - g_free (priv->name); - if (priv->filename) - g_free (priv->filename); - if (priv->chars) - TOMOE_PTR_ARRAY_FREE_ALL(priv->chars, g_object_unref); - - priv->name = NULL; - priv->filename = NULL; - priv->chars = NULL; + if (dict->name) + g_free (dict->name); + if (dict->filename) + g_free (dict->filename); + if (dict->chars) + TOMOE_PTR_ARRAY_FREE_ALL(dict->chars, g_object_unref); + + dict->name = NULL; + dict->filename = NULL; + dict->chars = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -287,25 +281,20 @@ get_name (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; - g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - return priv->name; + return dict->name; } static gboolean register_char (TomoeDict *_dict, TomoeChar *chr) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - if (_tomoe_dict_ptr_array_register_char (priv->chars, chr)) { - priv->modified = TRUE; + if (_tomoe_dict_ptr_array_register_char (dict->chars, chr)) { + dict->modified = TRUE; return TRUE; } else { return FALSE; @@ -316,13 +305,11 @@ unregister_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - if (_tomoe_dict_ptr_array_unregister_char (priv->chars, utf8)) { - priv->modified = TRUE; + if (_tomoe_dict_ptr_array_unregister_char (dict->chars, utf8)) { + dict->modified = TRUE; return TRUE; } else { return FALSE; @@ -333,37 +320,31 @@ get_char (TomoeDict *_dict, const gchar *utf8) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - return _tomoe_dict_ptr_array_get_char (priv->chars, utf8); + return _tomoe_dict_ptr_array_get_char (dict->chars, utf8); } static GList * search (TomoeDict *_dict, TomoeQuery *query) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - return _tomoe_dict_ptr_array_search (priv->chars, query); + return _tomoe_dict_ptr_array_search (dict->chars, query); } static gboolean flush (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - if (priv->editable && priv->modified) { - priv->modified = FALSE; + if (dict->editable && dict->modified) { + dict->modified = FALSE; return tomoe_dict_xml_save (dict); } else { return TRUE; @@ -374,24 +355,20 @@ is_editable (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), FALSE); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - return priv->editable; + return dict->editable; } static gchar * get_available_private_utf8 (TomoeDict *_dict) { TomoeDictXML *dict = TOMOE_DICT_XML (_dict); - TomoeDictXMLPrivate *priv; g_return_val_if_fail (TOMOE_IS_DICT_XML (dict), NULL); - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - return _tomoe_dict_ptr_array_get_available_private_utf8 (priv->chars); + return _tomoe_dict_ptr_array_get_available_private_utf8 (dict->chars); } static gboolean @@ -399,19 +376,16 @@ { gboolean success = TRUE; TomoeXMLParsedData result; - TomoeDictXMLPrivate *priv; - - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); result.name = NULL; - result.chars = priv->chars; - success = _tomoe_xml_parser_parse_dictionary_file (priv->filename, &result); + result.chars = dict->chars; + success = _tomoe_xml_parser_parse_dictionary_file (dict->filename, &result); if (result.name) { - g_free (priv->name); - priv->name = g_strdup (result.name); + g_free (dict->name); + dict->name = g_strdup (result.name); g_free (result.name); } - _tomoe_dict_ptr_array_sort (priv->chars); + _tomoe_dict_ptr_array_sort (dict->chars); return success; } @@ -419,19 +393,15 @@ static gboolean tomoe_dict_xml_save (TomoeDictXML *dict) { - TomoeDictXMLPrivate *priv; FILE *f; gchar *head; const gchar *foot = "\n"; guint i; - g_return_val_if_fail (TOMOE_IS_DICT (dict), FALSE); + if (!dict->editable) return FALSE; - priv = TOMOE_DICT_XML_GET_PRIVATE (dict); - if (!priv->editable) return FALSE; - - f = fopen (priv->filename, "wb"); + f = fopen (dict->filename, "wb"); g_return_val_if_fail (f, FALSE); /* write the header */ @@ -441,18 +411,18 @@ if (fwrite (head, strlen (head), 1, f) < 1) goto ERROR; g_free (head); - if (priv->name) + if (dict->name) head = g_markup_printf_escaped ("\n", - priv->name); + dict->name); else head = g_strdup ("\n"); if (fwrite (head, strlen (head), 1, f) < 1) goto ERROR; /* write each characters */ - for (i = 0; i < priv->chars->len; i++) { + for (i = 0; i < dict->chars->len; i++) { gchar *xml; gboolean failed; - TomoeChar* chr = (TomoeChar*)g_ptr_array_index (priv->chars, i); + TomoeChar* chr = (TomoeChar*)g_ptr_array_index (dict->chars, i); xml = tomoe_char_to_xml (chr); if (!xml) goto ERROR; @@ -468,12 +438,12 @@ /* clean */ g_free (head); fclose (f); - priv->modified = FALSE; + dict->modified = FALSE; return TRUE; ERROR: g_free (head); - g_warning ("Faild to write %s.", priv->filename); + g_warning ("Faild to write %s.", dict->filename); fclose (f); return FALSE; } Index: tomoe/module/dict/tomoe-dict-xml.h diff -u tomoe/module/dict/tomoe-dict-xml.h:1.2 tomoe/module/dict/tomoe-dict-xml.h:removed --- tomoe/module/dict/tomoe-dict-xml.h:1.2 Thu Dec 7 13:05:47 2006 +++ tomoe/module/dict/tomoe-dict-xml.h Thu Dec 7 14:07:25 2006 @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2006 Kouhei Sutou - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA - * - * $Id: tomoe-dict-xml.h,v 1.2 2006/12/07 04:05:47 kous Exp $ - */ - -#ifndef __TOMOE_DICT_XML_H__ -#define __TOMOE_DICT_XML_H__ - -#include - -G_BEGIN_DECLS - -#include "tomoe-char.h" -#include "tomoe-query.h" - -#define TOMOE_TYPE_DICT_XML (tomoe_dict_xml_get_type ()) -#define TOMOE_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_XML, TomoeDictXML)) -#define TOMOE_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) -#define TOMOE_IS_DICT_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_XML)) -#define TOMOE_IS_DICT_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_XML)) -#define TOMOE_DICT_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_XML, TomoeDictXMLClass)) - -typedef struct _TomoeDictXML TomoeDictXML; -typedef struct _TomoeDictXMLClass TomoeDictXMLClass; -struct _TomoeDictXML -{ - TomoeDict object; -}; - -struct _TomoeDictXMLClass -{ - TomoeDictClass parent_class; -}; - -GType tomoe_dict_xml_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __TOMOE_DICT_XML_H__ */ - -/* -vi:ts=4:nowrap:ai:expandtab -*/ Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.17 tomoe/module/dict/Makefile.am:1.18 --- tomoe/module/dict/Makefile.am:1.17 Thu Dec 7 13:59:07 2006 +++ tomoe/module/dict/Makefile.am Thu Dec 7 14:07:25 2006 @@ -43,9 +43,7 @@ dict_module_LTLIBRARIES = libxml.la -libxml_la_SOURCES = \ - tomoe-dict-xml.c tomoe-dict-xml.h \ - $(ptr_array_based_dict_sources) +libxml_la_SOURCES = tomoe-dict-xml.c $(ptr_array_based_dict_sources) if WITH_EST dict_module_LTLIBRARIES += libest.la From kous users.sourceforge.jp Thu Dec 7 14:08:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:08:29 +0900 Subject: [Tomoe-cvs 1774] CVS update: tomoe Message-ID: <20061207050829.C34452AC094@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.409 tomoe/ChangeLog:1.410 --- tomoe/ChangeLog:1.409 Thu Dec 7 14:07:24 2006 +++ tomoe/ChangeLog Thu Dec 7 14:08:29 2006 @@ -1,5 +1,8 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-svn.c: don't initialize working copy. + * ext/ruby/tomoe-rb-dict.c: followed the change. + * module/dict/tomoe-dict-xml.[ch], module/dict/Makefile.am: reverted. merged tomoe-dict-xml.c with tomoe-dict-xml.h. From kous users.sourceforge.jp Thu Dec 7 14:08:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:08:29 +0900 Subject: [Tomoe-cvs 1775] CVS update: tomoe/ext/ruby Message-ID: <20061207050829.F25F52AC0B4@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.17 tomoe/ext/ruby/tomoe-rb-dict.c:1.18 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.17 Thu Dec 7 13:59:07 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Thu Dec 7 14:08:29 2006 @@ -48,13 +48,11 @@ } else if (strcmp(name, "unihan") == 0) { dict = tomoe_dict_new(name, NULL); } else if (strcmp(name, "svn") == 0) { - VALUE dictionary, repository, working_copy; + VALUE dictionary, working_copy; dictionary = rb_hash_aref(props, CSTR2RVAL("dictionary")); - repository = rb_hash_aref(props, CSTR2RVAL("repository")); working_copy = rb_hash_aref(props, CSTR2RVAL("working_copy")); dict = tomoe_dict_new(name, "dictionary", RVAL2TDIC(dictionary), - "repository", RVAL2CSTR(repository), "working_copy", RVAL2CSTR(working_copy), NULL); } else { From kous users.sourceforge.jp Thu Dec 7 14:08:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:08:30 +0900 Subject: [Tomoe-cvs 1776] CVS update: tomoe/module/dict Message-ID: <20061207050830.23B462AC094@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.2 tomoe/module/dict/tomoe-dict-svn.c:1.3 --- tomoe/module/dict/tomoe-dict-svn.c:1.2 Thu Dec 7 13:59:07 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Thu Dec 7 14:08:30 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.2 2006/12/07 04:59:07 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.3 2006/12/07 05:08:30 kous Exp $ */ #include @@ -44,7 +44,6 @@ enum { PROP_0, PROP_DICTIONARY, - PROP_REPOSITORY, PROP_WORKING_COPY }; @@ -53,7 +52,6 @@ struct _TomoeDictSvn { TomoeDict object; - gchar *repository; gchar *working_copy; TomoeDict *sub_dict; @@ -97,7 +95,6 @@ static gboolean is_editable (TomoeDict *dict); static gchar *get_available_private_utf8 (TomoeDict *dict); -static void tomoe_dict_svn_init_wc (TomoeDictSvn *dict); static gboolean tomoe_dict_svn_update (TomoeDictSvn *dict); static gboolean tomoe_dict_svn_commit (TomoeDictSvn *dict); @@ -137,15 +134,6 @@ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property ( gobject_class, - PROP_REPOSITORY, - g_param_spec_string ( - "repository", - "Repository", - "The repository name of the dictionary", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property ( - gobject_class, PROP_WORKING_COPY, g_param_spec_string ( "working-copy", @@ -160,7 +148,6 @@ { svn_error_t *err; - dict->repository = NULL; dict->working_copy = NULL; dict->sub_dict = NULL; dict->pool = svn_pool_create (NULL); @@ -235,8 +222,6 @@ object = klass->constructor (type, n_props, props); dict = TOMOE_DICT_SVN (object); - tomoe_dict_svn_init_wc (dict); - return object; } @@ -256,10 +241,6 @@ if (dict->sub_dict) g_object_ref (dict->sub_dict); break; - case PROP_REPOSITORY: - g_free (dict->repository); - dict->repository = g_value_dup_string (value); - break; case PROP_WORKING_COPY: g_free (dict->working_copy); dict->working_copy = g_value_dup_string (value); @@ -283,9 +264,6 @@ case PROP_DICTIONARY: g_value_set_object (value, dict->sub_dict); break; - case PROP_REPOSITORY: - g_value_set_string (value, dict->repository); - break; case PROP_WORKING_COPY: g_value_set_string (value, dict->working_copy); break; @@ -304,8 +282,6 @@ /* tomoe_dict_svn_commit (dict); */ - if (dict->repository) - g_free (dict->repository); if (dict->working_copy) g_free (dict->working_copy); if (dict->sub_dict) @@ -313,7 +289,6 @@ if (dict->pool) apr_pool_destroy (dict->pool); - dict->repository = NULL; dict->working_copy = NULL; dict->sub_dict = NULL; dict->pool = NULL; @@ -426,33 +401,6 @@ } -static void -tomoe_dict_svn_init_wc (TomoeDictSvn *dict) -{ - svn_error_t *err; - svn_opt_revision_t revision; - apr_pool_t *sub_pool; - - g_return_if_fail (dict->working_copy); - - if (g_file_test (dict->working_copy, G_FILE_TEST_EXISTS)) - return; - - g_return_if_fail (dict->ctx); - g_return_if_fail (dict->repository); - - sub_pool = svn_pool_create (dict->pool); - revision.kind = svn_opt_revision_head; - err = svn_client_checkout (NULL, dict->repository, dict->working_copy, - &revision, TRUE, dict->ctx, sub_pool); - apr_pool_destroy (sub_pool); - - if (err) { - g_warning ("failed to checkout: %s", err->message); - svn_error_clear (err); - } -} - static gboolean tomoe_dict_svn_update (TomoeDictSvn *dict) { From kous users.sourceforge.jp Thu Dec 7 14:12:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:12:30 +0900 Subject: [Tomoe-cvs 1777] CVS update: tomoe Message-ID: <20061207051230.4479F2AC076@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.410 tomoe/ChangeLog:1.411 --- tomoe/ChangeLog:1.410 Thu Dec 7 14:08:29 2006 +++ tomoe/ChangeLog Thu Dec 7 14:12:30 2006 @@ -1,6 +1,9 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-svn.c: ensure flush all changes. + * module/dict/tomoe-dict-svn.c: don't initialize working copy. + * ext/ruby/tomoe-rb-dict.c: followed the change. * module/dict/tomoe-dict-xml.[ch], module/dict/Makefile.am: From kous users.sourceforge.jp Thu Dec 7 14:12:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:12:30 +0900 Subject: [Tomoe-cvs 1778] CVS update: tomoe/module/dict Message-ID: <20061207051230.6F2AD2AC0D9@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.3 tomoe/module/dict/tomoe-dict-svn.c:1.4 --- tomoe/module/dict/tomoe-dict-svn.c:1.3 Thu Dec 7 14:08:30 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Thu Dec 7 14:12:30 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.3 2006/12/07 05:08:30 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.4 2006/12/07 05:12:30 kous Exp $ */ #include @@ -280,7 +280,9 @@ dict = TOMOE_DICT_SVN (object); - /* tomoe_dict_svn_commit (dict); */ + if (dict->working_copy && + g_file_test (dict->working_copy, G_FILE_TEST_EXISTS)) + flush (TOMOE_DICT (object)); if (dict->working_copy) g_free (dict->working_copy); From kous users.sourceforge.jp Thu Dec 7 14:34:44 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:34:44 +0900 Subject: [Tomoe-cvs 1779] CVS update: tomoe Message-ID: <20061207053444.B12FF2AC0B4@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.411 tomoe/ChangeLog:1.412 --- tomoe/ChangeLog:1.411 Thu Dec 7 14:12:30 2006 +++ tomoe/ChangeLog Thu Dec 7 14:34:44 2006 @@ -1,7 +1,9 @@ 2006-12-07 Kouhei Sutou - * module/dict/tomoe-dict-svn.c: ensure flush all changes. + * module/dict/tomoe-dict-svn.c: don't always update. + * benchmark/search-by-dict.rb: supported TomoeDictSvn. + * module/dict/tomoe-dict-svn.c: ensure flush all changes. * module/dict/tomoe-dict-svn.c: don't initialize working copy. * ext/ruby/tomoe-rb-dict.c: followed the change. From kous users.sourceforge.jp Thu Dec 7 14:34:44 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:34:44 +0900 Subject: [Tomoe-cvs 1780] CVS update: tomoe/benchmark Message-ID: <20061207053444.D3FD02AC0EE@users.sourceforge.jp> Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.2 tomoe/benchmark/search-by-dict.rb:1.3 --- tomoe/benchmark/search-by-dict.rb:1.2 Fri Dec 1 14:27:16 2006 +++ tomoe/benchmark/search-by-dict.rb Thu Dec 7 14:34:44 2006 @@ -11,6 +11,8 @@ n = 10 use_est = false +use_svn = true +tmp_dir = TomoeSpecUtils::Config.tmp_dir Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| if use_est @@ -18,6 +20,25 @@ "name" => File.basename(dictionary), "database_name" => dictionary.sub(/\.xml$/, ''), "editable" => false) + elsif use_svn + repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) + FileUtils.mkdir_p(repos) + repos_url = "file://#{repos}" + wc = File.join(tmp_dir, "svn.wc", File.basename(dictionary)) + dict_file = File.join(wc, "dict.xml") + + `svnadmin create #{repos.dump}` + `svn co #{repos_url.dump} #{wc.dump}` + FileUtils.cp(dictionary, dict_file) + `svn add #{dict_file.dump}` + `svn ci -m '' #{wc.dump}` + + xml_dict = Tomoe::Dict.new("xml", + "filename" => dict_file, + "editable" => true) + dict = Tomoe::Dict.new("svn", + "dictionary" => xml_dict, + "working_copy" => wc) else dict = Tomoe::Dict.new("xml", "filename" => dictionary, @@ -36,3 +57,5 @@ end end end + +FileUtils.rm_rf(tmp_dir) From kous users.sourceforge.jp Thu Dec 7 14:34:45 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:34:45 +0900 Subject: [Tomoe-cvs 1781] CVS update: tomoe/module/dict Message-ID: <20061207053445.03A222AC0B4@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.4 tomoe/module/dict/tomoe-dict-svn.c:1.5 --- tomoe/module/dict/tomoe-dict-svn.c:1.4 Thu Dec 7 14:12:30 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Thu Dec 7 14:34:44 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.4 2006/12/07 05:12:30 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.5 2006/12/07 05:34:44 kous Exp $ */ #include @@ -34,6 +34,8 @@ #include "tomoe-dict-ptr-array.h" +#define DIRTY_BORDER 10 + #define TOMOE_TYPE_DICT_SVN tomoe_type_dict_svn #define TOMOE_DICT_SVN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_SVN, TomoeDictSvn)) #define TOMOE_DICT_SVN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_SVN, TomoeDictSvnClass)) @@ -54,6 +56,8 @@ TomoeDict object; gchar *working_copy; + gint dirty; + TomoeDict *sub_dict; apr_pool_t *pool; @@ -95,7 +99,8 @@ static gboolean is_editable (TomoeDict *dict); static gchar *get_available_private_utf8 (TomoeDict *dict); -static gboolean tomoe_dict_svn_update (TomoeDictSvn *dict); +static gboolean tomoe_dict_svn_update (TomoeDictSvn *dict, + gboolean force); static gboolean tomoe_dict_svn_commit (TomoeDictSvn *dict); static void @@ -149,6 +154,7 @@ svn_error_t *err; dict->working_copy = NULL; + dict->dirty = 0; dict->sub_dict = NULL; dict->pool = svn_pool_create (NULL); err = svn_client_create_context (&dict->ctx, dict->pool); @@ -292,6 +298,7 @@ apr_pool_destroy (dict->pool); dict->working_copy = NULL; + dict->dirty = 0; dict->sub_dict = NULL; dict->pool = NULL; dict->ctx = NULL; @@ -318,7 +325,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); - return (tomoe_dict_svn_update (dict) && + return (tomoe_dict_svn_update (dict, TRUE) && tomoe_dict_register_char (dict->sub_dict, chr) && tomoe_dict_svn_commit (dict)); } @@ -331,7 +338,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); - return (tomoe_dict_svn_update (dict) && + return (tomoe_dict_svn_update (dict, TRUE) && tomoe_dict_unregister_char (dict->sub_dict, utf8) && tomoe_dict_svn_commit (dict)); } @@ -344,7 +351,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), NULL); - if (tomoe_dict_svn_update (dict)) + if (tomoe_dict_svn_update (dict, FALSE)) return tomoe_dict_get_char (dict->sub_dict, utf8); else return NULL; @@ -358,7 +365,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), NULL); - if (tomoe_dict_svn_update (dict)) + if (tomoe_dict_svn_update (dict, FALSE)) return tomoe_dict_search (dict->sub_dict, query); else return NULL; @@ -372,7 +379,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), FALSE); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); - return (tomoe_dict_svn_update (dict) && + return (tomoe_dict_svn_update (dict, TRUE) && tomoe_dict_flush (dict->sub_dict) && tomoe_dict_svn_commit (dict)); } @@ -396,7 +403,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); - if (tomoe_dict_svn_update (dict)) + if (tomoe_dict_svn_update (dict, FALSE)) return tomoe_dict_get_available_private_utf8 (dict->sub_dict); else return NULL; @@ -404,7 +411,7 @@ static gboolean -tomoe_dict_svn_update (TomoeDictSvn *dict) +tomoe_dict_svn_update (TomoeDictSvn *dict, gboolean force) { svn_error_t *err; svn_opt_revision_t revision; @@ -416,6 +423,9 @@ g_return_val_if_fail (dict->ctx, FALSE); + if (!force && dict->dirty++ < DIRTY_BORDER) + return TRUE; + sub_pool = svn_pool_create (dict->pool); revision.kind = svn_opt_revision_head; err = svn_client_update (NULL, dict->working_copy, &revision, TRUE, @@ -427,6 +437,7 @@ svn_error_clear (err); return FALSE; } else { + dict->dirty = 0; return TRUE; } } From kous users.sourceforge.jp Thu Dec 7 14:35:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:35:46 +0900 Subject: [Tomoe-cvs 1782] CVS update: tomoe Message-ID: <20061207053546.696692AC1ED@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.412 tomoe/ChangeLog:1.413 --- tomoe/ChangeLog:1.412 Thu Dec 7 14:34:44 2006 +++ tomoe/ChangeLog Thu Dec 7 14:35:46 2006 @@ -1,6 +1,10 @@ 2006-12-07 Kouhei Sutou + * module/dict/tomoe-dict-svn.c (get_available_private_utf8): + update always. + * module/dict/tomoe-dict-svn.c: don't always update. + * benchmark/search-by-dict.rb: supported TomoeDictSvn. * module/dict/tomoe-dict-svn.c: ensure flush all changes. From kous users.sourceforge.jp Thu Dec 7 14:35:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 14:35:46 +0900 Subject: [Tomoe-cvs 1783] CVS update: tomoe/module/dict Message-ID: <20061207053546.943AD2AC1EF@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.5 tomoe/module/dict/tomoe-dict-svn.c:1.6 --- tomoe/module/dict/tomoe-dict-svn.c:1.5 Thu Dec 7 14:34:44 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Thu Dec 7 14:35:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.5 2006/12/07 05:34:44 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.6 2006/12/07 05:35:46 kous Exp $ */ #include @@ -403,7 +403,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_SVN (dict), NULL); g_return_val_if_fail (TOMOE_IS_DICT (dict->sub_dict), FALSE); - if (tomoe_dict_svn_update (dict, FALSE)) + if (tomoe_dict_svn_update (dict, TRUE)) return tomoe_dict_get_available_private_utf8 (dict->sub_dict); else return NULL; From kous users.sourceforge.jp Thu Dec 7 15:02:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 15:02:41 +0900 Subject: [Tomoe-cvs 1784] CVS update: tomoe Message-ID: <20061207060241.923962AC016@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.413 tomoe/ChangeLog:1.414 --- tomoe/ChangeLog:1.413 Thu Dec 7 14:35:46 2006 +++ tomoe/ChangeLog Thu Dec 7 15:02:41 2006 @@ -1,5 +1,7 @@ 2006-12-07 Kouhei Sutou + * test/context_spec.rb: added missing == true. + * module/dict/tomoe-dict-svn.c (get_available_private_utf8): update always. From kous users.sourceforge.jp Thu Dec 7 15:02:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 7 Dec 2006 15:02:41 +0900 Subject: [Tomoe-cvs 1785] CVS update: tomoe/test Message-ID: <20061207060241.BF8982AC01D@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.24 tomoe/test/context_spec.rb:1.25 --- tomoe/test/context_spec.rb:1.24 Wed Dec 6 15:28:37 2006 +++ tomoe/test/context_spec.rb Thu Dec 7 15:02:41 2006 @@ -70,12 +70,12 @@ char = Tomoe::Char.new char.utf8 = "?? - context.register(char).should + context.register(char).should == true context.search(Tomoe::Query.new).collect do |cand| cand.char.utf8 end.should == [char.utf8] - context.unregister(char.utf8).should + context.unregister(char.utf8).should == true context.search(Tomoe::Query.new).should_be_empty end @@ -93,7 +93,7 @@ char = Tomoe::Char.new char.n_strokes = n_strokes - context.register(char).should + context.register(char).should == true char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) context.search(query).collect do |cand| @@ -103,7 +103,7 @@ char2 = Tomoe::Char.new char2.n_strokes = n_strokes - context.register(char2).should + context.register(char2).should == true char2.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START + 1) context.search(query).collect do |cand| @@ -119,7 +119,7 @@ char = Tomoe::Char.new char.n_strokes = 8 - context.register(char).should + context.register(char).should == true char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) retrieved_char = context[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)] From kous users.sourceforge.jp Fri Dec 8 10:00:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 10:00:56 +0900 Subject: [Tomoe-cvs 1786] CVS update: tomoe Message-ID: <20061208010056.61C942AC01F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.414 tomoe/ChangeLog:1.415 --- tomoe/ChangeLog:1.414 Thu Dec 7 15:02:41 2006 +++ tomoe/ChangeLog Fri Dec 8 10:00:56 2006 @@ -1,3 +1,11 @@ +2006-12-08 Kouhei Sutou + + * configure.in, module/dict/Makefile.am: --enable-ruby-dict -> + --enable-dict-ruby. + + * module/dict/tomoe-dict-ruby.c: fixed a bug for Ruby + cleanup. Now, Ruby based dictionary is work at least. + 2006-12-07 Kouhei Sutou * test/context_spec.rb: added missing == true. Index: tomoe/configure.in diff -u tomoe/configure.in:1.45 tomoe/configure.in:1.46 --- tomoe/configure.in:1.45 Thu Dec 7 13:17:30 2006 +++ tomoe/configure.in Fri Dec 8 10:00:56 2006 @@ -355,9 +355,9 @@ dnl ************************************************************** dnl Check for Ruby dictionary module dnl ************************************************************** -AC_ARG_ENABLE(ruby_dict, [ --enable-ruby-dict - Enable Ruby-dict module]) -AM_CONDITIONAL(ENABLE_RUBY_DICT, test x"$enable_ruby" = "xyes") +AC_ARG_ENABLE(dict_ruby, [ --enable-dict-ruby + Enable Ruby based dictionary module]) +AM_CONDITIONAL(ENABLE_DICT_RUBY, test x"$enable_dict_ruby" = "xyes") dnl ************************************************************** From kous users.sourceforge.jp Fri Dec 8 10:00:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 10:00:56 +0900 Subject: [Tomoe-cvs 1787] CVS update: tomoe/ext/ruby Message-ID: <20061208010056.89B4D2AC03A@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.18 tomoe/ext/ruby/tomoe-rb-dict.c:1.19 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.18 Thu Dec 7 14:08:29 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Fri Dec 8 10:00:56 2006 @@ -55,6 +55,8 @@ "dictionary", RVAL2TDIC(dictionary), "working_copy", RVAL2CSTR(working_copy), NULL); + } else if (strcmp(name, "ruby") == 0) { + dict = tomoe_dict_new(name, NULL); } else { rb_raise(rb_eArgError, "unknown dictionary type: %s", name); dict = NULL; From kous users.sourceforge.jp Fri Dec 8 10:00:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 10:00:56 +0900 Subject: [Tomoe-cvs 1788] CVS update: tomoe/module/dict Message-ID: <20061208010056.AFC992AC01F@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.18 tomoe/module/dict/Makefile.am:1.19 --- tomoe/module/dict/Makefile.am:1.18 Thu Dec 7 14:07:25 2006 +++ tomoe/module/dict/Makefile.am Fri Dec 8 10:00:56 2006 @@ -52,7 +52,7 @@ libest_la_LIBADD = $(EST_LIBS) endif -if ENABLE_RUBY_DICT +if ENABLE_DICT_RUBY dict_module_LTLIBRARIES += libruby.la libruby_la_SOURCES = tomoe-dict-ruby.c Index: tomoe/module/dict/tomoe-dict-ruby.c diff -u tomoe/module/dict/tomoe-dict-ruby.c:1.1 tomoe/module/dict/tomoe-dict-ruby.c:1.2 --- tomoe/module/dict/tomoe-dict-ruby.c:1.1 Mon Dec 4 10:29:21 2006 +++ tomoe/module/dict/tomoe-dict-ruby.c Fri Dec 8 10:00:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ruby.c,v 1.1 2006/12/04 01:29:21 kous Exp $ + * $Id: tomoe-dict-ruby.c,v 1.2 2006/12/08 01:00:56 kous Exp $ */ #include @@ -184,29 +184,40 @@ &info, 0); } +static void +tomoe_dict_ruby_atexit(void) +{ + ruby_cleanup (0); +} + G_MODULE_EXPORT void TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { static gchar *argv[] = {G_STRINGIFY (PACKAGE)}; + static gboolean ruby_initialized = FALSE; register_type (type_module); - ruby_init (); - ruby_script (PACKAGE); - ruby_set_argv (1, argv); + if (!ruby_initialized) { + ruby_initialized = TRUE; - if (RARRAY(rb_load_path)->len == 0) { - ruby_init_loadpath (); - } + ruby_init (); + atexit(tomoe_dict_ruby_atexit); + ruby_script (PACKAGE); + ruby_set_argv (1, argv); + + if (RARRAY(rb_load_path)->len == 0) { + ruby_init_loadpath (); + } - rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_EXTDIR)); - rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_LIBDIR)); + rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_EXTDIR)); + rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_LIBDIR)); + } } G_MODULE_EXPORT void TOMOE_MODULE_IMPL_EXIT (void) { - ruby_cleanup (0); } G_MODULE_EXPORT GObject * From kous users.sourceforge.jp Fri Dec 8 12:23:45 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:23:45 +0900 Subject: [Tomoe-cvs 1789] CVS update: tomoe/db Message-ID: <20061208032345.C16442AC0C8@users.sourceforge.jp> From kous users.sourceforge.jp Fri Dec 8 12:24:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:24:56 +0900 Subject: [Tomoe-cvs 1790] CVS update: tomoe/db/lib Message-ID: <20061208032456.ABBC72AC0C8@users.sourceforge.jp> From kous users.sourceforge.jp Fri Dec 8 12:25:19 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:25:19 +0900 Subject: [Tomoe-cvs 1791] CVS update: tomoe/db/migrate Message-ID: <20061208032519.8BEE82AC055@users.sourceforge.jp> From kous users.sourceforge.jp Fri Dec 8 12:29:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:49 +0900 Subject: [Tomoe-cvs 1792] CVS update: tomoe Message-ID: <20061208032949.11EDD2AC0C8@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.415 tomoe/ChangeLog:1.416 --- tomoe/ChangeLog:1.415 Fri Dec 8 10:00:56 2006 +++ tomoe/ChangeLog Fri Dec 8 12:29:48 2006 @@ -1,5 +1,17 @@ 2006-12-08 Kouhei Sutou + * db/: added SQL database related directory. + * db/migrate/: for updating database schema. + * db/migrate.rb: administrate schema. + * db/xml2db.rb: convert XML dictionary data to SQL database. + * db/search.rb: a script for searching to research SQL database + backend design. + + * test/tomoe-spec-utils.rb: added Unicode related utility methods. + * module/dict/unihan-schemer.rb: used the utility methods. + + * ext/ruby/tomoe-rb-reading.c: define a class for TomoeReadingType. + * configure.in, module/dict/Makefile.am: --enable-ruby-dict -> --enable-dict-ruby. From kous users.sourceforge.jp Fri Dec 8 12:29:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:49 +0900 Subject: [Tomoe-cvs 1793] CVS update: tomoe/db Message-ID: <20061208032949.39C6E2AC204@users.sourceforge.jp> Index: tomoe/db/config.yml.example diff -u /dev/null tomoe/db/config.yml.example:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/config.yml.example Fri Dec 8 12:29:49 2006 @@ -0,0 +1,6 @@ +adapter: mysql +database: tomoe +username: root +password: +host: localhost +socket: /var/run/mysqld/mysqld.sock Index: tomoe/db/init.rb diff -u /dev/null tomoe/db/init.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/init.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,14 @@ +require 'rubygems' +require 'active_record' + +require 'yaml' + +base = File.expand_path(File.dirname(__FILE__)) +config_file = File.join(base, "config.yml") + +config = YAML.load(File.read(config_file)) +ActiveRecord::Base.establish_connection(config) + +logger = Logger.new($stdout) +logger.level = Logger::DEBUG +ActiveRecord::Base.logger = logger Index: tomoe/db/migrate.rb diff -u /dev/null tomoe/db/migrate.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby + +base = File.expand_path(File.dirname(__FILE__)) +require File.join(base, "init") + +migrations = File.join(base, "migrate") +version = ARGV.shift +ActiveRecord::Migrator.migrate(migrations, version ? version.to_i : nil) Index: tomoe/db/search.rb diff -u /dev/null tomoe/db/search.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/search.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,65 @@ +#!/usr/bin/env ruby + +top = File.expand_path(File.join(File.dirname(__FILE__), "..")) +base = File.join(top, File.dirname(__FILE__)) +require File.join(base, "init") + +ActiveRecord::Base.logger.level = Logger::INFO + +$LOAD_PATH.unshift(File.join(top, "test")) +$LOAD_PATH.unshift(File.join(top, "ext", "ruby", ".libs")) +$LOAD_PATH.unshift(File.join(top, "ext", "ruby")) + +require 'tomoe-spec-utils' + +def utf8_to_ucs4(utf8) + TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) +end + +def ucs4_to_utf8(ucs4) + TomoeSpecUtils::Unicode.ucs4_to_utf8(ucs4) +end + +$LOAD_PATH.unshift(File.join(base, "lib")) + +query = Tomoe::Query.new +query.min_n_strokes = 0 +query.max_n_strokes = 10 + +dict = Tomoe::Dict.new("unihan", {}) +cands = dict.search(Tomoe::Query.new)[0...10000].find_all do |cand| + n_strokes = cand.char.n_strokes + 0 <= n_strokes and + query.min_n_strokes <= n_strokes and + n_strokes <= query.max_n_strokes +end + +puts cands.size +cands.each do |cand| + char = cand.char + unless char.readings.empty? + p [utf8_to_ucs4(char.utf8), char.readings.collect {|x| [x.type, x.reading]}] + end + p [utf8_to_ucs4(char.utf8), char.radicals] unless char.radicals.empty? + p [utf8_to_ucs4(char.utf8), char.collect] unless char.collect.empty? +end + +ActiveRecord::Base.logger.level = Logger::DEBUG +chars = Char.find(:all, + :conditions => ["? <= n_strokes AND n_strokes <= ?", + query.min_n_strokes, + query.max_n_strokes], + :include => [:readings, :radicals]) +ActiveRecord::Base.logger.level = Logger::INFO +puts chars.size + +puts Reading.count +puts Radical.count + +chars.each do |char| + p [char.code_point, char.readings] unless char.readings.empty? + p [char.code_point, char.radicals] unless char.radicals.empty? + unless char.meta_data.empty? + p [char.code_point, char.meta_data.collect {|x| [x.key, x.value]}] + end +end Index: tomoe/db/xml2db.rb diff -u /dev/null tomoe/db/xml2db.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/xml2db.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby + +top = File.expand_path(File.join(File.dirname(__FILE__), "..")) +base = File.join(top, File.dirname(__FILE__)) +require File.join(base, "init") + +ActiveRecord::Base.logger.level = Logger::INFO + +$LOAD_PATH.unshift(File.join(top, "test")) +$LOAD_PATH.unshift(File.join(top, "ext", "ruby", ".libs")) +$LOAD_PATH.unshift(File.join(top, "ext", "ruby")) + +require 'tomoe-spec-utils' + +def utf8_to_ucs4(utf8) + if utf8 + TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) + else + nil + end +end + + +$LOAD_PATH.unshift(File.join(base, "lib")) + +migrate = File.join(base, "migrate.rb") +print "purging DB..." +$stdout.flush +`#{migrate} 0` +`#{migrate}` +puts "done." + +dict = Tomoe::Dict.new("unihan", {}) +cands = dict.search(Tomoe::Query.new)[0...10000] +puts "dict size: #{cands.size}" + +print "converting..." +$stdout.flush +cands.each_with_index do |cand, i| + char = cand.char + code_point = utf8_to_ucs4(char.utf8) + new_char = Char.new(:n_strokes => char.n_strokes < 0 ? nil : char.n_strokes, + :variant => utf8_to_ucs4(char.variant)) + new_char.id = code_point + new_char.save! + char.readings.each do |reading| + Reading.new(:code_point => code_point, + :reading_type => reading.type.to_i, + :reading => reading.reading).save! + end + char.radicals.each do |radical| + Radical.new(:code_point => code_point, + :radical_code_point => utf8_to_ucs4(radical)).save! + end + char.each do |key, value| + MetaDatum.new(:code_point => code_point, + :key => key, + :value => value).save! + end + if (i % 1000).zero? and !i.zero? + print "#{i}." + $stdout.flush + end +end +puts "done." + +puts "converted characters: #{Char.count}" From kous users.sourceforge.jp Fri Dec 8 12:29:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:49 +0900 Subject: [Tomoe-cvs 1794] CVS update: tomoe/db/lib Message-ID: <20061208032949.600C82AC20F@users.sourceforge.jp> Index: tomoe/db/lib/char.rb diff -u /dev/null tomoe/db/lib/char.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/char.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,6 @@ +class Char < ActiveRecord::Base + set_primary_key :code_point + has_many :readings, :foreign_key => "code_point" + has_many :radicals, :foreign_key => "code_point" + has_many :meta_data, :foreign_key => "code_point" +end Index: tomoe/db/lib/meta_datum.rb diff -u /dev/null tomoe/db/lib/meta_datum.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/meta_datum.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,2 @@ +class MetaDatum < ActiveRecord::Base +end Index: tomoe/db/lib/radical.rb diff -u /dev/null tomoe/db/lib/radical.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/radical.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,2 @@ +class Radical < ActiveRecord::Base +end Index: tomoe/db/lib/reading.rb diff -u /dev/null tomoe/db/lib/reading.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/reading.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,3 @@ +class Reading < ActiveRecord::Base + belongs_to :char, :foreign_key => "code_point" +end From kous users.sourceforge.jp Fri Dec 8 12:29:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:49 +0900 Subject: [Tomoe-cvs 1795] CVS update: tomoe/db/migrate Message-ID: <20061208032949.866A92AC0C8@users.sourceforge.jp> Index: tomoe/db/migrate/001_create_chars.rb diff -u /dev/null tomoe/db/migrate/001_create_chars.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/001_create_chars.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,14 @@ +class CreateChars < ActiveRecord::Migration + def self.up + create_table(:chars, :primary_key => :code_point) do |t| + t.column :code_point, :integer + t.column :n_strokes, :integer + t.column :variant, :integer + end + add_index :chars, :code_point + end + + def self.down + drop_table :chars + end +end Index: tomoe/db/migrate/002_create_readings.rb diff -u /dev/null tomoe/db/migrate/002_create_readings.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/002_create_readings.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,14 @@ +class CreateReadings < ActiveRecord::Migration + def self.up + create_table(:readings) do |t| + t.column :code_point, :integer + t.column :reading_type, :integer + t.column :reading, :string + end + add_index :readings, :code_point + end + + def self.down + drop_table :readings + end +end Index: tomoe/db/migrate/003_create_radicals.rb diff -u /dev/null tomoe/db/migrate/003_create_radicals.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/003_create_radicals.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,13 @@ +class CreateRadicals < ActiveRecord::Migration + def self.up + create_table(:radicals) do |t| + t.column :code_point, :integer + t.column :radical_code_point, :integer + end + add_index :radicals, :code_point + end + + def self.down + drop_table :radicals + end +end Index: tomoe/db/migrate/004_create_meta_data.rb diff -u /dev/null tomoe/db/migrate/004_create_meta_data.rb:1.1 --- /dev/null Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/004_create_meta_data.rb Fri Dec 8 12:29:49 2006 @@ -0,0 +1,14 @@ +class CreateMetaData < ActiveRecord::Migration + def self.up + create_table(:meta_data) do |t| + t.column :code_point, :integer + t.column :key, :string + t.column :value, :string + end + add_index :meta_data, :code_point + end + + def self.down + drop_table :meta_data + end +end From kous users.sourceforge.jp Fri Dec 8 12:29:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:49 +0900 Subject: [Tomoe-cvs 1796] CVS update: tomoe/ext/ruby Message-ID: <20061208032949.ADB8E2AC204@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-reading.c diff -u tomoe/ext/ruby/tomoe-rb-reading.c:1.3 tomoe/ext/ruby/tomoe-rb-reading.c:1.4 --- tomoe/ext/ruby/tomoe-rb-reading.c:1.3 Thu Nov 30 18:13:15 2006 +++ tomoe/ext/ruby/tomoe-rb-reading.c Fri Dec 8 12:29:49 2006 @@ -32,6 +32,8 @@ VALUE cTomoeReading; cTomoeReading = G_DEF_CLASS(TOMOE_TYPE_READING, "Reading", mTomoe); + G_DEF_CLASS(TOMOE_TYPE_READING_TYPE, "ReadingType", mTomoe); + G_DEF_CONSTANTS(mTomoe, TOMOE_TYPE_READING_TYPE, "TOMOE_"); G_DEF_CONSTANTS(cTomoeReading, TOMOE_TYPE_READING_TYPE, "TOMOE_READING_"); From kous users.sourceforge.jp Fri Dec 8 12:29:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:49 +0900 Subject: [Tomoe-cvs 1797] CVS update: tomoe/module/dict Message-ID: <20061208032949.D2F5F2AC0C8@users.sourceforge.jp> Index: tomoe/module/dict/unihan-schemer.rb diff -u tomoe/module/dict/unihan-schemer.rb:1.1 tomoe/module/dict/unihan-schemer.rb:1.2 --- tomoe/module/dict/unihan-schemer.rb:1.1 Wed Dec 6 21:43:11 2006 +++ tomoe/module/dict/unihan-schemer.rb Fri Dec 8 12:29:49 2006 @@ -45,11 +45,11 @@ end def ucs4_to_utf8(ucs4) - Uconv.u4tou8([Integer("0x#{ucs4}")].pack("I*")) + TomoeSpecUtils::Unicode.ucs4_to_utf8(Integer("0x#{ucs4}")) end def utf8_to_ucs4(utf8) - "%X" % Uconv.u8tou4(utf8).unpack("I*")[0] + "%X" % TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) end def cache(filename) From kous users.sourceforge.jp Fri Dec 8 12:29:50 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 12:29:50 +0900 Subject: [Tomoe-cvs 1798] CVS update: tomoe/test Message-ID: <20061208032950.035622AC20F@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.21 tomoe/test/tomoe-spec-utils.rb:1.22 --- tomoe/test/tomoe-spec-utils.rb:1.21 Wed Dec 6 18:05:36 2006 +++ tomoe/test/tomoe-spec-utils.rb Fri Dec 8 12:29:49 2006 @@ -185,9 +185,14 @@ end module Unicode + module_function def ucs4_to_utf8(ucs4) Uconv.u4tou8([ucs4].pack("I*")) end + + def utf8_to_ucs4(utf8) + Uconv.u8tou4(utf8).unpack("I*")[0] + end end end From kous users.sourceforge.jp Fri Dec 8 13:19:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 13:19:06 +0900 Subject: [Tomoe-cvs 1799] CVS update: tomoe Message-ID: <20061208041906.E9D112AC064@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.416 tomoe/ChangeLog:1.417 --- tomoe/ChangeLog:1.416 Fri Dec 8 12:29:48 2006 +++ tomoe/ChangeLog Fri Dec 8 13:19:06 2006 @@ -1,5 +1,8 @@ 2006-12-08 Kouhei Sutou + * module/dict/unihan-compiler.rb: re-renamed from + unihan-schemer.rb. We don't need to adjust external constraints, now! + * db/: added SQL database related directory. * db/migrate/: for updating database schema. * db/migrate.rb: administrate schema. From kous users.sourceforge.jp Fri Dec 8 13:19:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 13:19:07 +0900 Subject: [Tomoe-cvs 1800] CVS update: tomoe/module/dict Message-ID: <20061208041907.29F452AC0B8@users.sourceforge.jp> Index: tomoe/module/dict/unihan-compiler.rb diff -u /dev/null tomoe/module/dict/unihan-compiler.rb:1.8 --- /dev/null Fri Dec 8 13:19:07 2006 +++ tomoe/module/dict/unihan-compiler.rb Fri Dec 8 13:19:07 2006 @@ -0,0 +1,278 @@ +#!/usr/bin/env ruby + +require 'tomoe-spec-utils' + +require 'uconv' +require 'suikyo/suikyo' + +unihan_txt = ARGV.shift +kanjidic2_xml = ARGV.shift + +DO_NOT_EDIT_HEADER = <<-EOH +/* + DO NOT EDIT! + THIS FILE IS GENERATED FROM Unihan.txt: + ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip +*/ +EOH + + romaji_to_hiragana = Suikyo.new("romaji-kana") + hiragana_to_katakana = Suikyo.new("hiragana-katakana") + +def kcode(code) + old_kcode = $KCODE + $KCODE = code + yield +ensure + $KCODE = old_kcode +end + +def euc_to_utf8(euc) + Uconv.euctou8(euc) +end + +def romaji_to_hiragana(romaji) + kcode("e") do + euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) + end +end + +def romaji_to_katakana(romaji) + kcode("e") do + hiragana = @romaji_to_hiragana.convert("#{romaji} ") + euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) + end +end + +def ucs4_to_utf8(ucs4) + TomoeSpecUtils::Unicode.ucs4_to_utf8(Integer("0x#{ucs4}")) +end + +def utf8_to_ucs4(utf8) + "%X" % TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) +end + +def cache(filename) + cache = "#{filename}.cache" + if File.exists?(cache) and (File.mtime(cache) > File.mtime(filename)) + begin + return Marshal.load(File.read(cache)) + rescue ArgumentError + end + end + + result = yield + File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} + result +end + +def parse_unihan_entry(key, value) + case key + when "kCompatibilityVariant" + [:variants, value.split.collect {|v| ucs4_to_utf8(v.sub(/^U\+2?/, ''))}] + when "kJapaneseKun" + [:ja_kuns, value.split.collect {|k| romaji_to_hiragana(k)}] + when "kJapaneseOn" + [:ja_ons, value.split.collect {|o| romaji_to_katakana(o)}] + when "kTotalStrokes" + [:n_strokes, value] + else + [key, value] + end +end + +def parse_unihan_txt(unihan_txt) + cache(unihan_txt) do + infos = {} + File.open(unihan_txt).each do |line| + case line + when /^#/ # + next + when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u + ucs4 = $1.upcase + key = $2 + value = $3 + + infos[ucs4] ||= {} + key, value = parse_unihan_entry(key, value) + infos[ucs4][key] = value + else + STDERR.puts "Unknown line: #{line}" + end + end + infos + end +end + +def merge_kanjidic2_xml(kanjidic2_xml, infos) + dict = Tomoe::Dict.new("xml", + "filename" => kanjidic2_xml, + "editable" => false) + dict.search(Tomoe::Query.new).each do |cand| + char = cand.char + ucs4 = utf8_to_ucs4(char.utf8) + info = infos[ucs4] || {} + + info[:n_strokes] ||= char.n_strokes + + info[:ja_ons] ||= [] + info[:ja_kuns] ||= [] + char.readings.each do |reading| + case reading.type + when Tomoe::Reading::JA_ON + info[:ja_ons] << reading.reading + when Tomoe::Reading::JA_KUN + info[:ja_kuns] << reading.reading + end + end + info[:ja_ons].uniq! + info[:ja_kuns].uniq! + + info[:radicals] ||= [] + info[:radicals].concat(char.radicals) + info[:radicals].uniq! + + if char.variant + info[:variants] ||= [] + info[:variants] << char.variant + info[:variants].uniq! + end + + info[:meta_data] ||= {} + char.each do |key, value| + info[:meta_data][key] = value + end + + infos[ucs4] = info + end + infos +end + +def generate_header(infos) + prefix = "tomoe_unihan_" + + puts <<-EOH +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#{DO_NOT_EDIT_HEADER} + +#include "tomoe-unihan.h" + +#include + +typedef struct _TomoeUnihanReading TomoeUnihanReading; +typedef struct _TomoeUnihanMetaData TomoeUnihanMetaData; +typedef struct _TomoeUnihanInfo TomoeUnihanInfo; + +struct _TomoeUnihanReading { + TomoeReadingType type; + gchar *reading; +}; + +struct _TomoeUnihanMetaData { + gchar *key; + gchar *value; +}; + +struct _TomoeUnihanInfo { + gchar *utf8; + gint n_strokes; + TomoeUnihanReading *readings; + gint readings_size; + gchar **radicals; + gint radicals_size; + gchar **variants; + gint variants_size; + TomoeUnihanMetaData *meta_data; + gint meta_data_size; +}; + +EOH + + infos.each_with_index do |(ucs4, info), i| + readings = [] + kuns = info[:ja_kuns] + ons = info[:ja_ons] + if kuns + readings.concat(kuns.collect {|x| ["TOMOE_READING_JA_KUN", x]}) + end + if ons + readings.concat(ons.collect {|x| ["TOMOE_READING_JA_ON", x]}) + end + + unless readings.empty? + info[:have_readings] = true + puts("static TomoeUnihanReading #{prefix}readings_#{ucs4}[] = {") + readings.each do |type, reading| + puts(" {#{type}, \"#{reading}\"},") + end + puts("};") + end + + radicals = info[:radicals] || [] + unless radicals.empty? + info[:have_radicals] = true + puts("static gchar *#{prefix}radicals_#{ucs4}[] = {") + radicals.each do |radical| + puts(" \"#{radical}\",") + end + puts("};"); + end + + variants = info[:variants] || [] + unless variants.empty? + info[:have_variants] = true + puts("static gchar *#{prefix}variants_#{ucs4}[] = {") + variants.each do |variant| + puts(" \"#{variant}\",") + end + puts("};"); + end + + meta_data = info[:meta_data] || [] + unless meta_data.empty? + info[:have_meta_data] = true + puts("static TomoeUnihanMetaData #{prefix}meta_data_#{ucs4}[] = {") + meta_data.each do |key, value| + puts(" {\"#{key}\", \"#{value.gsub(/\"/, '\"')}\"},") + end + puts("};") + end + end + + puts("static TomoeUnihanInfo #{prefix}infos[] = {") + infos.each_with_index do |(ucs4, info), i| + utf8 = ucs4_to_utf8(ucs4) + n_strokes = info[:n_strokes] || -1 + readings = radicals = variants = meta_data = "NULL" + readings_size = radicals_size = variants_size = meta_data_size = "0" + if info[:have_readings] + readings = "#{prefix}readings_#{ucs4}" + readings_size = "G_N_ELEMENTS(#{readings})" + end + if info[:have_radicals] + radicals = "#{prefix}radicals_#{ucs4}" + radicals_size = "G_N_ELEMENTS(#{radicals})" + end + if info[:have_variants] + variants = "#{prefix}variants_#{ucs4}" + variants_size = "G_N_ELEMENTS(#{variants})" + end + if info[:have_meta_data] + meta_data = "#{prefix}meta_data_#{ucs4}" + meta_data_size = "G_N_ELEMENTS(#{meta_data})" + end + + puts(" {\"#{utf8}\", #{n_strokes}, #{readings}, #{readings_size},") + puts(" #{radicals}, #{radicals_size}, #{variants}, #{variants_size},") + puts(" #{meta_data}, #{meta_data_size}},") + end + puts("};") +end + +infos = parse_unihan_txt(unihan_txt) +infos = merge_kanjidic2_xml(kanjidic2_xml, infos).collect do |ucs4, info| + [ucs4, info] +end.sort_by do |ucs4, info| + ucs4 +end +generate_header(infos) Index: tomoe/module/dict/unihan-schemer.rb diff -u tomoe/module/dict/unihan-schemer.rb:1.2 tomoe/module/dict/unihan-schemer.rb:removed --- tomoe/module/dict/unihan-schemer.rb:1.2 Fri Dec 8 12:29:49 2006 +++ tomoe/module/dict/unihan-schemer.rb Fri Dec 8 13:19:07 2006 @@ -1,278 +0,0 @@ -#!/usr/bin/env ruby - -require 'tomoe-spec-utils' - -require 'uconv' -require 'suikyo/suikyo' - -unihan_txt = ARGV.shift -kanjidic2_xml = ARGV.shift - -DO_NOT_EDIT_HEADER = <<-EOH -/* - DO NOT EDIT! - THIS FILE IS GENERATED FROM Unihan.txt: - ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip -*/ -EOH - - romaji_to_hiragana = Suikyo.new("romaji-kana") - hiragana_to_katakana = Suikyo.new("hiragana-katakana") - -def kcode(code) - old_kcode = $KCODE - $KCODE = code - yield -ensure - $KCODE = old_kcode -end - -def euc_to_utf8(euc) - Uconv.euctou8(euc) -end - -def romaji_to_hiragana(romaji) - kcode("e") do - euc_to_utf8(@romaji_to_hiragana.convert("#{romaji} ")) - end -end - -def romaji_to_katakana(romaji) - kcode("e") do - hiragana = @romaji_to_hiragana.convert("#{romaji} ") - euc_to_utf8(@hiragana_to_katakana.convert("#{hiragana} ")) - end -end - -def ucs4_to_utf8(ucs4) - TomoeSpecUtils::Unicode.ucs4_to_utf8(Integer("0x#{ucs4}")) -end - -def utf8_to_ucs4(utf8) - "%X" % TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) -end - -def cache(filename) - cache = "#{filename}.cache" - if File.exists?(cache) and (File.mtime(cache) > File.mtime(filename)) - begin - return Marshal.load(File.read(cache)) - rescue ArgumentError - end - end - - result = yield - File.open(cache, "wb") {|f| f.print(Marshal.dump(result))} - result -end - -def parse_unihan_entry(key, value) - case key - when "kCompatibilityVariant" - [:variants, value.split.collect {|v| ucs4_to_utf8(v.sub(/^U\+2?/, ''))}] - when "kJapaneseKun" - [:ja_kuns, value.split.collect {|k| romaji_to_hiragana(k)}] - when "kJapaneseOn" - [:ja_ons, value.split.collect {|o| romaji_to_katakana(o)}] - when "kTotalStrokes" - [:n_strokes, value] - else - [key, value] - end -end - -def parse_unihan_txt(unihan_txt) - cache(unihan_txt) do - infos = {} - File.open(unihan_txt).each do |line| - case line - when /^#/ # - next - when /^U\+([\da-fA-F]+)\s+([a-zA-Z_]+)\s*(.*)\s*$/u - ucs4 = $1.upcase - key = $2 - value = $3 - - infos[ucs4] ||= {} - key, value = parse_unihan_entry(key, value) - infos[ucs4][key] = value - else - STDERR.puts "Unknown line: #{line}" - end - end - infos - end -end - -def merge_kanjidic2_xml(kanjidic2_xml, infos) - dict = Tomoe::Dict.new("xml", - "filename" => kanjidic2_xml, - "editable" => false) - dict.search(Tomoe::Query.new).each do |cand| - char = cand.char - ucs4 = utf8_to_ucs4(char.utf8) - info = infos[ucs4] || {} - - info[:n_strokes] ||= char.n_strokes - - info[:ja_ons] ||= [] - info[:ja_kuns] ||= [] - char.readings.each do |reading| - case reading.type - when Tomoe::Reading::JA_ON - info[:ja_ons] << reading.reading - when Tomoe::Reading::JA_KUN - info[:ja_kuns] << reading.reading - end - end - info[:ja_ons].uniq! - info[:ja_kuns].uniq! - - info[:radicals] ||= [] - info[:radicals].concat(char.radicals) - info[:radicals].uniq! - - if char.variant - info[:variants] ||= [] - info[:variants] << char.variant - info[:variants].uniq! - end - - info[:meta_data] ||= {} - char.each do |key, value| - info[:meta_data][key] = value - end - - infos[ucs4] = info - end - infos -end - -def generate_header(infos) - prefix = "tomoe_unihan_" - - puts <<-EOH -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#{DO_NOT_EDIT_HEADER} - -#include "tomoe-unihan.h" - -#include - -typedef struct _TomoeUnihanReading TomoeUnihanReading; -typedef struct _TomoeUnihanMetaData TomoeUnihanMetaData; -typedef struct _TomoeUnihanInfo TomoeUnihanInfo; - -struct _TomoeUnihanReading { - TomoeReadingType type; - gchar *reading; -}; - -struct _TomoeUnihanMetaData { - gchar *key; - gchar *value; -}; - -struct _TomoeUnihanInfo { - gchar *utf8; - gint n_strokes; - TomoeUnihanReading *readings; - gint readings_size; - gchar **radicals; - gint radicals_size; - gchar **variants; - gint variants_size; - TomoeUnihanMetaData *meta_data; - gint meta_data_size; -}; - -EOH - - infos.each_with_index do |(ucs4, info), i| - readings = [] - kuns = info[:ja_kuns] - ons = info[:ja_ons] - if kuns - readings.concat(kuns.collect {|x| ["TOMOE_READING_JA_KUN", x]}) - end - if ons - readings.concat(ons.collect {|x| ["TOMOE_READING_JA_ON", x]}) - end - - unless readings.empty? - info[:have_readings] = true - puts("static TomoeUnihanReading #{prefix}readings_#{ucs4}[] = {") - readings.each do |type, reading| - puts(" {#{type}, \"#{reading}\"},") - end - puts("};") - end - - radicals = info[:radicals] || [] - unless radicals.empty? - info[:have_radicals] = true - puts("static gchar *#{prefix}radicals_#{ucs4}[] = {") - radicals.each do |radical| - puts(" \"#{radical}\",") - end - puts("};"); - end - - variants = info[:variants] || [] - unless variants.empty? - info[:have_variants] = true - puts("static gchar *#{prefix}variants_#{ucs4}[] = {") - variants.each do |variant| - puts(" \"#{variant}\",") - end - puts("};"); - end - - meta_data = info[:meta_data] || [] - unless meta_data.empty? - info[:have_meta_data] = true - puts("static TomoeUnihanMetaData #{prefix}meta_data_#{ucs4}[] = {") - meta_data.each do |key, value| - puts(" {\"#{key}\", \"#{value.gsub(/\"/, '\"')}\"},") - end - puts("};") - end - end - - puts("static TomoeUnihanInfo #{prefix}infos[] = {") - infos.each_with_index do |(ucs4, info), i| - utf8 = ucs4_to_utf8(ucs4) - n_strokes = info[:n_strokes] || -1 - readings = radicals = variants = meta_data = "NULL" - readings_size = radicals_size = variants_size = meta_data_size = "0" - if info[:have_readings] - readings = "#{prefix}readings_#{ucs4}" - readings_size = "G_N_ELEMENTS(#{readings})" - end - if info[:have_radicals] - radicals = "#{prefix}radicals_#{ucs4}" - radicals_size = "G_N_ELEMENTS(#{radicals})" - end - if info[:have_variants] - variants = "#{prefix}variants_#{ucs4}" - variants_size = "G_N_ELEMENTS(#{variants})" - end - if info[:have_meta_data] - meta_data = "#{prefix}meta_data_#{ucs4}" - meta_data_size = "G_N_ELEMENTS(#{meta_data})" - end - - puts(" {\"#{utf8}\", #{n_strokes}, #{readings}, #{readings_size},") - puts(" #{radicals}, #{radicals_size}, #{variants}, #{variants_size},") - puts(" #{meta_data}, #{meta_data_size}},") - end - puts("};") -end - -infos = parse_unihan_txt(unihan_txt) -infos = merge_kanjidic2_xml(kanjidic2_xml, infos).collect do |ucs4, info| - [ucs4, info] -end.sort_by do |ucs4, info| - ucs4 -end -generate_header(infos) From kous users.sourceforge.jp Fri Dec 8 18:06:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 18:06:37 +0900 Subject: [Tomoe-cvs 1801] CVS update: tomoe/db Message-ID: <20061208090637.A77082AC104@users.sourceforge.jp> Index: tomoe/db/search.rb diff -u tomoe/db/search.rb:1.1 tomoe/db/search.rb:1.2 --- tomoe/db/search.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/search.rb Fri Dec 8 18:06:37 2006 @@ -57,9 +57,9 @@ puts Radical.count chars.each do |char| - p [char.code_point, char.readings] unless char.readings.empty? - p [char.code_point, char.radicals] unless char.radicals.empty? + p [utf8_to_ucs4(char.utf8), char.readings] unless char.readings.empty? + p [utf8_to_ucs4(char.utf8), char.radicals] unless char.radicals.empty? unless char.meta_data.empty? - p [char.code_point, char.meta_data.collect {|x| [x.key, x.value]}] + p [utf8_to_ucs4(char.utf8), char.meta_data.collect {|x| [x.key, x.value]}] end end Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.1 tomoe/db/xml2db.rb:1.2 --- tomoe/db/xml2db.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/xml2db.rb Fri Dec 8 18:06:37 2006 @@ -38,22 +38,21 @@ $stdout.flush cands.each_with_index do |cand, i| char = cand.char - code_point = utf8_to_ucs4(char.utf8) new_char = Char.new(:n_strokes => char.n_strokes < 0 ? nil : char.n_strokes, - :variant => utf8_to_ucs4(char.variant)) - new_char.id = code_point + :variant => char.variant) + new_char.id = char.utf8 new_char.save! char.readings.each do |reading| - Reading.new(:code_point => code_point, + Reading.new(:utf8 => char.utf8, :reading_type => reading.type.to_i, :reading => reading.reading).save! end char.radicals.each do |radical| - Radical.new(:code_point => code_point, - :radical_code_point => utf8_to_ucs4(radical)).save! + Radical.new(:utf8 => char.utf8, + :radical_utf8 => radical).save! end char.each do |key, value| - MetaDatum.new(:code_point => code_point, + MetaDatum.new(:utf8 => char.utf8, :key => key, :value => value).save! end From kous users.sourceforge.jp Fri Dec 8 18:06:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 18:06:37 +0900 Subject: [Tomoe-cvs 1802] CVS update: tomoe/db/lib Message-ID: <20061208090637.CD2B72AC217@users.sourceforge.jp> Index: tomoe/db/lib/char.rb diff -u tomoe/db/lib/char.rb:1.1 tomoe/db/lib/char.rb:1.2 --- tomoe/db/lib/char.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/char.rb Fri Dec 8 18:06:37 2006 @@ -1,6 +1,6 @@ class Char < ActiveRecord::Base - set_primary_key :code_point - has_many :readings, :foreign_key => "code_point" - has_many :radicals, :foreign_key => "code_point" - has_many :meta_data, :foreign_key => "code_point" + set_primary_key :utf8 + has_many :readings, :foreign_key => "utf8" + has_many :radicals, :foreign_key => "utf8" + has_many :meta_data, :foreign_key => "utf8" end Index: tomoe/db/lib/meta_datum.rb diff -u tomoe/db/lib/meta_datum.rb:1.1 tomoe/db/lib/meta_datum.rb:1.2 --- tomoe/db/lib/meta_datum.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/meta_datum.rb Fri Dec 8 18:06:37 2006 @@ -1,2 +1,3 @@ class MetaDatum < ActiveRecord::Base + belongs_to :char, :foreign_key => "utf8" end Index: tomoe/db/lib/radical.rb diff -u tomoe/db/lib/radical.rb:1.1 tomoe/db/lib/radical.rb:1.2 --- tomoe/db/lib/radical.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/radical.rb Fri Dec 8 18:06:37 2006 @@ -1,2 +1,3 @@ class Radical < ActiveRecord::Base + belongs_to :char, :foreign_key => "utf8" end Index: tomoe/db/lib/reading.rb diff -u tomoe/db/lib/reading.rb:1.1 tomoe/db/lib/reading.rb:1.2 --- tomoe/db/lib/reading.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/lib/reading.rb Fri Dec 8 18:06:37 2006 @@ -1,3 +1,3 @@ class Reading < ActiveRecord::Base - belongs_to :char, :foreign_key => "code_point" + belongs_to :char, :foreign_key => "utf8" end From kous users.sourceforge.jp Fri Dec 8 18:06:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 8 Dec 2006 18:06:37 +0900 Subject: [Tomoe-cvs 1803] CVS update: tomoe/db/migrate Message-ID: <20061208090638.0359A2AC219@users.sourceforge.jp> Index: tomoe/db/migrate/001_create_chars.rb diff -u tomoe/db/migrate/001_create_chars.rb:1.1 tomoe/db/migrate/001_create_chars.rb:1.2 --- tomoe/db/migrate/001_create_chars.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/001_create_chars.rb Fri Dec 8 18:06:37 2006 @@ -1,11 +1,11 @@ class CreateChars < ActiveRecord::Migration def self.up - create_table(:chars, :primary_key => :code_point) do |t| - t.column :code_point, :integer + create_table(:chars, :id => false) do |t| + t.column :utf8, :string t.column :n_strokes, :integer - t.column :variant, :integer + t.column :variant, :string end - add_index :chars, :code_point + add_index :chars, :utf8 end def self.down Index: tomoe/db/migrate/002_create_readings.rb diff -u tomoe/db/migrate/002_create_readings.rb:1.1 tomoe/db/migrate/002_create_readings.rb:1.2 --- tomoe/db/migrate/002_create_readings.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/002_create_readings.rb Fri Dec 8 18:06:37 2006 @@ -1,11 +1,11 @@ class CreateReadings < ActiveRecord::Migration def self.up create_table(:readings) do |t| - t.column :code_point, :integer + t.column :utf8, :string, :null => false t.column :reading_type, :integer - t.column :reading, :string + t.column :reading, :string, :null => false end - add_index :readings, :code_point + add_index :readings, :utf8 end def self.down Index: tomoe/db/migrate/003_create_radicals.rb diff -u tomoe/db/migrate/003_create_radicals.rb:1.1 tomoe/db/migrate/003_create_radicals.rb:1.2 --- tomoe/db/migrate/003_create_radicals.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/003_create_radicals.rb Fri Dec 8 18:06:37 2006 @@ -1,10 +1,10 @@ class CreateRadicals < ActiveRecord::Migration def self.up create_table(:radicals) do |t| - t.column :code_point, :integer - t.column :radical_code_point, :integer + t.column :utf8, :string, :null => false + t.column :radical_utf8, :string, :null => false end - add_index :radicals, :code_point + add_index :radicals, :utf8 end def self.down Index: tomoe/db/migrate/004_create_meta_data.rb diff -u tomoe/db/migrate/004_create_meta_data.rb:1.1 tomoe/db/migrate/004_create_meta_data.rb:1.2 --- tomoe/db/migrate/004_create_meta_data.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/migrate/004_create_meta_data.rb Fri Dec 8 18:06:37 2006 @@ -1,11 +1,11 @@ class CreateMetaData < ActiveRecord::Migration def self.up create_table(:meta_data) do |t| - t.column :code_point, :integer - t.column :key, :string - t.column :value, :string + t.column :utf8, :string, :null => false + t.column :key, :string, :null => false + t.column :value, :string, :null => false end - add_index :meta_data, :code_point + add_index :meta_data, :utf8 end def self.down From kous users.sourceforge.jp Sun Dec 10 14:21:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 14:21:16 +0900 Subject: [Tomoe-cvs 1804] CVS update: tomoe Message-ID: <20061210052116.389162AC111@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.417 tomoe/ChangeLog:1.418 --- tomoe/ChangeLog:1.417 Fri Dec 8 13:19:06 2006 +++ tomoe/ChangeLog Sun Dec 10 14:21:15 2006 @@ -1,3 +1,7 @@ +2006-12-10 Kouhei Sutou + + * module/dict/Makefile.am: unihan-schemer.rb -> unihan-compiler.rb. + 2006-12-08 Kouhei Sutou * module/dict/unihan-compiler.rb: re-renamed from From kous users.sourceforge.jp Sun Dec 10 14:21:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 14:21:16 +0900 Subject: [Tomoe-cvs 1805] CVS update: tomoe/module/dict Message-ID: <20061210052116.6E9892AC146@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.19 tomoe/module/dict/Makefile.am:1.20 --- tomoe/module/dict/Makefile.am:1.19 Fri Dec 8 10:00:56 2006 +++ tomoe/module/dict/Makefile.am Sun Dec 10 14:21:16 2006 @@ -67,7 +67,7 @@ CLEANFILES += Unihan.txt Unihan.txt.cache BUILT_SOURCES = $(unihan_built_sources) Unihan.zip -EXTRA_DIST = unihan-schemer.rb +EXTRA_DIST = unihan-compier.rb libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ @@ -76,9 +76,9 @@ $(unihan_built_sources) \ $(ptr_array_based_dict_sources) -tomoe-unihan-data.h: unihan-schemer.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml +tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ - -I$(top_srcdir)/test unihan-schemer.rb \ + -I$(top_srcdir)/test unihan-compiler.rb \ Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@ Unihan.txt: Unihan.zip From kous users.sourceforge.jp Sun Dec 10 14:51:50 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 14:51:50 +0900 Subject: [Tomoe-cvs 1806] CVS update: tomoe Message-ID: <20061210055150.633AE2AC0FE@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.418 tomoe/ChangeLog:1.419 --- tomoe/ChangeLog:1.418 Sun Dec 10 14:21:15 2006 +++ tomoe/ChangeLog Sun Dec 10 14:51:50 2006 @@ -1,5 +1,9 @@ 2006-12-10 Kouhei Sutou + * benchmark/search-by-dict.rb: checked results. + + * benchmark/convert-char.rb: added more information. + * module/dict/Makefile.am: unihan-schemer.rb -> unihan-compiler.rb. 2006-12-08 Kouhei Sutou From kous users.sourceforge.jp Sun Dec 10 14:51:50 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 14:51:50 +0900 Subject: [Tomoe-cvs 1807] CVS update: tomoe/benchmark Message-ID: <20061210055150.911AE2AC180@users.sourceforge.jp> Index: tomoe/benchmark/convert-char.rb diff -u tomoe/benchmark/convert-char.rb:1.1 tomoe/benchmark/convert-char.rb:1.2 --- tomoe/benchmark/convert-char.rb:1.1 Fri Dec 1 12:51:42 2006 +++ tomoe/benchmark/convert-char.rb Sun Dec 10 14:51:50 2006 @@ -39,8 +39,8 @@ n = 5000 Benchmark.bmbm do |x| - x.report("XML -> TomoeChar") {n.times {Tomoe::Char.new(xml)}} + x.report("XML -> TomoeChar (##{n})") {n.times {Tomoe::Char.new(xml)}} GC.start char = Tomoe::Char.new(xml) - x.report("TomoeChar -> XML") {n.times {char.to_xml}} + x.report("TomoeChar -> XML (##{n})") {n.times {char.to_xml}} end Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.3 tomoe/benchmark/search-by-dict.rb:1.4 --- tomoe/benchmark/search-by-dict.rb:1.3 Thu Dec 7 14:34:44 2006 +++ tomoe/benchmark/search-by-dict.rb Sun Dec 10 14:51:50 2006 @@ -11,7 +11,7 @@ n = 10 use_est = false -use_svn = true +use_svn = false tmp_dir = TomoeSpecUtils::Config.tmp_dir Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| @@ -47,12 +47,39 @@ x.report("#{File.basename(dictionary)}: all") do query = Tomoe::Query.new + expected = 13039 + actual = dict.search(query).size + if actual != expected + puts "expected: #{expected}" + puts " but was: #{actual}" + end n.times {dict.search(query)} end x.report("#{File.basename(dictionary)}: >= 5") do query = Tomoe::Query.new query.min_n_strokes = 10 + expected = 9889 + actual = dict.search(query).size + if actual != expected + puts "expected: #{expected}" + puts " but was: #{actual}" + end + n.times {dict.search(query)} + end + + x.report("#{File.basename(dictionary)}: readings") do + query = Tomoe::Query.new + query.add_reading(Tomoe::Reading.new(Tomoe::READING_JA_KUN, "???")) + expected = ["?, "??, "??].sort + actual = dict.search(query).collect do |cand| + cand.char.utf8 + end.sort + if actual != expected + $KCODE = "u" + puts "expected: #{expected.inspect}" + puts " but was: #{actual.inspect}" + end n.times {dict.search(query)} end end From kous users.sourceforge.jp Sun Dec 10 14:54:24 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 14:54:24 +0900 Subject: [Tomoe-cvs 1808] CVS update: tomoe Message-ID: <20061210055424.892732AC0FE@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.419 tomoe/ChangeLog:1.420 --- tomoe/ChangeLog:1.419 Sun Dec 10 14:51:50 2006 +++ tomoe/ChangeLog Sun Dec 10 14:54:24 2006 @@ -1,5 +1,7 @@ 2006-12-10 Kouhei Sutou + * module/dict/tomoe-dict-est.c: fixed a bug for empty query. + * benchmark/search-by-dict.rb: checked results. * benchmark/convert-char.rb: added more information. From kous users.sourceforge.jp Sun Dec 10 14:54:24 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 14:54:24 +0900 Subject: [Tomoe-cvs 1809] CVS update: tomoe/module/dict Message-ID: <20061210055424.B4C9A2AC180@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.8 tomoe/module/dict/tomoe-dict-est.c:1.9 --- tomoe/module/dict/tomoe-dict-est.c:1.8 Thu Dec 7 10:38:05 2006 +++ tomoe/module/dict/tomoe-dict-est.c Sun Dec 10 14:54:24 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.8 2006/12/07 01:38:05 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.9 2006/12/10 05:54:24 kous Exp $ */ #include @@ -463,6 +463,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), candidates); cond = est_cond_new (); + est_cond_set_phrase (cond, ""); est_cond_set_order (cond, "utf8 STRA"); min_n_strokes = tomoe_query_get_min_n_strokes (query); From kous users.sourceforge.jp Sun Dec 10 16:27:40 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 16:27:40 +0900 Subject: [Tomoe-cvs 1810] CVS update: tomoe Message-ID: <20061210072740.1D0BD2AC1A5@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.420 tomoe/ChangeLog:1.421 --- tomoe/ChangeLog:1.420 Sun Dec 10 14:54:24 2006 +++ tomoe/ChangeLog Sun Dec 10 16:27:39 2006 @@ -1,5 +1,8 @@ 2006-12-10 Kouhei Sutou + * module/dict/tomoe-dict-est.c: fixed a bug for caching. I want to + remove caching mechanism. + * module/dict/tomoe-dict-est.c: fixed a bug for empty query. * benchmark/search-by-dict.rb: checked results. From kous users.sourceforge.jp Sun Dec 10 16:27:40 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Sun, 10 Dec 2006 16:27:40 +0900 Subject: [Tomoe-cvs 1811] CVS update: tomoe/module/dict Message-ID: <20061210072740.4A7C42AC261@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.9 tomoe/module/dict/tomoe-dict-est.c:1.10 --- tomoe/module/dict/tomoe-dict-est.c:1.9 Sun Dec 10 14:54:24 2006 +++ tomoe/module/dict/tomoe-dict-est.c Sun Dec 10 16:27:40 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.9 2006/12/10 05:54:24 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.10 2006/12/10 07:27:40 kous Exp $ */ #include @@ -379,7 +379,16 @@ results = est_db_search (dict->db, cond, &n_results, NULL); for (i = 0; i < n_results; i++) { - success = est_db_out_doc (dict->db, results[i], ESTODCLEAN); + gint id; + const gchar *utf8; + + id = results[i]; + + utf8 = est_db_get_doc_attr (dict->db, id, "utf8"); + if (utf8) + g_hash_table_remove (dict->cache, utf8); + + success = est_db_out_doc (dict->db, id, ESTODCLEAN); if (!success) { g_warning ("out error: %s\n", est_err_msg (est_db_error (dict->db))); From kous users.sourceforge.jp Mon Dec 11 13:39:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:42 +0900 Subject: [Tomoe-cvs 1812] CVS update: tomoe Message-ID: <20061211043942.5E4D92AC1BC@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.421 tomoe/ChangeLog:1.422 --- tomoe/ChangeLog:1.421 Sun Dec 10 16:27:39 2006 +++ tomoe/ChangeLog Mon Dec 11 13:39:42 2006 @@ -1,3 +1,12 @@ +2006-12-11 Kouhei Sutou + + * configure.in, module/dict/tomoe-dict-mysql.c, + module/dict/Makefile.am, ext/ruby/tomoe-rb-dict.rb, + benchmark/search-by-dict.rb: supported MySQL. + + * test/tomoe-spec-utils.rb: added DB related configurations. + * db/: updated schemas. + 2006-12-10 Kouhei Sutou * module/dict/tomoe-dict-est.c: fixed a bug for caching. I want to Index: tomoe/configure.in diff -u tomoe/configure.in:1.46 tomoe/configure.in:1.47 --- tomoe/configure.in:1.46 Fri Dec 8 10:00:56 2006 +++ tomoe/configure.in Mon Dec 11 13:39:42 2006 @@ -169,6 +169,101 @@ AC_SUBST(recognizer_datadir) dnl ************************************************************** +dnl Bindings: Check for Ruby. +dnl ************************************************************** +ruby_available="no" +AC_ARG_WITH([ruby], + AS_HELP_STRING([--with-ruby=PATH], + [Ruby interpreter path (default: auto-detect)]), + [RUBY="$withval"]) + +if test "$RUBY" = "no"; then + : # ignore +elif test "$RUBY" = ""; then + AC_PATH_PROG(RUBY, ruby, none) + if test "$RUBY" != "none"; then + ruby_available="yes" + fi +else + AC_CHECK_FILE([$RUBY], + [ruby_available="yes"], + [AC_MSG_WARN([$RUBY is not found. Disable Ruby extension.])]) +fi + +if test "$ruby_available" = "yes"; then + rbconfig="$RUBY -rrbconfig -e " + + changequote(<<, >>) + for var_name in archdir sitearchdir CFLAGS LIBRUBYARG libdir \ + sitelibdir sitearchdir; do + rbconfig_tmp=`$rbconfig "print Config::CONFIG['$var_name']"` + eval "rbconfig_$var_name=\"$rbconfig_tmp\"" + done + changequote([, ]) + + RUBY_CFLAGS="$RUBY_CFLAGS -I$rbconfig_archdir " + RUBY_CFLAGS="$RUBY_CFLAGS -I$rbconfig_sitearchdir " + RUBY_CFLAGS="$RUBY_CFLAGS $rbconfig_CFLAGS " + RUBY_LIBS="$rbconfig_LIBRUBYARG" + RUBY_LDFLAGS="-L$rbconfig_libdir" + + AC_SUBST(RUBY_CFLAGS) + AC_SUBST(RUBY_LIBS) + AC_SUBST(RUBY_LDFLAGS) + + _SAVE_CFLAGS=$CFLAGS + ruby_undef_package_macros=" +#undef PACKAGE_NAME +#undef PACKAGE_TARNAME +#undef PACKAGE_STRING +#undef PACKAGE_VERSION +" + ruby_disable_message="Disable Ruby extension." + CFLAGS="$CFLAGS $RUBY_CFLAGS" + AC_CHECK_HEADERS(ruby.h, [], + [ruby_available="no" + AC_MSG_WARN([$ruby_disable_message])], + [$ruby_undef_package_macros]) + if test "x$ruby_available" = "xyes"; then + CFLAGS="$CFLAGS $GLIB_CFLAGS" + AC_CHECK_HEADERS(rbgobject.h, [], + [ruby_available="no" + AC_MSG_WARN([$ruby_disable_message])], + [$ruby_undef_package_macros]) + fi + CFLAGS=$_SAVE_CFLAGS + + AC_MSG_CHECKING([where to install Ruby extensions]) + AC_CACHE_VAL([tomoe_cv_ruby_archdir], + [tomoe_cv_ruby_archdir="$rbconfig_sitearchdir"]) + AC_ARG_WITH([ruby-extdir], + AC_HELP_STRING([--with-ruby-extdir=EXTDIR], + [install Ruby bindings in EXTDIR + (default is same as ruby's one)]), + [tomoe_ruby_extdir="$withval"], + [tomoe_ruby_extdir="$tomoe_cv_ruby_archdir"]) + ruby_extdir="$tomoe_ruby_extdir" + AC_MSG_RESULT([$ruby_extdir]) + + AC_MSG_CHECKING([where to install Ruby scripts]) + AC_CACHE_VAL([tomoe_cv_ruby_sitedir], + [tomoe_cv_ruby_sitedir="$rbconfig_sitelibdir"]) + AC_ARG_WITH([ruby-libdir], + AC_HELP_STRING([--with-ruby-libdir=LIBDIR], + [install Ruby scripts for bindings in LIBDIR + (default is same as ruby's one)]), + [tomoe_ruby_libdir="$withval"], + [tomoe_ruby_libdir="$tomoe_cv_ruby_sitedir"]) + ruby_libdir="$tomoe_ruby_libdir" + AC_MSG_RESULT([$ruby_libdir]) + + AC_SUBST(ruby_extdir) + AC_SUBST(ruby_libdir) +fi + +AM_CONDITIONAL([WITH_RUBY], [test "$ruby_available" = "yes"]) + +dnl ************************************************************** dnl Configure for modules. dnl ************************************************************** @@ -258,102 +353,24 @@ AM_CONDITIONAL([WITH_SVN], [test "$use_svn" = "yes"]) dnl ************************************************************** -dnl Bindings: Check for Ruby. +dnl Configure for MySQL dictionary. dnl ************************************************************** -ruby_available="no" -AC_ARG_WITH([ruby], - AS_HELP_STRING([--with-ruby=PATH], - [Ruby interpreter path (default: auto-detect)]), - [RUBY="$withval"]) - -if test "$RUBY" = "no"; then - : # ignore -elif test "$RUBY" = ""; then - AC_PATH_PROG(RUBY, ruby, none) - if test "$RUBY" != "none"; then - ruby_available="yes" - fi -else - AC_CHECK_FILE([$RUBY], - [ruby_available="yes"], - [AC_MSG_WARN([$RUBY is not found. Disable Ruby extension.])]) -fi - -if test "$ruby_available" = "yes"; then - rbconfig="$RUBY -rrbconfig -e " - - changequote(<<, >>) - for var_name in archdir sitearchdir CFLAGS LIBRUBYARG libdir \ - sitelibdir sitearchdir; do - rbconfig_tmp=`$rbconfig "print Config::CONFIG['$var_name']"` - eval "rbconfig_$var_name=\"$rbconfig_tmp\"" - done - changequote([, ]) - - RUBY_CFLAGS="$RUBY_CFLAGS -I$rbconfig_archdir " - RUBY_CFLAGS="$RUBY_CFLAGS -I$rbconfig_sitearchdir " - RUBY_CFLAGS="$RUBY_CFLAGS $rbconfig_CFLAGS " - RUBY_LIBS="$rbconfig_LIBRUBYARG" - RUBY_LDFLAGS="-L$rbconfig_libdir" - - AC_SUBST(RUBY_CFLAGS) - AC_SUBST(RUBY_LIBS) - AC_SUBST(RUBY_LDFLAGS) - - _SAVE_CFLAGS=$CFLAGS - ruby_undef_package_macros=" -#undef PACKAGE_NAME -#undef PACKAGE_TARNAME -#undef PACKAGE_STRING -#undef PACKAGE_VERSION -" - ruby_disable_message="Disable Ruby extension." - CFLAGS="$CFLAGS $RUBY_CFLAGS" - AC_CHECK_HEADERS(ruby.h, [], - [ruby_available="no" - AC_MSG_WARN([$ruby_disable_message])], - [$ruby_undef_package_macros]) - if test "x$ruby_available" = "xyes"; then - CFLAGS="$CFLAGS $GLIB_CFLAGS" - AC_CHECK_HEADERS(rbgobject.h, [], - [ruby_available="no" - AC_MSG_WARN([$ruby_disable_message])], - [$ruby_undef_package_macros]) - fi - CFLAGS=$_SAVE_CFLAGS - - AC_MSG_CHECKING([where to install Ruby extensions]) - AC_CACHE_VAL([tomoe_cv_ruby_archdir], - [tomoe_cv_ruby_archdir="$rbconfig_sitearchdir"]) - AC_ARG_WITH([ruby-extdir], - AC_HELP_STRING([--with-ruby-extdir=EXTDIR], - [install Ruby bindings in EXTDIR - (default is same as ruby's one)]), - [tomoe_ruby_extdir="$withval"], - [tomoe_ruby_extdir="$tomoe_cv_ruby_archdir"]) - ruby_extdir="$tomoe_ruby_extdir" - AC_MSG_RESULT([$ruby_extdir]) - AC_MSG_CHECKING([where to install Ruby scripts]) - AC_CACHE_VAL([tomoe_cv_ruby_sitedir], - [tomoe_cv_ruby_sitedir="$rbconfig_sitelibdir"]) - AC_ARG_WITH([ruby-libdir], - AC_HELP_STRING([--with-ruby-libdir=LIBDIR], - [install Ruby scripts for bindings in LIBDIR - (default is same as ruby's one)]), - [tomoe_ruby_libdir="$withval"], - [tomoe_ruby_libdir="$tomoe_cv_ruby_sitedir"]) - ruby_libdir="$tomoe_ruby_libdir" - AC_MSG_RESULT([$ruby_libdir]) +AC_PATH_PROG(MYSQL_CONFIG, mysql_config, mysql_config-not-found) - AC_SUBST(ruby_extdir) - AC_SUBST(ruby_libdir) +if test "x$MYSQL_CONFIG" != "xmysql_config-not-found"; then + enable_mysql=yes + MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags` + MYSQL_LIBS=`$MYSQL_CONFIG --libs` fi -AM_CONDITIONAL([WITH_RUBY], [test "$ruby_available" = "yes"]) +AC_SUBST(MYSQL_CFLAGS) +AC_SUBST(MYSQL_LIBS) + +AM_CONDITIONAL([WITH_MYSQL], [test "x$enable_mysql" = "xyes"]) dnl ************************************************************** -dnl Check for Ruby dictionary module +dnl Configure for Ruby dictionary. dnl ************************************************************** AC_ARG_ENABLE(dict_ruby, [ --enable-dict-ruby Enable Ruby based dictionary module]) From kous users.sourceforge.jp Mon Dec 11 13:39:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:42 +0900 Subject: [Tomoe-cvs 1813] CVS update: tomoe/benchmark Message-ID: <20061211043942.83BF82AC2BC@users.sourceforge.jp> Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.4 tomoe/benchmark/search-by-dict.rb:1.5 --- tomoe/benchmark/search-by-dict.rb:1.4 Sun Dec 10 14:51:50 2006 +++ tomoe/benchmark/search-by-dict.rb Mon Dec 11 13:39:42 2006 @@ -10,17 +10,19 @@ require "tomoe-spec-utils" n = 10 -use_est = false -use_svn = false +dict_type = ARGV.shift tmp_dir = TomoeSpecUtils::Config.tmp_dir Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| - if use_est + case dict_type + when "mysql" + dict = Tomoe::Dict.new("mysql", TomoeSpecUtils::Config.db_config) + when "est" dict = Tomoe::Dict.new("est", "name" => File.basename(dictionary), "database_name" => dictionary.sub(/\.xml$/, ''), "editable" => false) - elsif use_svn + when "svn" repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) FileUtils.mkdir_p(repos) repos_url = "file://#{repos}" From kous users.sourceforge.jp Mon Dec 11 13:39:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:42 +0900 Subject: [Tomoe-cvs 1814] CVS update: tomoe/db Message-ID: <20061211043942.AAB602AC1BC@users.sourceforge.jp> Index: tomoe/db/config.yml.example diff -u tomoe/db/config.yml.example:1.1 tomoe/db/config.yml.example:1.2 --- tomoe/db/config.yml.example:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/config.yml.example Mon Dec 11 13:39:42 2006 @@ -4,3 +4,4 @@ password: host: localhost socket: /var/run/mysqld/mysqld.sock +encoding: utf8 Index: tomoe/db/search.rb diff -u tomoe/db/search.rb:1.2 tomoe/db/search.rb:1.3 --- tomoe/db/search.rb:1.2 Fri Dec 8 18:06:37 2006 +++ tomoe/db/search.rb Mon Dec 11 13:39:42 2006 @@ -27,7 +27,7 @@ query.max_n_strokes = 10 dict = Tomoe::Dict.new("unihan", {}) -cands = dict.search(Tomoe::Query.new)[0...10000].find_all do |cand| +cands = dict.search(Tomoe::Query.new).find_all do |cand| n_strokes = cand.char.n_strokes 0 <= n_strokes and query.min_n_strokes <= n_strokes and Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.2 tomoe/db/xml2db.rb:1.3 --- tomoe/db/xml2db.rb:1.2 Fri Dec 8 18:06:37 2006 +++ tomoe/db/xml2db.rb Mon Dec 11 13:39:42 2006 @@ -30,18 +30,20 @@ `#{migrate}` puts "done." -dict = Tomoe::Dict.new("unihan", {}) -cands = dict.search(Tomoe::Query.new)[0...10000] +dict = Tomoe::Dict.new("xml", + "filename" => TomoeSpecUtils::Config.dictionaries.first, + "editable" => false) +cands = dict.search(Tomoe::Query.new) puts "dict size: #{cands.size}" print "converting..." $stdout.flush +$KCODE = "u" cands.each_with_index do |cand, i| char = cand.char - new_char = Char.new(:n_strokes => char.n_strokes < 0 ? nil : char.n_strokes, - :variant => char.variant) - new_char.id = char.utf8 - new_char.save! + Char.new(:utf8 => char.utf8, + :n_strokes => char.n_strokes < 0 ? nil : char.n_strokes, + :variant => char.variant).save! char.readings.each do |reading| Reading.new(:utf8 => char.utf8, :reading_type => reading.type.to_i, From kous users.sourceforge.jp Mon Dec 11 13:39:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:42 +0900 Subject: [Tomoe-cvs 1815] CVS update: tomoe/db/lib Message-ID: <20061211043942.CCBA02AC2BC@users.sourceforge.jp> Index: tomoe/db/lib/char.rb diff -u tomoe/db/lib/char.rb:1.2 tomoe/db/lib/char.rb:1.3 --- tomoe/db/lib/char.rb:1.2 Fri Dec 8 18:06:37 2006 +++ tomoe/db/lib/char.rb Mon Dec 11 13:39:42 2006 @@ -1,5 +1,4 @@ class Char < ActiveRecord::Base - set_primary_key :utf8 has_many :readings, :foreign_key => "utf8" has_many :radicals, :foreign_key => "utf8" has_many :meta_data, :foreign_key => "utf8" From kous users.sourceforge.jp Mon Dec 11 13:39:43 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:43 +0900 Subject: [Tomoe-cvs 1816] CVS update: tomoe/db/migrate Message-ID: <20061211043943.04A042AC1BC@users.sourceforge.jp> Index: tomoe/db/migrate/001_create_chars.rb diff -u tomoe/db/migrate/001_create_chars.rb:1.2 tomoe/db/migrate/001_create_chars.rb:1.3 --- tomoe/db/migrate/001_create_chars.rb:1.2 Fri Dec 8 18:06:37 2006 +++ tomoe/db/migrate/001_create_chars.rb Mon Dec 11 13:39:42 2006 @@ -1,6 +1,6 @@ class CreateChars < ActiveRecord::Migration def self.up - create_table(:chars, :id => false) do |t| + create_table(:chars) do |t| t.column :utf8, :string t.column :n_strokes, :integer t.column :variant, :string From kous users.sourceforge.jp Mon Dec 11 13:39:43 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:43 +0900 Subject: [Tomoe-cvs 1817] CVS update: tomoe/ext/ruby Message-ID: <20061211043943.2ABDF2AC2BC@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.19 tomoe/ext/ruby/tomoe-rb-dict.c:1.20 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.19 Fri Dec 8 10:00:56 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Mon Dec 11 13:39:43 2006 @@ -23,6 +23,8 @@ gchar *name; name = RVAL2CSTR(rb_name); + Check_Type(props, T_HASH); + if (strcmp(name, "xml") == 0) { VALUE filename, editable; filename = rb_hash_aref(props, CSTR2RVAL("filename")); @@ -57,6 +59,20 @@ NULL); } else if (strcmp(name, "ruby") == 0) { dict = tomoe_dict_new(name, NULL); + } else if (strcmp(name, "mysql") == 0) { + VALUE database, username, password, host, socket; + database = rb_hash_aref(props, CSTR2RVAL("database")); + username = rb_hash_aref(props, CSTR2RVAL("username")); + password = rb_hash_aref(props, CSTR2RVAL("password")); + host = rb_hash_aref(props, CSTR2RVAL("host")); + socket = rb_hash_aref(props, CSTR2RVAL("socket")); + dict = tomoe_dict_new(name, + "database", RVAL2CSTR2(database), + "user", RVAL2CSTR2(username), + "password", RVAL2CSTR2(password), + "host", RVAL2CSTR2(host), + "socket", RVAL2CSTR2(socket), + NULL); } else { rb_raise(rb_eArgError, "unknown dictionary type: %s", name); dict = NULL; Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.9 tomoe/ext/ruby/tomoe-rb.h:1.10 --- tomoe/ext/ruby/tomoe-rb.h:1.9 Wed Dec 6 15:28:36 2006 +++ tomoe/ext/ruby/tomoe-rb.h Mon Dec 11 13:39:43 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.9 2006/12/06 06:28:36 kous Exp $ + * $Id: tomoe-rb.h,v 1.10 2006/12/11 04:39:43 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -36,6 +36,10 @@ VALUE _tomoe_ruby_object_from_instance_with_unref(gpointer instance); #endif +#ifndef RVAL2CSTR2 +# define RVAL2CSTR2(v) (NIL_P(v) ? NULL : RVAL2CSTR(v)) +#endif + void Init_tomoe(void); void Init_tomoe_candidate(VALUE mTomoe); void Init_tomoe_char(VALUE mTomoe); From kous users.sourceforge.jp Mon Dec 11 13:39:43 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:43 +0900 Subject: [Tomoe-cvs 1818] CVS update: tomoe/module/dict Message-ID: <20061211043943.5396C2AC1BC@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.20 tomoe/module/dict/Makefile.am:1.21 --- tomoe/module/dict/Makefile.am:1.20 Sun Dec 10 14:21:16 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 11 13:39:43 2006 @@ -30,6 +30,7 @@ $(TOMOE_CFLAGS) \ $(EST_CFLAGS) \ $(SVN_CFLAGS) \ + $(MYSQL_CFLAGS) \ $(RUBY_CFLAGS) LIBADD = $(TOMOE_LIBS) @@ -96,3 +97,10 @@ libsvn_la_SOURCES = tomoe-dict-svn.c libsvn_la_LIBADD = $(SVN_LIBS) endif + +if WITH_MYSQL +dict_module_LTLIBRARIES += libmysql.la + +libmysql_la_SOURCES = tomoe-dict-mysql.c +libmysql_la_LIBADD = $(MYSQL_LIBS) +endif Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.10 tomoe/module/dict/tomoe-dict-est.c:1.11 --- tomoe/module/dict/tomoe-dict-est.c:1.10 Sun Dec 10 16:27:40 2006 +++ tomoe/module/dict/tomoe-dict-est.c Mon Dec 11 13:39:43 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.10 2006/12/10 07:27:40 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.11 2006/12/11 04:39:43 kous Exp $ */ #include @@ -447,7 +447,6 @@ g_free (expr); results = est_db_search (dict->db, cond, &n_results, NULL); - for (i = 0; i < n_results; i++) { chr = retrieve_char_by_id (dict, results[i]); if (chr) break; Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u /dev/null tomoe/module/dict/tomoe-dict-mysql.c:1.1 --- /dev/null Mon Dec 11 13:39:43 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 11 13:39:43 2006 @@ -0,0 +1,837 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: tomoe-dict-mysql.c,v 1.1 2006/12/11 04:39:43 kous Exp $ + */ + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#define TOMOE_TYPE_DICT_MYSQL tomoe_type_dict_mysql +#define TOMOE_DICT_MYSQL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICT_MYSQL, TomoeDictMySQL)) +#define TOMOE_DICT_MYSQL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICT_MYSQL, TomoeDictMySQLClass)) +#define TOMOE_IS_DICT_MYSQL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICT_MYSQL)) +#define TOMOE_IS_DICT_MYSQL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_MYSQL)) +#define TOMOE_DICT_MYSQL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_MYSQL, TomoeDictMySQLClass)) + +enum { + PROP_0, + PROP_NAME, + PROP_EDITABLE, + PROP_HOST, + PROP_USER, + PROP_PASSWORD, + PROP_DATABASE, + PROP_PORT, + PROP_SOCKET +}; + +typedef struct _TomoeDictMySQL TomoeDictMySQL; +typedef struct _TomoeDictMySQLClass TomoeDictMySQLClass; +struct _TomoeDictMySQL +{ + TomoeDict object; + gchar *name; + + gboolean editable; + + MYSQL *mysql; + + char *host; + char *user; + char *password; + char *database; + unsigned int port; + char *socket; +}; + +struct _TomoeDictMySQLClass +{ + TomoeDictClass parent_class; +}; + +static GType tomoe_type_dict_mysql = 0; +static GObjectClass *parent_class; + +static GObject *constructor (GType type, + guint n_props, + GObjectConstructParam *props); +static void dispose (GObject *object); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static const gchar *get_name (TomoeDict *dict); +static gboolean register_char (TomoeDict *dict, + TomoeChar *chr); +static gboolean unregister_char (TomoeDict *dict, + const gchar *utf8); +static TomoeChar *get_char (TomoeDict *dict, + const gchar *utf8); +static GList *search (TomoeDict *dict, + TomoeQuery *query); +static gboolean flush (TomoeDict *dict); +static gboolean is_editable (TomoeDict *dict); +static gboolean tomoe_dict_mysql_connect (TomoeDictMySQL *dict); +static gboolean tomoe_dict_mysql_close (TomoeDictMySQL *dict); + +static void +class_init (TomoeDictMySQLClass *klass) +{ + GObjectClass *gobject_class; + TomoeDictClass *dict_class; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->constructor = constructor; + gobject_class->dispose = dispose; + gobject_class->set_property = set_property; + gobject_class->get_property = get_property; + + dict_class = TOMOE_DICT_CLASS (klass); + dict_class->get_name = get_name; + dict_class->register_char = register_char; + dict_class->unregister_char = unregister_char; + dict_class->get_char = get_char; + dict_class->search = search; + dict_class->flush = flush; + dict_class->is_editable = is_editable; + + g_object_class_install_property ( + gobject_class, + PROP_NAME, + g_param_spec_string ( + "name", + "Name", + "The name of the dictionary", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property( + gobject_class, + PROP_EDITABLE, + g_param_spec_boolean( + "editable", + "Editable", + "Editable flag", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property ( + gobject_class, + PROP_HOST, + g_param_spec_string ( + "host", + "Host", + "The host name of MySQL server", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + gobject_class, + PROP_USER, + g_param_spec_string ( + "user", + "User", + "The user name to connect MySQL server", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + gobject_class, + PROP_PASSWORD, + g_param_spec_string ( + "password", + "Password", + "The password to connect MySQL server", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + gobject_class, + PROP_DATABASE, + g_param_spec_string ( + "database", + "Database", + "The database name of MySQL server", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + gobject_class, + PROP_PORT, + g_param_spec_uint ( + "port", + "Port", + "The port number to connect MySQL server", + 0, 65535, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property ( + gobject_class, + PROP_SOCKET, + g_param_spec_string ( + "socket", + "Socket", + "The socket file name of MySQL server", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); +} + +static void +init (TomoeDictMySQL *dict) +{ + dict->name = NULL; + dict->editable = FALSE; + + dict->mysql = NULL; + + dict->host = NULL; + dict->user = NULL; + dict->password = NULL; + dict->database = NULL; + dict->port = 0; + dict->socket = NULL; +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = + { + sizeof (TomoeDictMySQLClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (TomoeDictMySQL), + 0, + (GInstanceInitFunc) init, + }; + + tomoe_type_dict_mysql = g_type_module_register_type (type_module, + TOMOE_TYPE_DICT, + "TomoeDictMySQL", + &info, 0); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + register_type (type_module); +} + +G_MODULE_EXPORT void +TOMOE_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist (TOMOE_TYPE_DICT_MYSQL, first_property, var_args); +} + +static GObject * +constructor (GType type, guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GObjectClass *klass = G_OBJECT_CLASS (parent_class); + TomoeDictMySQL *dict; + + object = klass->constructor (type, n_props, props); + dict = TOMOE_DICT_MYSQL (object); + + tomoe_dict_mysql_connect (dict); + + return object; +} + +static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (object); + + switch (prop_id) { + case PROP_NAME: + g_free (dict->name); + dict->name = g_value_dup_string (value); + break; + case PROP_EDITABLE: + dict->editable = g_value_get_boolean (value); + break; + case PROP_HOST: + g_free (dict->host); + dict->host = g_value_dup_string (value); + break; + case PROP_USER: + g_free (dict->user); + dict->user = g_value_dup_string (value); + break; + case PROP_PASSWORD: + g_free (dict->password); + dict->password = g_value_dup_string (value); + break; + case PROP_DATABASE: + g_free (dict->database); + dict->database = g_value_dup_string (value); + break; + case PROP_PORT: + dict->port = g_value_get_uint (value); + break; + case PROP_SOCKET: + g_free (dict->socket); + dict->socket = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void +get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (object); + + switch (prop_id) { + case PROP_NAME: + g_value_set_string (value, dict->name); + break; + case PROP_EDITABLE: + g_value_set_boolean (value, dict->editable); + break; + case PROP_HOST: + g_value_set_string (value, dict->host); + break; + case PROP_USER: + g_value_set_string (value, dict->user); + break; + case PROP_PASSWORD: + g_value_set_string (value, dict->password); + break; + case PROP_DATABASE: + g_value_set_string (value, dict->database); + break; + case PROP_PORT: + g_value_set_uint (value, dict->port); + break; + case PROP_SOCKET: + g_value_set_string (value, dict->socket); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +dispose (GObject *object) +{ + TomoeDictMySQL *dict; + + dict = TOMOE_DICT_MYSQL (object); + + tomoe_dict_mysql_close (dict); + + if (dict->name) + g_free (dict->name); + if (dict->host) + g_free (dict->host); + if (dict->user) + g_free (dict->user); + if (dict->password) + g_free (dict->password); + if (dict->database) + g_free (dict->database); + if (dict->socket) + g_free (dict->socket); + + dict->name = NULL; + dict->host = NULL; + dict->user = NULL; + dict->password = NULL; + dict->database = NULL; + dict->socket = NULL; + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static const gchar* +get_name (TomoeDict *_dict) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), NULL); + return dict->name; +} + +static gboolean +execute_query (TomoeDictMySQL *dict, const gchar *sql) +{ + int status; + + status = mysql_query (dict->mysql, sql); + if (status) { + g_warning ("failed to execute query: %s: %s", + sql, mysql_error (dict->mysql)); + return FALSE; + } else { + return TRUE; + } +} + +static void +append_string_value (TomoeDictMySQL *dict, GString *sql, const gchar *value) +{ + gint len; + gchar *escaped_value; + + len = strlen (value); + escaped_value = g_new (gchar, len * 2 + 1); + mysql_real_escape_string (dict->mysql, escaped_value, value, len); + g_string_append_printf (sql, "'%s'", escaped_value); + g_free (escaped_value); +} + +static gboolean +register_char (TomoeDict *_dict, TomoeChar *chr) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + GString *sql; + gint n_strokes; + const gchar *variant; + GList *node; + const gchar *utf8; + + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), FALSE); + g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); + + g_return_val_if_fail (dict->mysql, FALSE); + + sql = g_string_new ("INSERT INTO chars (`utf8`, " \ + "`n_strokes` `variant`) VALUES ("); + + utf8 = tomoe_char_get_utf8 (chr); + append_string_value (dict, sql, utf8); + + n_strokes = tomoe_char_get_n_strokes (chr); + if (n_strokes >= 0) + g_string_append_printf (sql, ", %d, ", n_strokes); + else + g_string_append (sql, ", NULL, "); + + variant = tomoe_char_get_variant (chr); + if (variant) + g_string_append_printf (sql, "%d)", g_utf8_get_char (variant)); + else + g_string_append (sql, "NULL)"); + + if (!execute_query (dict, sql->str)) { + g_string_free (sql, TRUE); + return FALSE; + } + + for (node = (GList *)tomoe_char_get_readings (chr); + node; + node = g_list_next (node)) { + TomoeReading *reading = node->data; + + g_string_assign (sql, + "INSERT INTO readings (`utf8`, " \ + "`reading_type`, `reading`) VALUES ("); + append_string_value (dict, sql, utf8); + g_string_append_printf (sql, ", %d, ", + tomoe_reading_get_reading_type (reading)); + append_string_value (dict, sql, tomoe_reading_get_reading (reading)); + g_string_append (sql, ")"); + + if (!execute_query (dict, sql->str)) { + g_string_free (sql, TRUE); + return FALSE; + } + } + + for (node = (GList *)tomoe_char_get_radicals (chr); + node; + node = g_list_next (node)) { + const gchar *radical = node->data; + + g_string_assign (sql, + "INSERT INTO radicals (`utf8`, `radical`) VALUES ("); + append_string_value (dict, sql, utf8); + g_string_append (sql, ", "); + append_string_value (dict, sql, radical); + g_string_append (sql, ")"); + if (!execute_query (dict, sql->str)) { + g_string_free (sql, TRUE); + return FALSE; + } + } + + /* tomoe_char_meta_data_foreach (chr, register_meta_data, dict); */ + + g_string_free (sql, TRUE); + return TRUE; +} + +static gboolean +unregister_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + GString *sql; + gboolean success; + + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), FALSE); + g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); + + g_return_val_if_fail (dict->mysql, FALSE); + + sql = g_string_new ("DELETE FROM chars WHERE `utf8` = "); + append_string_value (dict, sql, utf8); + success = execute_query (dict, sql->str); + if (!success) goto done; + + g_string_assign (sql, "DELETE FROM readings WHERE `utf8` = "); + append_string_value (dict, sql, utf8); + success = execute_query (dict, sql->str); + if (!success) goto done; + + g_string_assign (sql, "DELETE FROM radicals WHERE `utf8` = "); + append_string_value (dict, sql, utf8); + success = execute_query (dict, sql->str); + if (!success) goto done; + + g_string_assign (sql, "DELETE FROM meta_data WHERE `utf8` = "); + append_string_value (dict, sql, utf8); + success = execute_query (dict, sql->str); + if (!success) goto done; + + done: + g_string_free (sql, TRUE); + return success; +} + +static gchar * +generate_sql (TomoeDictMySQL *dict, TomoeQuery *query) +{ + GString *sql; + const gchar *utf8; + gint min_n_strokes, max_n_strokes; + GList *node; + + sql = g_string_new ("SELECT " \ + "chars.utf8 AS utf8, " \ + "chars.n_strokes AS n_strokes, " \ + "chars.variant AS variant, " \ + "readings.id AS reading_id, " \ + "readings.reading_type AS reading_type, " \ + "readings.reading AS reading, " \ + "radicals.id AS radical_id, " \ + "radicals.radical_utf8 AS radical_utf8 " \ + "FROM chars " \ + "LEFT OUTER JOIN readings " \ + "ON chars.utf8 = readings.utf8 " \ + "LEFT OUTER JOIN radicals " \ + "ON chars.utf8 = radicals.utf8 " \ + "WHERE TRUE = TRUE"); + + utf8 = tomoe_query_get_utf8 (query); + if (utf8) { + g_string_append (sql, " AND chars.utf8 = "); + append_string_value (dict, sql, utf8); + } + + min_n_strokes = tomoe_query_get_min_n_strokes (query); + if (min_n_strokes >= 0) { + g_string_append_printf (sql, " AND chars.n_strokes >= %d", + min_n_strokes); + } + + max_n_strokes = tomoe_query_get_max_n_strokes (query); + if (max_n_strokes >= 0) { + g_string_append_printf (sql, " AND chars.n_strokes <= %d", + max_n_strokes); + } + + for (node = (GList *)tomoe_query_get_readings (query); + node; + node = g_list_next (node)) { + TomoeReading *tomoe_reading = node->data; + TomoeReadingType reading_type; + const gchar *reading; + + reading_type = tomoe_reading_get_reading_type (tomoe_reading); + if (reading_type != TOMOE_READING_INVALID) + g_string_append_printf (sql, " AND readings.reading_type = %d", + reading_type); + + reading = tomoe_reading_get_reading (tomoe_reading); + if (reading) { + g_string_append (sql, " AND readings.reading = "); + append_string_value (dict, sql, reading); + } + } + + return g_string_free (sql, FALSE); +} + +static GList * +retrieve_candidates (TomoeDictMySQL *dict, MYSQL_RES *result) +{ + GList *results = NULL; + TomoeChar *chr = NULL; + GArray *reading_ids = NULL, *radical_ids = NULL; + gchar *prev_utf8 = NULL; + MYSQL_ROW row; + + while ((row = mysql_fetch_row (result))) { + gchar *utf8; + gint n_strokes = -1; + gchar *variant; + gint reading_id = -1; + TomoeReadingType reading_type = TOMOE_READING_INVALID; + gchar *reading; + gint radical_id = -1; + gchar *radical; + + utf8 = row[0]; + if (row[1]) + n_strokes = atoi (row[1]); + variant = row[2]; + if (row[3]) + reading_id = atoi (row[3]); + if (row[4]) + reading_type = atoi (row[4]); + reading = row[5]; + if (row[6]) + radical_id = atoi (row[6]); + radical = row[7]; + + if (chr && utf8 && prev_utf8 && strcmp (utf8, prev_utf8) != 0) { + TomoeCandidate *cand; + + cand = tomoe_candidate_new (chr); + results = g_list_prepend (results, cand); + g_object_unref (chr); + chr = NULL; + g_free (prev_utf8); + prev_utf8 = NULL; + if (reading_ids) + g_array_free (reading_ids, TRUE); + if (radical_ids) + g_array_free (radical_ids, TRUE); + reading_ids = NULL; + radical_ids = NULL; + } + + if (!prev_utf8) + prev_utf8 = g_strdup (utf8); + + if (!reading_ids) + reading_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); + if (!radical_ids) + radical_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); + + if (!chr) { + chr = tomoe_char_new (); + tomoe_char_set_utf8 (chr, utf8); + tomoe_char_set_n_strokes (chr, n_strokes); + tomoe_char_set_variant (chr, variant); + } + + if (chr && reading_id >= 0 && + (reading_ids->len <= reading_id || + !reading_ids->data[reading_id])) { + TomoeReading *tomoe_reading; + + if (reading_ids->len <= reading_id) { + g_array_set_size (reading_ids, reading_id); + } + reading_ids->data[reading_id] = TRUE; + + tomoe_reading = tomoe_reading_new (reading_type, reading); + tomoe_char_add_reading (chr, tomoe_reading); + g_object_unref (tomoe_reading); + } + + if (chr && radical_id >= 0 && + (radical_ids->len <= radical_id || + !radical_ids->data[radical_id])) { + if (radical_ids->len <= radical_id) { + g_array_set_size (radical_ids, radical_id); + } + radical_ids->data[radical_id] = TRUE; + tomoe_char_add_radical (chr, radical); + } + } + + if (chr) { + TomoeCandidate *cand; + + cand = tomoe_candidate_new (chr); + results = g_list_prepend (results, cand); + g_object_unref (chr); + } + + if (prev_utf8) + g_free (prev_utf8); + if (reading_ids) + g_array_free (reading_ids, TRUE); + if (radical_ids) + g_array_free (radical_ids, TRUE); + + return results; +} + +static TomoeChar * +get_char (TomoeDict *_dict, const gchar *utf8) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + TomoeChar *chr = NULL; + TomoeQuery *query; + GList *cands; + + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), chr); + g_return_val_if_fail (TOMOE_IS_CHAR (chr), chr); + + g_return_val_if_fail (dict->mysql, chr); + + query = tomoe_query_new (); + tomoe_query_set_utf8 (query, utf8); + cands = search (_dict, query); + g_object_unref (query); + + if (cands) { + chr = g_object_ref (cands->data); + g_list_foreach (cands, (GFunc) g_object_unref, NULL); + g_list_free (cands); + } + + return chr; +} + +static GList * +search (TomoeDict *_dict, TomoeQuery *query) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + gchar *sql; + MYSQL_RES *result; + GList *results = NULL; + gboolean success; + + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), results); + g_return_val_if_fail (TOMOE_IS_QUERY (query), results); + + g_return_val_if_fail (dict->mysql, results); + + sql = generate_sql (dict, query); + success = execute_query (dict, sql); + g_free (sql); + if (!success) + return NULL; + + result = mysql_use_result (dict->mysql); + if (result) { + results = retrieve_candidates (dict, result); + mysql_free_result (result); + } + + return results; +} + +static gboolean +flush (TomoeDict *_dict) +{ + return TRUE; +} + +static gboolean +is_editable (TomoeDict *_dict) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), FALSE); + + return dict->editable; +} + +static gboolean +tomoe_dict_mysql_connect (TomoeDictMySQL *dict) +{ + tomoe_dict_mysql_close (dict); + + dict->mysql = mysql_init (NULL); + if (!dict->mysql) { + g_warning ("cannot initialize MySQL handler"); + return FALSE; + } + + mysql_options(dict->mysql, MYSQL_READ_DEFAULT_GROUP, "TOMOE"); + mysql_options(dict->mysql, MYSQL_SET_CHARSET_NAME, "UTF8"); + if (!mysql_real_connect (dict->mysql, dict->host, dict->user, + dict->password, dict->database, dict->port, + dict->socket, 0)) { + g_warning ("cannot connect to %s at %s:%d/%s by %s XXX: %s", + dict->database, dict->host, dict->port, + dict->socket, dict->user, mysql_error (dict->mysql)); + return FALSE; + } + + return TRUE; +} + +static gboolean +tomoe_dict_mysql_close (TomoeDictMySQL *dict) +{ + if (dict->mysql) + mysql_close (dict->mysql); + dict->mysql = NULL; + + return TRUE; +} + +/* +vi:ts=4:nowrap:ai:expandtab +*/ From kous users.sourceforge.jp Mon Dec 11 13:39:43 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 13:39:43 +0900 Subject: [Tomoe-cvs 1819] CVS update: tomoe/test Message-ID: <20061211043943.7B2172AC2BC@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.22 tomoe/test/tomoe-spec-utils.rb:1.23 --- tomoe/test/tomoe-spec-utils.rb:1.22 Fri Dec 8 12:29:49 2006 +++ tomoe/test/tomoe-spec-utils.rb Mon Dec 11 13:39:43 2006 @@ -1,5 +1,6 @@ require 'tempfile' require 'fileutils' +require 'yaml' require 'uconv' require 'tomoe' @@ -90,6 +91,18 @@ File.join(module_dir, "dict", ".libs") end + def db_dir + File.join(top_dir, "db") + end + + def db_config_file + File.join(db_dir, "config.yml") + end + + def db_config + YAML.load(File.read(db_config_file)) + end + def setup_context super @config_file = make_config_file From kous users.sourceforge.jp Mon Dec 11 14:40:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 14:40:36 +0900 Subject: [Tomoe-cvs 1820] CVS update: tomoe Message-ID: <20061211054036.AE7EE2AC2BC@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.422 tomoe/ChangeLog:1.423 --- tomoe/ChangeLog:1.422 Mon Dec 11 13:39:42 2006 +++ tomoe/ChangeLog Mon Dec 11 14:40:36 2006 @@ -1,5 +1,13 @@ 2006-12-11 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c (register_char, unregister_char): + clean up. + * test/dict_spec.rb: added tests for MySQL backend. + + * test/tomoe-spec-utils.rb, test/config.yaml.example: supported + environment. + * test/, benchmark/: followed the changes. + * configure.in, module/dict/tomoe-dict-mysql.c, module/dict/Makefile.am, ext/ruby/tomoe-rb-dict.rb, benchmark/search-by-dict.rb: supported MySQL. From kous users.sourceforge.jp Mon Dec 11 14:40:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 14:40:37 +0900 Subject: [Tomoe-cvs 1821] CVS update: tomoe/benchmark Message-ID: <20061211054037.1372C2AC1C9@users.sourceforge.jp> Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.5 tomoe/benchmark/search-by-dict.rb:1.6 --- tomoe/benchmark/search-by-dict.rb:1.5 Mon Dec 11 13:39:42 2006 +++ tomoe/benchmark/search-by-dict.rb Mon Dec 11 14:40:36 2006 @@ -16,7 +16,8 @@ TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| case dict_type when "mysql" - dict = Tomoe::Dict.new("mysql", TomoeSpecUtils::Config.db_config) + dict = Tomoe::Dict.new("mysql", + TomoeSpecUtils::Config.db_config("benchmark")) when "est" dict = Tomoe::Dict.new("est", "name" => File.basename(dictionary), From kous users.sourceforge.jp Mon Dec 11 14:40:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 14:40:37 +0900 Subject: [Tomoe-cvs 1822] CVS update: tomoe/db Message-ID: <20061211054037.3B3AC2AC2BC@users.sourceforge.jp> Index: tomoe/db/config.yml.example diff -u tomoe/db/config.yml.example:1.2 tomoe/db/config.yml.example:1.3 --- tomoe/db/config.yml.example:1.2 Mon Dec 11 13:39:42 2006 +++ tomoe/db/config.yml.example Mon Dec 11 14:40:37 2006 @@ -1,7 +1,19 @@ -adapter: mysql -database: tomoe -username: root -password: -host: localhost -socket: /var/run/mysqld/mysqld.sock -encoding: utf8 +test: + adapter: mysql + database: tomoe-test + username: root + password: + host: localhost + socket: /var/run/mysqld/mysqld.sock + encoding: utf8 + editable: true + +benchmark: + adapter: mysql + database: tomoe-benchmark + username: root + password: + host: localhost + socket: /var/run/mysqld/mysqld.sock + encoding: utf8 + editable: false Index: tomoe/db/init.rb diff -u tomoe/db/init.rb:1.1 tomoe/db/init.rb:1.2 --- tomoe/db/init.rb:1.1 Fri Dec 8 12:29:49 2006 +++ tomoe/db/init.rb Mon Dec 11 14:40:37 2006 @@ -4,9 +4,15 @@ require 'yaml' base = File.expand_path(File.dirname(__FILE__)) -config_file = File.join(base, "config.yml") +top = File.expand_path(File.join(base, "..")) -config = YAML.load(File.read(config_file)) +$LOAD_PATH.unshift(File.join(top, "test")) +$LOAD_PATH.unshift(File.join(top, "ext", "ruby", ".libs")) +$LOAD_PATH.unshift(File.join(top, "ext", "ruby")) + +require 'tomoe-spec-utils' + +config = TomoeSpecUtils::Config.db_config(ENV["TOMOE_ENV"]) ActiveRecord::Base.establish_connection(config) logger = Logger.new($stdout) Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.3 tomoe/db/xml2db.rb:1.4 --- tomoe/db/xml2db.rb:1.3 Mon Dec 11 13:39:42 2006 +++ tomoe/db/xml2db.rb Mon Dec 11 14:40:37 2006 @@ -1,17 +1,12 @@ #!/usr/bin/env ruby -top = File.expand_path(File.join(File.dirname(__FILE__), "..")) -base = File.join(top, File.dirname(__FILE__)) +ENV["TOMOE_ENV"] ||= "benchmark" + +base = File.expand_path(File.dirname(__FILE__)) require File.join(base, "init") ActiveRecord::Base.logger.level = Logger::INFO -$LOAD_PATH.unshift(File.join(top, "test")) -$LOAD_PATH.unshift(File.join(top, "ext", "ruby", ".libs")) -$LOAD_PATH.unshift(File.join(top, "ext", "ruby")) - -require 'tomoe-spec-utils' - def utf8_to_ucs4(utf8) if utf8 TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) @@ -20,7 +15,6 @@ end end - $LOAD_PATH.unshift(File.join(base, "lib")) migrate = File.join(base, "migrate.rb") From kous users.sourceforge.jp Mon Dec 11 14:40:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 14:40:37 +0900 Subject: [Tomoe-cvs 1823] CVS update: tomoe/ext/ruby Message-ID: <20061211054037.5F5782AC1C9@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.20 tomoe/ext/ruby/tomoe-rb-dict.c:1.21 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.20 Mon Dec 11 13:39:43 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Mon Dec 11 14:40:37 2006 @@ -60,18 +60,20 @@ } else if (strcmp(name, "ruby") == 0) { dict = tomoe_dict_new(name, NULL); } else if (strcmp(name, "mysql") == 0) { - VALUE database, username, password, host, socket; + VALUE database, username, password, host, socket, editable; database = rb_hash_aref(props, CSTR2RVAL("database")); username = rb_hash_aref(props, CSTR2RVAL("username")); password = rb_hash_aref(props, CSTR2RVAL("password")); host = rb_hash_aref(props, CSTR2RVAL("host")); socket = rb_hash_aref(props, CSTR2RVAL("socket")); + editable = rb_hash_aref(props, CSTR2RVAL("editable")); dict = tomoe_dict_new(name, "database", RVAL2CSTR2(database), "user", RVAL2CSTR2(username), "password", RVAL2CSTR2(password), "host", RVAL2CSTR2(host), "socket", RVAL2CSTR2(socket), + "editable", RVAL2CBOOL(editable), NULL); } else { rb_raise(rb_eArgError, "unknown dictionary type: %s", name); From kous users.sourceforge.jp Mon Dec 11 14:40:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 14:40:37 +0900 Subject: [Tomoe-cvs 1824] CVS update: tomoe/module/dict Message-ID: <20061211054037.83E122AC2BC@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.1 tomoe/module/dict/tomoe-dict-mysql.c:1.2 --- tomoe/module/dict/tomoe-dict-mysql.c:1.1 Mon Dec 11 13:39:43 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 11 14:40:37 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.1 2006/12/11 04:39:43 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.2 2006/12/11 05:40:37 kous Exp $ */ #include @@ -77,6 +77,15 @@ TomoeDictClass parent_class; }; +typedef struct _RegisterMetaDataContext RegisterMetaDataContext; +struct _RegisterMetaDataContext +{ + TomoeDictMySQL *dict; + const gchar *utf8; + gboolean success; +}; + + static GType tomoe_type_dict_mysql = 0; static GObjectClass *parent_class; @@ -436,22 +445,124 @@ } static gboolean +register_char_readings (TomoeDictMySQL *dict, const gchar *utf8, + const GList *readings) +{ + GString *sql; + GList *node; + gboolean success = TRUE; + + sql = g_string_new (""); + for (node = (GList *)readings; node; node = g_list_next (node)) { + TomoeReading *reading = node->data; + + g_string_assign (sql, + "INSERT INTO readings " \ + "(utf8, reading_type, reading) " \ + "VALUES ("); + append_string_value (dict, sql, utf8); + g_string_append_printf (sql, ", %d, ", + tomoe_reading_get_reading_type (reading)); + append_string_value (dict, sql, tomoe_reading_get_reading (reading)); + g_string_append (sql, ")"); + + success = execute_query (dict, sql->str); + if (!success) + break; + } + g_string_free (sql, TRUE); + + return success; +} + +static gboolean +register_char_radicals (TomoeDictMySQL *dict, const gchar *utf8, + const GList *radicals) +{ + GString *sql; + GList *node; + gboolean success = TRUE; + + sql = g_string_new (""); + for (node = (GList *)radicals; node; node = g_list_next (node)) { + const gchar *radical = node->data; + + g_string_assign (sql, "INSERT INTO radicals (utf8, radical) VALUES ("); + append_string_value (dict, sql, utf8); + g_string_append (sql, ", "); + append_string_value (dict, sql, radical); + g_string_append (sql, ")"); + + success = execute_query (dict, sql->str); + if (!success) + break; + } + g_string_free (sql, TRUE); + + return success; +} + +static void +register_char_meta_datum (gpointer _key, gpointer _value, gpointer user_data) +{ + const gchar *key = _key; + const gchar *value = _value; + RegisterMetaDataContext *context = user_data; + + if (context->success) { + GString *sql; + + sql = g_string_new ("INSERT INTO meta_data " \ + "(utf8, key, value) " \ + "VALUES ("); + append_string_value (context->dict, sql, context->utf8); + g_string_append (sql, ", "); + append_string_value (context->dict, sql, key); + g_string_append (sql, ", "); + append_string_value (context->dict, sql, value); + g_string_append (sql, ")"); + + context->success = execute_query (context->dict, sql->str); + g_string_free (sql, TRUE); + } +} + +static gboolean +register_char_meta_data (TomoeDictMySQL *dict, const gchar *utf8, + TomoeChar *chr) +{ + RegisterMetaDataContext context; + + context.dict = dict; + context.utf8 = utf8; + context.success = TRUE; + + tomoe_char_meta_data_foreach (chr, register_char_meta_datum, &context); + + return context.success; +} + +static gboolean register_char (TomoeDict *_dict, TomoeChar *chr) { TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); GString *sql; gint n_strokes; const gchar *variant; - GList *node; const gchar *utf8; + gboolean success = FALSE; g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), FALSE); g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); g_return_val_if_fail (dict->mysql, FALSE); - sql = g_string_new ("INSERT INTO chars (`utf8`, " \ - "`n_strokes` `variant`) VALUES ("); + if (!execute_query (dict, "START TRANSACTION")) + return FALSE; + + sql = g_string_new ("INSERT INTO chars " \ + "(utf8, n_strokes, variant) " \ + "VALUES ("); utf8 = tomoe_char_get_utf8 (chr); append_string_value (dict, sql, utf8); @@ -468,52 +579,17 @@ else g_string_append (sql, "NULL)"); - if (!execute_query (dict, sql->str)) { - g_string_free (sql, TRUE); - return FALSE; - } - - for (node = (GList *)tomoe_char_get_readings (chr); - node; - node = g_list_next (node)) { - TomoeReading *reading = node->data; - - g_string_assign (sql, - "INSERT INTO readings (`utf8`, " \ - "`reading_type`, `reading`) VALUES ("); - append_string_value (dict, sql, utf8); - g_string_append_printf (sql, ", %d, ", - tomoe_reading_get_reading_type (reading)); - append_string_value (dict, sql, tomoe_reading_get_reading (reading)); - g_string_append (sql, ")"); - - if (!execute_query (dict, sql->str)) { - g_string_free (sql, TRUE); - return FALSE; - } - } - - for (node = (GList *)tomoe_char_get_radicals (chr); - node; - node = g_list_next (node)) { - const gchar *radical = node->data; + success = execute_query (dict, sql->str); + g_string_free (sql, TRUE); - g_string_assign (sql, - "INSERT INTO radicals (`utf8`, `radical`) VALUES ("); - append_string_value (dict, sql, utf8); - g_string_append (sql, ", "); - append_string_value (dict, sql, radical); - g_string_append (sql, ")"); - if (!execute_query (dict, sql->str)) { - g_string_free (sql, TRUE); - return FALSE; - } + if (success && + register_char_readings (dict, utf8, tomoe_char_get_readings (chr)) && + register_char_radicals (dict, utf8, tomoe_char_get_radicals (chr)) && + register_char_meta_data (dict, utf8, chr)) { + return execute_query (dict, "COMMIT"); + } else { + return FALSE; } - - /* tomoe_char_meta_data_foreach (chr, register_meta_data, dict); */ - - g_string_free (sql, TRUE); - return TRUE; } static gboolean @@ -528,29 +604,36 @@ g_return_val_if_fail (dict->mysql, FALSE); - sql = g_string_new ("DELETE FROM chars WHERE `utf8` = "); + if (!execute_query (dict, "START TRANSACTION")) + return FALSE; + + sql = g_string_new ("DELETE FROM chars WHERE utf8 = "); append_string_value (dict, sql, utf8); success = execute_query (dict, sql->str); if (!success) goto done; - g_string_assign (sql, "DELETE FROM readings WHERE `utf8` = "); + g_string_assign (sql, "DELETE FROM readings WHERE utf8 = "); append_string_value (dict, sql, utf8); success = execute_query (dict, sql->str); if (!success) goto done; - g_string_assign (sql, "DELETE FROM radicals WHERE `utf8` = "); + g_string_assign (sql, "DELETE FROM radicals WHERE utf8 = "); append_string_value (dict, sql, utf8); success = execute_query (dict, sql->str); if (!success) goto done; - g_string_assign (sql, "DELETE FROM meta_data WHERE `utf8` = "); + g_string_assign (sql, "DELETE FROM meta_data WHERE utf8 = "); append_string_value (dict, sql, utf8); success = execute_query (dict, sql->str); if (!success) goto done; done: g_string_free (sql, TRUE); - return success; + + if (success) + return execute_query (dict, "COMMIT"); + else + return FALSE; } static gchar * From kous users.sourceforge.jp Mon Dec 11 14:40:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 14:40:37 +0900 Subject: [Tomoe-cvs 1825] CVS update: tomoe/test Message-ID: <20061211054037.ABFCA2AC1C9@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.15 tomoe/test/dict_spec.rb:1.16 --- tomoe/test/dict_spec.rb:1.15 Thu Dec 7 13:59:07 2006 +++ tomoe/test/dict_spec.rb Mon Dec 11 14:40:37 2006 @@ -68,6 +68,18 @@ end end + specify "should register/unregister to MySQL database" do + dict = Tomoe::Dict.new("mysql", db_config) + char = Tomoe::Char.new + char.utf8 = "?? + dict.register(char).should == true + dict.search(Tomoe::Query.new).collect do |cand| + cand.char.utf8 + end.should == ["??] + dict.unregister("??).should == true + dict.search(Tomoe::Query.new).should_empty + end + def setup_strokes @strokes = [ [ Index: tomoe/test/run-spec.rb diff -u tomoe/test/run-spec.rb:1.4 tomoe/test/run-spec.rb:1.5 --- tomoe/test/run-spec.rb:1.4 Mon Dec 4 12:02:18 2006 +++ tomoe/test/run-spec.rb Mon Dec 11 14:40:37 2006 @@ -12,6 +12,7 @@ $LOAD_PATH.unshift(File.join(test_dir)) ARGV.unshift("--diff") +ARGV.unshift("-sshould register/unregister to MySQL database") Dir.glob(File.join(test_dir, "*_spec.rb")).each do |file| require File.basename(file, ".rb") Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.23 tomoe/test/tomoe-spec-utils.rb:1.24 --- tomoe/test/tomoe-spec-utils.rb:1.23 Mon Dec 11 13:39:43 2006 +++ tomoe/test/tomoe-spec-utils.rb Mon Dec 11 14:40:37 2006 @@ -99,8 +99,8 @@ File.join(db_dir, "config.yml") end - def db_config - YAML.load(File.read(db_config_file)) + def db_config(type=nil) + YAML.load(File.read(db_config_file))[type || "test"] end def setup_context From kous users.sourceforge.jp Mon Dec 11 15:03:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:03:41 +0900 Subject: [Tomoe-cvs 1826] CVS update: tomoe Message-ID: <20061211060341.8DEED2AC2BC@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.423 tomoe/ChangeLog:1.424 --- tomoe/ChangeLog:1.423 Mon Dec 11 14:40:36 2006 +++ tomoe/ChangeLog Mon Dec 11 15:03:41 2006 @@ -1,7 +1,11 @@ 2006-12-11 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c: supported PUA register. + * test/dict_spec.rb: added tests for the function. + * module/dict/tomoe-dict-mysql.c (register_char, unregister_char): clean up. + * test/dict_spec.rb: added tests for MySQL backend. * test/tomoe-spec-utils.rb, test/config.yaml.example: supported From kous users.sourceforge.jp Mon Dec 11 15:03:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:03:41 +0900 Subject: [Tomoe-cvs 1827] CVS update: tomoe/module/dict Message-ID: <20061211060341.BA57E2AC311@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.2 tomoe/module/dict/tomoe-dict-mysql.c:1.3 --- tomoe/module/dict/tomoe-dict-mysql.c:1.2 Mon Dec 11 14:40:37 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 11 15:03:41 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.2 2006/12/11 05:40:37 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.3 2006/12/11 06:03:41 kous Exp $ */ #include @@ -112,6 +112,7 @@ TomoeQuery *query); static gboolean flush (TomoeDict *dict); static gboolean is_editable (TomoeDict *dict); +static gchar *get_available_private_utf8 (TomoeDict *dict); static gboolean tomoe_dict_mysql_connect (TomoeDictMySQL *dict); static gboolean tomoe_dict_mysql_close (TomoeDictMySQL *dict); @@ -138,6 +139,7 @@ dict_class->search = search; dict_class->flush = flush; dict_class->is_editable = is_editable; + dict_class->get_available_private_utf8 = get_available_private_utf8; g_object_class_install_property ( gobject_class, @@ -880,6 +882,48 @@ return dict->editable; } +static gchar * +get_available_private_utf8 (TomoeDict *_dict) +{ + TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); + GString *sql; + gchar *utf8; + gchar pua_start_utf8[6]; + gint len; + gboolean success; + MYSQL_RES *result; + + g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), NULL); + + len = g_unichar_to_utf8 (TOMOE_CHAR_PRIVATE_USE_AREA_START, pua_start_utf8); + pua_start_utf8[len] = '\0'; + + sql = g_string_new ("SELECT utf8 FROM chars WHERE utf8 >= "); + append_string_value (dict, sql, pua_start_utf8); + g_string_append (sql, " ORDER BY utf8 LIMIT 1"); + + success = execute_query (dict, sql->str); + g_string_free (sql, TRUE); + + if (!success) + return NULL; + + utf8 = NULL; + result = mysql_store_result (dict->mysql); + if (result) { + MYSQL_ROW row; + row = mysql_fetch_row (result); + if (row) { + utf8 = g_strdup (g_utf8_next_char (row[0])); + } else { + utf8 = g_strdup (pua_start_utf8); + } + mysql_free_result (result); + } + + return utf8; +} + static gboolean tomoe_dict_mysql_connect (TomoeDictMySQL *dict) { From kous users.sourceforge.jp Mon Dec 11 15:03:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:03:41 +0900 Subject: [Tomoe-cvs 1828] CVS update: tomoe/test Message-ID: <20061211060341.E64132AC2BC@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.16 tomoe/test/dict_spec.rb:1.17 --- tomoe/test/dict_spec.rb:1.16 Mon Dec 11 14:40:37 2006 +++ tomoe/test/dict_spec.rb Mon Dec 11 15:03:41 2006 @@ -80,6 +80,16 @@ dict.search(Tomoe::Query.new).should_empty end + specify "should register/unregister PUA character to MySQL database" do + dict = Tomoe::Dict.new("mysql", db_config) + char = Tomoe::Char.new + dict.register(char).should == true + dict.search(Tomoe::Query.new).size.should == 1 + char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) + dict.unregister(char.utf8).should == true + dict.search(Tomoe::Query.new).should_empty + end + def setup_strokes @strokes = [ [ Index: tomoe/test/run-spec.rb diff -u tomoe/test/run-spec.rb:1.5 tomoe/test/run-spec.rb:1.6 --- tomoe/test/run-spec.rb:1.5 Mon Dec 11 14:40:37 2006 +++ tomoe/test/run-spec.rb Mon Dec 11 15:03:41 2006 @@ -12,7 +12,6 @@ $LOAD_PATH.unshift(File.join(test_dir)) ARGV.unshift("--diff") -ARGV.unshift("-sshould register/unregister to MySQL database") Dir.glob(File.join(test_dir, "*_spec.rb")).each do |file| require File.basename(file, ".rb") From kous users.sourceforge.jp Mon Dec 11 15:15:00 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:15:00 +0900 Subject: [Tomoe-cvs 1829] CVS update: tomoe Message-ID: <20061211061500.E90022AC108@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.424 tomoe/ChangeLog:1.425 --- tomoe/ChangeLog:1.424 Mon Dec 11 15:03:41 2006 +++ tomoe/ChangeLog Mon Dec 11 15:15:00 2006 @@ -1,5 +1,8 @@ 2006-12-11 Kouhei Sutou + * lib/tomoe-config.c: supported MySQL backend in config file but + not tested. + * module/dict/tomoe-dict-mysql.c: supported PUA register. * test/dict_spec.rb: added tests for the function. From kous users.sourceforge.jp Mon Dec 11 15:15:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:15:01 +0900 Subject: [Tomoe-cvs 1830] CVS update: tomoe/ext/ruby Message-ID: <20061211061501.2B3DD2AC311@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.21 tomoe/ext/ruby/tomoe-rb-dict.c:1.22 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.21 Mon Dec 11 14:40:37 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Mon Dec 11 15:15:01 2006 @@ -60,11 +60,12 @@ } else if (strcmp(name, "ruby") == 0) { dict = tomoe_dict_new(name, NULL); } else if (strcmp(name, "mysql") == 0) { - VALUE database, username, password, host, socket, editable; + VALUE database, username, password, host, port, socket, editable; database = rb_hash_aref(props, CSTR2RVAL("database")); username = rb_hash_aref(props, CSTR2RVAL("username")); password = rb_hash_aref(props, CSTR2RVAL("password")); host = rb_hash_aref(props, CSTR2RVAL("host")); + port = rb_hash_aref(props, CSTR2RVAL("port")); socket = rb_hash_aref(props, CSTR2RVAL("socket")); editable = rb_hash_aref(props, CSTR2RVAL("editable")); dict = tomoe_dict_new(name, @@ -72,6 +73,7 @@ "user", RVAL2CSTR2(username), "password", RVAL2CSTR2(password), "host", RVAL2CSTR2(host), + "port", NIL_P(port) ? 0 : NUM2INT(port), "socket", RVAL2CSTR2(socket), "editable", RVAL2CBOOL(editable), NULL); From kous users.sourceforge.jp Mon Dec 11 15:15:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:15:01 +0900 Subject: [Tomoe-cvs 1831] CVS update: tomoe/lib Message-ID: <20061211061501.52C3B2AC108@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.52 tomoe/lib/tomoe-config.c:1.53 --- tomoe/lib/tomoe-config.c:1.52 Wed Dec 6 18:05:36 2006 +++ tomoe/lib/tomoe-config.c Mon Dec 11 15:15:01 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.52 2006/12/06 09:05:36 kous Exp $ + * $Id: tomoe-config.c,v 1.53 2006/12/11 06:15:01 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -80,6 +80,10 @@ const gchar *group, const gchar *key, const gchar *default_value); +static gint _tomoe_config_key_file_get_integer (GKeyFile *key_file, + const gchar *group, + const gchar *key, + gint default_value); static void _tomoe_config_load_system_dictionaries (TomoeConfig *config, TomoeShelf *shelf); static TomoeDict *_tomoe_config_load_dictionary (GKeyFile *key_file, @@ -385,6 +389,31 @@ return result; } +static gint +_tomoe_config_key_file_get_integer (GKeyFile *key_file, + const gchar *group, + const gchar *key, + gint default_value) +{ + gint result; + GError *error = NULL; + + result = g_key_file_get_integer (key_file, group, key, &error); + if (error) { + switch (error->code) { + case G_KEY_FILE_ERROR_NOT_FOUND: + g_error_free (error); + break; + case G_KEY_FILE_ERROR_INVALID_VALUE: + TOMOE_HANDLE_ERROR (error); + break; + } + result = default_value; + } + + return result; +} + static void _tomoe_config_load_system_dictionaries (TomoeConfig *config, TomoeShelf *shelf) { @@ -437,9 +466,9 @@ } editable = _tomoe_config_key_file_get_boolean (key_file, dict_name, - "editable", TRUE); + "editable", TRUE); user_dict = _tomoe_config_key_file_get_boolean (key_file, dict_name, - "user", TRUE); + "user", TRUE); if (!user_dict) { gchar *tmp; tmp = g_build_filename (DICT_DATADIR, filename, NULL); @@ -479,9 +508,9 @@ } editable = _tomoe_config_key_file_get_boolean (key_file, dict_name, - "editable", TRUE); + "editable", TRUE); user_dict = _tomoe_config_key_file_get_boolean (key_file, dict_name, - "user", TRUE); + "user", TRUE); if (!user_dict) { gchar *tmp; tmp = g_build_filename (DICT_DATADIR, database_name, NULL); @@ -518,6 +547,46 @@ } static TomoeDict * +load_mysql_dictionary (GKeyFile *key_file, const gchar *dict_name) +{ + TomoeDict *dict; + gchar *name, *user, *password, *host, *socket, *database; + gint port; + gboolean editable; + + name = _tomoe_config_key_file_get_string (key_file, dict_name, + "name", NULL); + editable = _tomoe_config_key_file_get_boolean (key_file, dict_name, + "editable", TRUE); + user = _tomoe_config_key_file_get_string (key_file, dict_name, + "user", NULL); + password = _tomoe_config_key_file_get_string (key_file, dict_name, + "password", NULL); + host = _tomoe_config_key_file_get_string (key_file, dict_name, + "host", NULL); + port = _tomoe_config_key_file_get_integer (key_file, dict_name, + "port", 0); + socket = _tomoe_config_key_file_get_string (key_file, dict_name, + "socket", NULL); + database = _tomoe_config_key_file_get_string (key_file, dict_name, + "database", NULL); + + dict = tomoe_dict_new ("mysql", + "name", name, + "editable", editable, + "user", user, + "password", password, + "host", host, + "port", port, + "socket", socket, + "database", database, + NULL); + g_free (name); + + return dict; +} + +static TomoeDict * _tomoe_config_load_dictionary (GKeyFile *key_file, const gchar *dict_name, const gchar *type) @@ -528,6 +597,8 @@ return load_est_dictionary (key_file, dict_name); } else if (strcmp (type, "unihan") == 0) { return load_unihan_dictionary (key_file, dict_name); + } else if (strcmp (type, "mysql") == 0) { + return load_mysql_dictionary (key_file, dict_name); } else { return NULL; } From kous users.sourceforge.jp Mon Dec 11 15:15:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:15:01 +0900 Subject: [Tomoe-cvs 1832] CVS update: tomoe/module/dict Message-ID: <20061211061501.8A7842AC314@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.3 tomoe/module/dict/tomoe-dict-mysql.c:1.4 --- tomoe/module/dict/tomoe-dict-mysql.c:1.3 Mon Dec 11 15:03:41 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 11 15:15:01 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.3 2006/12/11 06:03:41 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.4 2006/12/11 06:15:01 kous Exp $ */ #include @@ -415,7 +415,7 @@ { TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), NULL); - return dict->name; + return dict->name || "MySQL"; } static gboolean From kous users.sourceforge.jp Mon Dec 11 15:15:55 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:15:55 +0900 Subject: [Tomoe-cvs 1833] CVS update: tomoe Message-ID: <20061211061555.3DBD72AC311@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.425 tomoe/ChangeLog:1.426 --- tomoe/ChangeLog:1.425 Mon Dec 11 15:15:00 2006 +++ tomoe/ChangeLog Mon Dec 11 15:15:55 2006 @@ -1,5 +1,7 @@ 2006-12-11 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c (get_name): returned default value. + * lib/tomoe-config.c: supported MySQL backend in config file but not tested. From kous users.sourceforge.jp Mon Dec 11 15:15:55 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 11 Dec 2006 15:15:55 +0900 Subject: [Tomoe-cvs 1834] CVS update: tomoe/module/dict Message-ID: <20061211061555.73B8B2AC313@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.4 tomoe/module/dict/tomoe-dict-mysql.c:1.5 --- tomoe/module/dict/tomoe-dict-mysql.c:1.4 Mon Dec 11 15:15:01 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 11 15:15:55 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.4 2006/12/11 06:15:01 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.5 2006/12/11 06:15:55 kous Exp $ */ #include @@ -415,7 +415,10 @@ { TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), NULL); - return dict->name || "MySQL"; + if (dict->name) + return dict->name; + else + return "MySQL"; } static gboolean From makeinu users.sourceforge.jp Mon Dec 11 16:17:43 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 11 Dec 2006 16:17:43 +0900 Subject: [Tomoe-cvs 1835] CVS update: tomoe Message-ID: <20061211071743.364C32AC02E@users.sourceforge.jp> Index: tomoe/TODO diff -u tomoe/TODO:1.13 tomoe/TODO:1.14 --- tomoe/TODO:1.13 Wed Dec 6 18:12:41 2006 +++ tomoe/TODO Mon Dec 11 16:17:43 2006 @@ -3,8 +3,6 @@ should be language independent. * Implement advanced searching. * Add modulized dictionary types. - - QDBM? - - MySQL? - CHISE? * Add radicals and variant element into tomoe-dict.dtd. * Asynchronous dictionary loading? From makeinu users.sourceforge.jp Mon Dec 11 23:50:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 11 Dec 2006 23:50:20 +0900 Subject: [Tomoe-cvs 1836] CVS update: libtomoe-gtk Message-ID: <20061211145020.8EB672AC1CA@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.249 libtomoe-gtk/ChangeLog:1.250 --- libtomoe-gtk/ChangeLog:1.249 Thu Dec 7 12:49:19 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 11 23:50:20 2006 @@ -1,3 +1,7 @@ +2006-12-11 Takuro Ashie + + * src/tomoe-reading-search.c: Add "Specify range" check button. + 2006-12-07 Takuro Ashie * src/tomoe-window.c: Set the window title automatically. From makeinu users.sourceforge.jp Mon Dec 11 23:50:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 11 Dec 2006 23:50:20 +0900 Subject: [Tomoe-cvs 1837] CVS update: libtomoe-gtk/src Message-ID: <20061211145020.BC6682AC1D4@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.27 libtomoe-gtk/src/tomoe-reading-search.c:1.28 --- libtomoe-gtk/src/tomoe-reading-search.c:1.27 Thu Dec 7 12:32:15 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Mon Dec 11 23:50:20 2006 @@ -54,8 +54,11 @@ TomoeContext *context; GtkListStore *result_store; GtkWidget *input; + GtkWidget *min_strokes_label; + GtkWidget *max_strokes_label; GtkWidget *min_strokes_spin; GtkWidget *max_strokes_spin; + GtkWidget *range_check_button; GtkWidget *expander; GtkWidget *treeview; }; @@ -84,6 +87,8 @@ gpointer user_data); static void on_max_strokes_spin_button_changed (GtkSpinButton *spinbutton, gpointer user_data); +static void on_specify_range_button_toggled (GtkToggleButton *togglebutton, + gpointer user_data); static void on_result_view_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); @@ -132,7 +137,8 @@ tomoe_reading_search_init (TomoeReadingSearch *page) { TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); - GtkWidget *hbox, *vbox, *input, *button, *list, *label, *spin, *expander; + GtkWidget *hbox, *vbox, *expander; + GtkWidget *input, *button, *list, *label, *spin, *check; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkTreeSelection *result_sel; @@ -191,9 +197,10 @@ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); gtk_widget_show (label); - label = gtk_label_new (_("Minimum")); + label = gtk_label_new (_("Min")); + priv->min_strokes_label = label; gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); - gtk_widget_show (label); + /*gtk_widget_show (label);*/ adj = gtk_adjustment_new (1.0, 1.0, 200.0, 1.0, 5.0, 5.0); spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0.0, 0); @@ -204,9 +211,10 @@ gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 4); gtk_widget_show (spin); - label = gtk_label_new (_("Maximum")); + label = gtk_label_new (_("Max")); + priv->max_strokes_label = label; gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); - gtk_widget_show (label); + /*gtk_widget_show (label);*/ adj = gtk_adjustment_new (20.0, 1.0, 200.0, 1.0, 5.0, 5.0); spin = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0.0, 0); @@ -215,7 +223,15 @@ G_CALLBACK (on_max_strokes_spin_button_changed), page); gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 4); - gtk_widget_show (spin); + /*gtk_widget_show (spin);*/ + + check = gtk_check_button_new_with_label (_("Specify range")); + priv->range_check_button = check; + g_signal_connect (G_OBJECT (check), "toggled", + G_CALLBACK (on_specify_range_button_toggled), + page); + gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 4); + gtk_widget_show (check); /* result view */ priv->result_store = gtk_list_store_new (COLUMN_COUNT, @@ -343,7 +359,7 @@ { GList *result, *list; const gchar *reading_text; - gint min, max; + gint min = 0, max = 0; GtkSpinButton *min_spin, *max_spin; TomoeQuery *query; TomoeReading *reading; @@ -364,17 +380,27 @@ } min_spin = GTK_SPIN_BUTTON (priv->min_strokes_spin); + max_spin = GTK_SPIN_BUTTON (priv->max_strokes_spin); + if (gtk_expander_get_expanded (GTK_EXPANDER (priv->expander))) { min = gtk_spin_button_get_value (min_spin); tomoe_query_set_min_n_strokes (query, min); } - max_spin = GTK_SPIN_BUTTON (priv->max_strokes_spin); if (gtk_expander_get_expanded (GTK_EXPANDER (priv->expander))) { - max = gtk_spin_button_get_value (max_spin); + GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (priv->range_check_button); + if (gtk_toggle_button_get_active (toggle)) + max = gtk_spin_button_get_value (max_spin); + else + max = gtk_spin_button_get_value (min_spin); tomoe_query_set_max_n_strokes (query, max); } + if ((!reading_text || !*reading_text) && !min && !max) { + g_object_unref (G_OBJECT (query)); + return; + } + result = tomoe_context_search (priv->context, query); g_object_unref (query); @@ -533,6 +559,24 @@ } static void +on_specify_range_button_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); + TomoeReadingSearchPrivate *priv = TOMOE_READING_SEARCH_GET_PRIVATE (page); + + if (gtk_toggle_button_get_active (togglebutton)) { + gtk_widget_show (priv->min_strokes_label); + gtk_widget_show (priv->max_strokes_label); + gtk_widget_show (priv->max_strokes_spin); + } else { + gtk_widget_hide (priv->min_strokes_label); + gtk_widget_hide (priv->max_strokes_label); + gtk_widget_hide (priv->max_strokes_spin); + } +} + +static void on_find_button_clicked (GtkButton *button, gpointer user_data) { TomoeReadingSearch *page = TOMOE_READING_SEARCH (user_data); From makeinu users.sourceforge.jp Tue Dec 12 10:01:22 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:01:22 +0900 Subject: [Tomoe-cvs 1838] CVS update: libtomoe-gtk Message-ID: <20061212010122.8F9FF2AC0DD@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.250 libtomoe-gtk/ChangeLog:1.251 --- libtomoe-gtk/ChangeLog:1.250 Mon Dec 11 23:50:20 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 12 10:01:22 2006 @@ -1,5 +1,9 @@ 2006-12-11 Takuro Ashie + * po/ja.po: Update. + +2006-12-11 Takuro Ashie + * src/tomoe-reading-search.c: Add "Specify range" check button. 2006-12-07 Takuro Ashie From makeinu users.sourceforge.jp Tue Dec 12 10:01:22 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:01:22 +0900 Subject: [Tomoe-cvs 1839] CVS update: libtomoe-gtk/po Message-ID: <20061212010122.BD7F72AC343@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.13 libtomoe-gtk/po/ja.po:1.14 --- libtomoe-gtk/po/ja.po:1.13 Thu Dec 7 12:01:43 2006 +++ libtomoe-gtk/po/ja.po Tue Dec 12 10:01:22 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-07 11:48+0900\n" +"POT-Creation-Date: 2006-12-12 09:56+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -11,7 +11,7 @@ "Content-Transfer-Encoding: 8bit\n" #: src/tomoe-canvas.c:212 src/tomoe-handwriting.c:116 -#: src/tomoe-reading-search.c:123 +#: src/tomoe-reading-search.c:128 msgid "Tomoe context" msgstr "" @@ -118,7 +118,7 @@ msgid "Basic information" msgstr "ܾ" -#: src/tomoe-details.c:268 src/tomoe-reading-search.c:246 +#: src/tomoe-details.c:268 src/tomoe-reading-search.c:262 msgid "Character" msgstr "ʸ" @@ -158,7 +158,7 @@ msgid "Writing" msgstr "" -#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:124 +#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:129 msgid "A TomoeContext which stores handwriting dictionaries." msgstr "" @@ -191,71 +191,80 @@ msgid "Select the file name for dump" msgstr "" -#: src/tomoe-reading-search.c:154 +#: src/tomoe-reading-search.c:160 msgid "Reading:" msgstr "ɤ:" #. stroke count area -#: src/tomoe-reading-search.c:181 +#: src/tomoe-reading-search.c:187 msgid "More options" msgstr "¾θ" -#: src/tomoe-reading-search.c:190 +#: src/tomoe-reading-search.c:196 msgid "Stroke count:" msgstr ":" -#: src/tomoe-reading-search.c:194 -msgid "Minimum" +#: src/tomoe-reading-search.c:200 +msgid "Min" msgstr "Ǿ" -#: src/tomoe-reading-search.c:207 -msgid "Maximum" +#: src/tomoe-reading-search.c:214 +msgid "Max" msgstr "" -#: src/tomoe-reading-search.c:255 +#. gtk_widget_show (spin); +#: src/tomoe-reading-search.c:228 +msgid "Specify range" +msgstr "ϰϤ" + +#: src/tomoe-reading-search.c:271 msgid "Stroke count" msgstr "" -#: src/tomoe-reading-search.c:264 +#: src/tomoe-reading-search.c:280 msgid "Reading" msgstr "ɤ" -#: src/tomoe-window.c:110 +#: src/tomoe-window.c:115 msgid "TomoeHandwriting" msgstr "" -#: src/tomoe-window.c:111 +#: src/tomoe-window.c:116 msgid "The TomoeHandwriting widget inside of the TomoeWindow." msgstr "" -#: src/tomoe-window.c:118 +#: src/tomoe-window.c:123 msgid "TomoeReadingSearch" msgstr "" -#: src/tomoe-window.c:119 +#: src/tomoe-window.c:124 msgid "The TomoeReadingSearch widget inside of the TomoeWindow." msgstr "" -#: src/tomoe-window.c:126 +#: src/tomoe-window.c:131 msgid "TomoeGucharmap" msgstr "" -#: src/tomoe-window.c:127 +#: src/tomoe-window.c:132 msgid "The TomoeGucharmap widget inside of the TomoeWindow." msgstr "" -#: src/tomoe-window.c:160 src/tomoe-window.c:185 +#: src/tomoe-window.c:165 src/tomoe-window.c:197 msgid "Handwriting recognition" msgstr "ǧ" -#: src/tomoe-window.c:196 +#: src/tomoe-window.c:208 msgid "Search with reading" msgstr "ɤߤǸ" -#: src/tomoe-window.c:207 +#: src/tomoe-window.c:219 msgid "Unicode table" msgstr "Unicodeɽ" +#: src/tomoe-window.c:411 +msgid "Tomoe" +msgstr "" + #~ msgid "Use" #~ msgstr "" From makeinu users.sourceforge.jp Tue Dec 12 10:18:58 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:18:58 +0900 Subject: [Tomoe-cvs 1840] CVS update: tomoe Message-ID: <20061212011858.37CDF2AC3C8@users.sourceforge.jp> Index: tomoe/AUTHORS diff -u tomoe/AUTHORS:1.2 tomoe/AUTHORS:1.3 --- tomoe/AUTHORS:1.2 Mon Jun 5 03:28:33 2006 +++ tomoe/AUTHORS Tue Dec 12 10:18:58 2006 @@ -1,8 +1,13 @@ -Original code: - Hiroyuki Komatsu +Porting to Xml database: + Juernjakob Harder + +Authors: + Kouhei Sutou + Hiroyuki Ikezoe + Takuro Ashie -Porting to Ruby and C: +Porting to Ruby and C (Not in active): Hiroaki Nakamura -Porting to Xml database: - Juernjakob Harder \ No newline at end of file +Original code written in perl (Not in active): + Hiroyuki Komatsu From makeinu users.sourceforge.jp Tue Dec 12 10:20:23 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:20:23 +0900 Subject: [Tomoe-cvs 1841] CVS update: libtomoe-gtk Message-ID: <20061212012023.4ACFD2AC022@users.sourceforge.jp> Index: libtomoe-gtk/AUTHORS diff -u libtomoe-gtk/AUTHORS:1.4 libtomoe-gtk/AUTHORS:1.5 --- libtomoe-gtk/AUTHORS:1.4 Tue Aug 22 11:11:29 2006 +++ libtomoe-gtk/AUTHORS Tue Dec 12 10:20:23 2006 @@ -1,3 +1,4 @@ Takuro Ashie HIGUCHI Daisuke Juernjakob Harder +Hiroyuki Ikezoe From makeinu users.sourceforge.jp Tue Dec 12 10:22:34 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:22:34 +0900 Subject: [Tomoe-cvs 1842] CVS update: tomoe Message-ID: <20061212012234.AE4DD2AC3C8@users.sourceforge.jp> Index: tomoe/NEWS diff -u tomoe/NEWS:1.7 tomoe/NEWS:1.8 --- tomoe/NEWS:1.7 Thu Dec 7 10:39:20 2006 +++ tomoe/NEWS Tue Dec 12 10:22:34 2006 @@ -1,8 +1,9 @@ Overview of Changes from libtomoe-0.4.0 to libtomoe-0.4.1 ============================================================== -* New modulized dictionarys: +* New modulized dictionaries: - Hyper Estraier - Unihan database + - MySQL Overview of Changes from libtomoe-0.3.0 to libtomoe-0.4.0 ============================================================== From makeinu users.sourceforge.jp Tue Dec 12 10:41:30 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:41:30 +0900 Subject: [Tomoe-cvs 1843] CVS update: libtomoe-gtk Message-ID: <20061212014130.30E062AC3C8@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.251 libtomoe-gtk/ChangeLog:1.252 --- libtomoe-gtk/ChangeLog:1.251 Tue Dec 12 10:01:22 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 12 10:41:30 2006 @@ -1,5 +1,10 @@ 2006-12-11 Takuro Ashie + * src/tomoe-handwriting.c: Don't stretch the height of the candidates + view. + +2006-12-11 Takuro Ashie + * po/ja.po: Update. 2006-12-11 Takuro Ashie Index: libtomoe-gtk/TODO diff -u libtomoe-gtk/TODO:1.11 libtomoe-gtk/TODO:1.12 --- libtomoe-gtk/TODO:1.11 Tue Dec 5 10:36:13 2006 +++ libtomoe-gtk/TODO Tue Dec 12 10:41:30 2006 @@ -1,10 +1,12 @@ -* Consider about ABI stability. -* Consider about portability. * Add management tools - Glyph viewer and editor - Meta data editor +* Consider about ABI stability. +* Consider about portability. + * TomoeWindow + - Menu (GtkAction) - Plural canvas like zaurus * TomoeCanvas - Preferences for lines: @@ -18,7 +20,6 @@ - Suppport multiple rows and columns - Page switching, add Up and Down button - Mouse wheel support -* Menu (GtkAction) * Mode - ASCII only mode. - Hiragana only mode. From makeinu users.sourceforge.jp Tue Dec 12 10:41:30 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:41:30 +0900 Subject: [Tomoe-cvs 1844] CVS update: libtomoe-gtk/src Message-ID: <20061212014130.538C82AC431@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-handwriting.c diff -u libtomoe-gtk/src/tomoe-handwriting.c:1.10 libtomoe-gtk/src/tomoe-handwriting.c:1.11 --- libtomoe-gtk/src/tomoe-handwriting.c:1.10 Wed Dec 6 14:31:26 2006 +++ libtomoe-gtk/src/tomoe-handwriting.c Tue Dec 12 10:41:30 2006 @@ -232,7 +232,7 @@ /* candidates view */ frame = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 4); + gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 4); gtk_widget_show (frame); table = tomoe_char_table_new (); From makeinu users.sourceforge.jp Tue Dec 12 10:50:31 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:50:31 +0900 Subject: [Tomoe-cvs 1845] CVS update: tomoe Message-ID: <20061212015031.504012AC431@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.426 tomoe/ChangeLog:1.427 --- tomoe/ChangeLog:1.426 Mon Dec 11 15:15:55 2006 +++ tomoe/ChangeLog Tue Dec 12 10:50:31 2006 @@ -1,3 +1,7 @@ +2006-12-12 Takuro Ashie + + * module/dict/Makefile.am: Fix typo. + 2006-12-11 Kouhei Sutou * module/dict/tomoe-dict-mysql.c (get_name): returned default value. From makeinu users.sourceforge.jp Tue Dec 12 10:50:31 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:50:31 +0900 Subject: [Tomoe-cvs 1846] CVS update: tomoe/module/dict Message-ID: <20061212015031.7BB632AC47B@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.21 tomoe/module/dict/Makefile.am:1.22 --- tomoe/module/dict/Makefile.am:1.21 Mon Dec 11 13:39:43 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 10:50:31 2006 @@ -68,7 +68,7 @@ CLEANFILES += Unihan.txt Unihan.txt.cache BUILT_SOURCES = $(unihan_built_sources) Unihan.zip -EXTRA_DIST = unihan-compier.rb +EXTRA_DIST = unihan-compiler.rb libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ From kous users.sourceforge.jp Tue Dec 12 10:51:09 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 10:51:09 +0900 Subject: [Tomoe-cvs 1847] CVS update: tomoe Message-ID: <20061212015109.61FA12AC52B@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.427 tomoe/ChangeLog:1.428 --- tomoe/ChangeLog:1.427 Tue Dec 12 10:50:31 2006 +++ tomoe/ChangeLog Tue Dec 12 10:51:09 2006 @@ -1,3 +1,8 @@ +2006-12-12 Kouhei Sutou + + * configure.in: don't enable Ruby dictionary module when Ruby + isn't available. + 2006-12-12 Takuro Ashie * module/dict/Makefile.am: Fix typo. Index: tomoe/configure.in diff -u tomoe/configure.in:1.47 tomoe/configure.in:1.48 --- tomoe/configure.in:1.47 Mon Dec 11 13:39:42 2006 +++ tomoe/configure.in Tue Dec 12 10:51:09 2006 @@ -227,7 +227,7 @@ if test "x$ruby_available" = "xyes"; then CFLAGS="$CFLAGS $GLIB_CFLAGS" AC_CHECK_HEADERS(rbgobject.h, [], - [ruby_available="no" + [ruby_available="no" AC_MSG_WARN([$ruby_disable_message])], [$ruby_undef_package_macros]) fi @@ -374,7 +374,9 @@ dnl ************************************************************** AC_ARG_ENABLE(dict_ruby, [ --enable-dict-ruby Enable Ruby based dictionary module]) -AM_CONDITIONAL(ENABLE_DICT_RUBY, test x"$enable_dict_ruby" = "xyes") +AM_CONDITIONAL(ENABLE_DICT_RUBY, + [test x"$enable_dict_ruby" = "xyes" -a \ + x"$ruby_available" = "xyes"]) dnl ************************************************************** From makeinu users.sourceforge.jp Tue Dec 12 10:52:52 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 10:52:52 +0900 Subject: [Tomoe-cvs 1848] CVS update: libtomoe-gtk Message-ID: <20061212015252.1A62D2AC528@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.252 libtomoe-gtk/ChangeLog:1.253 --- libtomoe-gtk/ChangeLog:1.252 Tue Dec 12 10:41:30 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 12 10:52:51 2006 @@ -1,9 +1,9 @@ -2006-12-11 Takuro Ashie +2006-12-12 Takuro Ashie * src/tomoe-handwriting.c: Don't stretch the height of the candidates view. -2006-12-11 Takuro Ashie +2006-12-12 Takuro Ashie * po/ja.po: Update. From kous users.sourceforge.jp Tue Dec 12 12:38:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 12:38:25 +0900 Subject: [Tomoe-cvs 1849] CVS update: tomoe Message-ID: <20061212033825.271912AC15F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.428 tomoe/ChangeLog:1.429 --- tomoe/ChangeLog:1.428 Tue Dec 12 10:51:09 2006 +++ tomoe/ChangeLog Tue Dec 12 12:38:24 2006 @@ -1,5 +1,7 @@ 2006-12-12 Kouhei Sutou + * db/migrate/001_create_chars.rb: utf8 field must be unique. + * configure.in: don't enable Ruby dictionary module when Ruby isn't available. From kous users.sourceforge.jp Tue Dec 12 12:38:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 12:38:25 +0900 Subject: [Tomoe-cvs 1850] CVS update: tomoe/db/migrate Message-ID: <20061212033825.59DCD2AC1EB@users.sourceforge.jp> Index: tomoe/db/migrate/001_create_chars.rb diff -u tomoe/db/migrate/001_create_chars.rb:1.3 tomoe/db/migrate/001_create_chars.rb:1.4 --- tomoe/db/migrate/001_create_chars.rb:1.3 Mon Dec 11 13:39:42 2006 +++ tomoe/db/migrate/001_create_chars.rb Tue Dec 12 12:38:25 2006 @@ -5,7 +5,7 @@ t.column :n_strokes, :integer t.column :variant, :string end - add_index :chars, :utf8 + add_index :chars, :utf8, :unique => true end def self.down From kous users.sourceforge.jp Tue Dec 12 12:48:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 12:48:06 +0900 Subject: [Tomoe-cvs 1851] CVS update: tomoe Message-ID: <20061212034806.98CA12AC096@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.429 tomoe/ChangeLog:1.430 --- tomoe/ChangeLog:1.429 Tue Dec 12 12:38:24 2006 +++ tomoe/ChangeLog Tue Dec 12 12:48:06 2006 @@ -1,5 +1,8 @@ 2006-12-12 Kouhei Sutou + * module/dict/Makefile.am: ensure make libxml.la before + unihan-compiler.rb is run. + * db/migrate/001_create_chars.rb: utf8 field must be unique. * configure.in: don't enable Ruby dictionary module when Ruby From kous users.sourceforge.jp Tue Dec 12 12:48:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 12:48:06 +0900 Subject: [Tomoe-cvs 1852] CVS update: tomoe/module/dict Message-ID: <20061212034806.CADCE2AC12A@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.22 tomoe/module/dict/Makefile.am:1.23 --- tomoe/module/dict/Makefile.am:1.22 Tue Dec 12 10:50:31 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 12:48:06 2006 @@ -77,6 +77,8 @@ $(unihan_built_sources) \ $(ptr_array_based_dict_sources) +unihan-compiler.rb: libxml.la + tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ -I$(top_srcdir)/test unihan-compiler.rb \ From kous users.sourceforge.jp Tue Dec 12 13:09:19 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 13:09:19 +0900 Subject: [Tomoe-cvs 1853] CVS update: tomoe Message-ID: <20061212040919.520F62AC014@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.430 tomoe/ChangeLog:1.431 --- tomoe/ChangeLog:1.430 Tue Dec 12 12:48:06 2006 +++ tomoe/ChangeLog Tue Dec 12 13:09:19 2006 @@ -1,5 +1,9 @@ 2006-12-12 Kouhei Sutou + * db/migrate/004_create_meta_data.rb: renamed to "name" from "key" + because "key" is one of the reserved words in MySQL. + * module/dict/tomoe-dict-mysql.c: followed the change. + * module/dict/Makefile.am: ensure make libxml.la before unihan-compiler.rb is run. From kous users.sourceforge.jp Tue Dec 12 13:09:19 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 13:09:19 +0900 Subject: [Tomoe-cvs 1854] CVS update: tomoe/db/migrate Message-ID: <20061212040919.75E232AC15F@users.sourceforge.jp> Index: tomoe/db/migrate/004_create_meta_data.rb diff -u tomoe/db/migrate/004_create_meta_data.rb:1.2 tomoe/db/migrate/004_create_meta_data.rb:1.3 --- tomoe/db/migrate/004_create_meta_data.rb:1.2 Fri Dec 8 18:06:37 2006 +++ tomoe/db/migrate/004_create_meta_data.rb Tue Dec 12 13:09:19 2006 @@ -2,7 +2,7 @@ def self.up create_table(:meta_data) do |t| t.column :utf8, :string, :null => false - t.column :key, :string, :null => false + t.column :name, :string, :null => false t.column :value, :string, :null => false end add_index :meta_data, :utf8 From kous users.sourceforge.jp Tue Dec 12 13:09:19 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 13:09:19 +0900 Subject: [Tomoe-cvs 1855] CVS update: tomoe/module/dict Message-ID: <20061212040919.99EC42AC1EB@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.5 tomoe/module/dict/tomoe-dict-mysql.c:1.6 --- tomoe/module/dict/tomoe-dict-mysql.c:1.5 Mon Dec 11 15:15:55 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Tue Dec 12 13:09:19 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.5 2006/12/11 06:15:55 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.6 2006/12/12 04:09:19 kous Exp $ */ #include @@ -518,7 +518,7 @@ GString *sql; sql = g_string_new ("INSERT INTO meta_data " \ - "(utf8, key, value) " \ + "(utf8, name, value) " \ "VALUES ("); append_string_value (context->dict, sql, context->utf8); g_string_append (sql, ", "); From kous users.sourceforge.jp Tue Dec 12 14:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 14:00:59 +0900 Subject: [Tomoe-cvs 1856] CVS update: tomoe Message-ID: <20061212050059.577902AC01E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.431 tomoe/ChangeLog:1.432 --- tomoe/ChangeLog:1.431 Tue Dec 12 13:09:19 2006 +++ tomoe/ChangeLog Tue Dec 12 14:00:59 2006 @@ -1,5 +1,9 @@ 2006-12-12 Kouhei Sutou + * db/xml2db.rb: used Tomoe::DictMySQL#register. + * test/tomoe-spec-utils.rb (TomoeSpecUtils::Config::db_config): + used ENV["TOMOE_ENV"] as default value. + * db/migrate/004_create_meta_data.rb: renamed to "name" from "key" because "key" is one of the reserved words in MySQL. * module/dict/tomoe-dict-mysql.c: followed the change. From kous users.sourceforge.jp Tue Dec 12 14:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 14:00:59 +0900 Subject: [Tomoe-cvs 1857] CVS update: tomoe/db Message-ID: <20061212050059.7E69A2AC536@users.sourceforge.jp> Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.4 tomoe/db/xml2db.rb:1.5 --- tomoe/db/xml2db.rb:1.4 Mon Dec 11 14:40:37 2006 +++ tomoe/db/xml2db.rb Tue Dec 12 14:00:59 2006 @@ -27,6 +27,9 @@ dict = Tomoe::Dict.new("xml", "filename" => TomoeSpecUtils::Config.dictionaries.first, "editable" => false) +config = TomoeSpecUtils::Config.db_config.merge("editable" => true) +mysql_dict = Tomoe::Dict.new("mysql", config) + cands = dict.search(Tomoe::Query.new) puts "dict size: #{cands.size}" @@ -34,24 +37,7 @@ $stdout.flush $KCODE = "u" cands.each_with_index do |cand, i| - char = cand.char - Char.new(:utf8 => char.utf8, - :n_strokes => char.n_strokes < 0 ? nil : char.n_strokes, - :variant => char.variant).save! - char.readings.each do |reading| - Reading.new(:utf8 => char.utf8, - :reading_type => reading.type.to_i, - :reading => reading.reading).save! - end - char.radicals.each do |radical| - Radical.new(:utf8 => char.utf8, - :radical_utf8 => radical).save! - end - char.each do |key, value| - MetaDatum.new(:utf8 => char.utf8, - :key => key, - :value => value).save! - end + mysql_dict.register(cand.char) if (i % 1000).zero? and !i.zero? print "#{i}." $stdout.flush From kous users.sourceforge.jp Tue Dec 12 14:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 14:00:59 +0900 Subject: [Tomoe-cvs 1858] CVS update: tomoe/test Message-ID: <20061212050059.A71FB2AC01E@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.24 tomoe/test/tomoe-spec-utils.rb:1.25 --- tomoe/test/tomoe-spec-utils.rb:1.24 Mon Dec 11 14:40:37 2006 +++ tomoe/test/tomoe-spec-utils.rb Tue Dec 12 14:00:59 2006 @@ -100,7 +100,7 @@ end def db_config(type=nil) - YAML.load(File.read(db_config_file))[type || "test"] + YAML.load(File.read(db_config_file))[type || ENV["TOMOE_ENV"] || "test"] end def setup_context From kous users.sourceforge.jp Tue Dec 12 14:02:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 14:02:16 +0900 Subject: [Tomoe-cvs 1859] CVS update: tomoe Message-ID: <20061212050216.C2A782AC01E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.432 tomoe/ChangeLog:1.433 --- tomoe/ChangeLog:1.432 Tue Dec 12 14:00:59 2006 +++ tomoe/ChangeLog Tue Dec 12 14:02:16 2006 @@ -1,5 +1,8 @@ 2006-12-12 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c (generate_sql): split into small + functions which generate conditions. + * db/xml2db.rb: used Tomoe::DictMySQL#register. * test/tomoe-spec-utils.rb (TomoeSpecUtils::Config::db_config): used ENV["TOMOE_ENV"] as default value. From kous users.sourceforge.jp Tue Dec 12 14:02:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 14:02:17 +0900 Subject: [Tomoe-cvs 1860] CVS update: tomoe/module/dict Message-ID: <20061212050217.06F8C2AC531@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.6 tomoe/module/dict/tomoe-dict-mysql.c:1.7 --- tomoe/module/dict/tomoe-dict-mysql.c:1.6 Tue Dec 12 13:09:19 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Tue Dec 12 14:02:16 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.6 2006/12/12 04:09:19 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.7 2006/12/12 05:02:16 kous Exp $ */ #include @@ -641,47 +641,50 @@ return FALSE; } -static gchar * -generate_sql (TomoeDictMySQL *dict, TomoeQuery *query) +static void +generate_sql_condition_utf8 (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) { - GString *sql; const gchar *utf8; - gint min_n_strokes, max_n_strokes; - GList *node; - - sql = g_string_new ("SELECT " \ - "chars.utf8 AS utf8, " \ - "chars.n_strokes AS n_strokes, " \ - "chars.variant AS variant, " \ - "readings.id AS reading_id, " \ - "readings.reading_type AS reading_type, " \ - "readings.reading AS reading, " \ - "radicals.id AS radical_id, " \ - "radicals.radical_utf8 AS radical_utf8 " \ - "FROM chars " \ - "LEFT OUTER JOIN readings " \ - "ON chars.utf8 = readings.utf8 " \ - "LEFT OUTER JOIN radicals " \ - "ON chars.utf8 = radicals.utf8 " \ - "WHERE TRUE = TRUE"); utf8 = tomoe_query_get_utf8 (query); if (utf8) { - g_string_append (sql, " AND chars.utf8 = "); + g_string_append (sql, " AND utf8 = "); append_string_value (dict, sql, utf8); } +} + +static void +generate_sql_condition_min_n_strokes (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) +{ + gint min_n_strokes; min_n_strokes = tomoe_query_get_min_n_strokes (query); if (min_n_strokes >= 0) { - g_string_append_printf (sql, " AND chars.n_strokes >= %d", + g_string_append_printf (sql, " AND n_strokes >= %d", min_n_strokes); } +} + +static void +generate_sql_condition_max_n_strokes (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) +{ + gint max_n_strokes; max_n_strokes = tomoe_query_get_max_n_strokes (query); if (max_n_strokes >= 0) { - g_string_append_printf (sql, " AND chars.n_strokes <= %d", + g_string_append_printf (sql, " AND n_strokes <= %d", max_n_strokes); } +} + +static void +generate_sql_condition_readings (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) +{ + GList *node; for (node = (GList *)tomoe_query_get_readings (query); node; @@ -692,15 +695,43 @@ reading_type = tomoe_reading_get_reading_type (tomoe_reading); if (reading_type != TOMOE_READING_INVALID) - g_string_append_printf (sql, " AND readings.reading_type = %d", + g_string_append_printf (sql, " AND reading_type = %d", reading_type); reading = tomoe_reading_get_reading (tomoe_reading); if (reading) { - g_string_append (sql, " AND readings.reading = "); + g_string_append (sql, " AND reading = "); append_string_value (dict, sql, reading); } } +} + + +static gchar * +generate_sql (TomoeDictMySQL *dict, TomoeQuery *query) +{ + GString *sql; + + sql = g_string_new ("SELECT " \ + "chars.utf8 AS utf8, " \ + "chars.n_strokes AS n_strokes, " \ + "chars.variant AS variant, " \ + "readings.id AS reading_id, " \ + "readings.reading_type AS reading_type, " \ + "readings.reading AS reading, " \ + "radicals.id AS radical_id, " \ + "radicals.radical_utf8 AS radical_utf8 " \ + "FROM chars " \ + "LEFT OUTER JOIN readings " \ + "ON chars.utf8 = readings.utf8 " \ + "LEFT OUTER JOIN radicals " \ + "ON chars.utf8 = radicals.utf8 " \ + "WHERE TRUE = TRUE"); + + generate_sql_condition_utf8 (dict, sql, query); + generate_sql_condition_min_n_strokes (dict, sql, query); + generate_sql_condition_max_n_strokes (dict, sql, query); + generate_sql_condition_readings (dict, sql, query); return g_string_free (sql, FALSE); } From makeinu users.sourceforge.jp Tue Dec 12 14:21:19 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 14:21:19 +0900 Subject: [Tomoe-cvs 1861] CVS update: tomoe Message-ID: <20061212052119.5AB2C2AC01E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.433 tomoe/ChangeLog:1.434 --- tomoe/ChangeLog:1.433 Tue Dec 12 14:02:16 2006 +++ tomoe/ChangeLog Tue Dec 12 14:21:19 2006 @@ -1,3 +1,7 @@ +2006-12-12 Takuro Ashie + + * module/dict/Makefile.am: Don't replace tomoe-unihan-data.h. + 2006-12-12 Kouhei Sutou * module/dict/tomoe-dict-mysql.c (generate_sql): split into small From makeinu users.sourceforge.jp Tue Dec 12 14:21:19 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 14:21:19 +0900 Subject: [Tomoe-cvs 1862] CVS update: tomoe/module/dict Message-ID: <20061212052119.8937B2AC537@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.23 tomoe/module/dict/Makefile.am:1.24 --- tomoe/module/dict/Makefile.am:1.23 Tue Dec 12 12:48:06 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 14:21:19 2006 @@ -66,9 +66,9 @@ unihan_built_sources = tomoe-unihan-data.h CLEANFILES += Unihan.txt Unihan.txt.cache -BUILT_SOURCES = $(unihan_built_sources) Unihan.zip +BUILT_SOURCES = $(unihan_built_sources) -EXTRA_DIST = unihan-compiler.rb +EXTRA_DIST = unihan-compiler.rb $(unihan_built_sources) Unihan.stamp libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ @@ -79,18 +79,16 @@ unihan-compiler.rb: libxml.la -tomoe-unihan-data.h: unihan-compiler.rb Unihan.txt $(top_srcdir)/data/kanjidic2.xml +tomoe-unihan-data.h: unihan-compiler.rb Unihan.stamp $(top_srcdir)/data/kanjidic2.xml $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ -I$(top_srcdir)/test unihan-compiler.rb \ Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@ -Unihan.txt: Unihan.zip +Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip +Unihan.stamp: + $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > Unihan.zip $(UNZIP) Unihan.zip touch $@ - -Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip -Unihan.zip: - $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > $@ endif if WITH_SVN From makeinu users.sourceforge.jp Tue Dec 12 14:34:07 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 14:34:07 +0900 Subject: [Tomoe-cvs 1863] CVS update: tomoe Message-ID: <20061212053407.2E3BB2AC01E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.434 tomoe/ChangeLog:1.435 --- tomoe/ChangeLog:1.434 Tue Dec 12 14:21:19 2006 +++ tomoe/ChangeLog Tue Dec 12 14:34:06 2006 @@ -1,6 +1,7 @@ 2006-12-12 Takuro Ashie * module/dict/Makefile.am: Don't replace tomoe-unihan-data.h. + Check return value of ruby and zip command. 2006-12-12 Kouhei Sutou From makeinu users.sourceforge.jp Tue Dec 12 14:34:07 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 14:34:07 +0900 Subject: [Tomoe-cvs 1864] CVS update: tomoe/module/dict Message-ID: <20061212053407.5CA3D2AC537@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.24 tomoe/module/dict/Makefile.am:1.25 --- tomoe/module/dict/Makefile.am:1.24 Tue Dec 12 14:21:19 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 14:34:07 2006 @@ -86,8 +86,8 @@ Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip Unihan.stamp: - $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > Unihan.zip - $(UNZIP) Unihan.zip + $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > Unihan.zip || exit 1; + $(UNZIP) Unihan.zip || exit 1; touch $@ endif From makeinu users.sourceforge.jp Tue Dec 12 14:43:10 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 14:43:10 +0900 Subject: [Tomoe-cvs 1865] CVS update: tomoe/module/dict Message-ID: <20061212054310.D4AB52AC53A@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.25 tomoe/module/dict/Makefile.am:1.26 --- tomoe/module/dict/Makefile.am:1.25 Tue Dec 12 14:34:07 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 14:43:10 2006 @@ -82,7 +82,8 @@ tomoe-unihan-data.h: unihan-compiler.rb Unihan.stamp $(top_srcdir)/data/kanjidic2.xml $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ -I$(top_srcdir)/test unihan-compiler.rb \ - Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@ + Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@.tmp || exit 1; + mv $@.tmp $@ Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip Unihan.stamp: From makeinu users.sourceforge.jp Tue Dec 12 15:00:47 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 15:00:47 +0900 Subject: [Tomoe-cvs 1866] CVS update: tomoe/module/dict Message-ID: <20061212060047.BA8B82AC094@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.26 tomoe/module/dict/Makefile.am:1.27 --- tomoe/module/dict/Makefile.am:1.26 Tue Dec 12 14:43:10 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 15:00:47 2006 @@ -68,7 +68,7 @@ CLEANFILES += Unihan.txt Unihan.txt.cache BUILT_SOURCES = $(unihan_built_sources) -EXTRA_DIST = unihan-compiler.rb $(unihan_built_sources) Unihan.stamp +EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) Unihan.stamp libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ From makeinu users.sourceforge.jp Tue Dec 12 15:21:01 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Tue, 12 Dec 2006 15:21:01 +0900 Subject: [Tomoe-cvs 1867] CVS update: tomoe Message-ID: <20061212062101.6D5A62AC1EE@users.sourceforge.jp> Index: tomoe/NEWS diff -u tomoe/NEWS:1.8 tomoe/NEWS:1.9 --- tomoe/NEWS:1.8 Tue Dec 12 10:22:34 2006 +++ tomoe/NEWS Tue Dec 12 15:21:01 2006 @@ -1,4 +1,4 @@ -Overview of Changes from libtomoe-0.4.0 to libtomoe-0.4.1 +Overview of Changes from libtomoe-0.4.0 to libtomoe-0.5.0 ============================================================== * New modulized dictionaries: - Hyper Estraier From kous users.sourceforge.jp Tue Dec 12 18:29:55 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:55 +0900 Subject: [Tomoe-cvs 1868] CVS update: tomoe Message-ID: <20061212092955.792522AC094@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.435 tomoe/ChangeLog:1.436 --- tomoe/ChangeLog:1.435 Tue Dec 12 14:34:06 2006 +++ tomoe/ChangeLog Tue Dec 12 18:29:55 2006 @@ -1,3 +1,11 @@ +2006-12-12 Kouhei Sutou + + * lib/tomoe-dict.[ch], lib/tomoe-module.[ch], + module/dict/tomoe-dict-*.c, + module/recognizer/tomoe-recognizer-*.c, ext/ruby/tomoe-rb-dict.rb: + supported dynamic class definition for dictionary module. + * db/, test/, benchmark/: followed the changes. + 2006-12-12 Takuro Ashie * module/dict/Makefile.am: Don't replace tomoe-unihan-data.h. From kous users.sourceforge.jp Tue Dec 12 18:29:55 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:55 +0900 Subject: [Tomoe-cvs 1869] CVS update: tomoe/benchmark Message-ID: <20061212092955.9DF7A2AC0C3@users.sourceforge.jp> Index: tomoe/benchmark/load-dict.rb diff -u tomoe/benchmark/load-dict.rb:1.7 tomoe/benchmark/load-dict.rb:1.8 --- tomoe/benchmark/load-dict.rb:1.7 Mon Dec 4 00:04:42 2006 +++ tomoe/benchmark/load-dict.rb Tue Dec 12 18:29:55 2006 @@ -13,13 +13,12 @@ Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| x.report(File.basename(dictionary)) do - n.times {Tomoe::Dict.new("xml", - "filename" => dictionary, - "editable" => false)} + n.times {Tomoe::Dict::XML.new("filename" => dictionary, + "editable" => false)} end end x.report("Unihan") do - n.times {Tomoe::Dict.new("unihan", {})} + n.times {Tomoe::Dict::Unihan.new} end end Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.6 tomoe/benchmark/search-by-dict.rb:1.7 --- tomoe/benchmark/search-by-dict.rb:1.6 Mon Dec 11 14:40:36 2006 +++ tomoe/benchmark/search-by-dict.rb Tue Dec 12 18:29:55 2006 @@ -16,13 +16,13 @@ TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| case dict_type when "mysql" - dict = Tomoe::Dict.new("mysql", - TomoeSpecUtils::Config.db_config("benchmark")) + config = TomoeSpecUtils::Config.db_config("benchmark") + dict = Tomoe::Dict::MySQL.new(config) when "est" - dict = Tomoe::Dict.new("est", - "name" => File.basename(dictionary), - "database_name" => dictionary.sub(/\.xml$/, ''), - "editable" => false) + database_name = dictionary.sub(/\.xml$/, '') + dict = Tomoe::Dict::Est.new("name" => File.basename(dictionary), + "database_name" => database_name, + "editable" => false) when "svn" repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) FileUtils.mkdir_p(repos) @@ -36,16 +36,13 @@ `svn add #{dict_file.dump}` `svn ci -m '' #{wc.dump}` - xml_dict = Tomoe::Dict.new("xml", - "filename" => dict_file, - "editable" => true) - dict = Tomoe::Dict.new("svn", - "dictionary" => xml_dict, - "working_copy" => wc) + xml_dict = Tomoe::Dict::XML.new("filename" => dict_file, + "editable" => true) + dict = Tomoe::Dict::Svn.new("dictionary" => xml_dict, + "working_copy" => wc) else - dict = Tomoe::Dict.new("xml", - "filename" => dictionary, - "editable" => false) + dict = Tomoe::Dict::XML.new("filename" => dictionary, + "editable" => false) end x.report("#{File.basename(dictionary)}: all") do From kous users.sourceforge.jp Tue Dec 12 18:29:55 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:55 +0900 Subject: [Tomoe-cvs 1870] CVS update: tomoe/db Message-ID: <20061212092955.C53E32AC094@users.sourceforge.jp> Index: tomoe/db/init.rb diff -u tomoe/db/init.rb:1.2 tomoe/db/init.rb:1.3 --- tomoe/db/init.rb:1.2 Mon Dec 11 14:40:37 2006 +++ tomoe/db/init.rb Tue Dec 12 18:29:55 2006 @@ -12,7 +12,7 @@ require 'tomoe-spec-utils' -config = TomoeSpecUtils::Config.db_config(ENV["TOMOE_ENV"]) +config = TomoeSpecUtils::Config.db_config_for_active_record(ENV["TOMOE_ENV"]) ActiveRecord::Base.establish_connection(config) logger = Logger.new($stdout) Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.5 tomoe/db/xml2db.rb:1.6 --- tomoe/db/xml2db.rb:1.5 Tue Dec 12 14:00:59 2006 +++ tomoe/db/xml2db.rb Tue Dec 12 18:29:55 2006 @@ -24,11 +24,11 @@ `#{migrate}` puts "done." -dict = Tomoe::Dict.new("xml", - "filename" => TomoeSpecUtils::Config.dictionaries.first, - "editable" => false) +filename = TomoeSpecUtils::Config.dictionaries.first +dict = Tomoe::Dict::XML.new("filename" => filename, + "editable" => false) config = TomoeSpecUtils::Config.db_config.merge("editable" => true) -mysql_dict = Tomoe::Dict.new("mysql", config) +mysql_dict = Tomoe::Dict::MySQL.new(config) cands = dict.search(Tomoe::Query.new) puts "dict size: #{cands.size}" From kous users.sourceforge.jp Tue Dec 12 18:29:55 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:55 +0900 Subject: [Tomoe-cvs 1871] CVS update: tomoe/ext/ruby Message-ID: <20061212092955.ED0F72AC0C3@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.22 tomoe/ext/ruby/tomoe-rb-dict.c:1.23 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.22 Mon Dec 11 15:15:01 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Tue Dec 12 18:29:55 2006 @@ -2,87 +2,53 @@ #define _SELF(obj) RVAL2TDIC(obj) +#define TOMOE_DICT_PREFIX "TomoeDict" +#define TOMOE_DICT_PREFIX_LEN (strlen(TOMOE_DICT_PREFIX)) + +static VALUE cTomoeDict; + static VALUE td_s_load(VALUE self, VALUE base_dir) { + GList *registered_types, *node; + tomoe_dict_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); - return Qnil; -} -static VALUE -td_s_unload(VALUE self) -{ - tomoe_dict_unload(); + registered_types = tomoe_dict_get_registered_types (); + for (node = registered_types; node; node = g_list_next (node)) { + const gchar *name = node->data; + GType type; + + type = g_type_from_name (name); + if (type && g_str_has_prefix (name, TOMOE_DICT_PREFIX)) { + G_DEF_CLASS(type, name + TOMOE_DICT_PREFIX_LEN, cTomoeDict); + } + } + g_list_free (registered_types); + return Qnil; } static VALUE -td_s_new(VALUE self, VALUE rb_name, VALUE props) +td_s_unload(VALUE self) { - TomoeDict *dict; - gchar *name; - - name = RVAL2CSTR(rb_name); - Check_Type(props, T_HASH); + GList *registered_types, *node; - if (strcmp(name, "xml") == 0) { - VALUE filename, editable; - filename = rb_hash_aref(props, CSTR2RVAL("filename")); - editable = rb_hash_aref(props, CSTR2RVAL("editable")); - dict = tomoe_dict_new(name, - "filename", RVAL2CSTR(filename), - "editable", RVAL2CBOOL(editable), - NULL); - } else if (strcmp(name, "est") == 0) { - VALUE rb_dict_name, database_name, editable; - gchar *dict_name; - - rb_dict_name = rb_hash_aref(props, CSTR2RVAL("name")); - dict_name = NIL_P(rb_dict_name) ? NULL : RVAL2CSTR(rb_dict_name); - database_name = rb_hash_aref(props, CSTR2RVAL("database_name")); - editable = rb_hash_aref(props, CSTR2RVAL("editable")); - - dict = tomoe_dict_new(name, - "name", dict_name, - "database_name", RVAL2CSTR(database_name), - "editable", RVAL2CBOOL(editable), - NULL); - } else if (strcmp(name, "unihan") == 0) { - dict = tomoe_dict_new(name, NULL); - } else if (strcmp(name, "svn") == 0) { - VALUE dictionary, working_copy; - dictionary = rb_hash_aref(props, CSTR2RVAL("dictionary")); - working_copy = rb_hash_aref(props, CSTR2RVAL("working_copy")); - dict = tomoe_dict_new(name, - "dictionary", RVAL2TDIC(dictionary), - "working_copy", RVAL2CSTR(working_copy), - NULL); - } else if (strcmp(name, "ruby") == 0) { - dict = tomoe_dict_new(name, NULL); - } else if (strcmp(name, "mysql") == 0) { - VALUE database, username, password, host, port, socket, editable; - database = rb_hash_aref(props, CSTR2RVAL("database")); - username = rb_hash_aref(props, CSTR2RVAL("username")); - password = rb_hash_aref(props, CSTR2RVAL("password")); - host = rb_hash_aref(props, CSTR2RVAL("host")); - port = rb_hash_aref(props, CSTR2RVAL("port")); - socket = rb_hash_aref(props, CSTR2RVAL("socket")); - editable = rb_hash_aref(props, CSTR2RVAL("editable")); - dict = tomoe_dict_new(name, - "database", RVAL2CSTR2(database), - "user", RVAL2CSTR2(username), - "password", RVAL2CSTR2(password), - "host", RVAL2CSTR2(host), - "port", NIL_P(port) ? 0 : NUM2INT(port), - "socket", RVAL2CSTR2(socket), - "editable", RVAL2CBOOL(editable), - NULL); - } else { - rb_raise(rb_eArgError, "unknown dictionary type: %s", name); - dict = NULL; + registered_types = tomoe_dict_get_registered_types (); + for (node = registered_types; node; node = g_list_next (node)) { + const gchar *name = node->data; + + if (g_str_has_prefix(name, TOMOE_DICT_PREFIX)) { + const gchar *klass_name = name + TOMOE_DICT_PREFIX_LEN; + if (rb_const_defined (cTomoeDict, rb_intern(klass_name))) { + rb_mod_remove_const (cTomoeDict, rb_str_new2(klass_name)); + } + } } + g_list_free (registered_types); - return GOBJ2RVALU(dict); + tomoe_dict_unload(); + return Qnil; } static VALUE @@ -118,15 +84,11 @@ void Init_tomoe_dict(VALUE mTomoe) { - VALUE cTomoeDict; - cTomoeDict = G_DEF_CLASS(TOMOE_TYPE_DICT, "Dict", mTomoe); rb_define_singleton_method(cTomoeDict, "load", td_s_load, 1); rb_define_singleton_method(cTomoeDict, "unload", td_s_unload, 0); - rb_define_singleton_method(cTomoeDict, "new", td_s_new, 2); - rb_define_method(cTomoeDict, "[]", td_get_char, 1); rb_define_method(cTomoeDict, "register", td_register_char, 1); rb_define_method(cTomoeDict, "unregister", td_unregister_char, 1); From kous users.sourceforge.jp Tue Dec 12 18:29:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:56 +0900 Subject: [Tomoe-cvs 1872] CVS update: tomoe/lib Message-ID: <20061212092956.629512AC0C3@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.132 tomoe/lib/tomoe-dict.c:1.133 --- tomoe/lib/tomoe-dict.c:1.132 Wed Dec 6 13:09:16 2006 +++ tomoe/lib/tomoe-dict.c Tue Dec 12 18:29:55 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.132 2006/12/06 04:09:16 kous Exp $ + * $Id: tomoe-dict.c,v 1.133 2006/12/12 09:29:55 kous Exp $ */ #include "tomoe-dict.h" @@ -42,6 +42,12 @@ dicts = NULL; } +GList * +tomoe_dict_get_registered_types (void) +{ + return tomoe_module_collect_registered_types (dicts); +} + G_DEFINE_ABSTRACT_TYPE (TomoeDict, tomoe_dict, G_TYPE_OBJECT) static void Index: tomoe/lib/tomoe-dict.h diff -u tomoe/lib/tomoe-dict.h:1.56 tomoe/lib/tomoe-dict.h:1.57 --- tomoe/lib/tomoe-dict.h:1.56 Wed Dec 6 12:08:46 2006 +++ tomoe/lib/tomoe-dict.h Tue Dec 12 18:29:56 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.h,v 1.56 2006/12/06 03:08:46 kous Exp $ + * $Id: tomoe-dict.h,v 1.57 2006/12/12 09:29:56 kous Exp $ */ #ifndef __TOMOE_DICT_H__ @@ -71,6 +71,7 @@ void tomoe_dict_load (const gchar *base_dir); void tomoe_dict_unload (void); +GList *tomoe_dict_get_registered_types (void); TomoeDict *tomoe_dict_new (const gchar *name, const gchar *first_property, Index: tomoe/lib/tomoe-module-impl.h diff -u tomoe/lib/tomoe-module-impl.h:1.2 tomoe/lib/tomoe-module-impl.h:1.3 --- tomoe/lib/tomoe-module-impl.h:1.2 Fri Dec 1 10:35:42 2006 +++ tomoe/lib/tomoe-module-impl.h Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module-impl.h,v 1.2 2006/12/01 01:35:42 ikezoe Exp $ + * $Id: tomoe-module-impl.h,v 1.3 2006/12/12 09:29:56 kous Exp $ */ #ifndef __TOMOE_MODULE_IMPL_H__ @@ -29,7 +29,7 @@ #include "tomoe-module.h" -typedef void (*TomoeModuleInitFunc) (GTypeModule *module); +typedef GList *(*TomoeModuleInitFunc) (GTypeModule *module); typedef void (*TomoeModuleExitFunc) (void); typedef GObject *(*TomoeModuleInstantiateFunc) (const gchar *first_property, va_list var_args); @@ -39,7 +39,7 @@ #define TOMOE_MODULE_IMPL_INSTANTIATE tomoe_module_impl_instantiate -void TOMOE_MODULE_IMPL_INIT (GTypeModule *module); +GList *TOMOE_MODULE_IMPL_INIT (GTypeModule *module); void TOMOE_MODULE_IMPL_EXIT (void); GObject *TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args); Index: tomoe/lib/tomoe-module.c diff -u tomoe/lib/tomoe-module.c:1.6 tomoe/lib/tomoe-module.c:1.7 --- tomoe/lib/tomoe-module.c:1.6 Thu Dec 7 13:17:30 2006 +++ tomoe/lib/tomoe-module.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.c,v 1.6 2006/12/07 04:17:30 kous Exp $ + * $Id: tomoe-module.c,v 1.7 2006/12/12 09:29:56 kous Exp $ */ #include @@ -36,6 +36,7 @@ { GModule *library; gchar *mod_path; + GList *registered_types; TomoeModuleInitFunc init; TomoeModuleExitFunc exit; @@ -80,6 +81,7 @@ priv->library = NULL; priv->mod_path = NULL; + priv->registered_types = NULL; } static void @@ -89,6 +91,8 @@ g_free (priv->mod_path); priv->mod_path = NULL; + g_list_free (priv->registered_types); + priv->registered_types = NULL; G_OBJECT_CLASS (tomoe_module_parent_class)->finalize (object); } @@ -116,7 +120,8 @@ return FALSE; } - priv->init (module); + g_list_free (priv->registered_types); + priv->registered_types = priv->init (module); return TRUE; } @@ -134,6 +139,38 @@ priv->init = NULL; priv->exit = NULL; priv->instantiate = NULL; + + g_list_free (priv->registered_types); + priv->registered_types = NULL; +} + +GList * +tomoe_module_collect_registered_types (GList *modules) +{ + GList *results = NULL; + GList *node; + + for (node = modules; node; node = g_list_next (node)) { + TomoeModule *module = node->data; + GTypeModule *g_type_module; + + g_type_module = G_TYPE_MODULE (module); + if (g_type_module_use (g_type_module)) { + TomoeModulePrivate *priv; + GList *node; + + priv = TOMOE_MODULE_GET_PRIVATE (module); + for (node = priv->registered_types; + node; + node = g_list_next (node)) { + results = g_list_prepend (results, node->data); + } + + g_type_module_unuse (g_type_module); + } + } + + return results; } static void Index: tomoe/lib/tomoe-module.h diff -u tomoe/lib/tomoe-module.h:1.5 tomoe/lib/tomoe-module.h:1.6 --- tomoe/lib/tomoe-module.h:1.5 Wed Nov 29 11:53:11 2006 +++ tomoe/lib/tomoe-module.h Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.h,v 1.5 2006/11/29 02:53:11 kous Exp $ + * $Id: tomoe-module.h,v 1.6 2006/12/12 09:29:56 kous Exp $ */ #ifndef __TOMOE_MODULE_H__ @@ -57,6 +57,8 @@ const gchar *first_property, va_list var_args); +GList *tomoe_module_collect_registered_types (GList *modules); + G_END_DECLS #endif /* __TOMOE_MODULE_H__ */ From kous users.sourceforge.jp Tue Dec 12 18:29:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:56 +0900 Subject: [Tomoe-cvs 1873] CVS update: tomoe/module/dict Message-ID: <20061212092956.945EB2AC54B@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.11 tomoe/module/dict/tomoe-dict-est.c:1.12 --- tomoe/module/dict/tomoe-dict-est.c:1.11 Mon Dec 11 13:39:43 2006 +++ tomoe/module/dict/tomoe-dict-est.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.11 2006/12/11 04:39:43 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.12 2006/12/12 09:29:56 kous Exp $ */ #include @@ -189,10 +189,18 @@ &info, 0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; + register_type (type_module); + if (tomoe_type_dict_est) + registered_types = + g_list_prepend (registered_types, + (gchar *) g_type_name (tomoe_type_dict_est)); + + return registered_types; } G_MODULE_EXPORT void Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.7 tomoe/module/dict/tomoe-dict-mysql.c:1.8 --- tomoe/module/dict/tomoe-dict-mysql.c:1.7 Tue Dec 12 14:02:16 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.7 2006/12/12 05:02:16 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.8 2006/12/12 09:29:56 kous Exp $ */ #include @@ -260,10 +260,18 @@ &info, 0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; + register_type (type_module); + if (tomoe_type_dict_mysql) + registered_types = + g_list_prepend (registered_types, + (gchar *) g_type_name (tomoe_type_dict_mysql)); + + return registered_types; } G_MODULE_EXPORT void Index: tomoe/module/dict/tomoe-dict-ruby.c diff -u tomoe/module/dict/tomoe-dict-ruby.c:1.2 tomoe/module/dict/tomoe-dict-ruby.c:1.3 --- tomoe/module/dict/tomoe-dict-ruby.c:1.2 Fri Dec 8 10:00:56 2006 +++ tomoe/module/dict/tomoe-dict-ruby.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ruby.c,v 1.2 2006/12/08 01:00:56 kous Exp $ + * $Id: tomoe-dict-ruby.c,v 1.3 2006/12/12 09:29:56 kous Exp $ */ #include @@ -190,17 +190,19 @@ ruby_cleanup (0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; static gchar *argv[] = {G_STRINGIFY (PACKAGE)}; - static gboolean ruby_initialized = FALSE; register_type (type_module); + if (tomoe_type_dict_ruby) + registered_types = + g_list_prepend (registered_types, + (gchar *) g_type_name (tomoe_type_dict_ruby)); - if (!ruby_initialized) { - ruby_initialized = TRUE; - + if (!rb_load_path) { ruby_init (); atexit(tomoe_dict_ruby_atexit); ruby_script (PACKAGE); @@ -213,6 +215,8 @@ rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_EXTDIR)); rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_LIBDIR)); } + + return registered_types; } G_MODULE_EXPORT void Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.6 tomoe/module/dict/tomoe-dict-svn.c:1.7 --- tomoe/module/dict/tomoe-dict-svn.c:1.6 Thu Dec 7 14:35:46 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.6 2006/12/07 05:35:46 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.7 2006/12/12 09:29:56 kous Exp $ */ #include @@ -187,9 +187,10 @@ &info, 0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; apr_status_t status; status = apr_initialize (); @@ -197,13 +198,19 @@ char buf[1024]; apr_strerror (status, buf, sizeof(buf) - 1); g_warning ("cannot initialize APR: %s", buf); - return; + return registered_types; } pool = svn_pool_create (NULL); svn_utf_initialize (pool); register_type (type_module); + if (tomoe_type_dict_svn) + registered_types = + g_list_prepend (registered_types, + (gchar *) g_type_name (tomoe_type_dict_svn)); + + return registered_types; } G_MODULE_EXPORT void Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.5 tomoe/module/dict/tomoe-dict-unihan.c:1.6 --- tomoe/module/dict/tomoe-dict-unihan.c:1.5 Wed Dec 6 13:19:43 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.5 2006/12/06 04:19:43 ikezoe Exp $ + * $Id: tomoe-dict-unihan.c,v 1.6 2006/12/12 09:29:56 kous Exp $ */ #include @@ -150,13 +150,21 @@ &info, 0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; + register_type (type_module); + if (tomoe_type_dict_unihan) + registered_types = + g_list_prepend (registered_types, + (gchar *) g_type_name (tomoe_type_dict_unihan)); if (!chars) chars = _tomoe_unihan_create (); + + return registered_types; } G_MODULE_EXPORT void Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.12 tomoe/module/dict/tomoe-dict-xml.c:1.13 --- tomoe/module/dict/tomoe-dict-xml.c:1.12 Thu Dec 7 14:07:25 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Tue Dec 12 18:29:56 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.12 2006/12/07 05:07:25 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.13 2006/12/12 09:29:56 kous Exp $ */ #include @@ -178,10 +178,18 @@ &info, 0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; + register_type (type_module); + if (tomoe_type_dict_xml) + registered_types = + g_list_prepend (registered_types, + (gchar *) g_type_name (tomoe_type_dict_xml)); + + return registered_types; } G_MODULE_EXPORT void Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.8 tomoe/module/dict/unihan-compiler.rb:1.9 --- tomoe/module/dict/unihan-compiler.rb:1.8 Fri Dec 8 13:19:07 2006 +++ tomoe/module/dict/unihan-compiler.rb Tue Dec 12 18:29:56 2006 @@ -105,9 +105,8 @@ end def merge_kanjidic2_xml(kanjidic2_xml, infos) - dict = Tomoe::Dict.new("xml", - "filename" => kanjidic2_xml, - "editable" => false) + dict = Tomoe::Dict::XML.new("filename" => kanjidic2_xml, + "editable" => false) dict.search(Tomoe::Query.new).each do |cand| char = cand.char ucs4 = utf8_to_ucs4(char.utf8) From kous users.sourceforge.jp Tue Dec 12 18:29:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:56 +0900 Subject: [Tomoe-cvs 1874] CVS update: tomoe/module/recognizer Message-ID: <20061212092956.BA76E2AC0C3@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.7 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.8 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.7 Wed Dec 6 12:33:41 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Tue Dec 12 18:29:56 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.7 2006/12/06 03:33:41 ikezoe Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.8 2006/12/12 09:29:56 kous Exp $ */ #include @@ -127,10 +127,17 @@ &info, 0); } -G_MODULE_EXPORT void +G_MODULE_EXPORT GList * TOMOE_MODULE_IMPL_INIT (GTypeModule *type_module) { + GList *registered_types = NULL; + register_type (type_module); + if (tomoe_type_recognizer_simple) + registered_types = g_list_prepend (registered_types, + &tomoe_type_recognizer_simple); + + return registered_types; } G_MODULE_EXPORT void From kous users.sourceforge.jp Tue Dec 12 18:29:56 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:29:56 +0900 Subject: [Tomoe-cvs 1875] CVS update: tomoe/test Message-ID: <20061212092956.EAB392AC547@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.25 tomoe/test/context_spec.rb:1.26 --- tomoe/test/context_spec.rb:1.25 Thu Dec 7 15:02:41 2006 +++ tomoe/test/context_spec.rb Tue Dec 12 18:29:56 2006 @@ -4,9 +4,11 @@ @@context = nil def context return @@context if @@context - dict = Tomoe::Dict.new("xml", - "filename" => File.join(data_dir, "handwriting.xml"), - "editable" => false) + config = { + "filename" => File.join(data_dir, "handwriting.xml"), + "editable" => false, + } + dict = Tomoe::Dict::XML.new(config) recognizer = Tomoe::Recognizer.new("simple", dict) @@context = Tomoe::Context.new("recognizer" => recognizer) @@context.load_config(@config_file.path) Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.17 tomoe/test/dict_spec.rb:1.18 --- tomoe/test/dict_spec.rb:1.17 Mon Dec 11 15:03:41 2006 +++ tomoe/test/dict_spec.rb Tue Dec 12 18:29:56 2006 @@ -7,9 +7,8 @@ end specify "should load XML dictionary" do - dict = Tomoe::Dict.new("xml", - "filename" => @dict_file.path, - "editable" => true) + dict = Tomoe::Dict::XML.new("filename" => @dict_file.path, + "editable" => true) a = dict[@utf8] a.writing.strokes.should == @strokes end @@ -21,9 +20,8 @@ `estcmd create #{est_db.dump}` `estcmd put #{est_db.dump} #{@est_draft_file.path.dump}` - dict = Tomoe::Dict.new("est", - "database_name" => est_db, - "editable" => true) + dict = Tomoe::Dict::Est.new("database_name" => est_db, + "editable" => true) a = dict[@utf8] a.writing.strokes.should == @strokes ensure @@ -47,13 +45,10 @@ `svn ci -m '' #{wc.dump}` `svnlook youngest #{repos.dump}`.chomp.should == "1" - xml_dict = Tomoe::Dict.new("xml", - "filename" => dict_file, - "editable" => true) - dict = Tomoe::Dict.new("svn", - "dictionary" => xml_dict, - "repository" => repos_url, - "working_copy" => wc) + xml_dict = Tomoe::Dict::XML.new("filename" => dict_file, + "editable" => true) + dict = Tomoe::Dict::Svn.new("dictionary" => xml_dict, + "working_copy" => wc) a = dict[@utf8] a.writing.strokes.should == @strokes @@ -69,7 +64,7 @@ end specify "should register/unregister to MySQL database" do - dict = Tomoe::Dict.new("mysql", db_config) + dict = Tomoe::Dict::MySQL.new(db_config) char = Tomoe::Char.new char.utf8 = "?? dict.register(char).should == true @@ -81,7 +76,7 @@ end specify "should register/unregister PUA character to MySQL database" do - dict = Tomoe::Dict.new("mysql", db_config) + dict = Tomoe::Dict::MySQL.new(db_config) char = Tomoe::Char.new dict.register(char).should == true dict.search(Tomoe::Query.new).size.should == 1 Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.25 tomoe/test/tomoe-spec-utils.rb:1.26 --- tomoe/test/tomoe-spec-utils.rb:1.25 Tue Dec 12 14:00:59 2006 +++ tomoe/test/tomoe-spec-utils.rb Tue Dec 12 18:29:56 2006 @@ -99,10 +99,18 @@ File.join(db_dir, "config.yml") end - def db_config(type=nil) + def db_config_for_active_record(type=nil) YAML.load(File.read(db_config_file))[type || ENV["TOMOE_ENV"] || "test"] end + def db_config(type=nil) + config = db_config_for_active_record(type) + config.delete("adapter") + config.delete("encoding") + config["user"] = config.delete("username") if config["username"] + config + end + def setup_context super @config_file = make_config_file From kous users.sourceforge.jp Tue Dec 12 18:55:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:55:58 +0900 Subject: [Tomoe-cvs 1876] CVS update: tomoe Message-ID: <20061212095558.AE38B2AC094@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.436 tomoe/ChangeLog:1.437 --- tomoe/ChangeLog:1.436 Tue Dec 12 18:29:55 2006 +++ tomoe/ChangeLog Tue Dec 12 18:55:58 2006 @@ -1,5 +1,14 @@ 2006-12-12 Kouhei Sutou + * lib/tomoe-recognizer.[ch], + module/recognizer/tomoe-recognizer-*.c, + ext/ruby/tomoe-rb-recognizer.c: supported dynamic class + definition for recognizer module. + * ext/ruby/tomoe-rb-recognizer.c, ext/ruby/tomoe-rb-dict.c, + ext/ruby/tomoe-rb-module.c, ext/ruby/tomoe-rb.h, + ext/ruby/Makefile.am: unified duplicated codes. + * test/, benchmark/: followed the changes. + * lib/tomoe-dict.[ch], lib/tomoe-module.[ch], module/dict/tomoe-dict-*.c, module/recognizer/tomoe-recognizer-*.c, ext/ruby/tomoe-rb-dict.rb: From kous users.sourceforge.jp Tue Dec 12 18:55:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:55:58 +0900 Subject: [Tomoe-cvs 1877] CVS update: tomoe/benchmark Message-ID: <20061212095558.D1CF62AC117@users.sourceforge.jp> Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.6 tomoe/benchmark/search-by-recognizer.rb:1.7 --- tomoe/benchmark/search-by-recognizer.rb:1.6 Wed Dec 6 16:13:42 2006 +++ tomoe/benchmark/search-by-recognizer.rb Tue Dec 12 18:55:58 2006 @@ -13,15 +13,15 @@ data_dir = TomoeSpecUtils::Config.data_dir use_est = false if use_est - dict = Tomoe::Dict.new("est", - "database_name" => File.join(data_dir, "handwriting"), - "editable" => false) + database_name = File.join(data_dir, "handwriting") + dict = Tomoe::Dict::Est.new("database_name" => database_name, + "editable" => false) else - dict = Tomoe::Dict.new("xml", - "filename" => File.join(data_dir, "handwriting.xml"), - "editable" => false) + filename = File.join(data_dir, "handwriting.xml") + dict = Tomoe::Dict::XML.new("filename" => filename, + "editable" => false) end -recognizer = Tomoe::Recognizer.new("simple", dict) +recognizer = Tomoe::Recognizer::Simple.new("dictionary" => dict) context = Tomoe::Context.new("recognizer" => recognizer) config_file = TomoeSpecUtils::Config.make_config_file context.load_config(config_file.path) From kous users.sourceforge.jp Tue Dec 12 18:55:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:55:59 +0900 Subject: [Tomoe-cvs 1878] CVS update: tomoe/ext/ruby Message-ID: <20061212095559.09C472AC094@users.sourceforge.jp> Index: tomoe/ext/ruby/Makefile.am diff -u tomoe/ext/ruby/Makefile.am:1.11 tomoe/ext/ruby/Makefile.am:1.12 --- tomoe/ext/ruby/Makefile.am:1.11 Tue Dec 5 14:51:42 2006 +++ tomoe/ext/ruby/Makefile.am Tue Dec 12 18:55:58 2006 @@ -18,6 +18,7 @@ tomoe-rb-config.c \ tomoe-rb-context.c \ tomoe-rb-dict.c \ + tomoe-rb-module.c \ tomoe-rb-query.c \ tomoe-rb-reading.c \ tomoe-rb-recognizer.c \ Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.23 tomoe/ext/ruby/tomoe-rb-dict.c:1.24 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.23 Tue Dec 12 18:29:55 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Tue Dec 12 18:55:58 2006 @@ -10,43 +10,17 @@ static VALUE td_s_load(VALUE self, VALUE base_dir) { - GList *registered_types, *node; - tomoe_dict_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); - - registered_types = tomoe_dict_get_registered_types (); - for (node = registered_types; node; node = g_list_next (node)) { - const gchar *name = node->data; - GType type; - - type = g_type_from_name (name); - if (type && g_str_has_prefix (name, TOMOE_DICT_PREFIX)) { - G_DEF_CLASS(type, name + TOMOE_DICT_PREFIX_LEN, cTomoeDict); - } - } - g_list_free (registered_types); - + _tomoe_rb_module_load(tomoe_dict_get_registered_types(), cTomoeDict, + TOMOE_DICT_PREFIX, TOMOE_DICT_PREFIX_LEN); return Qnil; } static VALUE td_s_unload(VALUE self) { - GList *registered_types, *node; - - registered_types = tomoe_dict_get_registered_types (); - for (node = registered_types; node; node = g_list_next (node)) { - const gchar *name = node->data; - - if (g_str_has_prefix(name, TOMOE_DICT_PREFIX)) { - const gchar *klass_name = name + TOMOE_DICT_PREFIX_LEN; - if (rb_const_defined (cTomoeDict, rb_intern(klass_name))) { - rb_mod_remove_const (cTomoeDict, rb_str_new2(klass_name)); - } - } - } - g_list_free (registered_types); - + _tomoe_rb_module_unload(tomoe_dict_get_registered_types(), cTomoeDict, + TOMOE_DICT_PREFIX, TOMOE_DICT_PREFIX_LEN); tomoe_dict_unload(); return Qnil; } Index: tomoe/ext/ruby/tomoe-rb-module.c diff -u /dev/null tomoe/ext/ruby/tomoe-rb-module.c:1.1 --- /dev/null Tue Dec 12 18:55:58 2006 +++ tomoe/ext/ruby/tomoe-rb-module.c Tue Dec 12 18:55:58 2006 @@ -0,0 +1,38 @@ +#include "tomoe-rb.h" + +void +_tomoe_rb_module_load (GList *registered_types, VALUE klass, + const gchar *prefix, gint prefix_len) +{ + GList *node; + + for (node = registered_types; node; node = g_list_next (node)) { + const gchar *name = node->data; + GType type; + + type = g_type_from_name (name); + if (type && g_str_has_prefix (name, prefix)) { + G_DEF_CLASS(type, name + prefix_len, klass); + } + } + g_list_free (registered_types); +} + +void +_tomoe_rb_module_unload (GList *registered_types, VALUE klass, + const gchar *prefix, gint prefix_len) +{ + GList *node; + + for (node = registered_types; node; node = g_list_next (node)) { + const gchar *name = node->data; + + if (g_str_has_prefix(name, prefix)) { + const gchar *klass_name = name + prefix_len; + if (rb_const_defined (klass, rb_intern(klass_name))) { + rb_mod_remove_const (klass, rb_str_new2(klass_name)); + } + } + } + g_list_free (registered_types); +} Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.5 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.6 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.5 Wed Dec 6 15:28:36 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Tue Dec 12 18:55:58 2006 @@ -1,42 +1,37 @@ #include "tomoe-rb.h" +#define TOMOE_RECOGNIZER_PREFIX "TomoeRecognizer" +#define TOMOE_RECOGNIZER_PREFIX_LEN (strlen(TOMOE_RECOGNIZER_PREFIX)) + +static VALUE cTomoeRecognizer; + static VALUE tr_s_load(VALUE self, VALUE base_dir) { tomoe_recognizer_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); + _tomoe_rb_module_load(tomoe_recognizer_get_registered_types(), + cTomoeRecognizer, + TOMOE_RECOGNIZER_PREFIX, + TOMOE_RECOGNIZER_PREFIX_LEN); return Qnil; } static VALUE tr_s_unload(VALUE self) { + _tomoe_rb_module_unload(tomoe_recognizer_get_registered_types(), + cTomoeRecognizer, + TOMOE_RECOGNIZER_PREFIX, + TOMOE_RECOGNIZER_PREFIX_LEN); tomoe_recognizer_unload(); return Qnil; } -static VALUE -tr_s_new(int argc, VALUE *argv, VALUE self) -{ - TomoeRecognizer *recognizer; - VALUE name, dict; - - rb_scan_args(argc, argv, "11", &name, &dict); - - recognizer = tomoe_recognizer_new(RVAL2CSTR(name), - "dictionary", RVAL2TDIC(dict), - NULL); - return GOBJ2RVALU(recognizer); -} - void Init_tomoe_recognizer(VALUE mTomoe) { - VALUE cTomoeRecognizer; - cTomoeRecognizer = G_DEF_CLASS(TOMOE_TYPE_RECOGNIZER, "Recognizer", mTomoe); rb_define_singleton_method(cTomoeRecognizer, "load", tr_s_load, 1); rb_define_singleton_method(cTomoeRecognizer, "unload", tr_s_unload, 0); - - rb_define_singleton_method(cTomoeRecognizer, "new", tr_s_new, -1); } Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.10 tomoe/ext/ruby/tomoe-rb.h:1.11 --- tomoe/ext/ruby/tomoe-rb.h:1.10 Mon Dec 11 13:39:43 2006 +++ tomoe/ext/ruby/tomoe-rb.h Tue Dec 12 18:55:58 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.10 2006/12/11 04:39:43 kous Exp $ + * $Id: tomoe-rb.h,v 1.11 2006/12/12 09:55:58 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -51,6 +51,11 @@ void Init_tomoe_recognizer(VALUE mTomoe); void Init_tomoe_writing(VALUE mTomoe); +void _tomoe_rb_module_load (GList *registered_types, VALUE klass, + const gchar *prefix, gint prefix_len); +void _tomoe_rb_module_unload (GList *registered_types, VALUE klass, + const gchar *prefix, gint prefix_len); + G_END_DECLS #endif /* __TOMOE_RB_H__ */ From kous users.sourceforge.jp Tue Dec 12 18:55:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:55:59 +0900 Subject: [Tomoe-cvs 1879] CVS update: tomoe/lib Message-ID: <20061212095559.2E9332AC138@users.sourceforge.jp> Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.23 tomoe/lib/tomoe-recognizer.c:1.24 --- tomoe/lib/tomoe-recognizer.c:1.23 Tue Dec 5 14:51:42 2006 +++ tomoe/lib/tomoe-recognizer.c Tue Dec 12 18:55:59 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.23 2006/12/05 05:51:42 kous Exp $ + * $Id: tomoe-recognizer.c,v 1.24 2006/12/12 09:55:59 kous Exp $ */ #include @@ -46,6 +46,12 @@ recognizers = NULL; } +GList * +tomoe_recognizer_get_registered_types (void) +{ + return tomoe_module_collect_registered_types (recognizers); +} + G_DEFINE_ABSTRACT_TYPE (TomoeRecognizer, tomoe_recognizer, G_TYPE_OBJECT) static void Index: tomoe/lib/tomoe-recognizer.h diff -u tomoe/lib/tomoe-recognizer.h:1.20 tomoe/lib/tomoe-recognizer.h:1.21 --- tomoe/lib/tomoe-recognizer.h:1.20 Mon Dec 4 13:36:48 2006 +++ tomoe/lib/tomoe-recognizer.h Tue Dec 12 18:55:59 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.h,v 1.20 2006/12/04 04:36:48 kous Exp $ + * $Id: tomoe-recognizer.h,v 1.21 2006/12/12 09:55:59 kous Exp $ */ #ifndef __TOMOE_RECOGNIZER_H__ @@ -58,6 +58,7 @@ void tomoe_recognizer_load (const gchar *base_dir); void tomoe_recognizer_unload (void); +GList *tomoe_recognizer_get_registered_types (void); TomoeRecognizer *tomoe_recognizer_new (const gchar *name, const gchar *first_property, From kous users.sourceforge.jp Tue Dec 12 18:55:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:55:59 +0900 Subject: [Tomoe-cvs 1880] CVS update: tomoe/module/recognizer Message-ID: <20061212095559.52EAA2AC094@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.8 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.9 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.8 Tue Dec 12 18:29:56 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Tue Dec 12 18:55:59 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.8 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.9 2006/12/12 09:55:59 kous Exp $ */ #include @@ -133,9 +133,10 @@ GList *registered_types = NULL; register_type (type_module); - if (tomoe_type_recognizer_simple) - registered_types = g_list_prepend (registered_types, - &tomoe_type_recognizer_simple); + if (tomoe_type_recognizer_simple) { + gchar *name = (gchar *) g_type_name (tomoe_type_recognizer_simple); + registered_types = g_list_prepend (registered_types, name); + } return registered_types; } From kous users.sourceforge.jp Tue Dec 12 18:55:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 18:55:59 +0900 Subject: [Tomoe-cvs 1881] CVS update: tomoe/test Message-ID: <20061212095559.76A472AC138@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.26 tomoe/test/context_spec.rb:1.27 --- tomoe/test/context_spec.rb:1.26 Tue Dec 12 18:29:56 2006 +++ tomoe/test/context_spec.rb Tue Dec 12 18:55:59 2006 @@ -9,7 +9,7 @@ "editable" => false, } dict = Tomoe::Dict::XML.new(config) - recognizer = Tomoe::Recognizer.new("simple", dict) + recognizer = Tomoe::Recognizer::Simple.new("dictionary" => dict) @@context = Tomoe::Context.new("recognizer" => recognizer) @@context.load_config(@config_file.path) @@context From kous users.sourceforge.jp Tue Dec 12 19:04:38 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:04:38 +0900 Subject: [Tomoe-cvs 1882] CVS update: tomoe Message-ID: <20061212100438.63AD32AC094@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.437 tomoe/ChangeLog:1.438 --- tomoe/ChangeLog:1.437 Tue Dec 12 18:55:58 2006 +++ tomoe/ChangeLog Tue Dec 12 19:04:38 2006 @@ -1,5 +1,8 @@ 2006-12-12 Kouhei Sutou + * module/dict/Makefile.am: added dependencies on + $(top_builddir)/data/kanjidic2.xml. + * lib/tomoe-recognizer.[ch], module/recognizer/tomoe-recognizer-*.c, ext/ruby/tomoe-rb-recognizer.c: supported dynamic class From kous users.sourceforge.jp Tue Dec 12 19:04:38 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:04:38 +0900 Subject: [Tomoe-cvs 1883] CVS update: tomoe/module/dict Message-ID: <20061212100438.8FDBA2AC547@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.27 tomoe/module/dict/Makefile.am:1.28 --- tomoe/module/dict/Makefile.am:1.27 Tue Dec 12 15:00:47 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 19:04:38 2006 @@ -79,7 +79,10 @@ unihan-compiler.rb: libxml.la -tomoe-unihan-data.h: unihan-compiler.rb Unihan.stamp $(top_srcdir)/data/kanjidic2.xml +$(top_builddir)/data/kanjidic2.xml: + cd $(top_builddir)/data && $(MAKE) $(AM_MAKEFLAGS) kanjidic2.xml + +tomoe-unihan-data.h: unihan-compiler.rb Unihan.stamp $(top_builddir)/data/kanjidic2.xml $(RUBY) -I$(top_srcdir)/ext/ruby -I$(top_builddir)/ext/ruby/.libs \ -I$(top_srcdir)/test unihan-compiler.rb \ Unihan.txt $(top_srcdir)/data/kanjidic2.xml > $@.tmp || exit 1; From kous users.sourceforge.jp Tue Dec 12 19:08:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:08:11 +0900 Subject: [Tomoe-cvs 1884] CVS update: tomoe Message-ID: <20061212100811.9CB7D2AC0C3@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.438 tomoe/ChangeLog:1.439 --- tomoe/ChangeLog:1.438 Tue Dec 12 19:04:38 2006 +++ tomoe/ChangeLog Tue Dec 12 19:08:11 2006 @@ -1,5 +1,10 @@ 2006-12-12 Kouhei Sutou + * module/dict/tomoe-dict-est.c: changed property name: + "database_name" -> "database". + * test/, benchmark/, utils/, lib/tomoe-config.c: followed the + changes. + * module/dict/Makefile.am: added dependencies on $(top_builddir)/data/kanjidic2.xml. From kous users.sourceforge.jp Tue Dec 12 19:08:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:08:11 +0900 Subject: [Tomoe-cvs 1885] CVS update: tomoe/benchmark Message-ID: <20061212100811.D38882AC547@users.sourceforge.jp> Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.7 tomoe/benchmark/search-by-dict.rb:1.8 --- tomoe/benchmark/search-by-dict.rb:1.7 Tue Dec 12 18:29:55 2006 +++ tomoe/benchmark/search-by-dict.rb Tue Dec 12 19:08:11 2006 @@ -19,9 +19,9 @@ config = TomoeSpecUtils::Config.db_config("benchmark") dict = Tomoe::Dict::MySQL.new(config) when "est" - database_name = dictionary.sub(/\.xml$/, '') + database = dictionary.sub(/\.xml$/, '') dict = Tomoe::Dict::Est.new("name" => File.basename(dictionary), - "database_name" => database_name, + "database" => database, "editable" => false) when "svn" repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.7 tomoe/benchmark/search-by-recognizer.rb:1.8 --- tomoe/benchmark/search-by-recognizer.rb:1.7 Tue Dec 12 18:55:58 2006 +++ tomoe/benchmark/search-by-recognizer.rb Tue Dec 12 19:08:11 2006 @@ -13,8 +13,8 @@ data_dir = TomoeSpecUtils::Config.data_dir use_est = false if use_est - database_name = File.join(data_dir, "handwriting") - dict = Tomoe::Dict::Est.new("database_name" => database_name, + database = File.join(data_dir, "handwriting") + dict = Tomoe::Dict::Est.new("database" => database, "editable" => false) else filename = File.join(data_dir, "handwriting.xml") From kous users.sourceforge.jp Tue Dec 12 19:08:12 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:08:12 +0900 Subject: [Tomoe-cvs 1886] CVS update: tomoe/lib Message-ID: <20061212100812.0A5922AC0C3@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.53 tomoe/lib/tomoe-config.c:1.54 --- tomoe/lib/tomoe-config.c:1.53 Mon Dec 11 15:15:01 2006 +++ tomoe/lib/tomoe-config.c Tue Dec 12 19:08:11 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.53 2006/12/11 06:15:01 kous Exp $ + * $Id: tomoe-config.c,v 1.54 2006/12/12 10:08:11 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -491,7 +491,7 @@ { TomoeDict *dict; GError *error = NULL; - gchar *name, *database_name; + gchar *name, *database; gboolean user_dict, editable; name = g_key_file_get_string (key_file, dict_name, "name", &error); @@ -500,8 +500,7 @@ return NULL; } - database_name = g_key_file_get_string (key_file, dict_name, - "database", &error); + database = g_key_file_get_string (key_file, dict_name, "database", &error); if (error) { TOMOE_HANDLE_ERROR (error); return NULL; @@ -513,19 +512,19 @@ "user", TRUE); if (!user_dict) { gchar *tmp; - tmp = g_build_filename (DICT_DATADIR, database_name, NULL); - g_free (database_name); - database_name = tmp; + tmp = g_build_filename (DICT_DATADIR, database, NULL); + g_free (database); + database = tmp; } dict = tomoe_dict_new ("est", "name", name, - "database_name", database_name, + "database", database, "editable", editable, NULL); g_free (name); - g_free (database_name); + g_free (database); return dict; } From kous users.sourceforge.jp Tue Dec 12 19:08:12 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:08:12 +0900 Subject: [Tomoe-cvs 1887] CVS update: tomoe/module/dict Message-ID: <20061212100812.34C182AC547@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.12 tomoe/module/dict/tomoe-dict-est.c:1.13 --- tomoe/module/dict/tomoe-dict-est.c:1.12 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/tomoe-dict-est.c Tue Dec 12 19:08:12 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.12 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.13 2006/12/12 10:08:12 kous Exp $ */ #include @@ -45,7 +45,7 @@ enum { PROP_0, PROP_NAME, - PROP_DATABASE_NAME, + PROP_DATABASE, PROP_EDITABLE }; @@ -55,7 +55,7 @@ { TomoeDict object; gchar *name; - gchar *database_name; + gchar *database; gboolean editable; @@ -138,11 +138,11 @@ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property ( gobject_class, - PROP_DATABASE_NAME, + PROP_DATABASE, g_param_spec_string ( - "database_name", - "Database name", - "The name of Hyper Estraier database", + "database", + "Database", + "The database name of Hyper Estraier", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property( @@ -160,7 +160,7 @@ init (TomoeDictEst *dict) { dict->name = NULL; - dict->database_name = NULL; + dict->database = NULL; dict->db = NULL; dict->editable = FALSE; dict->cache = g_hash_table_new_full(g_str_hash, g_str_equal, @@ -242,8 +242,8 @@ case PROP_NAME: dict->name = g_value_dup_string (value); break; - case PROP_DATABASE_NAME: - dict->database_name = g_value_dup_string (value); + case PROP_DATABASE: + dict->database = g_value_dup_string (value); break; case PROP_EDITABLE: dict->editable = g_value_get_boolean (value); @@ -267,8 +267,8 @@ case PROP_NAME: g_value_set_string (value, dict->name); break; - case PROP_DATABASE_NAME: - g_value_set_string (value, dict->database_name); + case PROP_DATABASE: + g_value_set_string (value, dict->database); break; case PROP_EDITABLE: g_value_set_boolean (value, dict->editable); @@ -290,13 +290,13 @@ if (dict->name) g_free (dict->name); - if (dict->database_name) - g_free (dict->database_name); + if (dict->database) + g_free (dict->database); if (dict->cache) g_hash_table_destroy (dict->cache); dict->name = NULL; - dict->database_name = NULL; + dict->database = NULL; dict->cache = NULL; G_OBJECT_CLASS (parent_class)->dispose (object); @@ -543,7 +543,7 @@ int option, ecode; option = dict->editable ? ESTDBWRITER | ESTDBCREAT : ESTDBREADER; - dict->db = est_db_open (dict->database_name, option, &ecode); + dict->db = est_db_open (dict->database, option, &ecode); if (!dict->db) { g_warning ("open error: %s\n", est_err_msg (ecode)); From kous users.sourceforge.jp Tue Dec 12 19:08:12 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:08:12 +0900 Subject: [Tomoe-cvs 1888] CVS update: tomoe/test Message-ID: <20061212100812.5D4862AC0C3@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.18 tomoe/test/dict_spec.rb:1.19 --- tomoe/test/dict_spec.rb:1.18 Tue Dec 12 18:29:56 2006 +++ tomoe/test/dict_spec.rb Tue Dec 12 19:08:12 2006 @@ -20,7 +20,7 @@ `estcmd create #{est_db.dump}` `estcmd put #{est_db.dump} #{@est_draft_file.path.dump}` - dict = Tomoe::Dict::Est.new("database_name" => est_db, + dict = Tomoe::Dict::Est.new("database" => est_db, "editable" => true) a = dict[@utf8] a.writing.strokes.should == @strokes From kous users.sourceforge.jp Tue Dec 12 19:08:12 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 19:08:12 +0900 Subject: [Tomoe-cvs 1889] CVS update: tomoe/utils Message-ID: <20061212100812.878292AC547@users.sourceforge.jp> Index: tomoe/utils/xml2est.rb diff -u tomoe/utils/xml2est.rb:1.1 tomoe/utils/xml2est.rb:1.2 --- tomoe/utils/xml2est.rb:1.1 Thu Nov 30 18:15:31 2006 +++ tomoe/utils/xml2est.rb Tue Dec 12 19:08:12 2006 @@ -11,12 +11,12 @@ TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| print "converting #{dictionary}..." - est_db_name = dictionary.sub(/\.xml$/, "") + est_db = dictionary.sub(/\.xml$/, "") xml_dict = Tomoe::Dict.new("xml", "filename" => dictionary, "editable" => false) est_dict = Tomoe::Dict.new("est", - "database_name" => est_db_name, + "database" => est_db, "editable" => true) xml_dict.search(Tomoe::Query.new).each do |cand| est_dict.register(cand.char) From kous users.sourceforge.jp Tue Dec 12 22:24:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:24:29 +0900 Subject: [Tomoe-cvs 1890] CVS update: tomoe Message-ID: <20061212132429.E445D2AC562@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.439 tomoe/ChangeLog:1.440 --- tomoe/ChangeLog:1.439 Tue Dec 12 19:08:11 2006 +++ tomoe/ChangeLog Tue Dec 12 22:24:29 2006 @@ -1,5 +1,7 @@ 2006-12-12 Kouhei Sutou + * module/dict/Makefile.am: override Unihan.txt every time. + * module/dict/tomoe-dict-est.c: changed property name: "database_name" -> "database". * test/, benchmark/, utils/, lib/tomoe-config.c: followed the From kous users.sourceforge.jp Tue Dec 12 22:24:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:24:30 +0900 Subject: [Tomoe-cvs 1891] CVS update: tomoe/module/dict Message-ID: <20061212132430.2487A2AC563@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.28 tomoe/module/dict/Makefile.am:1.29 --- tomoe/module/dict/Makefile.am:1.28 Tue Dec 12 19:04:38 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 12 22:24:29 2006 @@ -91,7 +91,7 @@ Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip Unihan.stamp: $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > Unihan.zip || exit 1; - $(UNZIP) Unihan.zip || exit 1; + $(UNZIP) -o Unihan.zip || exit 1; touch $@ endif From kous users.sourceforge.jp Tue Dec 12 22:34:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:34:36 +0900 Subject: [Tomoe-cvs 1892] CVS update: tomoe Message-ID: <20061212133436.F41E42AC561@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.440 tomoe/ChangeLog:1.441 --- tomoe/ChangeLog:1.440 Tue Dec 12 22:24:29 2006 +++ tomoe/ChangeLog Tue Dec 12 22:34:36 2006 @@ -1,5 +1,8 @@ 2006-12-12 Kouhei Sutou + * lib/tomoe-context.c (ensure_user_dict_file): fixed typo. We + should use octal form not hex form. + * module/dict/Makefile.am: override Unihan.txt every time. * module/dict/tomoe-dict-est.c: changed property name: From kous users.sourceforge.jp Tue Dec 12 22:34:37 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:34:37 +0900 Subject: [Tomoe-cvs 1893] CVS update: tomoe/lib Message-ID: <20061212133437.2BDE32AC564@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.50 tomoe/lib/tomoe-context.c:1.51 --- tomoe/lib/tomoe-context.c:1.50 Wed Dec 6 15:28:36 2006 +++ tomoe/lib/tomoe-context.c Tue Dec 12 22:34:37 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.50 2006/12/06 06:28:36 kous Exp $ + * $Id: tomoe-context.c,v 1.51 2006/12/12 13:34:37 kous Exp $ */ #include @@ -213,7 +213,7 @@ tomoe_dir_name = g_build_filename (g_get_home_dir (), ".tomoe", NULL); if (!g_file_test (tomoe_dir_name, G_FILE_TEST_EXISTS)) { - if (!g_mkdir (tomoe_dir_name, 0x700)) { + if (!g_mkdir (tomoe_dir_name, 0700)) { g_warning ("can't create %s: %s", tomoe_dir_name, strerror (errno)); } } From kous users.sourceforge.jp Tue Dec 12 22:40:09 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:40:09 +0900 Subject: [Tomoe-cvs 1894] CVS update: tomoe Message-ID: <20061212134009.ABAAB2AC04F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.441 tomoe/ChangeLog:1.442 --- tomoe/ChangeLog:1.441 Tue Dec 12 22:34:36 2006 +++ tomoe/ChangeLog Tue Dec 12 22:40:09 2006 @@ -1,7 +1,8 @@ 2006-12-12 Kouhei Sutou - * lib/tomoe-context.c (ensure_user_dict_file): fixed typo. We - should use octal form not hex form. + * lib/tomoe-context.c (ensure_user_dict_file): + - fixed typo. We should use octal form not hex form. + - g_mkdir() returns 0 if success. * module/dict/Makefile.am: override Unihan.txt every time. From kous users.sourceforge.jp Tue Dec 12 22:40:09 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:40:09 +0900 Subject: [Tomoe-cvs 1895] CVS update: tomoe/lib Message-ID: <20061212134009.DB2A92AC561@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.51 tomoe/lib/tomoe-context.c:1.52 --- tomoe/lib/tomoe-context.c:1.51 Tue Dec 12 22:34:37 2006 +++ tomoe/lib/tomoe-context.c Tue Dec 12 22:40:09 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.51 2006/12/12 13:34:37 kous Exp $ + * $Id: tomoe-context.c,v 1.52 2006/12/12 13:40:09 kous Exp $ */ #include @@ -213,7 +213,7 @@ tomoe_dir_name = g_build_filename (g_get_home_dir (), ".tomoe", NULL); if (!g_file_test (tomoe_dir_name, G_FILE_TEST_EXISTS)) { - if (!g_mkdir (tomoe_dir_name, 0700)) { + if (g_mkdir (tomoe_dir_name, 0700) == -1) { g_warning ("can't create %s: %s", tomoe_dir_name, strerror (errno)); } } From kous users.sourceforge.jp Tue Dec 12 22:42:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:42:51 +0900 Subject: [Tomoe-cvs 1896] CVS update: tomoe Message-ID: <20061212134251.0548F2AC534@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.442 tomoe/ChangeLog:1.443 --- tomoe/ChangeLog:1.442 Tue Dec 12 22:40:09 2006 +++ tomoe/ChangeLog Tue Dec 12 22:42:50 2006 @@ -1,5 +1,13 @@ 2006-12-12 Kouhei Sutou + * ext/ruby/tomoe-rb-dict.c, ext/ruby/tomoe-rb-recognizer.c, + ext/ruby/tomoe-rb-module.c, ext/ruby/tomoe-rb.h: followed + Ruby-GNOME2 project's naming rules: + - Tomoe::Dict::XXX -> Tomoe::DictXXX. + - Tomoe::Recognizer::XXX -> Tomoe::RecognizerXXX. + * module/dict/unihan-compiler.rb, benchmark/, db/, test/: followed + the changes. + * lib/tomoe-context.c (ensure_user_dict_file): - fixed typo. We should use octal form not hex form. - g_mkdir() returns 0 if success. From kous users.sourceforge.jp Tue Dec 12 22:42:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:42:51 +0900 Subject: [Tomoe-cvs 1897] CVS update: tomoe/benchmark Message-ID: <20061212134251.2E8DC2AC554@users.sourceforge.jp> Index: tomoe/benchmark/load-dict.rb diff -u tomoe/benchmark/load-dict.rb:1.8 tomoe/benchmark/load-dict.rb:1.9 --- tomoe/benchmark/load-dict.rb:1.8 Tue Dec 12 18:29:55 2006 +++ tomoe/benchmark/load-dict.rb Tue Dec 12 22:42:51 2006 @@ -13,12 +13,12 @@ Benchmark.bmbm do |x| TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| x.report(File.basename(dictionary)) do - n.times {Tomoe::Dict::XML.new("filename" => dictionary, - "editable" => false)} + n.times {Tomoe::DictXML.new("filename" => dictionary, + "editable" => false)} end end x.report("Unihan") do - n.times {Tomoe::Dict::Unihan.new} + n.times {Tomoe::DictUnihan.new} end end Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.8 tomoe/benchmark/search-by-dict.rb:1.9 --- tomoe/benchmark/search-by-dict.rb:1.8 Tue Dec 12 19:08:11 2006 +++ tomoe/benchmark/search-by-dict.rb Tue Dec 12 22:42:51 2006 @@ -17,12 +17,12 @@ case dict_type when "mysql" config = TomoeSpecUtils::Config.db_config("benchmark") - dict = Tomoe::Dict::MySQL.new(config) + dict = Tomoe::DictMySQL.new(config) when "est" database = dictionary.sub(/\.xml$/, '') - dict = Tomoe::Dict::Est.new("name" => File.basename(dictionary), - "database" => database, - "editable" => false) + dict = Tomoe::DictEst.new("name" => File.basename(dictionary), + "database" => database, + "editable" => false) when "svn" repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) FileUtils.mkdir_p(repos) @@ -36,13 +36,10 @@ `svn add #{dict_file.dump}` `svn ci -m '' #{wc.dump}` - xml_dict = Tomoe::Dict::XML.new("filename" => dict_file, - "editable" => true) - dict = Tomoe::Dict::Svn.new("dictionary" => xml_dict, - "working_copy" => wc) + xml_dict = Tomoe::DictXML.new("filename" => dict_file, "editable" => true) + dict = Tomoe::DictSvn.new("dictionary" => xml_dict, "working_copy" => wc) else - dict = Tomoe::Dict::XML.new("filename" => dictionary, - "editable" => false) + dict = Tomoe::DictXML.new("filename" => dictionary, "editable" => false) end x.report("#{File.basename(dictionary)}: all") do Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.8 tomoe/benchmark/search-by-recognizer.rb:1.9 --- tomoe/benchmark/search-by-recognizer.rb:1.8 Tue Dec 12 19:08:11 2006 +++ tomoe/benchmark/search-by-recognizer.rb Tue Dec 12 22:42:51 2006 @@ -14,14 +14,12 @@ use_est = false if use_est database = File.join(data_dir, "handwriting") - dict = Tomoe::Dict::Est.new("database" => database, - "editable" => false) + dict = Tomoe::DictEst.new("database" => database, "editable" => false) else filename = File.join(data_dir, "handwriting.xml") - dict = Tomoe::Dict::XML.new("filename" => filename, - "editable" => false) + dict = Tomoe::DictXML.new("filename" => filename, "editable" => false) end -recognizer = Tomoe::Recognizer::Simple.new("dictionary" => dict) +recognizer = Tomoe::RecognizerSimple.new("dictionary" => dict) context = Tomoe::Context.new("recognizer" => recognizer) config_file = TomoeSpecUtils::Config.make_config_file context.load_config(config_file.path) From kous users.sourceforge.jp Tue Dec 12 22:42:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:42:51 +0900 Subject: [Tomoe-cvs 1898] CVS update: tomoe/db Message-ID: <20061212134251.521362AC534@users.sourceforge.jp> Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.6 tomoe/db/xml2db.rb:1.7 --- tomoe/db/xml2db.rb:1.6 Tue Dec 12 18:29:55 2006 +++ tomoe/db/xml2db.rb Tue Dec 12 22:42:51 2006 @@ -25,10 +25,10 @@ puts "done." filename = TomoeSpecUtils::Config.dictionaries.first -dict = Tomoe::Dict::XML.new("filename" => filename, - "editable" => false) +dict = Tomoe::DictXML.new("filename" => filename, + "editable" => false) config = TomoeSpecUtils::Config.db_config.merge("editable" => true) -mysql_dict = Tomoe::Dict::MySQL.new(config) +mysql_dict = Tomoe::DictMySQL.new(config) cands = dict.search(Tomoe::Query.new) puts "dict size: #{cands.size}" From kous users.sourceforge.jp Tue Dec 12 22:42:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:42:51 +0900 Subject: [Tomoe-cvs 1899] CVS update: tomoe/ext/ruby Message-ID: <20061212134251.7C4ED2AC554@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.24 tomoe/ext/ruby/tomoe-rb-dict.c:1.25 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.24 Tue Dec 12 18:55:58 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Tue Dec 12 22:42:51 2006 @@ -2,25 +2,24 @@ #define _SELF(obj) RVAL2TDIC(obj) -#define TOMOE_DICT_PREFIX "TomoeDict" -#define TOMOE_DICT_PREFIX_LEN (strlen(TOMOE_DICT_PREFIX)) +#define DICT_PREFIX "Dict" -static VALUE cTomoeDict; +static VALUE mTomoe; static VALUE td_s_load(VALUE self, VALUE base_dir) { tomoe_dict_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); - _tomoe_rb_module_load(tomoe_dict_get_registered_types(), cTomoeDict, - TOMOE_DICT_PREFIX, TOMOE_DICT_PREFIX_LEN); + _tomoe_rb_module_load(tomoe_dict_get_registered_types(), mTomoe, + DICT_PREFIX); return Qnil; } static VALUE td_s_unload(VALUE self) { - _tomoe_rb_module_unload(tomoe_dict_get_registered_types(), cTomoeDict, - TOMOE_DICT_PREFIX, TOMOE_DICT_PREFIX_LEN); + _tomoe_rb_module_unload(tomoe_dict_get_registered_types(), mTomoe, + DICT_PREFIX); tomoe_dict_unload(); return Qnil; } @@ -56,8 +55,11 @@ } void -Init_tomoe_dict(VALUE mTomoe) +Init_tomoe_dict(VALUE _mTomoe) { + VALUE cTomoeDict; + + mTomoe = _mTomoe; cTomoeDict = G_DEF_CLASS(TOMOE_TYPE_DICT, "Dict", mTomoe); rb_define_singleton_method(cTomoeDict, "load", td_s_load, 1); Index: tomoe/ext/ruby/tomoe-rb-module.c diff -u tomoe/ext/ruby/tomoe-rb-module.c:1.1 tomoe/ext/ruby/tomoe-rb-module.c:1.2 --- tomoe/ext/ruby/tomoe-rb-module.c:1.1 Tue Dec 12 18:55:58 2006 +++ tomoe/ext/ruby/tomoe-rb-module.c Tue Dec 12 22:42:51 2006 @@ -1,38 +1,50 @@ #include "tomoe-rb.h" +#define TOMOE_PREFIX "Tomoe" + void _tomoe_rb_module_load (GList *registered_types, VALUE klass, - const gchar *prefix, gint prefix_len) + const gchar *prefix) { GList *node; + gchar *full_prefix; + gint tomoe_prefix_len; + full_prefix = g_strconcat(TOMOE_PREFIX, prefix, NULL); + tomoe_prefix_len = strlen(TOMOE_PREFIX); for (node = registered_types; node; node = g_list_next (node)) { const gchar *name = node->data; GType type; type = g_type_from_name (name); - if (type && g_str_has_prefix (name, prefix)) { - G_DEF_CLASS(type, name + prefix_len, klass); + if (type && g_str_has_prefix (name, full_prefix)) { + G_DEF_CLASS(type, name + tomoe_prefix_len, klass); } } + g_free(full_prefix); g_list_free (registered_types); } void _tomoe_rb_module_unload (GList *registered_types, VALUE klass, - const gchar *prefix, gint prefix_len) + const gchar *prefix) { GList *node; + gchar *full_prefix; + gint tomoe_prefix_len; + full_prefix = g_strconcat(TOMOE_PREFIX, prefix, NULL); + tomoe_prefix_len = strlen(TOMOE_PREFIX); for (node = registered_types; node; node = g_list_next (node)) { const gchar *name = node->data; - if (g_str_has_prefix(name, prefix)) { - const gchar *klass_name = name + prefix_len; + if (g_str_has_prefix(name, full_prefix)) { + const gchar *klass_name = name + tomoe_prefix_len; if (rb_const_defined (klass, rb_intern(klass_name))) { rb_mod_remove_const (klass, rb_str_new2(klass_name)); } } } + g_free(full_prefix); g_list_free (registered_types); } Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.6 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.7 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.6 Tue Dec 12 18:55:58 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Tue Dec 12 22:42:51 2006 @@ -1,18 +1,15 @@ #include "tomoe-rb.h" -#define TOMOE_RECOGNIZER_PREFIX "TomoeRecognizer" -#define TOMOE_RECOGNIZER_PREFIX_LEN (strlen(TOMOE_RECOGNIZER_PREFIX)) +#define RECOGNIZER_PREFIX "Recognizer" -static VALUE cTomoeRecognizer; +static VALUE mTomoe; static VALUE tr_s_load(VALUE self, VALUE base_dir) { tomoe_recognizer_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); _tomoe_rb_module_load(tomoe_recognizer_get_registered_types(), - cTomoeRecognizer, - TOMOE_RECOGNIZER_PREFIX, - TOMOE_RECOGNIZER_PREFIX_LEN); + mTomoe, RECOGNIZER_PREFIX); return Qnil; } @@ -20,16 +17,17 @@ tr_s_unload(VALUE self) { _tomoe_rb_module_unload(tomoe_recognizer_get_registered_types(), - cTomoeRecognizer, - TOMOE_RECOGNIZER_PREFIX, - TOMOE_RECOGNIZER_PREFIX_LEN); + mTomoe, RECOGNIZER_PREFIX); tomoe_recognizer_unload(); return Qnil; } void -Init_tomoe_recognizer(VALUE mTomoe) +Init_tomoe_recognizer(VALUE _mTomoe) { + VALUE cTomoeRecognizer; + + mTomoe = _mTomoe; cTomoeRecognizer = G_DEF_CLASS(TOMOE_TYPE_RECOGNIZER, "Recognizer", mTomoe); rb_define_singleton_method(cTomoeRecognizer, "load", tr_s_load, 1); Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.11 tomoe/ext/ruby/tomoe-rb.h:1.12 --- tomoe/ext/ruby/tomoe-rb.h:1.11 Tue Dec 12 18:55:58 2006 +++ tomoe/ext/ruby/tomoe-rb.h Tue Dec 12 22:42:51 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.11 2006/12/12 09:55:58 kous Exp $ + * $Id: tomoe-rb.h,v 1.12 2006/12/12 13:42:51 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -52,9 +52,9 @@ void Init_tomoe_writing(VALUE mTomoe); void _tomoe_rb_module_load (GList *registered_types, VALUE klass, - const gchar *prefix, gint prefix_len); + const gchar *prefix); void _tomoe_rb_module_unload (GList *registered_types, VALUE klass, - const gchar *prefix, gint prefix_len); + const gchar *prefix); G_END_DECLS From kous users.sourceforge.jp Tue Dec 12 22:42:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:42:51 +0900 Subject: [Tomoe-cvs 1900] CVS update: tomoe/module/dict Message-ID: <20061212134251.9F7C32AC534@users.sourceforge.jp> Index: tomoe/module/dict/unihan-compiler.rb diff -u tomoe/module/dict/unihan-compiler.rb:1.9 tomoe/module/dict/unihan-compiler.rb:1.10 --- tomoe/module/dict/unihan-compiler.rb:1.9 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/unihan-compiler.rb Tue Dec 12 22:42:51 2006 @@ -105,8 +105,7 @@ end def merge_kanjidic2_xml(kanjidic2_xml, infos) - dict = Tomoe::Dict::XML.new("filename" => kanjidic2_xml, - "editable" => false) + dict = Tomoe::DictXML.new("filename" => kanjidic2_xml, "editable" => false) dict.search(Tomoe::Query.new).each do |cand| char = cand.char ucs4 = utf8_to_ucs4(char.utf8) From kous users.sourceforge.jp Tue Dec 12 22:42:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:42:51 +0900 Subject: [Tomoe-cvs 1901] CVS update: tomoe/test Message-ID: <20061212134251.C3C7B2AC554@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.27 tomoe/test/context_spec.rb:1.28 --- tomoe/test/context_spec.rb:1.27 Tue Dec 12 18:55:59 2006 +++ tomoe/test/context_spec.rb Tue Dec 12 22:42:51 2006 @@ -8,8 +8,8 @@ "filename" => File.join(data_dir, "handwriting.xml"), "editable" => false, } - dict = Tomoe::Dict::XML.new(config) - recognizer = Tomoe::Recognizer::Simple.new("dictionary" => dict) + dict = Tomoe::DictXML.new(config) + recognizer = Tomoe::RecognizerSimple.new("dictionary" => dict) @@context = Tomoe::Context.new("recognizer" => recognizer) @@context.load_config(@config_file.path) @@context Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.19 tomoe/test/dict_spec.rb:1.20 --- tomoe/test/dict_spec.rb:1.19 Tue Dec 12 19:08:12 2006 +++ tomoe/test/dict_spec.rb Tue Dec 12 22:42:51 2006 @@ -7,8 +7,7 @@ end specify "should load XML dictionary" do - dict = Tomoe::Dict::XML.new("filename" => @dict_file.path, - "editable" => true) + dict = Tomoe::DictXML.new("filename" => @dict_file.path, "editable" => true) a = dict[@utf8] a.writing.strokes.should == @strokes end @@ -20,8 +19,7 @@ `estcmd create #{est_db.dump}` `estcmd put #{est_db.dump} #{@est_draft_file.path.dump}` - dict = Tomoe::Dict::Est.new("database" => est_db, - "editable" => true) + dict = Tomoe::DictEst.new("database" => est_db, "editable" => true) a = dict[@utf8] a.writing.strokes.should == @strokes ensure @@ -45,10 +43,8 @@ `svn ci -m '' #{wc.dump}` `svnlook youngest #{repos.dump}`.chomp.should == "1" - xml_dict = Tomoe::Dict::XML.new("filename" => dict_file, - "editable" => true) - dict = Tomoe::Dict::Svn.new("dictionary" => xml_dict, - "working_copy" => wc) + xml_dict = Tomoe::DictXML.new("filename" => dict_file, "editable" => true) + dict = Tomoe::DictSvn.new("dictionary" => xml_dict, "working_copy" => wc) a = dict[@utf8] a.writing.strokes.should == @strokes @@ -64,7 +60,7 @@ end specify "should register/unregister to MySQL database" do - dict = Tomoe::Dict::MySQL.new(db_config) + dict = Tomoe::DictMySQL.new(db_config) char = Tomoe::Char.new char.utf8 = "?? dict.register(char).should == true @@ -76,7 +72,7 @@ end specify "should register/unregister PUA character to MySQL database" do - dict = Tomoe::Dict::MySQL.new(db_config) + dict = Tomoe::DictMySQL.new(db_config) char = Tomoe::Char.new dict.register(char).should == true dict.search(Tomoe::Query.new).size.should == 1 From kous users.sourceforge.jp Tue Dec 12 22:45:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:45:33 +0900 Subject: [Tomoe-cvs 1902] CVS update: tomoe Message-ID: <20061212134533.1AE122AC55C@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.443 tomoe/ChangeLog:1.444 --- tomoe/ChangeLog:1.443 Tue Dec 12 22:42:50 2006 +++ tomoe/ChangeLog Tue Dec 12 22:45:32 2006 @@ -1,5 +1,7 @@ 2006-12-12 Kouhei Sutou + * ext/ruby/: hid internal Init_* functions. + * ext/ruby/tomoe-rb-dict.c, ext/ruby/tomoe-rb-recognizer.c, ext/ruby/tomoe-rb-module.c, ext/ruby/tomoe-rb.h: followed Ruby-GNOME2 project's naming rules: From kous users.sourceforge.jp Tue Dec 12 22:45:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 12 Dec 2006 22:45:33 +0900 Subject: [Tomoe-cvs 1903] CVS update: tomoe/ext/ruby Message-ID: <20061212134533.54DF52AC554@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-candidate.c diff -u tomoe/ext/ruby/tomoe-rb-candidate.c:1.2 tomoe/ext/ruby/tomoe-rb-candidate.c:1.3 --- tomoe/ext/ruby/tomoe-rb-candidate.c:1.2 Tue Nov 21 17:20:55 2006 +++ tomoe/ext/ruby/tomoe-rb-candidate.c Tue Dec 12 22:45:33 2006 @@ -3,7 +3,7 @@ #define _SELF(obj) (TOMOE_CANDIDATE(RVAL2GOBJ(obj))) void -Init_tomoe_candidate(VALUE mTomoe) +_tomoe_rb_init_tomoe_candidate(VALUE mTomoe) { VALUE cTomoeCandidate; Index: tomoe/ext/ruby/tomoe-rb-char.c diff -u tomoe/ext/ruby/tomoe-rb-char.c:1.12 tomoe/ext/ruby/tomoe-rb-char.c:1.13 --- tomoe/ext/ruby/tomoe-rb-char.c:1.12 Wed Dec 6 18:00:59 2006 +++ tomoe/ext/ruby/tomoe-rb-char.c Tue Dec 12 22:45:33 2006 @@ -95,7 +95,7 @@ } void -Init_tomoe_char(VALUE mTomoe) +_tomoe_rb_init_tomoe_char(VALUE mTomoe) { VALUE cTomoeChar; Index: tomoe/ext/ruby/tomoe-rb-config.c diff -u tomoe/ext/ruby/tomoe-rb-config.c:1.1 tomoe/ext/ruby/tomoe-rb-config.c:1.2 --- tomoe/ext/ruby/tomoe-rb-config.c:1.1 Mon Nov 20 15:47:09 2006 +++ tomoe/ext/ruby/tomoe-rb-config.c Tue Dec 12 22:45:33 2006 @@ -1,7 +1,7 @@ #include "tomoe-rb.h" void -Init_tomoe_config(VALUE mTomoe) +_tomoe_rb_init_tomoe_config(VALUE mTomoe) { VALUE cTomoeConfig; Index: tomoe/ext/ruby/tomoe-rb-context.c diff -u tomoe/ext/ruby/tomoe-rb-context.c:1.14 tomoe/ext/ruby/tomoe-rb-context.c:1.15 --- tomoe/ext/ruby/tomoe-rb-context.c:1.14 Wed Dec 6 15:28:36 2006 +++ tomoe/ext/ruby/tomoe-rb-context.c Tue Dec 12 22:45:33 2006 @@ -48,7 +48,7 @@ } void -Init_tomoe_context(VALUE mTomoe) +_tomoe_rb_init_tomoe_context(VALUE mTomoe) { VALUE cTomoeContext; Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.25 tomoe/ext/ruby/tomoe-rb-dict.c:1.26 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.25 Tue Dec 12 22:42:51 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Tue Dec 12 22:45:33 2006 @@ -55,7 +55,7 @@ } void -Init_tomoe_dict(VALUE _mTomoe) +_tomoe_rb_init_tomoe_dict(VALUE _mTomoe) { VALUE cTomoeDict; Index: tomoe/ext/ruby/tomoe-rb-query.c diff -u tomoe/ext/ruby/tomoe-rb-query.c:1.2 tomoe/ext/ruby/tomoe-rb-query.c:1.3 --- tomoe/ext/ruby/tomoe-rb-query.c:1.2 Fri Dec 1 13:47:26 2006 +++ tomoe/ext/ruby/tomoe-rb-query.c Tue Dec 12 22:45:33 2006 @@ -19,7 +19,7 @@ } void -Init_tomoe_query(VALUE mTomoe) +_tomoe_rb_init_tomoe_query(VALUE mTomoe) { VALUE cTomoeQuery; Index: tomoe/ext/ruby/tomoe-rb-reading.c diff -u tomoe/ext/ruby/tomoe-rb-reading.c:1.4 tomoe/ext/ruby/tomoe-rb-reading.c:1.5 --- tomoe/ext/ruby/tomoe-rb-reading.c:1.4 Fri Dec 8 12:29:49 2006 +++ tomoe/ext/ruby/tomoe-rb-reading.c Tue Dec 12 22:45:33 2006 @@ -27,7 +27,7 @@ } void -Init_tomoe_reading(VALUE mTomoe) +_tomoe_rb_init_tomoe_reading(VALUE mTomoe) { VALUE cTomoeReading; Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.7 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.8 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.7 Tue Dec 12 22:42:51 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Tue Dec 12 22:45:33 2006 @@ -23,7 +23,7 @@ } void -Init_tomoe_recognizer(VALUE _mTomoe) +_tomoe_rb_init_tomoe_recognizer(VALUE _mTomoe) { VALUE cTomoeRecognizer; Index: tomoe/ext/ruby/tomoe-rb-writing.c diff -u tomoe/ext/ruby/tomoe-rb-writing.c:1.7 tomoe/ext/ruby/tomoe-rb-writing.c:1.8 --- tomoe/ext/ruby/tomoe-rb-writing.c:1.7 Mon Nov 27 18:11:09 2006 +++ tomoe/ext/ruby/tomoe-rb-writing.c Tue Dec 12 22:45:33 2006 @@ -96,7 +96,7 @@ } void -Init_tomoe_writing(VALUE mTomoe) +_tomoe_rb_init_tomoe_writing(VALUE mTomoe) { VALUE cTomoeWriting; Index: tomoe/ext/ruby/tomoe-rb.c diff -u tomoe/ext/ruby/tomoe-rb.c:1.5 tomoe/ext/ruby/tomoe-rb.c:1.6 --- tomoe/ext/ruby/tomoe-rb.c:1.5 Wed Dec 6 15:28:36 2006 +++ tomoe/ext/ruby/tomoe-rb.c Tue Dec 12 22:45:33 2006 @@ -23,13 +23,13 @@ mTomoe = rb_define_module("Tomoe"); - Init_tomoe_candidate(mTomoe); - Init_tomoe_char(mTomoe); - Init_tomoe_config(mTomoe); - Init_tomoe_context(mTomoe); - Init_tomoe_dict(mTomoe); - Init_tomoe_query(mTomoe); - Init_tomoe_reading(mTomoe); - Init_tomoe_recognizer(mTomoe); - Init_tomoe_writing(mTomoe); + _tomoe_rb_init_tomoe_candidate(mTomoe); + _tomoe_rb_init_tomoe_char(mTomoe); + _tomoe_rb_init_tomoe_config(mTomoe); + _tomoe_rb_init_tomoe_context(mTomoe); + _tomoe_rb_init_tomoe_dict(mTomoe); + _tomoe_rb_init_tomoe_query(mTomoe); + _tomoe_rb_init_tomoe_reading(mTomoe); + _tomoe_rb_init_tomoe_recognizer(mTomoe); + _tomoe_rb_init_tomoe_writing(mTomoe); } Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.12 tomoe/ext/ruby/tomoe-rb.h:1.13 --- tomoe/ext/ruby/tomoe-rb.h:1.12 Tue Dec 12 22:42:51 2006 +++ tomoe/ext/ruby/tomoe-rb.h Tue Dec 12 22:45:33 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.12 2006/12/12 13:42:51 kous Exp $ + * $Id: tomoe-rb.h,v 1.13 2006/12/12 13:45:33 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -41,15 +41,17 @@ #endif void Init_tomoe(void); -void Init_tomoe_candidate(VALUE mTomoe); -void Init_tomoe_char(VALUE mTomoe); -void Init_tomoe_config(VALUE mTomoe); -void Init_tomoe_context(VALUE mTomoe); -void Init_tomoe_dict(VALUE mTomoe); -void Init_tomoe_query(VALUE mTomoe); -void Init_tomoe_reading(VALUE mTomoe); -void Init_tomoe_recognizer(VALUE mTomoe); -void Init_tomoe_writing(VALUE mTomoe); + +void _tomoe_rb_init_tomoe_candidate(VALUE mTomoe); +void _tomoe_rb_init_tomoe_char(VALUE mTomoe); +void _tomoe_rb_init_tomoe_config(VALUE mTomoe); +void _tomoe_rb_init_tomoe_context(VALUE mTomoe); +void _tomoe_rb_init_tomoe_dict(VALUE mTomoe); +void _tomoe_rb_init_tomoe_query(VALUE mTomoe); +void _tomoe_rb_init_tomoe_reading(VALUE mTomoe); +void _tomoe_rb_init_tomoe_recognizer(VALUE mTomoe); +void _tomoe_rb_init_tomoe_writing(VALUE mTomoe); + void _tomoe_rb_module_load (GList *registered_types, VALUE klass, const gchar *prefix); From kous users.sourceforge.jp Thu Dec 14 17:34:39 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:34:39 +0900 Subject: [Tomoe-cvs 1904] CVS update: tomoe Message-ID: <20061214083439.B750C2AC0D2@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.444 tomoe/ChangeLog:1.445 --- tomoe/ChangeLog:1.444 Tue Dec 12 22:45:32 2006 +++ tomoe/ChangeLog Thu Dec 14 17:34:39 2006 @@ -1,3 +1,10 @@ +2006-12-14 Kouhei Sutou + + * lib/tomoe-dict.c: check TOMOE_DICT_MODULE_DIR + environemnet variable as default dictionary module directory. + * lib/tomoe-recognizer.c: check TOMOE_RECOGNIZER_MODULE_DIR + environemnet variable as default recognizer module directory. + 2006-12-12 Kouhei Sutou * ext/ruby/: hid internal Init_* functions. From kous users.sourceforge.jp Thu Dec 14 17:34:39 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:34:39 +0900 Subject: [Tomoe-cvs 1905] CVS update: tomoe/lib Message-ID: <20061214083439.E10F72AC173@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.133 tomoe/lib/tomoe-dict.c:1.134 --- tomoe/lib/tomoe-dict.c:1.133 Tue Dec 12 18:29:55 2006 +++ tomoe/lib/tomoe-dict.c Thu Dec 14 17:34:39 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.133 2006/12/12 09:29:55 kous Exp $ + * $Id: tomoe-dict.c,v 1.134 2006/12/14 08:34:39 kous Exp $ */ #include "tomoe-dict.h" @@ -29,6 +29,8 @@ tomoe_dict_load (const gchar *base_dir) { if (!base_dir) + base_dir = g_getenv ("TOMOE_DICT_MODULE_DIR"); + if (!base_dir) base_dir = DICT_MODULEDIR; dicts = g_list_concat (tomoe_module_load_modules (base_dir), dicts); Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.24 tomoe/lib/tomoe-recognizer.c:1.25 --- tomoe/lib/tomoe-recognizer.c:1.24 Tue Dec 12 18:55:59 2006 +++ tomoe/lib/tomoe-recognizer.c Thu Dec 14 17:34:39 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.24 2006/12/12 09:55:59 kous Exp $ + * $Id: tomoe-recognizer.c,v 1.25 2006/12/14 08:34:39 kous Exp $ */ #include @@ -32,6 +32,8 @@ tomoe_recognizer_load (const gchar *base_dir) { if (!base_dir) + base_dir = g_getenv ("TOMOE_RECOGNIZER_MODULE_DIR"); + if (!base_dir) base_dir = RECOGNIZER_MODULEDIR; recognizers = g_list_concat (tomoe_module_load_modules (base_dir), From kous users.sourceforge.jp Thu Dec 14 17:46:21 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:46:21 +0900 Subject: [Tomoe-cvs 1906] CVS update: tomoe Message-ID: <20061214084621.BBE972AC13C@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.445 tomoe/ChangeLog:1.446 --- tomoe/ChangeLog:1.445 Thu Dec 14 17:34:39 2006 +++ tomoe/ChangeLog Thu Dec 14 17:46:21 2006 @@ -1,5 +1,13 @@ 2006-12-14 Kouhei Sutou + * ext/ruby/tomoe-rb.c: defined dynamic loaded types in tomoe.so. + * ext/ruby/tomoe-rb-dict.c, ext/ruby/tomoe-rb-recognizer.c, + ext/ruby/tomoe-rb.h: exported function which defines classes from + load types. + + * test/tomoe-spec-utils.rb: used environment variables to specify + module directory. + * lib/tomoe-dict.c: check TOMOE_DICT_MODULE_DIR environemnet variable as default dictionary module directory. * lib/tomoe-recognizer.c: check TOMOE_RECOGNIZER_MODULE_DIR From kous users.sourceforge.jp Thu Dec 14 17:46:21 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:46:21 +0900 Subject: [Tomoe-cvs 1907] CVS update: tomoe/ext/ruby Message-ID: <20061214084621.E49C32AC175@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.26 tomoe/ext/ruby/tomoe-rb-dict.c:1.27 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.26 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Thu Dec 14 17:46:21 2006 @@ -6,20 +6,32 @@ static VALUE mTomoe; +void +_tomoe_rb_dict_module_load(void) +{ + _tomoe_rb_module_load(tomoe_dict_get_registered_types(), mTomoe, + DICT_PREFIX); +} + +static void +_tomoe_rb_dict_module_unload(void) +{ + _tomoe_rb_module_unload(tomoe_dict_get_registered_types(), mTomoe, + DICT_PREFIX); +} + static VALUE td_s_load(VALUE self, VALUE base_dir) { tomoe_dict_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); - _tomoe_rb_module_load(tomoe_dict_get_registered_types(), mTomoe, - DICT_PREFIX); + _tomoe_rb_dict_module_load(); return Qnil; } static VALUE td_s_unload(VALUE self) { - _tomoe_rb_module_unload(tomoe_dict_get_registered_types(), mTomoe, - DICT_PREFIX); + _tomoe_rb_dict_module_unload(); tomoe_dict_unload(); return Qnil; } Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.8 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.9 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.8 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Thu Dec 14 17:46:21 2006 @@ -4,20 +4,32 @@ static VALUE mTomoe; +void +_tomoe_rb_recognizer_module_load(void) +{ + _tomoe_rb_module_load(tomoe_recognizer_get_registered_types(), + mTomoe, RECOGNIZER_PREFIX); +} + +static void +_tomoe_rb_recognizer_module_unload(void) +{ + _tomoe_rb_module_unload(tomoe_recognizer_get_registered_types(), + mTomoe, RECOGNIZER_PREFIX); +} + static VALUE tr_s_load(VALUE self, VALUE base_dir) { tomoe_recognizer_load(NIL_P(base_dir) ? NULL : RVAL2CSTR(base_dir)); - _tomoe_rb_module_load(tomoe_recognizer_get_registered_types(), - mTomoe, RECOGNIZER_PREFIX); + _tomoe_rb_recognizer_module_load(); return Qnil; } static VALUE tr_s_unload(VALUE self) { - _tomoe_rb_module_unload(tomoe_recognizer_get_registered_types(), - mTomoe, RECOGNIZER_PREFIX); + _tomoe_rb_recognizer_module_unload(); tomoe_recognizer_unload(); return Qnil; } Index: tomoe/ext/ruby/tomoe-rb.c diff -u tomoe/ext/ruby/tomoe-rb.c:1.6 tomoe/ext/ruby/tomoe-rb.c:1.7 --- tomoe/ext/ruby/tomoe-rb.c:1.6 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb.c Thu Dec 14 17:46:21 2006 @@ -18,9 +18,6 @@ { VALUE mTomoe; - tomoe_init(); - atexit(tomoe_quit); - mTomoe = rb_define_module("Tomoe"); _tomoe_rb_init_tomoe_candidate(mTomoe); @@ -32,4 +29,11 @@ _tomoe_rb_init_tomoe_reading(mTomoe); _tomoe_rb_init_tomoe_recognizer(mTomoe); _tomoe_rb_init_tomoe_writing(mTomoe); + + + tomoe_init(); + atexit(tomoe_quit); + + _tomoe_rb_dict_module_load(); + _tomoe_rb_recognizer_module_load(); } Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.13 tomoe/ext/ruby/tomoe-rb.h:1.14 --- tomoe/ext/ruby/tomoe-rb.h:1.13 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb.h Thu Dec 14 17:46:21 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.13 2006/12/12 13:45:33 kous Exp $ + * $Id: tomoe-rb.h,v 1.14 2006/12/14 08:46:21 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -58,6 +58,9 @@ void _tomoe_rb_module_unload (GList *registered_types, VALUE klass, const gchar *prefix); +void _tomoe_rb_dict_module_load(void); +void _tomoe_rb_recognizer_module_load(void); + G_END_DECLS #endif /* __TOMOE_RB_H__ */ From kous users.sourceforge.jp Thu Dec 14 17:46:22 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:46:22 +0900 Subject: [Tomoe-cvs 1908] CVS update: tomoe/lib Message-ID: <20061214084622.17FA32AC13C@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.134 tomoe/lib/tomoe-dict.c:1.135 --- tomoe/lib/tomoe-dict.c:1.134 Thu Dec 14 17:34:39 2006 +++ tomoe/lib/tomoe-dict.c Thu Dec 14 17:46:21 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.134 2006/12/14 08:34:39 kous Exp $ + * $Id: tomoe-dict.c,v 1.135 2006/12/14 08:46:21 kous Exp $ */ #include "tomoe-dict.h" @@ -39,7 +39,7 @@ void tomoe_dict_unload (void) { - g_list_foreach (dicts, (GFunc) g_object_unref, NULL); + g_list_foreach (dicts, (GFunc) tomoe_module_unload, NULL); g_list_free (dicts); dicts = NULL; } Index: tomoe/lib/tomoe-module.c diff -u tomoe/lib/tomoe-module.c:1.7 tomoe/lib/tomoe-module.c:1.8 --- tomoe/lib/tomoe-module.c:1.7 Tue Dec 12 18:29:56 2006 +++ tomoe/lib/tomoe-module.c Thu Dec 14 17:46:21 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.c,v 1.7 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-module.c,v 1.8 2006/12/14 08:46:21 kous Exp $ */ #include @@ -312,6 +312,21 @@ return matched; } +void +tomoe_module_unload (TomoeModule *module) +{ + GTypeModule *type_module; + + g_return_if_fail (TOMOE_IS_MODULE (module)); + + type_module = G_TYPE_MODULE (type_module); + + if (type_module->type_infos || type_module->interface_infos) + return; + + g_object_unref (module); +} + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/lib/tomoe-module.h diff -u tomoe/lib/tomoe-module.h:1.6 tomoe/lib/tomoe-module.h:1.7 --- tomoe/lib/tomoe-module.h:1.6 Tue Dec 12 18:29:56 2006 +++ tomoe/lib/tomoe-module.h Thu Dec 14 17:46:21 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.h,v 1.6 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-module.h,v 1.7 2006/12/14 08:46:21 kous Exp $ */ #ifndef __TOMOE_MODULE_H__ @@ -59,6 +59,8 @@ GList *tomoe_module_collect_registered_types (GList *modules); +void tomoe_module_unload (TomoeModule *module); + G_END_DECLS #endif /* __TOMOE_MODULE_H__ */ Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.25 tomoe/lib/tomoe-recognizer.c:1.26 --- tomoe/lib/tomoe-recognizer.c:1.25 Thu Dec 14 17:34:39 2006 +++ tomoe/lib/tomoe-recognizer.c Thu Dec 14 17:46:21 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.25 2006/12/14 08:34:39 kous Exp $ + * $Id: tomoe-recognizer.c,v 1.26 2006/12/14 08:46:21 kous Exp $ */ #include @@ -43,7 +43,7 @@ void tomoe_recognizer_unload (void) { - g_list_foreach (recognizers, (GFunc) g_object_unref, NULL); + g_list_foreach (recognizers, (GFunc) tomoe_module_unload, NULL); g_list_free (recognizers); recognizers = NULL; } From kous users.sourceforge.jp Thu Dec 14 17:46:22 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:46:22 +0900 Subject: [Tomoe-cvs 1909] CVS update: tomoe/test Message-ID: <20061214084622.3BDA22AC175@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.26 tomoe/test/tomoe-spec-utils.rb:1.27 --- tomoe/test/tomoe-spec-utils.rb:1.26 Tue Dec 12 18:29:56 2006 +++ tomoe/test/tomoe-spec-utils.rb Thu Dec 14 17:46:22 2006 @@ -3,8 +3,6 @@ require 'yaml' require 'uconv' -require 'tomoe' - $KCODE = "u" module TomoeSpecSetup @@ -217,7 +215,7 @@ end end -Tomoe::Dict.unload -Tomoe::Dict.load(TomoeSpecUtils::Config.dict_dir) -Tomoe::Recognizer.unload -Tomoe::Recognizer.load(TomoeSpecUtils::Config.recognizer_dir) +ENV["TOMOE_DICT_MODULE_DIR"] ||= TomoeSpecUtils::Config.dict_dir +ENV["TOMOE_RECOGNIZER_MODULE_DIR"] ||= TomoeSpecUtils::Config.recognizer_dir + +require 'tomoe' From kous users.sourceforge.jp Thu Dec 14 17:52:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:52:57 +0900 Subject: [Tomoe-cvs 1910] CVS update: tomoe Message-ID: <20061214085257.B36312AC0D2@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.446 tomoe/ChangeLog:1.447 --- tomoe/ChangeLog:1.446 Thu Dec 14 17:46:21 2006 +++ tomoe/ChangeLog Thu Dec 14 17:52:57 2006 @@ -1,5 +1,7 @@ 2006-12-14 Kouhei Sutou + * lib/tomoe-module.c (tomoe_module_unload): fixed a typo. + * ext/ruby/tomoe-rb.c: defined dynamic loaded types in tomoe.so. * ext/ruby/tomoe-rb-dict.c, ext/ruby/tomoe-rb-recognizer.c, ext/ruby/tomoe-rb.h: exported function which defines classes from From kous users.sourceforge.jp Thu Dec 14 17:52:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 14 Dec 2006 17:52:57 +0900 Subject: [Tomoe-cvs 1911] CVS update: tomoe/lib Message-ID: <20061214085257.E144F2AC13C@users.sourceforge.jp> Index: tomoe/lib/tomoe-module.c diff -u tomoe/lib/tomoe-module.c:1.8 tomoe/lib/tomoe-module.c:1.9 --- tomoe/lib/tomoe-module.c:1.8 Thu Dec 14 17:46:21 2006 +++ tomoe/lib/tomoe-module.c Thu Dec 14 17:52:57 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.c,v 1.8 2006/12/14 08:46:21 kous Exp $ + * $Id: tomoe-module.c,v 1.9 2006/12/14 08:52:57 kous Exp $ */ #include @@ -319,7 +319,7 @@ g_return_if_fail (TOMOE_IS_MODULE (module)); - type_module = G_TYPE_MODULE (type_module); + type_module = G_TYPE_MODULE (module); if (type_module->type_infos || type_module->interface_infos) return; Index: tomoe/lib/tomoe.c diff -u tomoe/lib/tomoe.c:1.49 tomoe/lib/tomoe.c:1.50 --- tomoe/lib/tomoe.c:1.49 Fri Dec 1 10:40:38 2006 +++ tomoe/lib/tomoe.c Thu Dec 14 17:52:57 2006 @@ -20,7 +20,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe.c,v 1.49 2006/12/01 01:40:38 ikezoe Exp $ + * $Id: tomoe.c,v 1.50 2006/12/14 08:52:57 kous Exp $ */ #include @@ -60,6 +60,8 @@ { if (initialized) { initialized = FALSE; + tomoe_dict_unload (); + tomoe_recognizer_unload (); } } From kous users.sourceforge.jp Fri Dec 15 11:14:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 11:14:36 +0900 Subject: [Tomoe-cvs 1912] CVS update: tomoe/module/dict Message-ID: <20061215021436.7DD682AC19C@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.6 tomoe/module/dict/tomoe-dict-unihan.c:1.7 --- tomoe/module/dict/tomoe-dict-unihan.c:1.6 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Fri Dec 15 11:14:36 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.6 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict-unihan.c,v 1.7 2006/12/15 02:14:36 kous Exp $ */ #include @@ -66,11 +66,13 @@ static GType tomoe_type_dict_unihan = 0; static GObjectClass *parent_class; static GPtrArray *chars = NULL; +static guint chars_ref_count = 0; static GObject *constructor (GType type, guint n_props, GObjectConstructParam *props); static void dispose (GObject *object); +static void finalize (GObject *object); static void set_property (GObject *object, guint prop_id, const GValue *value, @@ -100,6 +102,7 @@ gobject_class->constructor = constructor; gobject_class->dispose = dispose; + gobject_class->finalize = finalize; gobject_class->set_property = set_property; gobject_class->get_property = get_property; @@ -161,19 +164,12 @@ g_list_prepend (registered_types, (gchar *) g_type_name (tomoe_type_dict_unihan)); - if (!chars) - chars = _tomoe_unihan_create (); - return registered_types; } G_MODULE_EXPORT void TOMOE_MODULE_IMPL_EXIT (void) { - if (chars) { - TOMOE_PTR_ARRAY_FREE_ALL (chars, g_object_unref); - chars = NULL; - } } G_MODULE_EXPORT GObject * @@ -191,6 +187,12 @@ object = klass->constructor (type, n_props, props); + chars_ref_count++; + if (chars_ref_count == 1) { + g_assert (chars == NULL); + chars = _tomoe_unihan_create (); + } + return object; } @@ -247,6 +249,19 @@ G_OBJECT_CLASS (parent_class)->dispose (object); } +static void +finalize (GObject *object) +{ + chars_ref_count--; + if (chars_ref_count == 0) { + g_assert (chars != NULL); + TOMOE_PTR_ARRAY_FREE_ALL (chars, g_object_unref); + chars = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + static const gchar* get_name (TomoeDict *_dict) { From kous users.sourceforge.jp Fri Dec 15 11:14:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 11:14:36 +0900 Subject: [Tomoe-cvs 1913] CVS update: tomoe Message-ID: <20061215021436.A4BF82AC239@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.447 tomoe/ChangeLog:1.448 --- tomoe/ChangeLog:1.447 Thu Dec 14 17:52:57 2006 +++ tomoe/ChangeLog Fri Dec 15 11:14:36 2006 @@ -1,3 +1,7 @@ +2006-12-15 Kouhei Sutou + + * module/dict/tomoe-dict-unihan.c: load chars on demand. + 2006-12-14 Kouhei Sutou * lib/tomoe-module.c (tomoe_module_unload): fixed a typo. From kous users.sourceforge.jp Fri Dec 15 12:19:44 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:19:44 +0900 Subject: [Tomoe-cvs 1914] CVS update: tomoe Message-ID: <20061215031944.ADEA52AC154@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.448 tomoe/ChangeLog:1.449 --- tomoe/ChangeLog:1.448 Fri Dec 15 11:14:36 2006 +++ tomoe/ChangeLog Fri Dec 15 12:19:44 2006 @@ -1,5 +1,12 @@ 2006-12-15 Kouhei Sutou + * test/tomoe-spec-utils.rb: + - test target dictionary can be specified by TOMOE_DICT_MODULE + environment variable. + - split path related methods to Path from Config. + * test/context_spec.rb, test/dict_spec.rb: followed the changes. + * db/config.yml.example: supported temporary database. + * module/dict/tomoe-dict-unihan.c: load chars on demand. 2006-12-14 Kouhei Sutou From kous users.sourceforge.jp Fri Dec 15 12:19:44 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:19:44 +0900 Subject: [Tomoe-cvs 1915] CVS update: tomoe/db Message-ID: <20061215031944.D0F4E2AC16E@users.sourceforge.jp> Index: tomoe/db/config.yml.example diff -u tomoe/db/config.yml.example:1.3 tomoe/db/config.yml.example:1.4 --- tomoe/db/config.yml.example:1.3 Mon Dec 11 14:40:37 2006 +++ tomoe/db/config.yml.example Fri Dec 15 12:19:44 2006 @@ -8,6 +8,16 @@ encoding: utf8 editable: true +temp: + adapter: mysql + database: tomoe-temp + username: root + password: + host: localhost + socket: /var/run/mysqld/mysqld.sock + encoding: utf8 + editable: true + benchmark: adapter: mysql database: tomoe-benchmark From kous users.sourceforge.jp Fri Dec 15 12:19:45 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:19:45 +0900 Subject: [Tomoe-cvs 1916] CVS update: tomoe/test Message-ID: <20061215031945.03F2D2AC575@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.28 tomoe/test/context_spec.rb:1.29 --- tomoe/test/context_spec.rb:1.28 Tue Dec 12 22:42:51 2006 +++ tomoe/test/context_spec.rb Fri Dec 15 12:19:44 2006 @@ -44,7 +44,7 @@ @user_dict_config_file.close end - TomoeSpecUtils::Config.test_data_files.each do |file| + TomoeSpecUtils::Path.test_data_files.each do |file| base = File.basename(file) specify "Search by strokes for #{base}" do expected, writing = TomoeSpecUtils::TestData.parse(file) Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.20 tomoe/test/dict_spec.rb:1.21 --- tomoe/test/dict_spec.rb:1.20 Tue Dec 12 22:42:51 2006 +++ tomoe/test/dict_spec.rb Fri Dec 15 12:19:44 2006 @@ -1,84 +1,57 @@ require 'tomoe-spec-utils' -context "Tomoe::Dict" do - setup do - setup_dict_file - setup_est_draft_file +dict_module_type = TomoeSpecUtils::Config.dict_module_type +context "Tomoe::Dict (#{dict_module_type})" do + read_only_dictionaries = %w(unihan) + if read_only_dictionaries.include?(dict_module_type) + puts "#{dict_module_type} is read-only dictionary. skip tests." + break end - specify "should load XML dictionary" do - dict = Tomoe::DictXML.new("filename" => @dict_file.path, "editable" => true) - a = dict[@utf8] - a.writing.strokes.should == @strokes + setup do + setup_dict_file + @original = Tomoe::DictXML.new("filename" => @dict_file.path) end - specify "should make Hyper Estraier dictionary" do - begin - est_db = File.join(tmp_dir, "est") - - `estcmd create #{est_db.dump}` - `estcmd put #{est_db.dump} #{@est_draft_file.path.dump}` - - dict = Tomoe::DictEst.new("database" => est_db, "editable" => true) + specify "should load" do + make_temporary_dict(@original) do |dict| a = dict[@utf8] a.writing.strokes.should == @strokes - ensure - FileUtils.rm_rf(est_db) end end - specify "should load Subverion dictionary" do - begin - repos = File.join(tmp_dir, "svn.repos") - repos_url = "file://#{repos}" - wc = File.join(tmp_dir, "svn.wc") - dict_file = File.join(wc, "dict.xml") - - `svnadmin create #{repos.dump}` - `svn co #{repos_url.dump} #{wc.dump}` - FileUtils.cp(@dict_file.path, dict_file) - `svn add #{dict_file.dump}` - - `svnlook youngest #{repos.dump}`.chomp.should == "0" - `svn ci -m '' #{wc.dump}` - `svnlook youngest #{repos.dump}`.chomp.should == "1" - - xml_dict = Tomoe::DictXML.new("filename" => dict_file, "editable" => true) - dict = Tomoe::DictSvn.new("dictionary" => xml_dict, "working_copy" => wc) - a = dict[@utf8] - a.writing.strokes.should == @strokes + specify "should register/unregister" do + make_temporary_dict(@original) do |dict| + prev = dict.search(Tomoe::Query.new).collect do |cand| + cand.char.utf8 + end - `svnlook youngest #{repos.dump}`.chomp.should == "1" - dict.register(Tomoe::Char.new) - `svnlook youngest #{repos.dump}`.chomp.should == "1" - dict.flush - `svnlook youngest #{repos.dump}`.chomp.should == "2" - ensure - FileUtils.rm_rf(repos) - FileUtils.rm_rf(wc) + char = Tomoe::Char.new + char.utf8 = "?? + dict.register(char).should == true + dict["??].should == char + dict.search(Tomoe::Query.new).collect do |cand| + cand.char.utf8 + end.sort.should == ["??, *prev].sort + dict.unregister("??).should == true + dict["??].should_nil + + dict.search(Tomoe::Query.new).collect do |cand| + cand.char.utf8 + end.should == prev end end - specify "should register/unregister to MySQL database" do - dict = Tomoe::DictMySQL.new(db_config) - char = Tomoe::Char.new - char.utf8 = "?? - dict.register(char).should == true - dict.search(Tomoe::Query.new).collect do |cand| - cand.char.utf8 - end.should == ["??] - dict.unregister("??).should == true - dict.search(Tomoe::Query.new).should_empty - end - - specify "should register/unregister PUA character to MySQL database" do - dict = Tomoe::DictMySQL.new(db_config) - char = Tomoe::Char.new - dict.register(char).should == true - dict.search(Tomoe::Query.new).size.should == 1 - char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) - dict.unregister(char.utf8).should == true - dict.search(Tomoe::Query.new).should_empty + specify "should register/unregister PUA character" do + make_temporary_dict(@original) do |dict| + char = Tomoe::Char.new + dict.register(char).should == true + char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) + + dict[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)].should == char + dict.unregister(char.utf8).should == true + dict[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)].should_nil + end end def setup_strokes Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.27 tomoe/test/tomoe-spec-utils.rb:1.28 --- tomoe/test/tomoe-spec-utils.rb:1.27 Thu Dec 14 17:46:22 2006 +++ tomoe/test/tomoe-spec-utils.rb Fri Dec 15 12:19:44 2006 @@ -42,7 +42,9 @@ def self.included(base) base.class_eval do include Base + include Path include Config + include Dictionary include Unicode end end @@ -55,7 +57,7 @@ end end - module Config + module Path module_function def base_dir File.expand_path(File.dirname(__FILE__)) @@ -97,6 +99,17 @@ File.join(db_dir, "config.yml") end + def test_data_files + Dir.glob(File.join(test_data_dir, "*.data")) + end + + def dictionary + File.join(data_dir, "kanjidic2.xml") + end + end + + module Config + module_function def db_config_for_active_record(type=nil) YAML.load(File.read(db_config_file))[type || ENV["TOMOE_ENV"] || "test"] end @@ -120,18 +133,13 @@ FileUtils.rm_rf(tmp_dir) end - def dictionaries - %w(kanjidic2.xml).collect do |xml| - File.join(data_dir, xml) - end + def dict_module_type + ENV["TOMOE_DICT_MODULE"] || "xml" end - def test_data_files - Dir.glob(File.join(test_data_dir, "*.data")) - end - - def make_config_file(name=nil, dict_type=:unihan) - name ||= "tomoe" + def make_config_file(dict_type=nil) + dict_type ||= dict_module_type + name ||= "tomoe-#{dict_type}" config_file = Tempfile.new(name) config_file.open config_file.puts(<<-EOC) @@ -139,36 +147,148 @@ use_system_dictionaries = false EOC - case dict_type - when :unihan - config_file.puts(<<-EOC) + config_maker = "make_config_file_for_#{dict_type}" + unless respond_to?(config_maker, true) + raise "unknown dictionary type: #{dict_type}" + end + config_file.puts(send(config_maker)) + + config_file.close + config_file + end + + def make_config_file_for_unihan + <<-EOC [unihan-dictionary] type = unihan EOC - else - dictionaries.each_with_index do |dictionary, i| - case dict_type - when :est - config_file.puts(<<-EOC) + end + + def make_config_file_for_est + <<-EOC [#{File.basename(dictionary)}-dictionary] type = est name = #{File.basename(dictionary)} database = #{dictionary.sub(/\.xml$/, '')} -#{(i % 2).zero? ? 'use = true' : ''} EOC - else - config_file.puts(<<-EOC) + end + + def make_config_file_for_xml + <<-EOC [#{File.basename(dictionary)}-dictionary] type = xml file = #{dictionary} -#{(i % 2).zero? ? 'use = true' : ''} EOC - end + end + end + + module Dictionary + module_function + def make_dict(dict_type=nil, config=nil) + dict_type ||= dict_module_type + dict_maker = "make_dict_#{dict_type}" + unless respond_to?(dict_maker, true) + raise "unknown dictionary type: #{dict_type}" + end + send(dict_maker, config) + end + + def make_temporary_dict(original, dict_type=nil, config=nil, &block) + dict_type ||= dict_module_type + temporary_dict_maker = "make_temporary_dict_#{dict_type}" + unless respond_to?(temporary_dict_maker, true) + raise "unknown dictionary type: #{dict_type}" + end + send(temporary_dict_maker, config) do |dict| + original.search(Tomoe::Query.new).each do |cand| + dict.register(cand.char) end + block.call(dict) end + end - config_file.close - config_file + def make_dict_unihan(config=nil) + check_dict_module_availability("Unihan") + Tomoe::DictUnihan.new(config || {}) + end + + def make_dict_xml(config=nil) + check_dict_module_availability("XML") + config ||= {} + config = config.dup + config["filename"] ||= dictionary + Tomoe::DictXML.new(config) + end + + def make_temporary_dict_xml(config=nil) + check_dict_module_availability("XML") + dict = nil + begin + tmp_dict_dir = File.join(tmp_dir, "dict") + FileUtils.mkdir_p(tmp_dict_dir) + dict_file = File.join(tmp_dict_dir, "dict.xml") + dict = Tomoe::DictXML.new("filename" => dict_file, "editable" => true) + yield dict + ensure + dict.flush if dict + FileUtils.rm_rf(tmp_dict_dir) + end + end + + def make_dict_est(config=nil) + check_dict_module_availability("Est") + config ||= {} + config = config.dup + config["database"] ||= dictionary.sub(/\.xml/, '') + config["editable"] = true unless config.has_key?("editable") + Tomoe::DictEst.new(config) + end + + def make_temporary_dict_est(config=nil) + check_dict_module_availability("Est") + begin + tmp_dict_dir = File.join(tmp_dir, "est") + yield Tomoe::DictEst.new("database" => tmp_dict_dir, "editable" => true) + ensure + FileUtils.rm_rf(tmp_dict_dir) + end + end + + def make_dict_mysql(config=nil) + check_dict_module_availability("MySQL") + config ||= db_config + config = config.dup + Tomoe::DictMySQL.new(config) + end + + def make_temporary_dict_mysql(config=nil) + check_dict_module_availability("MySQL") + sql_purge("temp") + yield Tomoe::DictMySQL.new(db_config("temp")) + end + + def check_dict_module_availability(type) + unless Tomoe.const_defined?("Dict#{type}") + raise "Tomoe doesn't support the dictionary type: #{type}" + end + end + + def sql_migrate(type=nil, version=nil) + migrate = File.join(db_dir, "migrate.rb") + tomoe_env = ENV["TOMOE_ENV"] + ENV["TOMOE_ENV"] = type if type + unless `#{migrate} #{version}` + message = "failed to migrate" + message << " to #{version}" if version + raise message + end + ensure + ENV["TOMOE_ENV"] = tomoe_env + end + + def sql_purge(type=nil) + sql_migrate(type, 0) + sql_migrate(type) end end @@ -215,7 +335,7 @@ end end -ENV["TOMOE_DICT_MODULE_DIR"] ||= TomoeSpecUtils::Config.dict_dir -ENV["TOMOE_RECOGNIZER_MODULE_DIR"] ||= TomoeSpecUtils::Config.recognizer_dir +ENV["TOMOE_DICT_MODULE_DIR"] ||= TomoeSpecUtils::Path.dict_dir +ENV["TOMOE_RECOGNIZER_MODULE_DIR"] ||= TomoeSpecUtils::Path.recognizer_dir require 'tomoe' From kous users.sourceforge.jp Fri Dec 15 12:20:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:20:36 +0900 Subject: [Tomoe-cvs 1917] CVS update: tomoe Message-ID: <20061215032036.5EA8D2AC0ED@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.449 tomoe/ChangeLog:1.450 --- tomoe/ChangeLog:1.449 Fri Dec 15 12:19:44 2006 +++ tomoe/ChangeLog Fri Dec 15 12:20:36 2006 @@ -1,5 +1,8 @@ 2006-12-15 Kouhei Sutou + * module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): show more + useful error message. + * test/tomoe-spec-utils.rb: - test target dictionary can be specified by TOMOE_DICT_MODULE environment variable. From kous users.sourceforge.jp Fri Dec 15 12:20:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:20:36 +0900 Subject: [Tomoe-cvs 1918] CVS update: tomoe/module/dict Message-ID: <20061215032036.A88A72AC0ED@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.13 tomoe/module/dict/tomoe-dict-xml.c:1.14 --- tomoe/module/dict/tomoe-dict-xml.c:1.13 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Fri Dec 15 12:20:36 2006 @@ -21,12 +21,13 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.13 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.14 2006/12/15 03:20:36 kous Exp $ */ #include #include #include +#include #include #include #include @@ -385,6 +386,9 @@ gboolean success = TRUE; TomoeXMLParsedData result; + if (!g_file_test (dict->filename, G_FILE_TEST_EXISTS)) + return success; + result.name = NULL; result.chars = dict->chars; success = _tomoe_xml_parser_parse_dictionary_file (dict->filename, &result); @@ -410,7 +414,10 @@ if (!dict->editable) return FALSE; f = fopen (dict->filename, "wb"); - g_return_val_if_fail (f, FALSE); + if (!f) { + g_warning ("can't open %s: %s", dict->filename, strerror (errno)); + return FALSE; + } /* write the header */ head = g_strdup ( From kous users.sourceforge.jp Fri Dec 15 12:30:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:30:53 +0900 Subject: [Tomoe-cvs 1919] CVS update: tomoe Message-ID: <20061215033053.9BD8A2AC09F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.450 tomoe/ChangeLog:1.451 --- tomoe/ChangeLog:1.450 Fri Dec 15 12:20:36 2006 +++ tomoe/ChangeLog Fri Dec 15 12:30:53 2006 @@ -1,7 +1,10 @@ 2006-12-15 Kouhei Sutou + * utils/, db/, test/, benchmark/: followed TomoeSpecUtils changes. + * module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): show more useful error message. + (tomoe_dict_xml_load): don't load if the filename doesn't exist. * test/tomoe-spec-utils.rb: - test target dictionary can be specified by TOMOE_DICT_MODULE From kous users.sourceforge.jp Fri Dec 15 12:30:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:30:53 +0900 Subject: [Tomoe-cvs 1920] CVS update: tomoe/benchmark Message-ID: <20061215033053.D0EC32AC0ED@users.sourceforge.jp> Index: tomoe/benchmark/Makefile.am diff -u tomoe/benchmark/Makefile.am:1.3 tomoe/benchmark/Makefile.am:1.4 --- tomoe/benchmark/Makefile.am:1.3 Fri Dec 1 12:51:42 2006 +++ tomoe/benchmark/Makefile.am Fri Dec 15 12:30:53 2006 @@ -2,7 +2,11 @@ .PHONY: benchamrk -benchmark_files = load-dict.rb search-by-recognizer.rb convert-char.rb +benchmark_files = \ + load-dict.rb \ + search-by-recognizer.rb \ + search-by-dict.rb \ + convert-char.rb benchmark: $(top_builddir)/ext/ruby/tomoe.la for bench in $(benchmark_files); \ Index: tomoe/benchmark/load-dict.rb diff -u tomoe/benchmark/load-dict.rb:1.9 tomoe/benchmark/load-dict.rb:1.10 --- tomoe/benchmark/load-dict.rb:1.9 Tue Dec 12 22:42:51 2006 +++ tomoe/benchmark/load-dict.rb Fri Dec 15 12:30:53 2006 @@ -11,11 +11,10 @@ n = 3 Benchmark.bmbm do |x| - TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| - x.report(File.basename(dictionary)) do - n.times {Tomoe::DictXML.new("filename" => dictionary, - "editable" => false)} - end + dictionary = TomoeSpecUtils::Path.dictionary + x.report(File.basename(dictionary)) do + n.times {Tomoe::DictXML.new("filename" => dictionary, + "editable" => false)} end x.report("Unihan") do Index: tomoe/benchmark/search-by-dict.rb diff -u tomoe/benchmark/search-by-dict.rb:1.9 tomoe/benchmark/search-by-dict.rb:1.10 --- tomoe/benchmark/search-by-dict.rb:1.9 Tue Dec 12 22:42:51 2006 +++ tomoe/benchmark/search-by-dict.rb Fri Dec 15 12:30:53 2006 @@ -11,74 +11,73 @@ n = 10 dict_type = ARGV.shift -tmp_dir = TomoeSpecUtils::Config.tmp_dir +tmp_dir = TomoeSpecUtils::Path.tmp_dir Benchmark.bmbm do |x| - TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| - case dict_type - when "mysql" - config = TomoeSpecUtils::Config.db_config("benchmark") - dict = Tomoe::DictMySQL.new(config) - when "est" - database = dictionary.sub(/\.xml$/, '') - dict = Tomoe::DictEst.new("name" => File.basename(dictionary), - "database" => database, - "editable" => false) - when "svn" - repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) - FileUtils.mkdir_p(repos) - repos_url = "file://#{repos}" - wc = File.join(tmp_dir, "svn.wc", File.basename(dictionary)) - dict_file = File.join(wc, "dict.xml") - - `svnadmin create #{repos.dump}` - `svn co #{repos_url.dump} #{wc.dump}` - FileUtils.cp(dictionary, dict_file) - `svn add #{dict_file.dump}` - `svn ci -m '' #{wc.dump}` - - xml_dict = Tomoe::DictXML.new("filename" => dict_file, "editable" => true) - dict = Tomoe::DictSvn.new("dictionary" => xml_dict, "working_copy" => wc) - else - dict = Tomoe::DictXML.new("filename" => dictionary, "editable" => false) - end + dictionary = TomoeSpecUtils::Path.dictionary + case dict_type + when "mysql" + config = TomoeSpecUtils::Config.db_config("benchmark") + dict = Tomoe::DictMySQL.new(config) + when "est" + database = dictionary.sub(/\.xml$/, '') + dict = Tomoe::DictEst.new("name" => File.basename(dictionary), + "database" => database, + "editable" => false) + when "svn" + repos = File.join(tmp_dir, "svn.repos", File.basename(dictionary)) + FileUtils.mkdir_p(repos) + repos_url = "file://#{repos}" + wc = File.join(tmp_dir, "svn.wc", File.basename(dictionary)) + dict_file = File.join(wc, "dict.xml") + + `svnadmin create #{repos.dump}` + `svn co #{repos_url.dump} #{wc.dump}` + FileUtils.cp(dictionary, dict_file) + `svn add #{dict_file.dump}` + `svn ci -m '' #{wc.dump}` + + xml_dict = Tomoe::DictXML.new("filename" => dict_file, "editable" => true) + dict = Tomoe::DictSvn.new("dictionary" => xml_dict, "working_copy" => wc) + else + dict = Tomoe::DictXML.new("filename" => dictionary, "editable" => false) + end - x.report("#{File.basename(dictionary)}: all") do - query = Tomoe::Query.new - expected = 13039 - actual = dict.search(query).size - if actual != expected - puts "expected: #{expected}" - puts " but was: #{actual}" - end - n.times {dict.search(query)} + x.report("#{File.basename(dictionary)}: all") do + query = Tomoe::Query.new + expected = 13039 + actual = dict.search(query).size + if actual != expected + puts "expected: #{expected}" + puts " but was: #{actual}" end + n.times {dict.search(query)} + end - x.report("#{File.basename(dictionary)}: >= 5") do - query = Tomoe::Query.new - query.min_n_strokes = 10 - expected = 9889 - actual = dict.search(query).size - if actual != expected - puts "expected: #{expected}" - puts " but was: #{actual}" - end - n.times {dict.search(query)} + x.report("#{File.basename(dictionary)}: >= 5") do + query = Tomoe::Query.new + query.min_n_strokes = 10 + expected = 9889 + actual = dict.search(query).size + if actual != expected + puts "expected: #{expected}" + puts " but was: #{actual}" end + n.times {dict.search(query)} + end - x.report("#{File.basename(dictionary)}: readings") do - query = Tomoe::Query.new - query.add_reading(Tomoe::Reading.new(Tomoe::READING_JA_KUN, "???")) - expected = ["?, "??, "??].sort - actual = dict.search(query).collect do |cand| - cand.char.utf8 - end.sort - if actual != expected - $KCODE = "u" - puts "expected: #{expected.inspect}" - puts " but was: #{actual.inspect}" - end - n.times {dict.search(query)} + x.report("#{File.basename(dictionary)}: readings") do + query = Tomoe::Query.new + query.add_reading(Tomoe::Reading.new(Tomoe::READING_JA_KUN, "???")) + expected = ["?, "??, "??].sort + actual = dict.search(query).collect do |cand| + cand.char.utf8 + end.sort + if actual != expected + $KCODE = "u" + puts "expected: #{expected.inspect}" + puts " but was: #{actual.inspect}" end + n.times {dict.search(query)} end end Index: tomoe/benchmark/search-by-recognizer.rb diff -u tomoe/benchmark/search-by-recognizer.rb:1.9 tomoe/benchmark/search-by-recognizer.rb:1.10 --- tomoe/benchmark/search-by-recognizer.rb:1.9 Tue Dec 12 22:42:51 2006 +++ tomoe/benchmark/search-by-recognizer.rb Fri Dec 15 12:30:53 2006 @@ -10,7 +10,7 @@ require 'tomoe-spec-utils' -data_dir = TomoeSpecUtils::Config.data_dir +data_dir = TomoeSpecUtils::Path.data_dir use_est = false if use_est database = File.join(data_dir, "handwriting") @@ -26,7 +26,7 @@ n = 10 Benchmark.bmbm do |x| - TomoeSpecUtils::Config.test_data_files.sort.each do |file| + TomoeSpecUtils::Path.test_data_files.sort.each do |file| expected, writing = TomoeSpecUtils::TestData.parse(file) query = Tomoe::Query.new query.writing = writing From kous users.sourceforge.jp Fri Dec 15 12:30:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:30:53 +0900 Subject: [Tomoe-cvs 1921] CVS update: tomoe/db Message-ID: <20061215033054.00C132AC09F@users.sourceforge.jp> Index: tomoe/db/xml2db.rb diff -u tomoe/db/xml2db.rb:1.7 tomoe/db/xml2db.rb:1.8 --- tomoe/db/xml2db.rb:1.7 Tue Dec 12 22:42:51 2006 +++ tomoe/db/xml2db.rb Fri Dec 15 12:30:53 2006 @@ -24,7 +24,7 @@ `#{migrate}` puts "done." -filename = TomoeSpecUtils::Config.dictionaries.first +filename = TomoeSpecUtils::Path.dictionary dict = Tomoe::DictXML.new("filename" => filename, "editable" => false) config = TomoeSpecUtils::Config.db_config.merge("editable" => true) From kous users.sourceforge.jp Fri Dec 15 12:30:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:30:54 +0900 Subject: [Tomoe-cvs 1922] CVS update: tomoe/test Message-ID: <20061215033054.2D9E92AC0ED@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.28 tomoe/test/tomoe-spec-utils.rb:1.29 --- tomoe/test/tomoe-spec-utils.rb:1.28 Fri Dec 15 12:19:44 2006 +++ tomoe/test/tomoe-spec-utils.rb Fri Dec 15 12:30:54 2006 @@ -109,6 +109,8 @@ end module Config + extend Path + module_function def db_config_for_active_record(type=nil) YAML.load(File.read(db_config_file))[type || ENV["TOMOE_ENV"] || "test"] From kous users.sourceforge.jp Fri Dec 15 12:30:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 15 Dec 2006 12:30:54 +0900 Subject: [Tomoe-cvs 1923] CVS update: tomoe/utils Message-ID: <20061215033054.5A7EE2AC09F@users.sourceforge.jp> Index: tomoe/utils/xml2est.rb diff -u tomoe/utils/xml2est.rb:1.2 tomoe/utils/xml2est.rb:1.3 --- tomoe/utils/xml2est.rb:1.2 Tue Dec 12 19:08:12 2006 +++ tomoe/utils/xml2est.rb Fri Dec 15 12:30:54 2006 @@ -9,17 +9,16 @@ require "tomoe-spec-utils" -TomoeSpecUtils::Config.dictionaries.sort.each do |dictionary| - print "converting #{dictionary}..." - est_db = dictionary.sub(/\.xml$/, "") - xml_dict = Tomoe::Dict.new("xml", - "filename" => dictionary, - "editable" => false) - est_dict = Tomoe::Dict.new("est", - "database" => est_db, - "editable" => true) - xml_dict.search(Tomoe::Query.new).each do |cand| - est_dict.register(cand.char) - end - puts "done." +dictionary = TomoeSpecUtils::Path.dictionary +print "converting #{dictionary}..." +est_db = dictionary.sub(/\.xml$/, "") +xml_dict = Tomoe::Dict.new("xml", + "filename" => dictionary, + "editable" => false) +est_dict = Tomoe::Dict.new("est", + "database" => est_db, + "editable" => true) +xml_dict.search(Tomoe::Query.new).each do |cand| + est_dict.register(cand.char) end +puts "done." From kous users.sourceforge.jp Mon Dec 18 10:02:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:02:06 +0900 Subject: [Tomoe-cvs 1924] CVS update: tomoe Message-ID: <20061218010206.8AE102AC016@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.451 tomoe/ChangeLog:1.452 --- tomoe/ChangeLog:1.451 Fri Dec 15 12:30:53 2006 +++ tomoe/ChangeLog Mon Dec 18 10:02:05 2006 @@ -1,5 +1,26 @@ 2006-12-15 Kouhei Sutou + * test/tomoe-spec-utils.rb: + - patched RSpec to show results even if interrupted. + - removed a patch that was merged into RSpec. + + * test/: supported tests for each dictionary module. + + * module/dict/tomoe-dict-ptr-array.c: used tomoe_query_is_empty(). + + * lib/tomoe-dict.c (tomoe_dict_get_available_private_utf8): added + warning message. + + * module/dict/tomoe-dict-mysql.c (get_char): should return + TomoeChar not TomoeCandidate. + + * module/dict/tomoe-dict-est.c (get_available_private_utf8): + supported PUA. + + * lib/tomoe-query.[ch] (tomoe_query_is_empty): added. + * module/dict/tomoe-dict-ptr-array.c, + module/dict/tomoe-dict-est.c: used tomoe_query_is_empty(). + * utils/, db/, test/, benchmark/: followed TomoeSpecUtils changes. * module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): show more From kous users.sourceforge.jp Mon Dec 18 10:02:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:02:06 +0900 Subject: [Tomoe-cvs 1925] CVS update: tomoe/lib Message-ID: <20061218010206.BC9222AC12E@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.135 tomoe/lib/tomoe-dict.c:1.136 --- tomoe/lib/tomoe-dict.c:1.135 Thu Dec 14 17:46:21 2006 +++ tomoe/lib/tomoe-dict.c Mon Dec 18 10:02:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.135 2006/12/14 08:46:21 kous Exp $ + * $Id: tomoe-dict.c,v 1.136 2006/12/18 01:02:06 kous Exp $ */ #include "tomoe-dict.h" @@ -261,10 +261,13 @@ g_return_val_if_fail (TOMOE_IS_DICT (dict), NULL); klass = TOMOE_DICT_GET_CLASS (dict); - if (klass->get_available_private_utf8) + if (klass->get_available_private_utf8) { return klass->get_available_private_utf8 (dict); - else + } else { + g_warning ("%s backend doesn't support PUA(Private Use Area)", + tomoe_dict_get_name (dict)); return NULL; + } } /* Index: tomoe/lib/tomoe-query.c diff -u tomoe/lib/tomoe-query.c:1.6 tomoe/lib/tomoe-query.c:1.7 --- tomoe/lib/tomoe-query.c:1.6 Fri Dec 1 13:47:26 2006 +++ tomoe/lib/tomoe-query.c Mon Dec 18 10:02:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.c,v 1.6 2006/12/01 04:47:26 kous Exp $ + * $Id: tomoe-query.c,v 1.7 2006/12/18 01:02:06 kous Exp $ */ #include @@ -226,7 +226,7 @@ } const gchar * -tomoe_query_get_utf8 (TomoeQuery* query) +tomoe_query_get_utf8 (TomoeQuery *query) { TomoeQueryPrivate *priv; @@ -237,7 +237,7 @@ } void -tomoe_query_set_utf8 (TomoeQuery* query, const gchar *utf8) +tomoe_query_set_utf8 (TomoeQuery *query, const gchar *utf8) { TomoeQueryPrivate *priv; @@ -251,7 +251,7 @@ } const GList * -tomoe_query_get_readings (TomoeQuery* query) +tomoe_query_get_readings (TomoeQuery *query) { TomoeQueryPrivate *priv; @@ -262,7 +262,7 @@ } void -tomoe_query_add_reading (TomoeQuery* query, TomoeReading *reading) +tomoe_query_add_reading (TomoeQuery *query, TomoeReading *reading) { TomoeQueryPrivate *priv; @@ -366,7 +366,7 @@ } void -tomoe_query_set_writing (TomoeQuery* query, TomoeWriting *writing) +tomoe_query_set_writing (TomoeQuery *query, TomoeWriting *writing) { TomoeQueryPrivate *priv; @@ -380,7 +380,7 @@ } TomoeWriting * -tomoe_query_get_writing (TomoeQuery* query) +tomoe_query_get_writing (TomoeQuery *query) { TomoeQueryPrivate *priv; @@ -390,6 +390,22 @@ return priv->writing; } +gboolean +tomoe_query_is_empty (TomoeQuery *query) +{ + TomoeQueryPrivate *priv; + + g_return_val_if_fail (TOMOE_IS_QUERY (query), TRUE); + + priv = TOMOE_QUERY_GET_PRIVATE (query); + return !(priv->utf8 || + priv->min_n_strokes > 0 || + priv->max_n_strokes > 0 || + priv->readings || + priv->radicals || + priv->writing || + priv->variant); +} /* vi:ts=4:nowrap:ai:expandtab Index: tomoe/lib/tomoe-query.h diff -u tomoe/lib/tomoe-query.h:1.6 tomoe/lib/tomoe-query.h:1.7 --- tomoe/lib/tomoe-query.h:1.6 Fri Dec 1 13:47:26 2006 +++ tomoe/lib/tomoe-query.h Mon Dec 18 10:02:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.h,v 1.6 2006/12/01 04:47:26 kous Exp $ + * $Id: tomoe-query.h,v 1.7 2006/12/18 01:02:06 kous Exp $ */ #ifndef __TOMOE_QUERY_H__ @@ -83,6 +83,8 @@ TomoeWriting *writing); TomoeWriting *tomoe_query_get_writing (TomoeQuery *query); +gboolean tomoe_query_is_empty (TomoeQuery *query); + G_END_DECLS #endif /* __TOMOE_QUERY_H__ */ From kous users.sourceforge.jp Mon Dec 18 10:02:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:02:07 +0900 Subject: [Tomoe-cvs 1926] CVS update: tomoe/module/dict Message-ID: <20061218010207.3FF612AC016@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.13 tomoe/module/dict/tomoe-dict-est.c:1.14 --- tomoe/module/dict/tomoe-dict-est.c:1.13 Tue Dec 12 19:08:12 2006 +++ tomoe/module/dict/tomoe-dict-est.c Mon Dec 18 10:02:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.13 2006/12/12 10:08:12 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.14 2006/12/18 01:02:06 kous Exp $ */ #include @@ -100,6 +100,7 @@ TomoeQuery *query); static gboolean flush (TomoeDict *dict); static gboolean is_editable (TomoeDict *dict); +static gchar *get_available_private_utf8 (TomoeDict *dict); static gboolean tomoe_dict_est_open (TomoeDictEst *dict); static gboolean tomoe_dict_est_close (TomoeDictEst *dict); @@ -126,6 +127,7 @@ dict_class->search = search; dict_class->flush = flush; dict_class->is_editable = is_editable; + dict_class->get_available_private_utf8 = get_available_private_utf8; g_object_class_install_property ( gobject_class, @@ -332,6 +334,10 @@ g_free (value); est_doc_add_attr (doc, "utf8", original_value); + + value = g_strdup_printf ("%d", g_utf8_get_char (original_value)); + est_doc_add_attr (doc, "code-point", value); + g_free (value); } n_strokes = tomoe_char_get_n_strokes (chr); @@ -344,7 +350,7 @@ if (n_strokes >= 0) { value = g_strdup_printf ("%d", n_strokes); - est_doc_add_attr (doc, "n_strokes", value); + est_doc_add_attr (doc, "n-strokes", value); g_free (value); } @@ -479,28 +485,34 @@ g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), candidates); cond = est_cond_new (); - est_cond_set_phrase (cond, ""); est_cond_set_order (cond, "utf8 STRA"); - min_n_strokes = tomoe_query_get_min_n_strokes (query); - if (min_n_strokes >= 0) { - expr = g_strdup_printf ("n_strokes NUMGE %d", min_n_strokes); - est_cond_add_attr (cond, expr); - g_free (expr); - } - - max_n_strokes = tomoe_query_get_max_n_strokes (query); - if (max_n_strokes >= 0) { - expr = g_strdup_printf ("n_strokes NUMLE %d", max_n_strokes); - est_cond_add_attr (cond, expr); - g_free (expr); - } - - reading = g_list_nth_data ((GList *)tomoe_query_get_readings (query), 0); - if (reading) { - expr = tomoe_reading_to_xml (reading); - est_cond_set_phrase (cond, expr); - g_free (expr); + if (tomoe_query_is_empty (query)) { + est_cond_set_phrase (cond, "[UVSET]"); + } else { + GList *node; + + min_n_strokes = tomoe_query_get_min_n_strokes (query); + if (min_n_strokes >= 0) { + expr = g_strdup_printf ("n-strokes NUMGE %d", min_n_strokes); + est_cond_add_attr (cond, expr); + g_free (expr); + } + + max_n_strokes = tomoe_query_get_max_n_strokes (query); + if (max_n_strokes >= 0) { + expr = g_strdup_printf ("n-strokes NUMLE %d", max_n_strokes); + est_cond_add_attr (cond, expr); + g_free (expr); + } + + node = (GList *)tomoe_query_get_readings (query); + reading = node ? node->data : NULL; + if (reading) { + expr = tomoe_reading_to_xml (reading); + est_cond_set_phrase (cond, expr); + g_free (expr); + } } results = est_db_search (dict->db, cond, &n_results, NULL); @@ -536,6 +548,63 @@ return dict->editable; } +static gchar * +get_available_private_utf8 (TomoeDict *_dict) +{ + TomoeDictEst *dict = TOMOE_DICT_EST (_dict); + ESTCOND *cond; + gchar *expr; + int i, *results, n_results; + gunichar result_ucs = TOMOE_CHAR_PRIVATE_USE_AREA_START; + + g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), FALSE); + + cond = est_cond_new (); + est_cond_set_order (cond, "utf8 STRA"); + est_cond_set_max (cond, 1); + + expr = g_strdup_printf ("code-point NUMGE %d", + TOMOE_CHAR_PRIVATE_USE_AREA_START); + est_cond_add_attr (cond, expr); + g_free (expr); + + expr = g_strdup_printf ("code-point NUMLE %d", + TOMOE_CHAR_PRIVATE_USE_AREA_END); + est_cond_add_attr (cond, expr); + g_free (expr); + + results = est_db_search (dict->db, cond, &n_results, NULL); + for (i = 0; i < n_results; i++) { + TomoeChar *chr; + gunichar ucs; + + chr = retrieve_char_by_id (dict, results[i]); + ucs = g_utf8_get_char (tomoe_char_get_utf8 (chr)); + if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_START) { + if (ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_END) { + result_ucs = 0; + } else { + result_ucs = ucs + 1; + } + } + } + g_free (results); + est_cond_delete (cond); + + if (result_ucs >= TOMOE_CHAR_PRIVATE_USE_AREA_START) { + gint result_len; + gchar *result; + + result_len = g_unichar_to_utf8 (result_ucs, NULL); + result = g_new (gchar, result_len + 1); + g_unichar_to_utf8 (result_ucs, result); + result[result_len] = '\0'; + return result; + } else { + return NULL; + } +} + static gboolean tomoe_dict_est_open (TomoeDictEst *dict) { Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.8 tomoe/module/dict/tomoe-dict-mysql.c:1.9 --- tomoe/module/dict/tomoe-dict-mysql.c:1.8 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 18 10:02:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.8 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.9 2006/12/18 01:02:06 kous Exp $ */ #include @@ -657,7 +657,7 @@ utf8 = tomoe_query_get_utf8 (query); if (utf8) { - g_string_append (sql, " AND utf8 = "); + g_string_append (sql, " AND chars.utf8 = "); append_string_value (dict, sql, utf8); } } @@ -861,7 +861,7 @@ GList *cands; g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), chr); - g_return_val_if_fail (TOMOE_IS_CHAR (chr), chr); + g_return_val_if_fail (utf8 && utf8[0] != '\0', chr); g_return_val_if_fail (dict->mysql, chr); @@ -871,7 +871,7 @@ g_object_unref (query); if (cands) { - chr = g_object_ref (cands->data); + chr = g_object_ref (tomoe_candidate_get_char (cands->data)); g_list_foreach (cands, (GFunc) g_object_unref, NULL); g_list_free (cands); } Index: tomoe/module/dict/tomoe-dict-ptr-array.c diff -u tomoe/module/dict/tomoe-dict-ptr-array.c:1.3 tomoe/module/dict/tomoe-dict-ptr-array.c:1.4 --- tomoe/module/dict/tomoe-dict-ptr-array.c:1.3 Wed Dec 6 15:28:36 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.c Mon Dec 18 10:02:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ptr-array.c,v 1.3 2006/12/06 06:28:36 kous Exp $ + * $Id: tomoe-dict-ptr-array.c,v 1.4 2006/12/18 01:02:06 kous Exp $ */ #include @@ -169,6 +169,16 @@ tomoe_candidate_new (chr)); } +static void +collect_all_chars (gpointer data, gpointer user_data) +{ + TomoeChar *chr = data; + TomoeDictSearchContext *context = user_data; + + context->results = g_list_prepend (context->results, + tomoe_candidate_new (chr)); +} + GList * _tomoe_dict_ptr_array_search (GPtrArray *chars, TomoeQuery *query) { @@ -177,8 +187,13 @@ search_context.query = g_object_ref (query); search_context.results = NULL; - g_ptr_array_foreach_reverse (chars, collect_chars_by_query, - &search_context); + if (tomoe_query_is_empty (query)) { + g_ptr_array_foreach_reverse (chars, collect_all_chars, + &search_context); + } else { + g_ptr_array_foreach_reverse (chars, collect_chars_by_query, + &search_context); + } g_object_unref (search_context.query); return search_context.results; From kous users.sourceforge.jp Mon Dec 18 10:02:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:02:07 +0900 Subject: [Tomoe-cvs 1927] CVS update: tomoe/test Message-ID: <20061218010207.6DBD42AC12E@users.sourceforge.jp> Index: tomoe/test/Makefile.am diff -u tomoe/test/Makefile.am:1.17 tomoe/test/Makefile.am:1.18 --- tomoe/test/Makefile.am:1.17 Mon Nov 27 15:46:41 2006 +++ tomoe/test/Makefile.am Mon Dec 18 10:02:07 2006 @@ -31,4 +31,28 @@ dict_spec.rb \ writing_spec.rb -TESTS = run-spec.rb +dict_modules = xml +if WITH_EST +dict_modules += est +endif +# if ENABLE_DICT_RUBY +# dict_modules += ruby +# endif +if WITH_UNIHAN +dict_modules += unihan +endif +# if WITH_SVN +# dict_modules += svn +# endif +if WITH_MYSQL +dict_modules += mysql +endif + +TESTS = run-specs.sh +TESTS_ENVIRONMENT = DICT_MODULES="$(dict_modules)" + +output_dict_modules: + @echo $(dict_modules) + +output_RUBY: + @echo $(RUBY) Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.21 tomoe/test/dict_spec.rb:1.22 --- tomoe/test/dict_spec.rb:1.21 Fri Dec 15 12:19:44 2006 +++ tomoe/test/dict_spec.rb Mon Dec 18 10:02:07 2006 @@ -1,7 +1,7 @@ require 'tomoe-spec-utils' dict_module_type = TomoeSpecUtils::Config.dict_module_type -context "Tomoe::Dict (#{dict_module_type})" do +context "Tomoe::Dict(#{dict_module_type})" do read_only_dictionaries = %w(unihan) if read_only_dictionaries.include?(dict_module_type) puts "#{dict_module_type} is read-only dictionary. skip tests." Index: tomoe/test/run-spec.rb diff -u tomoe/test/run-spec.rb:1.6 tomoe/test/run-spec.rb:1.7 --- tomoe/test/run-spec.rb:1.6 Mon Dec 11 15:03:41 2006 +++ tomoe/test/run-spec.rb Mon Dec 18 10:02:07 2006 @@ -11,8 +11,8 @@ $LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby")) $LOAD_PATH.unshift(File.join(test_dir)) -ARGV.unshift("--diff") +require 'tomoe-spec-utils' -Dir.glob(File.join(test_dir, "*_spec.rb")).each do |file| - require File.basename(file, ".rb") -end +ARGV.unshift("--diff=unified") +ARGV.concat(Dir.glob(File.join(test_dir, "*_spec.rb"))) +Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true) Index: tomoe/test/run-specs.sh diff -u /dev/null tomoe/test/run-specs.sh:1.1 --- /dev/null Mon Dec 18 10:02:07 2006 +++ tomoe/test/run-specs.sh Mon Dec 18 10:02:07 2006 @@ -0,0 +1,6 @@ +#!/bin/sh + +for dict_module in $DICT_MODULES; do + echo "tests for $dict_module" + TOMOE_DICT_MODULE="$dict_module" $RUBY `dirname $0`/run-spec.rb || exit 1 +done Index: tomoe/test/run-test.sh diff -u tomoe/test/run-test.sh:1.2 tomoe/test/run-test.sh:1.3 --- tomoe/test/run-test.sh:1.2 Wed Nov 22 15:39:44 2006 +++ tomoe/test/run-test.sh Mon Dec 18 10:02:07 2006 @@ -1,4 +1,10 @@ #!/bin/sh -make -C `dirname $0`/.. > /dev/null && \ - `dirname $0`/run-spec.rb +base=`dirname $0` +make -C $base/.. > /dev/null || exit 1 + +RUBY=`(cd $base && make output_RUBY)` +for dict_module in `(cd $base && make output_dict_modules)`; do + echo "tests for $dict_module" + TOMOE_DICT_MODULE="$dict_module" $RUBY $base/run-spec.rb +done Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.29 tomoe/test/tomoe-spec-utils.rb:1.30 --- tomoe/test/tomoe-spec-utils.rb:1.29 Fri Dec 15 12:30:54 2006 +++ tomoe/test/tomoe-spec-utils.rb Mon Dec 18 10:02:07 2006 @@ -28,10 +28,21 @@ include TomoeSpecSetup end - module Formatter - class ProgressBarFormatter - def format_backtrace(backtrace) - super(backtrace.collect {|bt| bt.sub(/\A([^:]+:\d+)$/, '\\1:')}) + class ContextRunner + def run(exit_when_done) + @reporter.start(number_of_specs) + begin + @contexts.each do |context| + context.run(@reporter, @dry_run) + end + rescue Interrupt + ensure + @reporter.end + end + failure_count = @reporter.dump + if(exit_when_done) + exit_code = (failure_count == 0) ? 0 : 1 + exit(exit_code) end end end @@ -182,6 +193,17 @@ file = #{dictionary} EOC end + + def make_config_file_for_mysql + config = <<-EOC +[mysql-dictionary] +type = mysql +EOC + db_config.each do |key, value| + config << "#{key} = #{value}\n" + end + config + end end module Dictionary From kous users.sourceforge.jp Mon Dec 18 10:35:40 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:35:40 +0900 Subject: [Tomoe-cvs 1927] CVS update: tomoe Message-ID: <20061218013540.37EE42AC147@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.452 tomoe/ChangeLog:1.453 --- tomoe/ChangeLog:1.452 Mon Dec 18 10:02:05 2006 +++ tomoe/ChangeLog Mon Dec 18 10:35:40 2006 @@ -1,3 +1,7 @@ +2006-12-18 Kouhei Sutou + + * ext/ruby/tomoe-rb.h: fixed a typo. + 2006-12-15 Kouhei Sutou * test/tomoe-spec-utils.rb: From kous users.sourceforge.jp Mon Dec 18 10:35:40 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:35:40 +0900 Subject: [Tomoe-cvs 1928] CVS update: tomoe/ext/ruby Message-ID: <20061218013540.64CE32AC14C@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.14 tomoe/ext/ruby/tomoe-rb.h:1.15 --- tomoe/ext/ruby/tomoe-rb.h:1.14 Thu Dec 14 17:46:21 2006 +++ tomoe/ext/ruby/tomoe-rb.h Mon Dec 18 10:35:40 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.14 2006/12/14 08:46:21 kous Exp $ + * $Id: tomoe-rb.h,v 1.15 2006/12/18 01:35:40 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -27,7 +27,7 @@ G_BEGIN_DECLS -#if GOBJ2RVALU +#ifdef GOBJ2RVALU # define HAVE_GOBJ2RVALU #endif From kous users.sourceforge.jp Mon Dec 18 10:40:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:40:53 +0900 Subject: [Tomoe-cvs 1929] CVS update: tomoe Message-ID: <20061218014053.5752E2AC016@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.453 tomoe/ChangeLog:1.454 --- tomoe/ChangeLog:1.453 Mon Dec 18 10:35:40 2006 +++ tomoe/ChangeLog Mon Dec 18 10:40:53 2006 @@ -1,5 +1,7 @@ 2006-12-18 Kouhei Sutou + * module/dict/Makefile.am: remove Unihan.stamp when 'make clean'. + * ext/ruby/tomoe-rb.h: fixed a typo. 2006-12-15 Kouhei Sutou From kous users.sourceforge.jp Mon Dec 18 10:40:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 10:40:53 +0900 Subject: [Tomoe-cvs 1930] CVS update: tomoe/module/dict Message-ID: <20061218014053.83EB72AC12E@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.29 tomoe/module/dict/Makefile.am:1.30 --- tomoe/module/dict/Makefile.am:1.29 Tue Dec 12 22:24:29 2006 +++ tomoe/module/dict/Makefile.am Mon Dec 18 10:40:53 2006 @@ -65,7 +65,7 @@ unihan_built_sources = tomoe-unihan-data.h -CLEANFILES += Unihan.txt Unihan.txt.cache +CLEANFILES += Unihan.stamp Unihan.txt Unihan.txt.cache BUILT_SOURCES = $(unihan_built_sources) EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) Unihan.stamp From kous users.sourceforge.jp Mon Dec 18 11:11:23 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:11:23 +0900 Subject: [Tomoe-cvs 1931] CVS update: tomoe Message-ID: <20061218021123.0D6702AC12E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.454 tomoe/ChangeLog:1.455 --- tomoe/ChangeLog:1.454 Mon Dec 18 10:40:53 2006 +++ tomoe/ChangeLog Mon Dec 18 11:11:22 2006 @@ -1,5 +1,8 @@ 2006-12-18 Kouhei Sutou + * lib/tomoe-writing.c (tomoe_point_get_type): don't use + g_intern_static_string() if not available. + * module/dict/Makefile.am: remove Unihan.stamp when 'make clean'. * ext/ruby/tomoe-rb.h: fixed a typo. From kous users.sourceforge.jp Mon Dec 18 11:11:23 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:11:23 +0900 Subject: [Tomoe-cvs 1932] CVS update: tomoe/lib Message-ID: <20061218021123.3BC122AC14C@users.sourceforge.jp> Index: tomoe/lib/tomoe-writing.c diff -u tomoe/lib/tomoe-writing.c:1.11 tomoe/lib/tomoe-writing.c:1.12 --- tomoe/lib/tomoe-writing.c:1.11 Mon Nov 27 18:11:09 2006 +++ tomoe/lib/tomoe-writing.c Mon Dec 18 11:11:23 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-writing.c,v 1.11 2006/11/27 09:11:09 kous Exp $ + * $Id: tomoe-writing.c,v 1.12 2006/12/18 02:11:23 kous Exp $ */ #include @@ -250,12 +250,20 @@ { static GType our_type = 0; - if (our_type == 0) + if (our_type == 0) { + const gchar *str; +#if GLIB_CHECK_VERSION(2, 6, 10) + str = g_intern_static_string ("TomoePoint"); +#else + str = "TomoePoint"; +#endif our_type = - g_boxed_type_register_static (g_intern_static_string ("TomoePoint"), + g_boxed_type_register_static (str, (GBoxedCopyFunc)tomoe_point_copy, (GBoxedFreeFunc)tomoe_point_free); - return our_type; + } + + return our_type; } static GList * From kous users.sourceforge.jp Mon Dec 18 11:12:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:12:49 +0900 Subject: [Tomoe-cvs 1933] CVS update: tomoe/lib Message-ID: <20061218021249.3B0872AC0EF@users.sourceforge.jp> Index: tomoe/lib/tomoe-writing.c diff -u tomoe/lib/tomoe-writing.c:1.12 tomoe/lib/tomoe-writing.c:1.13 --- tomoe/lib/tomoe-writing.c:1.12 Mon Dec 18 11:11:23 2006 +++ tomoe/lib/tomoe-writing.c Mon Dec 18 11:12:49 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-writing.c,v 1.12 2006/12/18 02:11:23 kous Exp $ + * $Id: tomoe-writing.c,v 1.13 2006/12/18 02:12:49 kous Exp $ */ #include @@ -252,7 +252,7 @@ if (our_type == 0) { const gchar *str; -#if GLIB_CHECK_VERSION(2, 6, 10) +#if GLIB_CHECK_VERSION(2, 10, 0) str = g_intern_static_string ("TomoePoint"); #else str = "TomoePoint"; From kous users.sourceforge.jp Mon Dec 18 11:15:16 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:15:16 +0900 Subject: [Tomoe-cvs 1934] CVS update: tomoe Message-ID: <20061218021516.054DB2AC0EF@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.455 tomoe/ChangeLog:1.456 --- tomoe/ChangeLog:1.455 Mon Dec 18 11:11:22 2006 +++ tomoe/ChangeLog Mon Dec 18 11:15:16 2006 @@ -1,5 +1,7 @@ 2006-12-18 Kouhei Sutou + * lib/glib-utils.[ch] (g_file_set_contents): copied from GLib. + * lib/tomoe-writing.c (tomoe_point_get_type): don't use g_intern_static_string() if not available. From kous users.sourceforge.jp Mon Dec 18 11:15:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:15:17 +0900 Subject: [Tomoe-cvs 1935] CVS update: tomoe/lib Message-ID: <20061218021517.63F8C2AC0EF@users.sourceforge.jp> Index: tomoe/lib/glib-utils.c diff -u tomoe/lib/glib-utils.c:1.2 tomoe/lib/glib-utils.c:1.3 --- tomoe/lib/glib-utils.c:1.2 Tue Dec 5 17:33:05 2006 +++ tomoe/lib/glib-utils.c Mon Dec 18 11:15:17 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.c,v 1.2 2006/12/05 08:33:05 kous Exp $ + * $Id: glib-utils.c,v 1.3 2006/12/18 02:15:17 kous Exp $ */ #include @@ -36,6 +36,96 @@ } } +#if !GLIB_CHECK_VERSION(2, 8, 10) +/* copied from GLib. */ +gboolean +g_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + GError **error) +{ + gchar *tmp_filename; + gboolean retval; + GError *rename_error = NULL; + + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + g_return_val_if_fail (contents != NULL || length == 0, FALSE); + g_return_val_if_fail (length >= -1, FALSE); + + if (length == -1) + length = strlen (contents); + + tmp_filename = write_to_temp_file (contents, length, filename, error); + + if (!tmp_filename) + { + retval = FALSE; + goto out; + } + + if (!rename_file (tmp_filename, filename, &rename_error)) + { +#ifndef G_OS_WIN32 + + g_unlink (tmp_filename); + g_propagate_error (error, rename_error); + retval = FALSE; + goto out; + +#else /* G_OS_WIN32 */ + + /* Renaming failed, but on Windows this may just mean + * the file already exists. So if the target file + * exists, try deleting it and do the rename again. + */ + if (!g_file_test (filename, G_FILE_TEST_EXISTS)) + { + g_unlink (tmp_filename); + g_propagate_error (error, rename_error); + retval = FALSE; + goto out; + } + + g_error_free (rename_error); + + if (g_unlink (filename) == -1) + { + gchar *display_filename = g_filename_display_name (filename); + + int save_errno = errno; + + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Existing file '%s' could not be removed: g_unlink() failed: %s"), + display_filename, + g_strerror (save_errno)); + + g_free (display_filename); + g_unlink (tmp_filename); + retval = FALSE; + goto out; + } + + if (!rename_file (tmp_filename, filename, error)) + { + g_unlink (tmp_filename); + retval = FALSE; + goto out; + } + +#endif + } + + retval = TRUE; + + out: + g_free (tmp_filename); + return retval; +} +#endif + /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/lib/glib-utils.h diff -u tomoe/lib/glib-utils.h:1.5 tomoe/lib/glib-utils.h:1.6 --- tomoe/lib/glib-utils.h:1.5 Mon Nov 27 17:52:01 2006 +++ tomoe/lib/glib-utils.h Mon Dec 18 11:15:17 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.h,v 1.5 2006/11/27 08:52:01 kous Exp $ + * $Id: glib-utils.h,v 1.6 2006/12/18 02:15:17 kous Exp $ */ @@ -47,6 +47,13 @@ GFunc func, gpointer user_data); +#if !GLIB_CHECK_VERSION(2, 8, 10) +gboolean g_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + GError **error); +#endif + G_END_DECLS #endif /* __GLIB_UTILS_H__ */ From kous users.sourceforge.jp Mon Dec 18 11:29:07 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:29:07 +0900 Subject: [Tomoe-cvs 1936] CVS update: tomoe/lib Message-ID: <20061218022907.DF4A12AC06D@users.sourceforge.jp> Index: tomoe/lib/glib-utils.c diff -u tomoe/lib/glib-utils.c:1.3 tomoe/lib/glib-utils.c:1.4 --- tomoe/lib/glib-utils.c:1.3 Mon Dec 18 11:15:17 2006 +++ tomoe/lib/glib-utils.c Mon Dec 18 11:29:07 2006 @@ -17,10 +17,25 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.c,v 1.3 2006/12/18 02:15:17 kous Exp $ + * $Id: glib-utils.c,v 1.4 2006/12/18 02:29:07 kous Exp $ */ +#include +#include +#include +#include +#include +#include +#include + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #include +#include +#include + #include "glib-utils.h" void @@ -36,8 +51,205 @@ } } -#if !GLIB_CHECK_VERSION(2, 8, 10) +#if !GLIB_CHECK_VERSION(2, 8, 0) /* copied from GLib. */ + +/* + * create_temp_file based on the mkstemp implementation from the GNU C library. + * Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc. + */ +static gint +create_temp_file (gchar *tmpl, + int permissions) +{ + char *XXXXXX; + int count, fd; + static const char letters[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + static const int NLETTERS = sizeof (letters) - 1; + glong value; + GTimeVal tv; + static int counter = 0; + + /* find the last occurrence of "XXXXXX" */ + XXXXXX = g_strrstr (tmpl, "XXXXXX"); + + if (!XXXXXX || strncmp (XXXXXX, "XXXXXX", 6)) + { + errno = EINVAL; + return -1; + } + + /* Get some more or less random data. */ + g_get_current_time (&tv); + value = (tv.tv_usec ^ tv.tv_sec) + counter++; + + for (count = 0; count < 100; value += 7777, ++count) + { + glong v = value; + + /* Fill in the random bits. */ + XXXXXX[0] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[1] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[2] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[3] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[4] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[5] = letters[v % NLETTERS]; + + /* tmpl is in UTF-8 on Windows, thus use g_open() */ + fd = g_open (tmpl, O_RDWR | O_CREAT | O_EXCL | O_BINARY, permissions); + + if (fd >= 0) + return fd; + else if (errno != EEXIST) + /* Any other error will apply also to other names we might + * try, and there are 2^32 or so of them, so give up now. + */ + return -1; + } + + /* We got out of the loop because we ran out of combinations to try. */ + errno = EEXIST; + return -1; +} + +static gchar * +write_to_temp_file (const gchar *contents, + gssize length, + const gchar *template, + GError **err) +{ + gchar *tmp_name; + gchar *display_name; + gchar *retval; + FILE *file; + gint fd; + int save_errno; + + retval = NULL; + + tmp_name = g_strdup_printf ("%s.XXXXXX", template); + + errno = 0; + fd = create_temp_file (tmp_name, 0666); + display_name = g_filename_display_name (tmp_name); + + if (fd == -1) + { + save_errno = errno; + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to create file '%s': %s"), + display_name, g_strerror (save_errno)); + + goto out; + } + + errno = 0; + file = fdopen (fd, "wb"); + if (!file) + { + save_errno = errno; + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to open file '%s' for writing: fdopen() failed: %s"), + display_name, + g_strerror (save_errno)); + + close (fd); + g_unlink (tmp_name); + + goto out; + } + + if (length > 0) + { + size_t n_written; + + errno = 0; + + n_written = fwrite (contents, 1, length, file); + + if (n_written < length) + { + save_errno = errno; + + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to write file '%s': fwrite() failed: %s"), + display_name, + g_strerror (save_errno)); + + fclose (file); + g_unlink (tmp_name); + + goto out; + } + } + + errno = 0; + if (fclose (file) == EOF) + { + save_errno = 0; + + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to close file '%s': fclose() failed: %s"), + display_name, + g_strerror (save_errno)); + + g_unlink (tmp_name); + + goto out; + } + + retval = g_strdup (tmp_name); + + out: + g_free (tmp_name); + g_free (display_name); + + return retval; +} + +static gboolean +rename_file (const char *old_name, + const char *new_name, + GError **err) +{ + errno = 0; + if (g_rename (old_name, new_name) == -1) + { + int save_errno = errno; + gchar *display_old_name = g_filename_display_name (old_name); + gchar *display_new_name = g_filename_display_name (new_name); + + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to rename file '%s' to '%s': g_rename() failed: %s"), + display_old_name, + display_new_name, + g_strerror (save_errno)); + + g_free (display_old_name); + g_free (display_new_name); + + return FALSE; + } + + return TRUE; +} + gboolean g_file_set_contents (const gchar *filename, const gchar *contents, Index: tomoe/lib/glib-utils.h diff -u tomoe/lib/glib-utils.h:1.6 tomoe/lib/glib-utils.h:1.7 --- tomoe/lib/glib-utils.h:1.6 Mon Dec 18 11:15:17 2006 +++ tomoe/lib/glib-utils.h Mon Dec 18 11:29:07 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.h,v 1.6 2006/12/18 02:15:17 kous Exp $ + * $Id: glib-utils.h,v 1.7 2006/12/18 02:29:07 kous Exp $ */ @@ -47,7 +47,7 @@ GFunc func, gpointer user_data); -#if !GLIB_CHECK_VERSION(2, 8, 10) +#if !GLIB_CHECK_VERSION(2, 8, 0) gboolean g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, From kous users.sourceforge.jp Mon Dec 18 11:40:15 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:40:15 +0900 Subject: [Tomoe-cvs 1937] CVS update: tomoe Message-ID: <20061218024015.182332AC06D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.456 tomoe/ChangeLog:1.457 --- tomoe/ChangeLog:1.456 Mon Dec 18 11:15:16 2006 +++ tomoe/ChangeLog Mon Dec 18 11:40:14 2006 @@ -1,5 +1,9 @@ 2006-12-18 Kouhei Sutou + * lib/tomoe-context.c (ensure_user_dict_file_content), + module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): used + g_file_set_contents(). + * lib/glib-utils.[ch] (g_file_set_contents): copied from GLib. * lib/tomoe-writing.c (tomoe_point_get_type): don't use From kous users.sourceforge.jp Mon Dec 18 11:40:15 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:40:15 +0900 Subject: [Tomoe-cvs 1938] CVS update: tomoe/lib Message-ID: <20061218024015.451042AC07F@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.52 tomoe/lib/tomoe-context.c:1.53 --- tomoe/lib/tomoe-context.c:1.52 Tue Dec 12 22:40:09 2006 +++ tomoe/lib/tomoe-context.c Mon Dec 18 11:40:15 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.52 2006/12/12 13:40:09 kous Exp $ + * $Id: tomoe-context.c,v 1.53 2006/12/18 02:40:15 kous Exp $ */ #include @@ -182,24 +182,15 @@ ensure_user_dict_file_content (const gchar *user_dict_filename) { if (!g_file_test (user_dict_filename, G_FILE_TEST_EXISTS)) { - FILE *f; const gchar *content; - - f = fopen (user_dict_filename, "wb"); - if (!f) { - g_warning ("failed to open %s: %s", - user_dict_filename, strerror (errno)); - return FALSE; - } + GError *error = NULL; content = DEFAULT_USER_DICT_CONTENT; - if (fwrite (content, strlen (content), 1, f) < 1) { - g_warning ("failed to write to %s: %s", - user_dict_filename, strerror (errno)); + if (!g_file_set_contents (user_dict_filename, + content, strlen (content), &error)) { + TOMOE_HANDLE_ERROR (error); return FALSE; } - - fclose (f); } return TRUE; From kous users.sourceforge.jp Mon Dec 18 11:40:15 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:40:15 +0900 Subject: [Tomoe-cvs 1939] CVS update: tomoe/module/dict Message-ID: <20061218024015.6E5962AC06D@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.14 tomoe/module/dict/tomoe-dict-xml.c:1.15 --- tomoe/module/dict/tomoe-dict-xml.c:1.14 Fri Dec 15 12:20:36 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Mon Dec 18 11:40:15 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.14 2006/12/15 03:20:36 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.15 2006/12/18 02:40:15 kous Exp $ */ #include @@ -405,62 +405,44 @@ static gboolean tomoe_dict_xml_save (TomoeDictXML *dict) { - FILE *f; - gchar *head; - const gchar *foot = "\n"; + GString *xml; + GError *error = NULL; + gboolean success; guint i; g_return_val_if_fail (TOMOE_IS_DICT (dict), FALSE); if (!dict->editable) return FALSE; - f = fopen (dict->filename, "wb"); - if (!f) { - g_warning ("can't open %s: %s", dict->filename, strerror (errno)); - return FALSE; - } - - /* write the header */ - head = g_strdup ( + xml = g_string_new ( "\n" "\n"); - if (fwrite (head, strlen (head), 1, f) < 1) goto ERROR; - g_free (head); - if (dict->name) - head = g_markup_printf_escaped ("\n", - dict->name); + g_string_append_printf (xml, + "\n", dict->name); else - head = g_strdup ("\n"); - if (fwrite (head, strlen (head), 1, f) < 1) goto ERROR; + g_string_append (xml, "\n"); - /* write each characters */ for (i = 0; i < dict->chars->len; i++) { - gchar *xml; - gboolean failed; - TomoeChar* chr = (TomoeChar*)g_ptr_array_index (dict->chars, i); - - xml = tomoe_char_to_xml (chr); - if (!xml) goto ERROR; - - failed = fwrite (xml, strlen (xml), 1, f) < 1; - g_free (xml); - if (failed) goto ERROR; + gchar *chr_xml; + TomoeChar *chr = g_ptr_array_index (dict->chars, i); + + chr_xml = tomoe_char_to_xml (chr); + if (chr_xml) { + g_string_append (xml, chr_xml); + g_free (chr_xml); + } } - /* close root element */ - if (fwrite (foot, strlen (foot), 1, f) < 1) goto ERROR; + g_string_append (xml, "\n"); - /* clean */ - g_free (head); - fclose (f); - dict->modified = FALSE; - return TRUE; + success = g_file_set_contents (dict->filename, xml->str, xml->len, &error); + if (success) + dict->modified = FALSE; + else + TOMOE_HANDLE_ERROR (error); -ERROR: - g_free (head); - g_warning ("Faild to write %s.", dict->filename); - fclose (f); - return FALSE; + g_string_free (xml, TRUE); + return success; } /* From kous users.sourceforge.jp Mon Dec 18 11:53:32 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:53:32 +0900 Subject: [Tomoe-cvs 1940] CVS update: tomoe Message-ID: <20061218025332.EC1DD2AC07F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.457 tomoe/ChangeLog:1.458 --- tomoe/ChangeLog:1.457 Mon Dec 18 11:40:14 2006 +++ tomoe/ChangeLog Mon Dec 18 11:53:32 2006 @@ -1,5 +1,9 @@ 2006-12-18 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c: + - cleanup if can't connect to server. + - check connection before action. + * lib/tomoe-context.c (ensure_user_dict_file_content), module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): used g_file_set_contents(). From kous users.sourceforge.jp Mon Dec 18 11:53:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 11:53:33 +0900 Subject: [Tomoe-cvs 1941] CVS update: tomoe/module/dict Message-ID: <20061218025333.2565E2AC12A@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.9 tomoe/module/dict/tomoe-dict-mysql.c:1.10 --- tomoe/module/dict/tomoe-dict-mysql.c:1.9 Mon Dec 18 10:02:06 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 18 11:53:33 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.9 2006/12/18 01:02:06 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.10 2006/12/18 02:53:33 kous Exp $ */ #include @@ -41,6 +41,8 @@ #define TOMOE_IS_DICT_MYSQL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICT_MYSQL)) #define TOMOE_DICT_MYSQL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOMOE_TYPE_DICT_MYSQL, TomoeDictMySQLClass)) +#define TOMOE_DICT_MYSQL_IS_CONNECTED(dict) (dict->mysql) + enum { PROP_0, PROP_NAME, @@ -568,7 +570,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), FALSE); g_return_val_if_fail (TOMOE_IS_CHAR (chr), FALSE); - g_return_val_if_fail (dict->mysql, FALSE); + g_return_val_if_fail (TOMOE_DICT_MYSQL_IS_CONNECTED (dict), FALSE); if (!execute_query (dict, "START TRANSACTION")) return FALSE; @@ -615,7 +617,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), FALSE); g_return_val_if_fail (utf8 && *utf8 != '\0', FALSE); - g_return_val_if_fail (dict->mysql, FALSE); + g_return_val_if_fail (TOMOE_DICT_MYSQL_IS_CONNECTED (dict), FALSE); if (!execute_query (dict, "START TRANSACTION")) return FALSE; @@ -863,7 +865,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), chr); g_return_val_if_fail (utf8 && utf8[0] != '\0', chr); - g_return_val_if_fail (dict->mysql, chr); + g_return_val_if_fail (TOMOE_DICT_MYSQL_IS_CONNECTED (dict), chr); query = tomoe_query_new (); tomoe_query_set_utf8 (query, utf8); @@ -891,7 +893,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), results); g_return_val_if_fail (TOMOE_IS_QUERY (query), results); - g_return_val_if_fail (dict->mysql, results); + g_return_val_if_fail (TOMOE_DICT_MYSQL_IS_CONNECTED (dict), results); sql = generate_sql (dict, query); success = execute_query (dict, sql); @@ -936,6 +938,7 @@ MYSQL_RES *result; g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), NULL); + g_return_val_if_fail (TOMOE_DICT_MYSQL_IS_CONNECTED (dict), NULL); len = g_unichar_to_utf8 (TOMOE_CHAR_PRIVATE_USE_AREA_START, pua_start_utf8); pua_start_utf8[len] = '\0'; @@ -977,14 +980,15 @@ return FALSE; } - mysql_options(dict->mysql, MYSQL_READ_DEFAULT_GROUP, "TOMOE"); - mysql_options(dict->mysql, MYSQL_SET_CHARSET_NAME, "UTF8"); + mysql_options (dict->mysql, MYSQL_READ_DEFAULT_GROUP, "TOMOE"); + mysql_options (dict->mysql, MYSQL_SET_CHARSET_NAME, "UTF8"); if (!mysql_real_connect (dict->mysql, dict->host, dict->user, dict->password, dict->database, dict->port, dict->socket, 0)) { g_warning ("cannot connect to %s at %s:%d/%s by %s XXX: %s", dict->database, dict->host, dict->port, dict->socket, dict->user, mysql_error (dict->mysql)); + tomoe_dict_mysql_close (dict); return FALSE; } From kous users.sourceforge.jp Mon Dec 18 13:56:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 13:56:57 +0900 Subject: [Tomoe-cvs 1942] CVS update: tomoe Message-ID: <20061218045657.4AA9F2AC01A@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.458 tomoe/ChangeLog:1.459 --- tomoe/ChangeLog:1.458 Mon Dec 18 11:53:32 2006 +++ tomoe/ChangeLog Mon Dec 18 13:56:57 2006 @@ -3,6 +3,7 @@ * module/dict/tomoe-dict-mysql.c: - cleanup if can't connect to server. - check connection before action. + - retry if charset can't be specified. * lib/tomoe-context.c (ensure_user_dict_file_content), module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): used From kous users.sourceforge.jp Mon Dec 18 13:56:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 13:56:57 +0900 Subject: [Tomoe-cvs 1943] CVS update: tomoe/module/dict Message-ID: <20061218045657.77EC62AC052@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.10 tomoe/module/dict/tomoe-dict-mysql.c:1.11 --- tomoe/module/dict/tomoe-dict-mysql.c:1.10 Mon Dec 18 11:53:33 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Mon Dec 18 13:56:57 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.10 2006/12/18 02:53:33 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.11 2006/12/18 04:56:57 kous Exp $ */ #include @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -982,9 +983,17 @@ mysql_options (dict->mysql, MYSQL_READ_DEFAULT_GROUP, "TOMOE"); mysql_options (dict->mysql, MYSQL_SET_CHARSET_NAME, "UTF8"); - if (!mysql_real_connect (dict->mysql, dict->host, dict->user, - dict->password, dict->database, dict->port, - dict->socket, 0)) { + + while (!mysql_real_connect (dict->mysql, dict->host, dict->user, + dict->password, dict->database, dict->port, + dict->socket, 0)) { + if (mysql_errno (dict->mysql) == CR_CANT_READ_CHARSET) { + g_warning ("cannot set charset to UTF8"); + g_free (dict->mysql->options.charset_name); + dict->mysql->options.charset_name = NULL; + continue; + } + g_warning ("cannot connect to %s at %s:%d/%s by %s XXX: %s", dict->database, dict->host, dict->port, dict->socket, dict->user, mysql_error (dict->mysql)); From kous users.sourceforge.jp Mon Dec 18 14:23:45 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 14:23:45 +0900 Subject: [Tomoe-cvs 1944] CVS update: tomoe Message-ID: <20061218052345.9B8252AC015@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.459 tomoe/ChangeLog:1.460 --- tomoe/ChangeLog:1.459 Mon Dec 18 13:56:57 2006 +++ tomoe/ChangeLog Mon Dec 18 14:23:45 2006 @@ -1,5 +1,7 @@ 2006-12-18 Kouhei Sutou + * configure.in: 0.4.0 -> 0.5.0. + * module/dict/tomoe-dict-mysql.c: - cleanup if can't connect to server. - check connection before action. Index: tomoe/configure.in diff -u tomoe/configure.in:1.48 tomoe/configure.in:1.49 --- tomoe/configure.in:1.48 Tue Dec 12 10:51:09 2006 +++ tomoe/configure.in Mon Dec 18 14:23:45 2006 @@ -2,7 +2,7 @@ AC_PREREQ(2.57) m4_define([tomoe_major_version], [0]) -m4_define([tomoe_minor_version], [4]) +m4_define([tomoe_minor_version], [5]) m4_define([tomoe_micro_version], [0]) m4_define([tomoe_version], [tomoe_major_version.tomoe_minor_version.tomoe_micro_version]) From kous users.sourceforge.jp Mon Dec 18 15:19:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:19:46 +0900 Subject: [Tomoe-cvs 1945] CVS update: tomoe Message-ID: <20061218061946.BF9632AC03E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.460 tomoe/ChangeLog:1.461 --- tomoe/ChangeLog:1.460 Mon Dec 18 14:23:45 2006 +++ tomoe/ChangeLog Mon Dec 18 15:19:46 2006 @@ -1,6 +1,9 @@ 2006-12-18 Kouhei Sutou - * configure.in: 0.4.0 -> 0.5.0. + * configure.in: + - 0.4.0 -> 0.5.0. + - enabled static library. + - don't expand configure time. * module/dict/tomoe-dict-mysql.c: - cleanup if can't connect to server. Index: tomoe/configure.in diff -u tomoe/configure.in:1.49 tomoe/configure.in:1.50 --- tomoe/configure.in:1.49 Mon Dec 18 14:23:45 2006 +++ tomoe/configure.in Mon Dec 18 15:19:46 2006 @@ -12,7 +12,7 @@ AM_CONFIG_HEADER(config.h) AC_ENABLE_SHARED(yes) -AC_ENABLE_STATIC(no) +AC_ENABLE_STATIC(yes) AM_PROG_LIBTOOL TOMOE_VERSION=tomoe_version @@ -153,19 +153,17 @@ dnl Configure for configuration. dnl ************************************************************** -confdir="${sysconfdir}/\$(PACKAGE)" +confdir="\${sysconfdir}/\$(PACKAGE)" AC_SUBST(confdir) dnl ************************************************************** dnl Configure for data. dnl ************************************************************** -datadir="${datadir}/\$(PACKAGE)" - -dict_datadir="${datadir}/dict" +dict_datadir="\${pkgdatadir}/dict" AC_SUBST(dict_datadir) -recognizer_datadir="${datadir}/recognizer" +recognizer_datadir="\${pkgdatadir}/recognizer" AC_SUBST(recognizer_datadir) dnl ************************************************************** @@ -267,21 +265,21 @@ dnl Configure for modules. dnl ************************************************************** -moduledir="${libdir}/\$(PACKAGE)/module" +moduledir="\${libdir}/\$(PACKAGE)/module" AC_SUBST(moduledir) dnl ************************************************************** dnl Configure for recognizer modules. dnl ************************************************************** -recognizer_moduledir="${moduledir}/recognizer" +recognizer_moduledir="\${moduledir}/recognizer" AC_SUBST(recognizer_moduledir) dnl ************************************************************** dnl Configure for dictionary modules. dnl ************************************************************** -dict_moduledir="${moduledir}/dict" +dict_moduledir="\${moduledir}/dict" AC_SUBST(dict_moduledir) dnl ************************************************************** From kous users.sourceforge.jp Mon Dec 18 15:26:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:26:41 +0900 Subject: [Tomoe-cvs 1946] CVS update: tomoe Message-ID: <20061218062641.1F58B2AC072@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.461 tomoe/ChangeLog:1.462 --- tomoe/ChangeLog:1.461 Mon Dec 18 15:19:46 2006 +++ tomoe/ChangeLog Mon Dec 18 15:26:40 2006 @@ -1,5 +1,9 @@ 2006-12-18 Kouhei Sutou + * data/dict.dtd: renamed from tomoe-dict.dtd. + * data/Makefile.am, data/kanjidic2-original.xsl, + data/handwriting.xml, lib/tomoe-context.c: followed the changes. + * configure.in: - 0.4.0 -> 0.5.0. - enabled static library. From kous users.sourceforge.jp Mon Dec 18 15:26:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:26:41 +0900 Subject: [Tomoe-cvs 1947] CVS update: tomoe/data Message-ID: <20061218062641.C8E8A2AC072@users.sourceforge.jp> Index: tomoe/data/Makefile.am diff -u tomoe/data/Makefile.am:1.22 tomoe/data/Makefile.am:1.23 --- tomoe/data/Makefile.am:1.22 Wed Dec 6 18:00:59 2006 +++ tomoe/data/Makefile.am Mon Dec 18 15:26:41 2006 @@ -20,7 +20,7 @@ CLEANFILES = *~ *.bak *.valid -data_DATA = tomoe-dict.dtd +pkgdata_DATA = dict.dtd dict_data_DATA = recognizer_data_DATA = handwriting.xml conf_DATA = config @@ -28,7 +28,7 @@ EXTRA_DIST = \ kanjidic2-original.xml kanjidic2-original.xsl \ kanjidic2.xml \ - $(data_DATA) \ + $(pkgdata_DATA) \ $(dict_data_DATA) \ $(recognizer_data_DATA) \ $(conf_DATA) Index: tomoe/data/dict.dtd diff -u /dev/null tomoe/data/dict.dtd:1.1 --- /dev/null Mon Dec 18 15:26:41 2006 +++ tomoe/data/dict.dtd Mon Dec 18 15:26:41 2006 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + Index: tomoe/data/handwriting.xml diff -u tomoe/data/handwriting.xml:1.1 tomoe/data/handwriting.xml:1.2 --- tomoe/data/handwriting.xml:1.1 Tue Dec 5 14:07:16 2006 +++ tomoe/data/handwriting.xml Mon Dec 18 15:26:41 2006 @@ -1,5 +1,5 @@ - + Index: tomoe/data/kanjidic2-original.xsl diff -u tomoe/data/kanjidic2-original.xsl:1.4 tomoe/data/kanjidic2-original.xsl:1.5 --- tomoe/data/kanjidic2-original.xsl:1.4 Fri Dec 1 16:28:04 2006 +++ tomoe/data/kanjidic2-original.xsl Mon Dec 18 15:26:41 2006 @@ -1,6 +1,6 @@ - + Index: tomoe/data/tomoe-dict.dtd diff -u tomoe/data/tomoe-dict.dtd:1.4 tomoe/data/tomoe-dict.dtd:removed --- tomoe/data/tomoe-dict.dtd:1.4 Mon Nov 27 15:58:39 2006 +++ tomoe/data/tomoe-dict.dtd Mon Dec 18 15:26:41 2006 @@ -1,21 +0,0 @@ - - - - - - - - - - - - - From kous users.sourceforge.jp Mon Dec 18 15:26:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:26:41 +0900 Subject: [Tomoe-cvs 1948] CVS update: tomoe/lib Message-ID: <20061218062641.EE82A2AC07F@users.sourceforge.jp> Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.53 tomoe/lib/tomoe-context.c:1.54 --- tomoe/lib/tomoe-context.c:1.53 Mon Dec 18 11:40:15 2006 +++ tomoe/lib/tomoe-context.c Mon Dec 18 15:26:41 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.53 2006/12/18 02:40:15 kous Exp $ + * $Id: tomoe-context.c,v 1.54 2006/12/18 06:26:41 kous Exp $ */ #include @@ -36,7 +36,7 @@ #define DEFAULT_USER_DICT_CONTENT \ "\n" \ -"\n" \ +"\n" \ "\n" \ "\n" From kous users.sourceforge.jp Mon Dec 18 15:41:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:41:11 +0900 Subject: [Tomoe-cvs 1949] CVS update: tomoe Message-ID: <20061218064111.610972AC015@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.462 tomoe/ChangeLog:1.463 --- tomoe/ChangeLog:1.462 Mon Dec 18 15:26:40 2006 +++ tomoe/ChangeLog Mon Dec 18 15:41:11 2006 @@ -1,5 +1,8 @@ 2006-12-18 Kouhei Sutou + * lib/tomoe-config.c (_tomoe_config_load_system_dictionaries): + added error check. + * data/dict.dtd: renamed from tomoe-dict.dtd. * data/Makefile.am, data/kanjidic2-original.xsl, data/handwriting.xml, lib/tomoe-context.c: followed the changes. From kous users.sourceforge.jp Mon Dec 18 15:41:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:41:11 +0900 Subject: [Tomoe-cvs 1950] CVS update: tomoe/lib Message-ID: <20061218064111.984DF2AC03E@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.54 tomoe/lib/tomoe-config.c:1.55 --- tomoe/lib/tomoe-config.c:1.54 Tue Dec 12 19:08:11 2006 +++ tomoe/lib/tomoe-config.c Mon Dec 18 15:41:11 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.54 2006/12/12 10:08:11 kous Exp $ + * $Id: tomoe-config.c,v 1.55 2006/12/18 06:41:11 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -428,6 +428,9 @@ } gdir = g_dir_open (DICT_DATADIR, 0, NULL); + if (!gdir) + return; + while ((filename = g_dir_read_name (gdir))) { gchar *path; From kous users.sourceforge.jp Mon Dec 18 15:45:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:45:03 +0900 Subject: [Tomoe-cvs 1951] CVS update: tomoe Message-ID: <20061218064504.CE5DC2AC015@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.463 tomoe/ChangeLog:1.464 --- tomoe/ChangeLog:1.463 Mon Dec 18 15:41:11 2006 +++ tomoe/ChangeLog Mon Dec 18 15:45:03 2006 @@ -1,5 +1,7 @@ 2006-12-18 Kouhei Sutou + * tomoe.spec.in: added. + * lib/tomoe-config.c (_tomoe_config_load_system_dictionaries): added error check. Index: tomoe/tomoe.spec.in diff -u /dev/null tomoe/tomoe.spec.in:1.1 --- /dev/null Mon Dec 18 15:45:03 2006 +++ tomoe/tomoe.spec.in Mon Dec 18 15:45:03 2006 @@ -0,0 +1,92 @@ +# -*- coding:utf-8-unix -*- +# +# $Id: tomoe.spec.in,v 1.1 2006/12/18 06:45:03 kous Exp $ +# +# Copyright (c) 2006 Kouhei Sutou +# This file and all modifications and/or additions are under +# the same license as package itself. +# + +Name: tomoe +Version: @VERSION@ +Release: 0 +Serial: 2006121801 + +Summary: Tegaki Online MOji-ninshiki Engine +Summary(ja_JP.utf8): ??????????????Tomoe +URL: http://tomoe.sourceforge.jp/ +Source0: %{name}-%{version}.tar.gz +License: LGPL +Group: System Environment/Libraries +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +Requires: /sbin/ldconfig +BuildRequires: pkgconfig +BuildRequires: glib2-devel +BuildRequires: mysql-devel + +%description +Tomoe provides a handwriting recognition engine and its user interface on open source desktop environment. + +%description -l ja_JP.utf8 +Tomoe???????????????????????????????????????????????+ +%package devel +Summary: Tomoe developmental libraries and header files +Summary(ja_JP.utf8): Tomoe?????????????????????? +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: glib2-devel +Requires: mysql-devel + +%description devel +Developmental libraries and header files required for developing or +compiling software which links to the Tomoe library, which is an open +source handwriting recognition engine. + +%description devel -l ja_JP.utf8 +Tomoe????????????????????????????????????????????????? +??????????????Tomoe????????????????????????????+ +%prep +%setup -q + +%build +%configure --without-ruby +make + +%install +rm -rf $RPM_BUILD_ROOT + +%makeinstall +rm $RPM_BUILD_ROOT%{_libdir}/*.la +rm $RPM_BUILD_ROOT%{_libdir}/*.a + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root,-) +#%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO +%doc AUTHORS ChangeLog COPYING NEWS TODO + +%{_libdir}/libtomoe*.so.* +%{_libdir}/tomoe/module/dict/* +%{_libdir}/tomoe/module/recognizer/* +%{_sysconfdir}/tomoe/* +%{_datadir}/tomoe/dict.dtd +%{_datadir}/tomoe/recognizer/* + +%files devel +%defattr(-,root,root,-) +%{_includedir}/* +%{_libdir}/libtomoe*.so +%{_libdir}/pkgconfig/* +%{_datadir}/gtk-doc/* + +%changelog +* Mon Dec 18 2006 Kouhei Sutou - 0.5.0-0 +- initial release. Index: tomoe/configure.in diff -u tomoe/configure.in:1.50 tomoe/configure.in:1.51 --- tomoe/configure.in:1.50 Mon Dec 18 15:19:46 2006 +++ tomoe/configure.in Mon Dec 18 15:45:03 2006 @@ -383,7 +383,7 @@ TOMOE_CFLAGS="$TOMOE_CFLAGS \$(GLIB_CFLAGS)" TOMOE_CFLAGS="$TOMOE_CFLAGS -DCONFDIR=\\\"\"\$(confdir)\"\\\"" -TOMOE_CFLAGS="$TOMOE_CFLAGS -DDATADIR=\\\"\"\$(datadir)\"\\\"" +TOMOE_CFLAGS="$TOMOE_CFLAGS -DDATADIR=\\\"\"\$(pkgdatadir)\"\\\"" TOMOE_CFLAGS="$TOMOE_CFLAGS -DDICT_DATADIR=\\\"\"\$(dict_datadir)\"\\\"" TOMOE_CFLAGS="$TOMOE_CFLAGS -DRECOGNIZER_DATADIR=\\\"\"\$(recognizer_datadir)\"\\\"" TOMOE_CFLAGS="$TOMOE_CFLAGS -DDICT_MODULEDIR=\\\"\"\$(dict_moduledir)\"\\\"" @@ -410,6 +410,7 @@ doc/reference/Makefile doc/reference/version.xml tomoe.pc +tomoe.spec ]) AC_OUTPUT From kous users.sourceforge.jp Mon Dec 18 15:57:15 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 18 Dec 2006 15:57:15 +0900 Subject: [Tomoe-cvs 1952] CVS update: tomoe Message-ID: <20061218065715.E13412AC029@users.sourceforge.jp> Index: tomoe/tomoe.spec.in diff -u tomoe/tomoe.spec.in:1.1 tomoe/tomoe.spec.in:1.2 --- tomoe/tomoe.spec.in:1.1 Mon Dec 18 15:45:03 2006 +++ tomoe/tomoe.spec.in Mon Dec 18 15:57:15 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.1 2006/12/18 06:45:03 kous Exp $ +# $Id: tomoe.spec.in,v 1.2 2006/12/18 06:57:15 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -21,15 +21,19 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root Requires: /sbin/ldconfig +Requires: mysql-client BuildRequires: pkgconfig BuildRequires: glib2-devel BuildRequires: mysql-devel -%description -Tomoe provides a handwriting recognition engine and its user interface on open source desktop environment. +%description +Tomoe provides a handwriting recognition engine and its user +interface on open source desktop environment. + %description -l ja_JP.utf8 -Tomoe???????????????????????????????????????????????+Tomoe????????????????????????????????? +?????????????? %package devel Summary: Tomoe developmental libraries and header files @@ -52,13 +56,13 @@ %setup -q %build -%configure --without-ruby +%configure --without-ruby --enable-mysql make %install rm -rf $RPM_BUILD_ROOT -%makeinstall +%makeinstall rm $RPM_BUILD_ROOT%{_libdir}/*.la rm $RPM_BUILD_ROOT%{_libdir}/*.a Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.464 tomoe/ChangeLog:1.465 --- tomoe/ChangeLog:1.464 Mon Dec 18 15:45:03 2006 +++ tomoe/ChangeLog Mon Dec 18 15:57:15 2006 @@ -1,6 +1,8 @@ 2006-12-18 Kouhei Sutou - * tomoe.spec.in: added. + * tomoe.spec.in: + - added. + - updated dependencies. * lib/tomoe-config.c (_tomoe_config_load_system_dictionaries): added error check. From makeinu users.sourceforge.jp Mon Dec 18 16:39:02 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 18 Dec 2006 16:39:02 +0900 Subject: [Tomoe-cvs 1953] CVS update: libtomoe-gtk Message-ID: <20061218073902.EE4662AC015@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.253 libtomoe-gtk/ChangeLog:1.254 --- libtomoe-gtk/ChangeLog:1.253 Tue Dec 12 10:52:51 2006 +++ libtomoe-gtk/ChangeLog Mon Dec 18 16:39:02 2006 @@ -1,3 +1,7 @@ +2006-12-18 Takuro Ashie + + * configure.ac: Bump version number. + 2006-12-12 Takuro Ashie * src/tomoe-handwriting.c: Don't stretch the height of the candidates Index: libtomoe-gtk/configure.ac diff -u libtomoe-gtk/configure.ac:1.15 libtomoe-gtk/configure.ac:1.16 --- libtomoe-gtk/configure.ac:1.15 Fri Dec 1 12:09:27 2006 +++ libtomoe-gtk/configure.ac Mon Dec 18 16:39:02 2006 @@ -3,7 +3,7 @@ AC_PREREQ(2.59) -AC_INIT([libtomoe-gtk], 0.4.0, [daih users.sourceforge.jp]) +AC_INIT([libtomoe-gtk], 0.5.0, [daih users.sourceforge.jp]) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION, no-define) # libtool From makeinu users.sourceforge.jp Mon Dec 18 16:39:03 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Mon, 18 Dec 2006 16:39:03 +0900 Subject: [Tomoe-cvs 1954] CVS update: libtomoe-gtk/po Message-ID: <20061218073903.20D9D2AC055@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.14 libtomoe-gtk/po/ja.po:1.15 --- libtomoe-gtk/po/ja.po:1.14 Tue Dec 12 10:01:22 2006 +++ libtomoe-gtk/po/ja.po Mon Dec 18 16:39:02 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-12 09:56+0900\n" +"POT-Creation-Date: 2006-12-12 11:01+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" From kous users.sourceforge.jp Thu Dec 21 11:55:10 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 11:55:10 +0900 Subject: [Tomoe-cvs 1955] CVS update: tomoe Message-ID: <20061221025510.C5AE12AC018@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.465 tomoe/ChangeLog:1.466 --- tomoe/ChangeLog:1.465 Mon Dec 18 15:57:15 2006 +++ tomoe/ChangeLog Thu Dec 21 11:55:10 2006 @@ -1,3 +1,10 @@ +2006-12-21 Kouhei Sutou + + * lib/tomoe-config.c (tomoe_config_load): fixed memory leak. + * lib/tomoe-config.c, data/config, test/tomoe-spec-utils.rb, + test/context_spec.rb: used "-" instead of "_" for key name to work + with GLib 2.12.5. + 2006-12-18 Kouhei Sutou * tomoe.spec.in: From kous users.sourceforge.jp Thu Dec 21 11:55:10 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 11:55:10 +0900 Subject: [Tomoe-cvs 1956] CVS update: tomoe/data Message-ID: <20061221025510.EB9902AC024@users.sourceforge.jp> Index: tomoe/data/config diff -u tomoe/data/config:1.2 tomoe/data/config:1.3 --- tomoe/data/config:1.2 Sat Nov 25 19:43:24 2006 +++ tomoe/data/config Thu Dec 21 11:55:10 2006 @@ -1,2 +1,2 @@ [config] -use_system_dictionaries = true +use-system-dictionaries = true From kous users.sourceforge.jp Thu Dec 21 11:55:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 11:55:11 +0900 Subject: [Tomoe-cvs 1957] CVS update: tomoe/lib Message-ID: <20061221025511.2CA8D2AC018@users.sourceforge.jp> Index: tomoe/lib/tomoe-config.c diff -u tomoe/lib/tomoe-config.c:1.55 tomoe/lib/tomoe-config.c:1.56 --- tomoe/lib/tomoe-config.c:1.55 Mon Dec 18 15:41:11 2006 +++ tomoe/lib/tomoe-config.c Thu Dec 21 11:55:11 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-config.c,v 1.55 2006/12/18 06:41:11 kous Exp $ + * $Id: tomoe-config.c,v 1.56 2006/12/21 02:55:11 kous Exp $ */ #ifdef HAVE_CONFIG_H @@ -223,6 +223,7 @@ G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) { + g_key_file_free (key_file); TOMOE_HANDLE_ERROR (error); return; } @@ -231,7 +232,7 @@ priv->user_dict_name = _tomoe_config_key_file_get_string (key_file, - "config", "user_dictionary", + "config", "user-dictionary", DEFAULT_USER_DICT_NAME); } @@ -330,7 +331,7 @@ g_strfreev(dicts); if (_tomoe_config_key_file_get_boolean (key_file, - "config", "use_system_dictionaries", + "config", "use-system-dictionaries", TRUE)) { _tomoe_config_load_system_dictionaries (config, shelf); } From kous users.sourceforge.jp Thu Dec 21 11:55:11 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 11:55:11 +0900 Subject: [Tomoe-cvs 1958] CVS update: tomoe/test Message-ID: <20061221025511.53BFE2AC024@users.sourceforge.jp> Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.29 tomoe/test/context_spec.rb:1.30 --- tomoe/test/context_spec.rb:1.29 Fri Dec 15 12:19:44 2006 +++ tomoe/test/context_spec.rb Thu Dec 21 11:55:11 2006 @@ -34,8 +34,8 @@ @user_dict_config_file.open @user_dict_config_file.puts(<<-EOC) [config] -use_system_dictionaries = false -user_dictionary = user +use-system-dictionaries = false +user-dictionary = user [user-dictionary] type = xml Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.30 tomoe/test/tomoe-spec-utils.rb:1.31 --- tomoe/test/tomoe-spec-utils.rb:1.30 Mon Dec 18 10:02:07 2006 +++ tomoe/test/tomoe-spec-utils.rb Thu Dec 21 11:55:11 2006 @@ -157,7 +157,7 @@ config_file.open config_file.puts(<<-EOC) [config] -use_system_dictionaries = false +use-system-dictionaries = false EOC config_maker = "make_config_file_for_#{dict_type}" From kous users.sourceforge.jp Thu Dec 21 13:26:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 13:26:26 +0900 Subject: [Tomoe-cvs 1956] CVS update: tomoe Message-ID: <20061221042626.18FAB2AC00E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.466 tomoe/ChangeLog:1.467 --- tomoe/ChangeLog:1.466 Thu Dec 21 11:55:10 2006 +++ tomoe/ChangeLog Thu Dec 21 13:26:25 2006 @@ -1,5 +1,7 @@ 2006-12-21 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c: do ROLLBACK if failed. + * lib/tomoe-config.c (tomoe_config_load): fixed memory leak. * lib/tomoe-config.c, data/config, test/tomoe-spec-utils.rb, test/context_spec.rb: used "-" instead of "_" for key name to work From kous users.sourceforge.jp Thu Dec 21 13:26:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 13:26:26 +0900 Subject: [Tomoe-cvs 1957] CVS update: tomoe/module/dict Message-ID: <20061221042626.470F92AC042@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.11 tomoe/module/dict/tomoe-dict-mysql.c:1.12 --- tomoe/module/dict/tomoe-dict-mysql.c:1.11 Mon Dec 18 13:56:57 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 13:26:26 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.11 2006/12/18 04:56:57 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.12 2006/12/21 04:26:26 kous Exp $ */ #include @@ -604,6 +604,7 @@ register_char_meta_data (dict, utf8, chr)) { return execute_query (dict, "COMMIT"); } else { + execute_query (dict, "ROLLBACK"); return FALSE; } } @@ -646,10 +647,12 @@ done: g_string_free (sql, TRUE); - if (success) + if (success) { return execute_query (dict, "COMMIT"); - else + } else { + execute_query (dict, "ROLLBACK"); return FALSE; + } } static void From kous users.sourceforge.jp Thu Dec 21 13:44:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 13:44:06 +0900 Subject: [Tomoe-cvs 1958] CVS update: tomoe Message-ID: <20061221044406.C3D052AC00E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.467 tomoe/ChangeLog:1.468 --- tomoe/ChangeLog:1.467 Thu Dec 21 13:26:25 2006 +++ tomoe/ChangeLog Thu Dec 21 13:44:06 2006 @@ -1,6 +1,8 @@ 2006-12-21 Kouhei Sutou - * module/dict/tomoe-dict-mysql.c: do ROLLBACK if failed. + * module/dict/tomoe-dict-mysql.c: + - do ROLLBACK if failed. + - fixed a search bug that result set doesn't have all information. * lib/tomoe-config.c (tomoe_config_load): fixed memory leak. * lib/tomoe-config.c, data/config, test/tomoe-spec-utils.rb, From kous users.sourceforge.jp Thu Dec 21 13:44:06 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 13:44:06 +0900 Subject: [Tomoe-cvs 1959] CVS update: tomoe/module/dict Message-ID: <20061221044406.E88DA2AC042@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.12 tomoe/module/dict/tomoe-dict-mysql.c:1.13 --- tomoe/module/dict/tomoe-dict-mysql.c:1.12 Thu Dec 21 13:26:26 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 13:44:06 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.12 2006/12/21 04:26:26 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.13 2006/12/21 04:44:06 kous Exp $ */ #include @@ -656,96 +656,116 @@ } static void -generate_sql_condition_utf8 (TomoeDictMySQL *dict, GString *sql, - TomoeQuery *query) +append_sql_condition_utf8 (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) { const gchar *utf8; utf8 = tomoe_query_get_utf8 (query); if (utf8) { - g_string_append (sql, " AND chars.utf8 = "); + g_string_append (sql, " AND utf8 = "); append_string_value (dict, sql, utf8); + g_string_append (sql, "\n"); } } static void -generate_sql_condition_min_n_strokes (TomoeDictMySQL *dict, GString *sql, - TomoeQuery *query) +append_sql_condition_min_n_strokes (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) { gint min_n_strokes; min_n_strokes = tomoe_query_get_min_n_strokes (query); if (min_n_strokes >= 0) { - g_string_append_printf (sql, " AND n_strokes >= %d", + g_string_append_printf (sql, " AND n_strokes >= %d\n", min_n_strokes); } } static void -generate_sql_condition_max_n_strokes (TomoeDictMySQL *dict, GString *sql, - TomoeQuery *query) +append_sql_condition_max_n_strokes (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) { gint max_n_strokes; max_n_strokes = tomoe_query_get_max_n_strokes (query); if (max_n_strokes >= 0) { - g_string_append_printf (sql, " AND n_strokes <= %d", + g_string_append_printf (sql, " AND n_strokes <= %d\n", max_n_strokes); } } static void -generate_sql_condition_readings (TomoeDictMySQL *dict, GString *sql, - TomoeQuery *query) +append_sql_condition_readings (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) { GList *node; - for (node = (GList *)tomoe_query_get_readings (query); - node; - node = g_list_next (node)) { + node = (GList *)tomoe_query_get_readings (query); + if (!node) + return; + + g_string_append (sql, + " AND utf8 IN\n" + " (SELECT DISTINCT utf8 FROM readings\n" + " WHERE TRUE = TRUE\n"); + for (; node; node = g_list_next (node)) { TomoeReading *tomoe_reading = node->data; TomoeReadingType reading_type; const gchar *reading; reading_type = tomoe_reading_get_reading_type (tomoe_reading); if (reading_type != TOMOE_READING_INVALID) - g_string_append_printf (sql, " AND reading_type = %d", + g_string_append_printf (sql, " AND reading_type = %d\n", reading_type); reading = tomoe_reading_get_reading (tomoe_reading); if (reading) { - g_string_append (sql, " AND reading = "); + g_string_append (sql, " AND reading = "); append_string_value (dict, sql, reading); + g_string_append (sql, "\n"); } } + g_string_append (sql, " )\n"); } +static void +append_utf8_search_sql (TomoeDictMySQL *dict, GString *sql, TomoeQuery *query) +{ + g_string_append (sql, + "SELECT utf8 FROM chars\n" + "WHERE TRUE = TRUE\n"); + append_sql_condition_utf8 (dict, sql, query); + append_sql_condition_min_n_strokes (dict, sql, query); + append_sql_condition_max_n_strokes (dict, sql, query); + + append_sql_condition_readings (dict, sql, query); +} static gchar * generate_sql (TomoeDictMySQL *dict, TomoeQuery *query) { GString *sql; - sql = g_string_new ("SELECT " \ - "chars.utf8 AS utf8, " \ - "chars.n_strokes AS n_strokes, " \ - "chars.variant AS variant, " \ - "readings.id AS reading_id, " \ - "readings.reading_type AS reading_type, " \ - "readings.reading AS reading, " \ - "radicals.id AS radical_id, " \ - "radicals.radical_utf8 AS radical_utf8 " \ - "FROM chars " \ - "LEFT OUTER JOIN readings " \ - "ON chars.utf8 = readings.utf8 " \ - "LEFT OUTER JOIN radicals " \ - "ON chars.utf8 = radicals.utf8 " \ - "WHERE TRUE = TRUE"); - - generate_sql_condition_utf8 (dict, sql, query); - generate_sql_condition_min_n_strokes (dict, sql, query); - generate_sql_condition_max_n_strokes (dict, sql, query); - generate_sql_condition_readings (dict, sql, query); + sql = g_string_new ("SELECT\n" + " chars.utf8 AS utf8,\n" + " chars.n_strokes AS n_strokes,\n" + " chars.variant AS variant,\n" + " readings.id AS reading_id,\n" + " readings.reading_type AS reading_type,\n" + " readings.reading AS reading,\n" + " radicals.id AS radical_id,\n" + " radicals.radical_utf8 AS radical_utf8\n" + "FROM chars\n" + "LEFT OUTER JOIN readings\n" + " ON chars.utf8 = readings.utf8\n" + "LEFT OUTER JOIN radicals\n" + " ON chars.utf8 = radicals.utf8\n" + "WHERE chars.utf8 IN ("); + append_utf8_search_sql (dict, sql, query); + g_string_append (sql, + ")\n" + "ORDER BY chars.utf8 DESC\n"); return g_string_free (sql, FALSE); } @@ -905,7 +925,7 @@ if (!success) return NULL; - result = mysql_use_result (dict->mysql); + result = mysql_store_result (dict->mysql); if (result) { results = retrieve_candidates (dict, result); mysql_free_result (result); From kous users.sourceforge.jp Thu Dec 21 14:17:19 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 14:17:19 +0900 Subject: [Tomoe-cvs 1960] CVS update: tomoe Message-ID: <20061221051719.03C932AC00E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.468 tomoe/ChangeLog:1.469 --- tomoe/ChangeLog:1.468 Thu Dec 21 13:44:06 2006 +++ tomoe/ChangeLog Thu Dec 21 14:17:18 2006 @@ -3,6 +3,7 @@ * module/dict/tomoe-dict-mysql.c: - do ROLLBACK if failed. - fixed a search bug that result set doesn't have all information. + - 30%~50% speed up. * lib/tomoe-config.c (tomoe_config_load): fixed memory leak. * lib/tomoe-config.c, data/config, test/tomoe-spec-utils.rb, From kous users.sourceforge.jp Thu Dec 21 14:17:19 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 14:17:19 +0900 Subject: [Tomoe-cvs 1961] CVS update: tomoe/module/dict Message-ID: <20061221051719.346272AC068@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.13 tomoe/module/dict/tomoe-dict-mysql.c:1.14 --- tomoe/module/dict/tomoe-dict-mysql.c:1.13 Thu Dec 21 13:44:06 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 14:17:19 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.13 2006/12/21 04:44:06 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.14 2006/12/21 05:17:19 kous Exp $ */ #include @@ -775,10 +775,12 @@ { GList *results = NULL; TomoeChar *chr = NULL; - GArray *reading_ids = NULL, *radical_ids = NULL; + GArray *reading_ids, *radical_ids; gchar *prev_utf8 = NULL; MYSQL_ROW row; + reading_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); + radical_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); while ((row = mysql_fetch_row (result))) { gchar *utf8; gint n_strokes = -1; @@ -811,22 +813,15 @@ chr = NULL; g_free (prev_utf8); prev_utf8 = NULL; - if (reading_ids) - g_array_free (reading_ids, TRUE); - if (radical_ids) - g_array_free (radical_ids, TRUE); - reading_ids = NULL; - radical_ids = NULL; + memset(reading_ids->data, 0, + sizeof(reading_ids->data[0]) * reading_ids->len); + memset(radical_ids->data, 0, + sizeof(radical_ids->data[0]) * radical_ids->len); } if (!prev_utf8) prev_utf8 = g_strdup (utf8); - if (!reading_ids) - reading_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); - if (!radical_ids) - radical_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); - if (!chr) { chr = tomoe_char_new (); tomoe_char_set_utf8 (chr, utf8); @@ -834,29 +829,29 @@ tomoe_char_set_variant (chr, variant); } - if (chr && reading_id >= 0 && - (reading_ids->len <= reading_id || - !reading_ids->data[reading_id])) { - TomoeReading *tomoe_reading; - - if (reading_ids->len <= reading_id) { + if (reading_id >= 0) { + if (reading_ids->len <= reading_id) g_array_set_size (reading_ids, reading_id); - } - reading_ids->data[reading_id] = TRUE; - tomoe_reading = tomoe_reading_new (reading_type, reading); - tomoe_char_add_reading (chr, tomoe_reading); - g_object_unref (tomoe_reading); + if (!reading_ids->data[reading_id]) { + TomoeReading *tomoe_reading; + + reading_ids->data[reading_id] = TRUE; + + tomoe_reading = tomoe_reading_new (reading_type, reading); + tomoe_char_add_reading (chr, tomoe_reading); + g_object_unref (tomoe_reading); + } } - if (chr && radical_id >= 0 && - (radical_ids->len <= radical_id || - !radical_ids->data[radical_id])) { - if (radical_ids->len <= radical_id) { + if (radical_id >= 0) { + if (radical_ids->len <= radical_id) g_array_set_size (radical_ids, radical_id); + + if (!radical_ids->data[radical_id]) { + radical_ids->data[radical_id] = TRUE; + tomoe_char_add_radical (chr, radical); } - radical_ids->data[radical_id] = TRUE; - tomoe_char_add_radical (chr, radical); } } @@ -868,12 +863,9 @@ g_object_unref (chr); } - if (prev_utf8) - g_free (prev_utf8); - if (reading_ids) - g_array_free (reading_ids, TRUE); - if (radical_ids) - g_array_free (radical_ids, TRUE); + g_free (prev_utf8); + g_array_free (reading_ids, TRUE); + g_array_free (radical_ids, TRUE); return results; } From kous users.sourceforge.jp Thu Dec 21 14:26:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 14:26:03 +0900 Subject: [Tomoe-cvs 1962] CVS update: tomoe Message-ID: <20061221052603.E6F122AC00E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.469 tomoe/ChangeLog:1.470 --- tomoe/ChangeLog:1.469 Thu Dec 21 14:17:18 2006 +++ tomoe/ChangeLog Thu Dec 21 14:26:03 2006 @@ -4,6 +4,7 @@ - do ROLLBACK if failed. - fixed a search bug that result set doesn't have all information. - 30%~50% speed up. + - used chars.id to check duplication. * lib/tomoe-config.c (tomoe_config_load): fixed memory leak. * lib/tomoe-config.c, data/config, test/tomoe-spec-utils.rb, From kous users.sourceforge.jp Thu Dec 21 14:26:04 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 14:26:04 +0900 Subject: [Tomoe-cvs 1963] CVS update: tomoe/module/dict Message-ID: <20061221052604.1FD802AC059@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.14 tomoe/module/dict/tomoe-dict-mysql.c:1.15 --- tomoe/module/dict/tomoe-dict-mysql.c:1.14 Thu Dec 21 14:17:19 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 14:26:03 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.14 2006/12/21 05:17:19 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.15 2006/12/21 05:26:03 kous Exp $ */ #include @@ -748,6 +748,7 @@ GString *sql; sql = g_string_new ("SELECT\n" + " chars.id AS char_id,\n" " chars.utf8 AS utf8,\n" " chars.n_strokes AS n_strokes,\n" " chars.variant AS variant,\n" @@ -776,12 +777,13 @@ GList *results = NULL; TomoeChar *chr = NULL; GArray *reading_ids, *radical_ids; - gchar *prev_utf8 = NULL; + gint prev_char_id = -1; MYSQL_ROW row; reading_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); radical_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); while ((row = mysql_fetch_row (result))) { + gint char_id; gchar *utf8; gint n_strokes = -1; gchar *variant; @@ -791,36 +793,36 @@ gint radical_id = -1; gchar *radical; - utf8 = row[0]; - if (row[1]) - n_strokes = atoi (row[1]); - variant = row[2]; - if (row[3]) - reading_id = atoi (row[3]); + char_id = atoi (row[0]); + utf8 = row[1]; + if (row[2]) + n_strokes = atoi (row[2]); + variant = row[3]; if (row[4]) - reading_type = atoi (row[4]); - reading = row[5]; - if (row[6]) - radical_id = atoi (row[6]); - radical = row[7]; + reading_id = atoi (row[4]); + if (row[5]) + reading_type = atoi (row[5]); + reading = row[6]; + if (row[7]) + radical_id = atoi (row[7]); + radical = row[8]; - if (chr && utf8 && prev_utf8 && strcmp (utf8, prev_utf8) != 0) { + if (chr && char_id != prev_char_id) { TomoeCandidate *cand; cand = tomoe_candidate_new (chr); results = g_list_prepend (results, cand); g_object_unref (chr); chr = NULL; - g_free (prev_utf8); - prev_utf8 = NULL; + prev_char_id = -1; memset(reading_ids->data, 0, sizeof(reading_ids->data[0]) * reading_ids->len); memset(radical_ids->data, 0, sizeof(radical_ids->data[0]) * radical_ids->len); } - if (!prev_utf8) - prev_utf8 = g_strdup (utf8); + if (prev_char_id < 0) + prev_char_id = char_id; if (!chr) { chr = tomoe_char_new (); @@ -863,7 +865,6 @@ g_object_unref (chr); } - g_free (prev_utf8); g_array_free (reading_ids, TRUE); g_array_free (radical_ids, TRUE); From kous users.sourceforge.jp Thu Dec 21 15:09:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:09:25 +0900 Subject: [Tomoe-cvs 1964] CVS update: tomoe Message-ID: <20061221060925.E4A5F2AC00E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.470 tomoe/ChangeLog:1.471 --- tomoe/ChangeLog:1.470 Thu Dec 21 14:26:03 2006 +++ tomoe/ChangeLog Thu Dec 21 15:09:25 2006 @@ -1,5 +1,12 @@ 2006-12-21 Kouhei Sutou + * test/dict_spec.rb: added more strict tests. + * ext/ruby/tomoe-rb-dict.c: added + Tomoe::Dict#available_private_utf8. + * db/migrate/001_create_chars.rb: added code_point. + * module/dict/tomoe-dict-mysql.c, module/dict/tomoe-dict-est.c: + fixed to pass the tests. + * module/dict/tomoe-dict-mysql.c: - do ROLLBACK if failed. - fixed a search bug that result set doesn't have all information. Index: tomoe/tomoe.spec.in diff -u tomoe/tomoe.spec.in:1.2 tomoe/tomoe.spec.in:1.3 --- tomoe/tomoe.spec.in:1.2 Mon Dec 18 15:57:15 2006 +++ tomoe/tomoe.spec.in Thu Dec 21 15:09:25 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.2 2006/12/18 06:57:15 kous Exp $ +# $Id: tomoe.spec.in,v 1.3 2006/12/21 06:09:25 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -69,7 +69,7 @@ %clean rm -rf $RPM_BUILD_ROOT -%post -p /sbin/ldconfig +%post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files @@ -77,7 +77,7 @@ #%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO %doc AUTHORS ChangeLog COPYING NEWS TODO -%{_libdir}/libtomoe*.so.* +%{_libdir}/libtomoe*.so.* %{_libdir}/tomoe/module/dict/* %{_libdir}/tomoe/module/recognizer/* %{_sysconfdir}/tomoe/* From kous users.sourceforge.jp Thu Dec 21 15:09:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:09:26 +0900 Subject: [Tomoe-cvs 1965] CVS update: tomoe/test Message-ID: <20061221060926.15F6C2AC068@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.22 tomoe/test/dict_spec.rb:1.23 --- tomoe/test/dict_spec.rb:1.22 Mon Dec 18 10:02:07 2006 +++ tomoe/test/dict_spec.rb Thu Dec 21 15:09:25 2006 @@ -44,13 +44,30 @@ specify "should register/unregister PUA character" do make_temporary_dict(@original) do |dict| - char = Tomoe::Char.new - dict.register(char).should == true - char.utf8.should == ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START) - - dict[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)].should == char - dict.unregister(char.utf8).should == true - dict[ucs4_to_utf8(Tomoe::Char::PRIVATE_USE_AREA_START)].should_nil + pua_start = Tomoe::Char::PRIVATE_USE_AREA_START + + utf8_to_ucs4(dict.available_private_utf8).should == pua_start + + char1 = Tomoe::Char.new + dict.register(char1).should == true + char1.utf8.should == ucs4_to_utf8(pua_start) + utf8_to_ucs4(dict.available_private_utf8).should == pua_start + 1 + + char2 = Tomoe::Char.new + dict.register(char2).should == true + char2.utf8.should == ucs4_to_utf8(pua_start + 1) + utf8_to_ucs4(dict.available_private_utf8).should == pua_start + 2 + + dict[ucs4_to_utf8(pua_start)].should == char1 + dict[ucs4_to_utf8(pua_start + 1)].should == char2 + dict.unregister(char1.utf8).should == true + dict[ucs4_to_utf8(pua_start)].should_nil + dict[ucs4_to_utf8(pua_start + 1)].should == char2 + + char3 = Tomoe::Char.new + dict.register(char3).should == true + char3.utf8.should == ucs4_to_utf8(pua_start + 2) + utf8_to_ucs4(dict.available_private_utf8).should == pua_start + 3 end end From kous users.sourceforge.jp Thu Dec 21 15:09:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:09:26 +0900 Subject: [Tomoe-cvs 1966] CVS update: tomoe/db/migrate Message-ID: <20061221060926.3AB302AC00E@users.sourceforge.jp> Index: tomoe/db/migrate/001_create_chars.rb diff -u tomoe/db/migrate/001_create_chars.rb:1.4 tomoe/db/migrate/001_create_chars.rb:1.5 --- tomoe/db/migrate/001_create_chars.rb:1.4 Tue Dec 12 12:38:25 2006 +++ tomoe/db/migrate/001_create_chars.rb Thu Dec 21 15:09:26 2006 @@ -2,6 +2,7 @@ def self.up create_table(:chars) do |t| t.column :utf8, :string + t.column :code_point, :integer t.column :n_strokes, :integer t.column :variant, :string end From kous users.sourceforge.jp Thu Dec 21 15:09:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:09:26 +0900 Subject: [Tomoe-cvs 1967] CVS update: tomoe/module/dict Message-ID: <20061221060926.677452AC068@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.14 tomoe/module/dict/tomoe-dict-est.c:1.15 --- tomoe/module/dict/tomoe-dict-est.c:1.14 Mon Dec 18 10:02:06 2006 +++ tomoe/module/dict/tomoe-dict-est.c Thu Dec 21 15:09:26 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.14 2006/12/18 01:02:06 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.15 2006/12/21 06:09:26 kous Exp $ */ #include @@ -560,7 +560,7 @@ g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), FALSE); cond = est_cond_new (); - est_cond_set_order (cond, "utf8 STRA"); + est_cond_set_order (cond, "utf8 STRD"); est_cond_set_max (cond, 1); expr = g_strdup_printf ("code-point NUMGE %d", Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.15 tomoe/module/dict/tomoe-dict-mysql.c:1.16 --- tomoe/module/dict/tomoe-dict-mysql.c:1.15 Thu Dec 21 14:26:03 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 15:09:26 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.15 2006/12/21 05:26:03 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.16 2006/12/21 06:09:26 kous Exp $ */ #include @@ -576,18 +576,23 @@ if (!execute_query (dict, "START TRANSACTION")) return FALSE; - sql = g_string_new ("INSERT INTO chars " \ - "(utf8, n_strokes, variant) " \ + sql = g_string_new ("INSERT INTO chars " + "(utf8, code_point, n_strokes, variant) " "VALUES ("); utf8 = tomoe_char_get_utf8 (chr); append_string_value (dict, sql, utf8); + if (g_utf8_strlen (utf8, -1) == 1) + g_string_append_printf (sql, ", %d, ", g_utf8_get_char (utf8)); + else + g_string_append (sql, ", NULL, "); + n_strokes = tomoe_char_get_n_strokes (chr); if (n_strokes >= 0) - g_string_append_printf (sql, ", %d, ", n_strokes); + g_string_append_printf (sql, "%d, ", n_strokes); else - g_string_append (sql, ", NULL, "); + g_string_append (sql, "NULL, "); variant = tomoe_char_get_variant (chr); if (variant) @@ -949,20 +954,19 @@ TomoeDictMySQL *dict = TOMOE_DICT_MYSQL (_dict); GString *sql; gchar *utf8; - gchar pua_start_utf8[6]; - gint len; gboolean success; MYSQL_RES *result; g_return_val_if_fail (TOMOE_IS_DICT_MYSQL (dict), NULL); g_return_val_if_fail (TOMOE_DICT_MYSQL_IS_CONNECTED (dict), NULL); - len = g_unichar_to_utf8 (TOMOE_CHAR_PRIVATE_USE_AREA_START, pua_start_utf8); - pua_start_utf8[len] = '\0'; - - sql = g_string_new ("SELECT utf8 FROM chars WHERE utf8 >= "); - append_string_value (dict, sql, pua_start_utf8); - g_string_append (sql, " ORDER BY utf8 LIMIT 1"); + sql = g_string_new ("SELECT code_point FROM chars\n"); + g_string_append_printf (sql, + "WHERE code_point >= %d\n" + " AND code_point <= %d\n", + TOMOE_CHAR_PRIVATE_USE_AREA_START, + TOMOE_CHAR_PRIVATE_USE_AREA_END); + g_string_append (sql, "ORDER BY code_point DESC LIMIT 1"); success = execute_query (dict, sql->str); g_string_free (sql, TRUE); @@ -974,12 +978,21 @@ result = mysql_store_result (dict->mysql); if (result) { MYSQL_ROW row; + gunichar pua = TOMOE_CHAR_PRIVATE_USE_AREA_START;; + row = mysql_fetch_row (result); - if (row) { - utf8 = g_strdup (g_utf8_next_char (row[0])); - } else { - utf8 = g_strdup (pua_start_utf8); + if (row) + pua = strtoul (row[0], NULL, 10) + 1; + + if (pua <= TOMOE_CHAR_PRIVATE_USE_AREA_END) { + gchar pua_utf8[6]; + gint len; + + len = g_unichar_to_utf8 (pua, pua_utf8); + pua_utf8[len] = '\0'; + utf8 = g_strdup (pua_utf8); } + mysql_free_result (result); } From kous users.sourceforge.jp Thu Dec 21 15:09:26 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:09:26 +0900 Subject: [Tomoe-cvs 1968] CVS update: tomoe/ext/ruby Message-ID: <20061221060926.8D62D2AC00E@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.27 tomoe/ext/ruby/tomoe-rb-dict.c:1.28 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.27 Thu Dec 14 17:46:21 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Thu Dec 21 15:09:26 2006 @@ -61,6 +61,12 @@ } static VALUE +td_get_available_private_utf8(VALUE self) +{ + return CSTR2RVAL2(tomoe_dict_get_available_private_utf8(_SELF(self))); +} + +static VALUE td_flush(VALUE self) { return CBOOL2RVAL(tomoe_dict_flush(_SELF(self))); @@ -83,5 +89,7 @@ rb_define_method(cTomoeDict, "search", td_search, 1); + rb_define_method(cTomoeDict, "available_private_utf8", + td_get_available_private_utf8, 0); rb_define_method(cTomoeDict, "flush", td_flush, 0); } From kous users.sourceforge.jp Thu Dec 21 15:14:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:14:36 +0900 Subject: [Tomoe-cvs 1969] CVS update: tomoe/module/dict Message-ID: <20061221061436.41CD72AC051@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.15 tomoe/module/dict/tomoe-dict-est.c:1.16 --- tomoe/module/dict/tomoe-dict-est.c:1.15 Thu Dec 21 15:09:26 2006 +++ tomoe/module/dict/tomoe-dict-est.c Thu Dec 21 15:14:36 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.15 2006/12/21 06:09:26 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.16 2006/12/21 06:14:36 kous Exp $ */ #include @@ -436,7 +436,7 @@ chr = tomoe_char_new_from_xml_data (est_doc_hidden_texts (doc), -1); if (chr) - g_hash_table_insert (dict->cache, g_strdup (utf8), g_object_ref (chr)); + g_hash_table_insert (dict->cache, g_strdup (utf8), chr); est_doc_delete (doc); @@ -468,6 +468,9 @@ g_free (results); est_cond_delete (cond); + if (chr) + g_object_ref (chr); + return chr; } From kous users.sourceforge.jp Thu Dec 21 15:14:35 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:14:35 +0900 Subject: [Tomoe-cvs 1970] CVS update: tomoe Message-ID: <20061221061436.133FB2AC054@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.471 tomoe/ChangeLog:1.472 --- tomoe/ChangeLog:1.471 Thu Dec 21 15:09:25 2006 +++ tomoe/ChangeLog Thu Dec 21 15:14:35 2006 @@ -1,5 +1,7 @@ 2006-12-21 Kouhei Sutou + * module/dict/tomoe-dict-est.c: fixed a reference count bug. + * test/dict_spec.rb: added more strict tests. * ext/ruby/tomoe-rb-dict.c: added Tomoe::Dict#available_private_utf8. From kous users.sourceforge.jp Thu Dec 21 15:22:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:22:58 +0900 Subject: [Tomoe-cvs 1971] CVS update: tomoe Message-ID: <20061221062258.BAFE02AC00E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.472 tomoe/ChangeLog:1.473 --- tomoe/ChangeLog:1.472 Thu Dec 21 15:14:35 2006 +++ tomoe/ChangeLog Thu Dec 21 15:22:58 2006 @@ -1,5 +1,9 @@ 2006-12-21 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c: sorted alphabetical order. + + * utils/xml2est.rb: followed the current API. + * module/dict/tomoe-dict-est.c: fixed a reference count bug. * test/dict_spec.rb: added more strict tests. From kous users.sourceforge.jp Thu Dec 21 15:22:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:22:58 +0900 Subject: [Tomoe-cvs 1972] CVS update: tomoe/utils Message-ID: <20061221062258.E61C92AC051@users.sourceforge.jp> Index: tomoe/utils/xml2est.rb diff -u tomoe/utils/xml2est.rb:1.3 tomoe/utils/xml2est.rb:1.4 --- tomoe/utils/xml2est.rb:1.3 Fri Dec 15 12:30:54 2006 +++ tomoe/utils/xml2est.rb Thu Dec 21 15:22:58 2006 @@ -12,13 +12,17 @@ dictionary = TomoeSpecUtils::Path.dictionary print "converting #{dictionary}..." est_db = dictionary.sub(/\.xml$/, "") -xml_dict = Tomoe::Dict.new("xml", - "filename" => dictionary, - "editable" => false) -est_dict = Tomoe::Dict.new("est", - "database" => est_db, - "editable" => true) -xml_dict.search(Tomoe::Query.new).each do |cand| +xml_dict = Tomoe::DictXML.new("filename" => dictionary, + "editable" => false) +est_dict = Tomoe::DictEst.new("database" => est_db, + "editable" => true) +xml_dict.search(Tomoe::Query.new).each_with_index do |cand, i| est_dict.register(cand.char) + if (i % 1000).zero? and !i.zero? + print "#{i}." + $stdout.flush + end end puts "done." + +puts "converted characters: #{est_dict.search(Tomoe::Query.new).size}" From kous users.sourceforge.jp Thu Dec 21 15:22:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 15:22:59 +0900 Subject: [Tomoe-cvs 1973] CVS update: tomoe/module/dict Message-ID: <20061221062259.143042AC00E@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.16 tomoe/module/dict/tomoe-dict-mysql.c:1.17 --- tomoe/module/dict/tomoe-dict-mysql.c:1.16 Thu Dec 21 15:09:26 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 15:22:58 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.16 2006/12/21 06:09:26 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.17 2006/12/21 06:22:58 kous Exp $ */ #include @@ -771,7 +771,7 @@ append_utf8_search_sql (dict, sql, query); g_string_append (sql, ")\n" - "ORDER BY chars.utf8 DESC\n"); + "ORDER BY chars.utf8 ASC\n"); return g_string_free (sql, FALSE); } From kous users.sourceforge.jp Thu Dec 21 16:39:28 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:39:28 +0900 Subject: [Tomoe-cvs 1974] CVS update: tomoe Message-ID: <20061221073928.77EB82AC078@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.473 tomoe/ChangeLog:1.474 --- tomoe/ChangeLog:1.473 Thu Dec 21 15:22:58 2006 +++ tomoe/ChangeLog Thu Dec 21 16:39:28 2006 @@ -1,5 +1,9 @@ 2006-12-21 Kouhei Sutou + * test/dict_spec.rb: added tests for meta data. + * module/dict/tomoe-dict-mysql.c: supported meta data. + * ext/ruby/tomoe-rb-char.c: supported meta data related methods. + * module/dict/tomoe-dict-mysql.c: sorted alphabetical order. * utils/xml2est.rb: followed the current API. From kous users.sourceforge.jp Thu Dec 21 16:39:28 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:39:28 +0900 Subject: [Tomoe-cvs 1975] CVS update: tomoe/test Message-ID: <20061221073928.9BB272AC083@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.23 tomoe/test/dict_spec.rb:1.24 --- tomoe/test/dict_spec.rb:1.23 Thu Dec 21 15:09:25 2006 +++ tomoe/test/dict_spec.rb Thu Dec 21 16:39:28 2006 @@ -13,7 +13,7 @@ @original = Tomoe::DictXML.new("filename" => @dict_file.path) end - specify "should load" do + specify "should load successfully" do make_temporary_dict(@original) do |dict| a = dict[@utf8] a.writing.strokes.should == @strokes @@ -71,6 +71,24 @@ end end + specify "should save/restore meta data" do + make_temporary_dict(@original) do |dict| + char = Tomoe::Char.new + char.utf8 = "?? + char.should.not.have_meta_data + + char["meta1"] = "value1" + char["meta2"] = "value2" + + dict.register(char).should == true + + registered_char = dict["??] + char.should.have_meta_data + registered_char["meta1"].should == "value1" + registered_char["meta2"].should == "value2" + end + end + def setup_strokes @strokes = [ [ From kous users.sourceforge.jp Thu Dec 21 16:39:28 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:39:28 +0900 Subject: [Tomoe-cvs 1976] CVS update: tomoe/ext/ruby Message-ID: <20061221073928.BF5DE2AC078@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-char.c diff -u tomoe/ext/ruby/tomoe-rb-char.c:1.13 tomoe/ext/ruby/tomoe-rb-char.c:1.14 --- tomoe/ext/ruby/tomoe-rb-char.c:1.13 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb-char.c Thu Dec 21 16:39:28 2006 @@ -55,6 +55,26 @@ return Qnil; } +static VALUE +tc_get_meta_data(VALUE self, VALUE key) +{ + return CSTR2RVAL(tomoe_char_get_meta_data(_SELF(self), RVAL2CSTR(key))); +} + +static VALUE +tc_register_meta_data(VALUE self, VALUE key, VALUE value) +{ + tomoe_char_register_meta_data(_SELF(self), + RVAL2CSTR(key), RVAL2CSTR(value)); + return Qnil; +} + +static VALUE +tc_has_meta_data(VALUE self) +{ + return CBOOL2RVAL(tomoe_char_has_meta_data(_SELF(self))); +} + static void yield_meta_data(gpointer _key, gpointer _value, gpointer user_data) { @@ -118,6 +138,10 @@ rb_define_method(cTomoeChar, "radicals", tc_get_radicals, 0); rb_define_method(cTomoeChar, "add_radical", tc_add_radical, 1); + rb_define_method(cTomoeChar, "[]", tc_get_meta_data, 1); + rb_define_method(cTomoeChar, "[]=", tc_register_meta_data, 2); + rb_define_method(cTomoeChar, "has_meta_data?", tc_has_meta_data, 0); + rb_define_method(cTomoeChar, "each", tc_meta_data_foreach, 0); rb_define_method(cTomoeChar, "to_xml", tc_to_xml, 0); From kous users.sourceforge.jp Thu Dec 21 16:39:28 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:39:28 +0900 Subject: [Tomoe-cvs 1977] CVS update: tomoe/module/dict Message-ID: <20061221073928.E5EA32AC083@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.17 tomoe/module/dict/tomoe-dict-mysql.c:1.18 --- tomoe/module/dict/tomoe-dict-mysql.c:1.17 Thu Dec 21 15:22:58 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 16:39:28 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.17 2006/12/21 06:22:58 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.18 2006/12/21 07:39:28 kous Exp $ */ #include @@ -761,12 +761,17 @@ " readings.reading_type AS reading_type,\n" " readings.reading AS reading,\n" " radicals.id AS radical_id,\n" - " radicals.radical_utf8 AS radical_utf8\n" + " radicals.radical_utf8 AS radical_utf8,\n" + " meta_data.id AS meta_datum_id,\n" + " meta_data.name AS meta_datum_name,\n" + " meta_data.value AS meta_datum_value\n" "FROM chars\n" "LEFT OUTER JOIN readings\n" " ON chars.utf8 = readings.utf8\n" "LEFT OUTER JOIN radicals\n" " ON chars.utf8 = radicals.utf8\n" + "LEFT OUTER JOIN meta_data" + " ON chars.utf8 = meta_data.utf8\n" "WHERE chars.utf8 IN ("); append_utf8_search_sql (dict, sql, query); g_string_append (sql, @@ -781,12 +786,13 @@ { GList *results = NULL; TomoeChar *chr = NULL; - GArray *reading_ids, *radical_ids; + GArray *reading_ids, *radical_ids, *meta_datum_ids; gint prev_char_id = -1; MYSQL_ROW row; reading_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); radical_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); + meta_datum_ids = g_array_new (FALSE, TRUE, sizeof (gboolean)); while ((row = mysql_fetch_row (result))) { gint char_id; gchar *utf8; @@ -797,6 +803,8 @@ gchar *reading; gint radical_id = -1; gchar *radical; + gint meta_datum_id = -1; + gchar *meta_datum_name, *meta_datum_value; char_id = atoi (row[0]); utf8 = row[1]; @@ -811,6 +819,10 @@ if (row[7]) radical_id = atoi (row[7]); radical = row[8]; + if (row[9]) + meta_datum_id = atoi (row[9]); + meta_datum_name = row[10]; + meta_datum_value = row[11]; if (chr && char_id != prev_char_id) { TomoeCandidate *cand; @@ -824,6 +836,8 @@ sizeof(reading_ids->data[0]) * reading_ids->len); memset(radical_ids->data, 0, sizeof(radical_ids->data[0]) * radical_ids->len); + memset(meta_datum_ids->data, 0, + sizeof(meta_datum_ids->data[0]) * meta_datum_ids->len); } if (prev_char_id < 0) @@ -860,6 +874,19 @@ tomoe_char_add_radical (chr, radical); } } + + if (meta_datum_id >= 0) { + if (meta_datum_ids->len <= meta_datum_id) + g_array_set_size (meta_datum_ids, meta_datum_id); + + if (!meta_datum_ids->data[meta_datum_id]) { + meta_datum_ids->data[meta_datum_id] = TRUE; + if (meta_datum_name && meta_datum_value) + tomoe_char_register_meta_data (chr, + meta_datum_name, + meta_datum_value); + } + } } if (chr) { @@ -872,6 +899,7 @@ g_array_free (reading_ids, TRUE); g_array_free (radical_ids, TRUE); + g_array_free (meta_datum_ids, TRUE); return results; } From kous users.sourceforge.jp Thu Dec 21 16:49:31 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:49:31 +0900 Subject: [Tomoe-cvs 1978] CVS update: tomoe Message-ID: <20061221074931.1665F2AC051@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.474 tomoe/ChangeLog:1.475 --- tomoe/ChangeLog:1.474 Thu Dec 21 16:39:28 2006 +++ tomoe/ChangeLog Thu Dec 21 16:49:30 2006 @@ -1,5 +1,7 @@ 2006-12-21 Kouhei Sutou + * test/dict_spec.rb: MySQL backend doesn't support writing yet. + * test/dict_spec.rb: added tests for meta data. * module/dict/tomoe-dict-mysql.c: supported meta data. * ext/ruby/tomoe-rb-char.c: supported meta data related methods. From kous users.sourceforge.jp Thu Dec 21 16:49:31 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:49:31 +0900 Subject: [Tomoe-cvs 1979] CVS update: tomoe/test Message-ID: <20061221074931.41A7B2AC070@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.24 tomoe/test/dict_spec.rb:1.25 --- tomoe/test/dict_spec.rb:1.24 Thu Dec 21 16:39:28 2006 +++ tomoe/test/dict_spec.rb Thu Dec 21 16:49:31 2006 @@ -16,7 +16,12 @@ specify "should load successfully" do make_temporary_dict(@original) do |dict| a = dict[@utf8] - a.writing.strokes.should == @strokes + a.should.not.nil + if dict_module_type == "mysql" + puts "MySQL backend doesn't support writing" + else + a.writing.strokes.should == @strokes + end end end From kous users.sourceforge.jp Thu Dec 21 16:57:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:57:01 +0900 Subject: [Tomoe-cvs 1980] CVS update: tomoe Message-ID: <20061221075701.8F4772AC051@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.475 tomoe/ChangeLog:1.476 --- tomoe/ChangeLog:1.475 Thu Dec 21 16:49:30 2006 +++ tomoe/ChangeLog Thu Dec 21 16:57:01 2006 @@ -1,5 +1,10 @@ 2006-12-21 Kouhei Sutou + * test/dict_spec.rb: added tests for reading search. + + * ext/ruby/tomoe-rb-reading.c: removed Tomoe::READING_*. + * test/context_spec.rb: followed the change. + * test/dict_spec.rb: MySQL backend doesn't support writing yet. * test/dict_spec.rb: added tests for meta data. From kous users.sourceforge.jp Thu Dec 21 16:57:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:57:01 +0900 Subject: [Tomoe-cvs 1981] CVS update: tomoe/test Message-ID: <20061221075701.B418E2AC070@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.25 tomoe/test/dict_spec.rb:1.26 --- tomoe/test/dict_spec.rb:1.25 Thu Dec 21 16:49:31 2006 +++ tomoe/test/dict_spec.rb Thu Dec 21 16:57:01 2006 @@ -94,6 +94,22 @@ end end + specify "should be able to search by reading" do + make_temporary_dict(@original) do |dict| + char = Tomoe::Char.new + char.utf8 = "? + char.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_ON, "??")) + + dict.register(char).should == true + + query = Tomoe::Query.new + query.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_ON, "??")) + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + end + end + def setup_strokes @strokes = [ [ Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.30 tomoe/test/context_spec.rb:1.31 --- tomoe/test/context_spec.rb:1.30 Thu Dec 21 11:55:11 2006 +++ tomoe/test/context_spec.rb Thu Dec 21 16:57:01 2006 @@ -59,7 +59,7 @@ specify "Search by reading" do query = Tomoe::Query.new - query.add_reading(Tomoe::Reading.new(Tomoe::READING_JA_KUN, "???")) + query.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_KUN, "???")) cands = context.search(query) cands.collect {|cand| cand.char.utf8}.sort.should == ["?, "??, "??].sort end From kous users.sourceforge.jp Thu Dec 21 16:57:01 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:57:01 +0900 Subject: [Tomoe-cvs 1982] CVS update: tomoe/ext/ruby Message-ID: <20061221075701.D77C32AC051@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-reading.c diff -u tomoe/ext/ruby/tomoe-rb-reading.c:1.5 tomoe/ext/ruby/tomoe-rb-reading.c:1.6 --- tomoe/ext/ruby/tomoe-rb-reading.c:1.5 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb-reading.c Thu Dec 21 16:57:01 2006 @@ -34,7 +34,6 @@ cTomoeReading = G_DEF_CLASS(TOMOE_TYPE_READING, "Reading", mTomoe); G_DEF_CLASS(TOMOE_TYPE_READING_TYPE, "ReadingType", mTomoe); - G_DEF_CONSTANTS(mTomoe, TOMOE_TYPE_READING_TYPE, "TOMOE_"); G_DEF_CONSTANTS(cTomoeReading, TOMOE_TYPE_READING_TYPE, "TOMOE_READING_"); rb_define_method(cTomoeReading, "initialize", tr_initialize, 2); From kous users.sourceforge.jp Thu Dec 21 16:59:40 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:59:40 +0900 Subject: [Tomoe-cvs 1983] CVS update: tomoe Message-ID: <20061221075940.8AB0A2AC051@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.476 tomoe/ChangeLog:1.477 --- tomoe/ChangeLog:1.476 Thu Dec 21 16:57:01 2006 +++ tomoe/ChangeLog Thu Dec 21 16:59:40 2006 @@ -1,6 +1,8 @@ 2006-12-21 Kouhei Sutou - * test/dict_spec.rb: added tests for reading search. + * test/dict_spec.rb: + - added tests for reading search. + - added tests for n_strokes search. * ext/ruby/tomoe-rb-reading.c: removed Tomoe::READING_*. * test/context_spec.rb: followed the change. From kous users.sourceforge.jp Thu Dec 21 16:59:40 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 16:59:40 +0900 Subject: [Tomoe-cvs 1984] CVS update: tomoe/test Message-ID: <20061221075940.C87452AC070@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.26 tomoe/test/dict_spec.rb:1.27 --- tomoe/test/dict_spec.rb:1.26 Thu Dec 21 16:57:01 2006 +++ tomoe/test/dict_spec.rb Thu Dec 21 16:59:40 2006 @@ -94,7 +94,7 @@ end end - specify "should be able to search by reading" do + specify "should support reading search" do make_temporary_dict(@original) do |dict| char = Tomoe::Char.new char.utf8 = "? @@ -110,6 +110,49 @@ end end + specify "should support n_strokes search" do + make_temporary_dict(@original) do |dict| + char = Tomoe::Char.new + char.utf8 = "? + char.n_strokes = 6 + + dict.register(char).should == true + + query = Tomoe::Query.new + query.min_n_strokes = 6 + query.max_n_strokes = 6 + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + + query = Tomoe::Query.new + query.min_n_strokes = 6 + query.max_n_strokes = 7 + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + + query = Tomoe::Query.new + query.min_n_strokes = 5 + query.max_n_strokes = 6 + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + + query = Tomoe::Query.new + query.min_n_strokes = 6 + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + + query = Tomoe::Query.new + query.max_n_strokes = 6 + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + end + end + def setup_strokes @strokes = [ [ From kous users.sourceforge.jp Thu Dec 21 17:18:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 17:18:17 +0900 Subject: [Tomoe-cvs 1985] CVS update: tomoe Message-ID: <20061221081817.2DB662AC02E@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.477 tomoe/ChangeLog:1.478 --- tomoe/ChangeLog:1.477 Thu Dec 21 16:59:40 2006 +++ tomoe/ChangeLog Thu Dec 21 17:18:17 2006 @@ -1,8 +1,14 @@ 2006-12-21 Kouhei Sutou + * lib/tomoe-query.[ch]: made radical as utf8 strings instead of + TomoeChar. + * ext/ruby/tomoe-query.c: supported add_radical. + * module/dict/tomoe-dict-mysql.c: fixed typo. + * test/dict_spec.rb: - added tests for reading search. - added tests for n_strokes search. + - added tests for radical search. But not implemented yet. * ext/ruby/tomoe-rb-reading.c: removed Tomoe::READING_*. * test/context_spec.rb: followed the change. From kous users.sourceforge.jp Thu Dec 21 17:18:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 17:18:17 +0900 Subject: [Tomoe-cvs 1986] CVS update: tomoe/test Message-ID: <20061221081817.5662F2AC051@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.27 tomoe/test/dict_spec.rb:1.28 --- tomoe/test/dict_spec.rb:1.27 Thu Dec 21 16:59:40 2006 +++ tomoe/test/dict_spec.rb Thu Dec 21 17:18:17 2006 @@ -98,12 +98,12 @@ make_temporary_dict(@original) do |dict| char = Tomoe::Char.new char.utf8 = "? - char.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_ON, "??")) + char.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_KUN, "???")) dict.register(char).should == true query = Tomoe::Query.new - query.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_ON, "??")) + query.add_reading(Tomoe::Reading.new(Tomoe::Reading::JA_KUN, "???")) dict.search(query).collect do |cand| cand.char.utf8 end.should == ["?] @@ -153,6 +153,22 @@ end end + specify "should support radical search" do + make_temporary_dict(@original) do |dict| + char = Tomoe::Char.new + char.utf8 = "? + char.add_radical("?) + + dict.register(char).should == true + + query = Tomoe::Query.new + query.add_radical("?) + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + end + end + def setup_strokes @strokes = [ [ From kous users.sourceforge.jp Thu Dec 21 17:18:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 17:18:17 +0900 Subject: [Tomoe-cvs 1987] CVS update: tomoe/ext/ruby Message-ID: <20061221081817.7F40C2AC02E@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-query.c diff -u tomoe/ext/ruby/tomoe-rb-query.c:1.3 tomoe/ext/ruby/tomoe-rb-query.c:1.4 --- tomoe/ext/ruby/tomoe-rb-query.c:1.3 Tue Dec 12 22:45:33 2006 +++ tomoe/ext/ruby/tomoe-rb-query.c Thu Dec 21 17:18:17 2006 @@ -12,6 +12,13 @@ } static VALUE +tq_add_radical(VALUE self, VALUE radical) +{ + tomoe_query_add_radical(_SELF(self), RVAL2CSTR(radical)); + return Qnil; +} + +static VALUE tq_set_writing(VALUE self, VALUE writing) { tomoe_query_set_writing(_SELF(self), RVAL2TWTG(writing)); @@ -26,7 +33,7 @@ cTomoeQuery = G_DEF_CLASS(TOMOE_TYPE_QUERY, "Query", mTomoe); rb_define_method(cTomoeQuery, "add_reading", tq_add_reading, 1); -/* rb_define_method(cTomoeQuery, "add_radical", tq_add_radical, 1); */ + rb_define_method(cTomoeQuery, "add_radical", tq_add_radical, 1); /* rb_define_method(cTomoeQuery, "add_variant", tq_add_variant, 1); */ rb_define_method(cTomoeQuery, "set_writing", tq_set_writing, 1); From kous users.sourceforge.jp Thu Dec 21 17:18:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 17:18:17 +0900 Subject: [Tomoe-cvs 1988] CVS update: tomoe/lib Message-ID: <20061221081817.AC4602AC051@users.sourceforge.jp> Index: tomoe/lib/tomoe-query.c diff -u tomoe/lib/tomoe-query.c:1.7 tomoe/lib/tomoe-query.c:1.8 --- tomoe/lib/tomoe-query.c:1.7 Mon Dec 18 10:02:06 2006 +++ tomoe/lib/tomoe-query.c Thu Dec 21 17:18:17 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.c,v 1.7 2006/12/18 01:02:06 kous Exp $ + * $Id: tomoe-query.c,v 1.8 2006/12/21 08:18:17 kous Exp $ */ #include @@ -145,7 +145,7 @@ g_list_free (priv->readings); } if (priv->radicals) { - g_list_foreach (priv->radicals, (GFunc)g_object_unref, NULL); + g_list_foreach (priv->radicals, (GFunc)g_free, NULL); g_list_free (priv->radicals); } if (priv->variant) @@ -284,15 +284,16 @@ } void -tomoe_query_add_radical (TomoeQuery *query, TomoeChar *radical) +tomoe_query_add_radical (TomoeQuery *query, const gchar *radical) { TomoeQueryPrivate *priv; g_return_if_fail (TOMOE_IS_QUERY (query)); + g_return_if_fail (radical && radical[0] != '\0'); priv = TOMOE_QUERY_GET_PRIVATE (query); - priv->radicals = g_list_prepend (priv->radicals, g_object_ref (radical)); + priv->radicals = g_list_prepend (priv->radicals, g_strdup (radical)); } TomoeChar * Index: tomoe/lib/tomoe-query.h diff -u tomoe/lib/tomoe-query.h:1.7 tomoe/lib/tomoe-query.h:1.8 --- tomoe/lib/tomoe-query.h:1.7 Mon Dec 18 10:02:06 2006 +++ tomoe/lib/tomoe-query.h Thu Dec 21 17:18:17 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.h,v 1.7 2006/12/18 01:02:06 kous Exp $ + * $Id: tomoe-query.h,v 1.8 2006/12/21 08:18:17 kous Exp $ */ #ifndef __TOMOE_QUERY_H__ @@ -64,7 +64,7 @@ const GList *tomoe_query_get_readings (TomoeQuery *query); void tomoe_query_add_radical (TomoeQuery *query, - TomoeChar *chr); + const gchar *radical); const GList *tomoe_query_get_radicals (TomoeQuery *query); void tomoe_query_set_variant (TomoeQuery *query, From kous users.sourceforge.jp Thu Dec 21 17:18:18 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 21 Dec 2006 17:18:18 +0900 Subject: [Tomoe-cvs 1989] CVS update: tomoe/module/dict Message-ID: <20061221081818.1132B2AC02E@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.18 tomoe/module/dict/tomoe-dict-mysql.c:1.19 --- tomoe/module/dict/tomoe-dict-mysql.c:1.18 Thu Dec 21 16:39:28 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Thu Dec 21 17:18:17 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.18 2006/12/21 07:39:28 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.19 2006/12/21 08:18:17 kous Exp $ */ #include @@ -503,7 +503,9 @@ for (node = (GList *)radicals; node; node = g_list_next (node)) { const gchar *radical = node->data; - g_string_assign (sql, "INSERT INTO radicals (utf8, radical) VALUES ("); + g_string_assign (sql, + "INSERT INTO radicals (utf8, radical_utf8)\n" + "VALUES ("); append_string_value (dict, sql, utf8); g_string_append (sql, ", "); append_string_value (dict, sql, radical); From kous users.sourceforge.jp Fri Dec 22 10:22:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 10:22:54 +0900 Subject: [Tomoe-cvs 1990] CVS update: tomoe Message-ID: <20061222012254.0B99E2AC0F0@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.478 tomoe/ChangeLog:1.479 --- tomoe/ChangeLog:1.478 Thu Dec 21 17:18:17 2006 +++ tomoe/ChangeLog Fri Dec 22 10:22:53 2006 @@ -1,3 +1,7 @@ +2006-12-22 Kouhei Sutou + + * module/dict/tomoe-dict-mysql.c: supported radical search. + 2006-12-21 Kouhei Sutou * lib/tomoe-query.[ch]: made radical as utf8 strings instead of From kous users.sourceforge.jp Fri Dec 22 10:22:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 10:22:54 +0900 Subject: [Tomoe-cvs 1991] CVS update: tomoe/module/dict Message-ID: <20061222012254.3C9372AC0F6@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.19 tomoe/module/dict/tomoe-dict-mysql.c:1.20 --- tomoe/module/dict/tomoe-dict-mysql.c:1.19 Thu Dec 21 17:18:17 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Fri Dec 22 10:22:54 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.19 2006/12/21 08:18:17 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.20 2006/12/22 01:22:54 kous Exp $ */ #include @@ -737,6 +737,32 @@ } static void +append_sql_condition_radicals (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) +{ + GList *node; + + node = (GList *)tomoe_query_get_radicals (query); + if (!node) + return; + + g_string_append (sql, + " AND utf8 IN\n" + " (SELECT DISTINCT utf8 FROM radicals\n" + " WHERE TRUE = TRUE\n"); + for (; node; node = g_list_next (node)) { + const gchar *radical = node->data; + + if (radical) { + g_string_append (sql, " AND radical_utf8 ="); + append_string_value (dict, sql, radical); + g_string_append (sql, "\n"); + } + } + g_string_append (sql, " )\n"); +} + +static void append_utf8_search_sql (TomoeDictMySQL *dict, GString *sql, TomoeQuery *query) { g_string_append (sql, @@ -747,6 +773,8 @@ append_sql_condition_max_n_strokes (dict, sql, query); append_sql_condition_readings (dict, sql, query); + + append_sql_condition_radicals (dict, sql, query); } static gchar * From kous users.sourceforge.jp Fri Dec 22 11:26:21 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 11:26:21 +0900 Subject: [Tomoe-cvs 1992] CVS update: libtomoe-gtk Message-ID: <20061222022621.6AEA82AC0BD@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.254 libtomoe-gtk/ChangeLog:1.255 --- libtomoe-gtk/ChangeLog:1.254 Mon Dec 18 16:39:02 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 22 11:26:21 2006 @@ -1,3 +1,8 @@ +2006-12-22 Kouhei Sutou + + * src/tomoe-reading-search.c: showed UCS4 code-point but it's too + dirty... + 2006-12-18 Takuro Ashie * configure.ac: Bump version number. From kous users.sourceforge.jp Fri Dec 22 11:26:21 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 11:26:21 +0900 Subject: [Tomoe-cvs 1993] CVS update: libtomoe-gtk/src Message-ID: <20061222022621.975252AC1F4@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.28 libtomoe-gtk/src/tomoe-reading-search.c:1.29 --- libtomoe-gtk/src/tomoe-reading-search.c:1.28 Mon Dec 11 23:50:20 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Fri Dec 22 11:26:21 2006 @@ -41,6 +41,7 @@ enum { TERMINATOR = -1, UTF8_COLUMN, + CODE_POINT_COLUMN, STROKECOUNT_COLUMN, STROKECOUNT_TEXT_COLUMN, READING_COLUMN, @@ -236,6 +237,7 @@ /* result view */ priv->result_store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, @@ -265,6 +267,14 @@ gtk_tree_view_column_set_sort_column_id (column, UTF8_COLUMN); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ( + _("Code point"), renderer, + "text", CODE_POINT_COLUMN, + NULL); + gtk_tree_view_column_set_sort_column_id (column, CODE_POINT_COLUMN); + gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); + /* stroke count column */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ( @@ -409,9 +419,23 @@ TomoeChar *c = tomoe_candidate_get_char (cand); const GList *readings = tomoe_char_get_readings (c); gchar *strokes_text, *readings_text; + gchar *utf8; + gint i, utf8_len; + GString *code_point_text; gint strokes = 0; GtkTreeIter iter; + code_point_text = g_string_new (""); + utf8 = (gchar *)tomoe_char_get_utf8 (c); + utf8_len = g_utf8_strlen (utf8, -1); + for (i = 0; i < utf8_len; i++) { + g_string_append_printf (code_point_text, + "U+%d ", g_utf8_get_char (utf8)); + utf8 = g_utf8_next_char (utf8); + } + if (code_point_text->len > 0) + g_string_erase (code_point_text, code_point_text->len - 1, 1); + strokes = tomoe_char_get_n_strokes (c); if (strokes == 0 && tomoe_char_get_writing (c)) strokes = tomoe_writing_get_n_strokes (tomoe_char_get_writing (c)); @@ -440,12 +464,14 @@ gtk_list_store_append (priv->result_store, &iter); gtk_list_store_set (priv->result_store, &iter, UTF8_COLUMN, tomoe_char_get_utf8 (c), + CODE_POINT_COLUMN, code_point_text->str, STROKECOUNT_COLUMN, strokes, STROKECOUNT_TEXT_COLUMN, strokes_text, READING_COLUMN, readings_text, CHAR_COLUMN, c, TERMINATOR); + g_string_free (code_point_text, TRUE); g_free (readings_text); g_free (strokes_text); } From kous users.sourceforge.jp Fri Dec 22 11:50:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 11:50:33 +0900 Subject: [Tomoe-cvs 1994] CVS update: tomoe Message-ID: <20061222025033.B78932AC106@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.479 tomoe/ChangeLog:1.480 --- tomoe/ChangeLog:1.479 Fri Dec 22 10:22:53 2006 +++ tomoe/ChangeLog Fri Dec 22 11:50:33 2006 @@ -1,5 +1,12 @@ 2006-12-22 Kouhei Sutou + * test/dict_spec.rb: used numeric reference to sanzui. + + * module/dict/tomoe-dict-ptr-array.c: supported radical search. + + * module/dict/tomoe-dict-xml.c (tomoe_dict_xml_save): fixed DTD + path. + * module/dict/tomoe-dict-mysql.c: supported radical search. 2006-12-21 Kouhei Sutou From kous users.sourceforge.jp Fri Dec 22 11:50:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 11:50:33 +0900 Subject: [Tomoe-cvs 1995] CVS update: tomoe/test Message-ID: <20061222025033.DB9A22AC1DA@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.28 tomoe/test/dict_spec.rb:1.29 --- tomoe/test/dict_spec.rb:1.28 Thu Dec 21 17:18:17 2006 +++ tomoe/test/dict_spec.rb Fri Dec 22 11:50:33 2006 @@ -149,20 +149,21 @@ query.max_n_strokes = 6 dict.search(query).collect do |cand| cand.char.utf8 - end.should == ["?] + end.sort.should == ["??, "?].sort end end specify "should support radical search" do make_temporary_dict(@original) do |dict| + sanzui = ucs4_to_utf8(27701) # ?????? char = Tomoe::Char.new char.utf8 = "? - char.add_radical("?) + char.add_radical(sanzui) dict.register(char).should == true query = Tomoe::Query.new - query.add_radical("?) + query.add_radical(sanzui) dict.search(query).collect do |cand| cand.char.utf8 end.should == ["?] From kous users.sourceforge.jp Fri Dec 22 11:50:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 11:50:34 +0900 Subject: [Tomoe-cvs 1996] CVS update: tomoe/module/dict Message-ID: <20061222025034.0E1202AC106@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-ptr-array.c diff -u tomoe/module/dict/tomoe-dict-ptr-array.c:1.4 tomoe/module/dict/tomoe-dict-ptr-array.c:1.5 --- tomoe/module/dict/tomoe-dict-ptr-array.c:1.4 Mon Dec 18 10:02:06 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.c Fri Dec 22 11:50:33 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ptr-array.c,v 1.4 2006/12/18 01:02:06 kous Exp $ + * $Id: tomoe-dict-ptr-array.c,v 1.5 2006/12/22 02:50:33 kous Exp $ */ #include @@ -133,7 +133,7 @@ } static gboolean -does_match_char_with_readings (TomoeChar *chr, TomoeReading *reading) +does_match_char_with_reading (TomoeChar *chr, TomoeReading *reading) { if (!reading) return TRUE; @@ -145,24 +145,65 @@ return FALSE; } +static gboolean +does_match_char_with_readings (TomoeChar *chr, const GList *readings) +{ + GList *node; + + for (node = (GList *)readings; node; node = g_list_next (node)) { + TomoeReading *reading = node->data; + if (!does_match_char_with_reading (chr, reading)) + return FALSE; + } + + return TRUE; +} + +static gboolean +does_match_char_with_radical (TomoeChar *chr, const gchar *radical) +{ + if (!radical) + return TRUE; + + if (g_list_find_custom ((GList *)tomoe_char_get_radicals (chr), + radical, (GCompareFunc)g_utf8_collate)) + return TRUE; + else + return FALSE; +} + +static gboolean +does_match_char_with_radicals (TomoeChar *chr, const GList *radicals) +{ + GList *node; + + for (node = (GList *)radicals; node; node = g_list_next (node)) { + const gchar *radical = node->data; + if (!does_match_char_with_radical (chr, radical)) + return FALSE; + } + + return TRUE; +} + static void collect_chars_by_query (gpointer data, gpointer user_data) { TomoeChar *chr = data; TomoeDictSearchContext *context = user_data; TomoeQuery *query; - TomoeReading *reading; - gint min_n_strokes, max_n_strokes; query = context->query; - min_n_strokes = tomoe_query_get_min_n_strokes (query); - max_n_strokes = tomoe_query_get_max_n_strokes (query); - if (!does_match_char_with_n_strokes (chr, min_n_strokes, max_n_strokes)) + if (!does_match_char_with_n_strokes (chr, + tomoe_query_get_min_n_strokes (query), + tomoe_query_get_max_n_strokes (query))) + return; + + if (!does_match_char_with_readings (chr, tomoe_query_get_readings (query))) return; - reading = g_list_nth_data ((GList *)tomoe_query_get_readings (query), 0); - if (!does_match_char_with_readings (chr, reading)) + if (!does_match_char_with_radicals (chr, tomoe_query_get_radicals (query))) return; context->results = g_list_prepend (context->results, Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.15 tomoe/module/dict/tomoe-dict-xml.c:1.16 --- tomoe/module/dict/tomoe-dict-xml.c:1.15 Mon Dec 18 11:40:15 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Fri Dec 22 11:50:33 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.15 2006/12/18 02:40:15 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.16 2006/12/22 02:50:33 kous Exp $ */ #include @@ -415,7 +415,7 @@ xml = g_string_new ( "\n" - "\n"); + "\n"); if (dict->name) g_string_append_printf (xml, "\n", dict->name); From kous users.sourceforge.jp Fri Dec 22 13:19:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 13:19:34 +0900 Subject: [Tomoe-cvs 1997] CVS update: tomoe Message-ID: <20061222041934.24E8A2AC107@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.480 tomoe/ChangeLog:1.481 --- tomoe/ChangeLog:1.480 Fri Dec 22 11:50:33 2006 +++ tomoe/ChangeLog Fri Dec 22 13:19:33 2006 @@ -1,5 +1,14 @@ 2006-12-22 Kouhei Sutou + * data/dict.dtd: added radicals. + * test/char_spec.rb: added tests for load/dump XML with radicals. + * lib/tomoe-xml-parser.c: supported parsing radicals. + * lib/tomoe-char.c: supported outputting radicals to XML. + * module/dict/tomoe-dict-est.c: supported radical search. + + * test/tomoe-spec-utils.rb: removed patch for interrupt because + the patch was applied to RSpec. + * test/dict_spec.rb: used numeric reference to sanzui. * module/dict/tomoe-dict-ptr-array.c: supported radical search. From kous users.sourceforge.jp Fri Dec 22 13:19:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 13:19:34 +0900 Subject: [Tomoe-cvs 1998] CVS update: tomoe/test Message-ID: <20061222041934.4CC002AC1DA@users.sourceforge.jp> Index: tomoe/test/char_spec.rb diff -u tomoe/test/char_spec.rb:1.7 tomoe/test/char_spec.rb:1.8 --- tomoe/test/char_spec.rb:1.7 Thu Nov 30 12:03:32 2006 +++ tomoe/test/char_spec.rb Fri Dec 22 13:19:34 2006 @@ -15,6 +15,20 @@ char.to_xml.should == xml end + specify "should dump XML with radicals" do + sanzui = ucs4_to_utf8(27701) # ?????? + char = Tomoe::Char.new + char.utf8 = "? + char.add_radical(sanzui) + xml = " \n" + xml << " ?/utf8>\n" + xml << " \n" + xml << " #{sanzui}\n" + xml << " \n" + xml << " \n" + char.to_xml.should == xml + end + specify "should load from dumped XML" do char = Tomoe::Char.new char.utf8 = "?? @@ -22,6 +36,17 @@ new_char.utf8.should == char.utf8 end + specify "should load from dumped XML with radicals" do + sanzui = ucs4_to_utf8(27701) # ?????? + char = Tomoe::Char.new + char.utf8 = "? + char.add_radical(sanzui) + + new_char = Tomoe::Char.new(char.to_xml) + new_char.utf8.should == char.utf8 + new_char.radicals.should == [sanzui] + end + specify "should set/get n_strokes" do char = Tomoe::Char.new char.n_strokes.should == -1 Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.29 tomoe/test/dict_spec.rb:1.30 --- tomoe/test/dict_spec.rb:1.29 Fri Dec 22 11:50:33 2006 +++ tomoe/test/dict_spec.rb Fri Dec 22 13:19:34 2006 @@ -17,6 +17,7 @@ make_temporary_dict(@original) do |dict| a = dict[@utf8] a.should.not.nil + a.utf8.should == @utf8 if dict_module_type == "mysql" puts "MySQL backend doesn't support writing" else @@ -213,6 +214,7 @@ @character_xml = <<-EOC #{@utf8} + #{@strokes.size} #{strokes_xml} EOC @@ -232,6 +234,7 @@ @est_draft_content = <<-EOC @uri=font:#{@utf8} utf8=#{@utf8} +n_strokes=#{@strokes.size} #{@character_xml.collect {|line| "\t#{line}"}} EOC From kous users.sourceforge.jp Fri Dec 22 13:19:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 13:19:34 +0900 Subject: [Tomoe-cvs 1999] CVS update: tomoe/data Message-ID: <20061222041934.7108A2AC107@users.sourceforge.jp> Index: tomoe/data/dict.dtd diff -u tomoe/data/dict.dtd:1.1 tomoe/data/dict.dtd:1.2 --- tomoe/data/dict.dtd:1.1 Mon Dec 18 15:26:41 2006 +++ tomoe/data/dict.dtd Fri Dec 22 13:19:34 2006 @@ -3,7 +3,7 @@ name CDATA #IMPLIED > + readings?, radicals?, meta?)*> @@ -18,4 +18,6 @@ + + From kous users.sourceforge.jp Fri Dec 22 13:19:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 13:19:34 +0900 Subject: [Tomoe-cvs 2000] CVS update: tomoe/lib Message-ID: <20061222041934.9770F2AC1DA@users.sourceforge.jp> Index: tomoe/lib/tomoe-char.c diff -u tomoe/lib/tomoe-char.c:1.60 tomoe/lib/tomoe-char.c:1.61 --- tomoe/lib/tomoe-char.c:1.60 Fri Dec 1 09:53:44 2006 +++ tomoe/lib/tomoe-char.c Fri Dec 22 13:19:34 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-char.c,v 1.60 2006/12/01 00:53:44 ikezoe Exp $ + * $Id: tomoe-char.c,v 1.61 2006/12/22 04:19:34 kous Exp $ */ #include @@ -483,6 +483,26 @@ } static void +tomoe_char_to_xml_radicals (TomoeChar *chr, TomoeCharPrivate *priv, + GString *output) +{ + GList *node; + + if (!priv->radicals) return; + + g_string_append (output, " \n"); + for (node = priv->radicals; node; node = g_list_next (node)) { + const gchar *radical = node->data; + gchar *xml; + + xml = g_markup_printf_escaped (radical, -1); + g_string_append_printf (output, " %s\n", xml); + g_free (xml); + } + g_string_append (output, " \n"); +} + +static void tomoe_char_to_xml_writing (TomoeChar *chr, TomoeCharPrivate *priv, GString *output) { @@ -536,6 +556,7 @@ tomoe_char_to_xml_utf8 (chr, priv, output); tomoe_char_to_xml_readings (chr, priv, output); + tomoe_char_to_xml_radicals (chr, priv, output); tomoe_char_to_xml_writing (chr, priv, output); tomoe_char_to_xml_meta (chr, priv, output); Index: tomoe/lib/tomoe-xml-parser.c diff -u tomoe/lib/tomoe-xml-parser.c:1.2 tomoe/lib/tomoe-xml-parser.c:1.3 --- tomoe/lib/tomoe-xml-parser.c:1.2 Fri Dec 1 12:29:28 2006 +++ tomoe/lib/tomoe-xml-parser.c Fri Dec 22 13:19:34 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-xml-parser.c,v 1.2 2006/12/01 03:29:28 kous Exp $ + * $Id: tomoe-xml-parser.c,v 1.3 2006/12/22 04:19:34 kous Exp $ */ #include @@ -38,6 +38,8 @@ STATE_STROKES, STATE_READINGS, STATE_READING, + STATE_RADICALS, + STATE_RADICAL, STATE_WRITING, STATE_STROKE, STATE_POINT, @@ -206,6 +208,21 @@ return; } + if (!strcmp ("radicals", element_name)) { + data->state = STATE_RADICALS; + return; + } + + if (!strcmp ("radical", element_name)) { + if (data->state != STATE_RADICALS) { + set_parse_error (context, error, data); + return; + } + + data->state = STATE_RADICAL; + return; + } + if (!strcmp ("meta", element_name)) { data->state = STATE_META; return; @@ -283,6 +300,16 @@ return; } + if (!strcmp ("radicals", element_name)) { + data->state = STATE_NONE; + return; + } + + if (!strcmp ("radical", element_name)) { + data->state = STATE_RADICALS; + return; + } + if (!strcmp ("meta", element_name)) { data->state = STATE_NONE; return; @@ -327,6 +354,11 @@ g_object_unref (reading); return; } + case STATE_RADICAL: + { + tomoe_char_add_radical (data->chr, text); + return; + } case STATE_META: { g_free (data->value); From kous users.sourceforge.jp Fri Dec 22 13:19:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 13:19:34 +0900 Subject: [Tomoe-cvs 2001] CVS update: tomoe/module/dict Message-ID: <20061222041934.BB8FE2AC107@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.16 tomoe/module/dict/tomoe-dict-est.c:1.17 --- tomoe/module/dict/tomoe-dict-est.c:1.16 Thu Dec 21 15:14:36 2006 +++ tomoe/module/dict/tomoe-dict-est.c Fri Dec 22 13:19:34 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.16 2006/12/21 06:14:36 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.17 2006/12/22 04:19:34 kous Exp $ */ #include @@ -479,9 +479,8 @@ { TomoeDictEst *dict = TOMOE_DICT_EST (_dict); GList *candidates = NULL; - TomoeReading *reading; ESTCOND *cond; - gchar *expr; + GString *attr, *phrase; int i, *results, n_results; gint min_n_strokes, max_n_strokes; @@ -490,34 +489,57 @@ cond = est_cond_new (); est_cond_set_order (cond, "utf8 STRA"); + attr = g_string_new (""); + phrase = g_string_new (""); + if (tomoe_query_is_empty (query)) { - est_cond_set_phrase (cond, "[UVSET]"); + g_string_assign (phrase, "[UVSET]"); } else { GList *node; min_n_strokes = tomoe_query_get_min_n_strokes (query); if (min_n_strokes >= 0) { - expr = g_strdup_printf ("n-strokes NUMGE %d", min_n_strokes); - est_cond_add_attr (cond, expr); - g_free (expr); + g_string_printf (attr, "n-strokes NUMGE %d", min_n_strokes); + est_cond_add_attr (cond, attr->str); } max_n_strokes = tomoe_query_get_max_n_strokes (query); if (max_n_strokes >= 0) { - expr = g_strdup_printf ("n-strokes NUMLE %d", max_n_strokes); - est_cond_add_attr (cond, expr); - g_free (expr); + g_string_printf (attr, "n-strokes NUMLE %d", max_n_strokes); + est_cond_add_attr (cond, attr->str); + } + + for (node = (GList *)tomoe_query_get_readings (query); + node; + node = g_list_next (node)) { + TomoeReading *reading = node->data; + gchar *xml; + + xml = tomoe_reading_to_xml (reading); + g_string_append_printf (phrase, " %s", xml); + g_free (xml); } - node = (GList *)tomoe_query_get_readings (query); - reading = node ? node->data : NULL; - if (reading) { - expr = tomoe_reading_to_xml (reading); - est_cond_set_phrase (cond, expr); - g_free (expr); + for (node = (GList *)tomoe_query_get_radicals (query); + node; + node = g_list_next (node)) { + const gchar *radical = node->data; + gchar *escaped_radical; + + escaped_radical = g_markup_escape_text (radical, -1); + g_string_append_printf (phrase, + " %s", + escaped_radical); + g_free (escaped_radical); } } + if (phrase->len > 0) + est_cond_set_phrase (cond, phrase->str); + + g_string_free (attr, TRUE); + g_string_free (phrase, TRUE); + results = est_db_search (dict->db, cond, &n_results, NULL); for (i = 0; i < n_results; i++) { TomoeChar *chr; From makeinu users.sourceforge.jp Fri Dec 22 13:25:58 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:25:58 +0900 Subject: [Tomoe-cvs 2002] CVS update: libtomoe-gtk Message-ID: <20061222042558.40FB32AC107@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.255 libtomoe-gtk/ChangeLog:1.256 --- libtomoe-gtk/ChangeLog:1.255 Fri Dec 22 11:26:21 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 22 13:25:58 2006 @@ -1,3 +1,8 @@ +2006-12-22 Takuro Ashie + + * src/tomoe-reading-search.c: Temporary unset the tree model from tree + view when set search results to improve redrawing performance. + 2006-12-22 Kouhei Sutou * src/tomoe-reading-search.c: showed UCS4 code-point but it's too From makeinu users.sourceforge.jp Fri Dec 22 13:25:58 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:25:58 +0900 Subject: [Tomoe-cvs 2003] CVS update: libtomoe-gtk/doc/reference/tmpl Message-ID: <20061222042558.6E62E2AC1DA@users.sourceforge.jp> Index: libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml diff -u libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml:1.1 libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml:1.2 --- libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml:1.1 Fri Dec 1 13:08:44 2006 +++ libtomoe-gtk/doc/reference/tmpl/tomoe-canvas.sgml Fri Dec 22 13:25:58 2006 @@ -59,74 +59,91 @@ @tomoecanvas: the object which received the signal. - + - Returns: + + + - + - canvas: + + + - + - canvas: - nth: - Returns: + + + - + + + + + + + + + + + - canvas: @Returns: - + @canvas: + context: - + @canvas: + writing: - + @canvas: + Returns: - + @canvas: + lock: - + @@ -135,16 +152,25 @@ @Returns: - + + + + + + canvas: + time_msec: + + + @canvas: - size: + Returns: - + @@ -153,7 +179,7 @@ @color: - + @@ -162,7 +188,7 @@ @color: - + @@ -180,16 +206,15 @@ @color: - + @canvas: - time_msec: - + @@ -198,16 +223,17 @@ @Returns: - + @canvas: - context: + nth: + Returns: - + @@ -216,25 +242,31 @@ @Returns: - + @canvas: - writing: - + @canvas: - lock: - + + + + + + canvas: + + + From makeinu users.sourceforge.jp Fri Dec 22 13:25:58 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:25:58 +0900 Subject: [Tomoe-cvs 2004] CVS update: libtomoe-gtk/src Message-ID: <20061222042558.94DFA2AC107@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.29 libtomoe-gtk/src/tomoe-reading-search.c:1.30 --- libtomoe-gtk/src/tomoe-reading-search.c:1.29 Fri Dec 22 11:26:21 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Fri Dec 22 13:25:58 2006 @@ -379,6 +379,7 @@ g_return_if_fail (GTK_IS_ENTRY (priv->input)); gtk_list_store_clear (priv->result_store); + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), NULL); query = tomoe_query_new (); @@ -478,6 +479,9 @@ g_list_foreach (result, (GFunc) g_object_unref, NULL); g_list_free (result); + + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), + GTK_TREE_MODEL (priv->result_store)); } static void From makeinu users.sourceforge.jp Fri Dec 22 13:32:26 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:32:26 +0900 Subject: [Tomoe-cvs 2005] CVS update: libtomoe-gtk/src Message-ID: <20061222043226.E825B2AC0CA@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.30 libtomoe-gtk/src/tomoe-reading-search.c:1.31 --- libtomoe-gtk/src/tomoe-reading-search.c:1.30 Fri Dec 22 13:25:58 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Fri Dec 22 13:32:26 2006 @@ -378,8 +378,8 @@ g_return_if_fail (GTK_IS_LIST_STORE (priv->result_store)); g_return_if_fail (GTK_IS_ENTRY (priv->input)); - gtk_list_store_clear (priv->result_store); gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), NULL); + gtk_list_store_clear (priv->result_store); query = tomoe_query_new (); @@ -494,7 +494,10 @@ g_return_if_fail (GTK_IS_ENTRY (priv->input)); gtk_entry_set_text (GTK_ENTRY (priv->input), ""); + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), NULL); gtk_list_store_clear (priv->result_store); + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview), + GTK_TREE_MODEL (priv->result_store)); } const gchar * From makeinu users.sourceforge.jp Fri Dec 22 13:35:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:35:20 +0900 Subject: [Tomoe-cvs 2006] CVS update: libtomoe-gtk Message-ID: <20061222043520.7990E2AC0EC@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.256 libtomoe-gtk/ChangeLog:1.257 --- libtomoe-gtk/ChangeLog:1.256 Fri Dec 22 13:25:58 2006 +++ libtomoe-gtk/ChangeLog Fri Dec 22 13:35:20 2006 @@ -2,6 +2,7 @@ * src/tomoe-reading-search.c: Temporary unset the tree model from tree view when set search results to improve redrawing performance. + * po/ja.po: Update. 2006-12-22 Kouhei Sutou From makeinu users.sourceforge.jp Fri Dec 22 13:35:20 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:35:20 +0900 Subject: [Tomoe-cvs 2007] CVS update: libtomoe-gtk/po Message-ID: <20061222043520.A53802AC106@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.15 libtomoe-gtk/po/ja.po:1.16 --- libtomoe-gtk/po/ja.po:1.15 Mon Dec 18 16:39:02 2006 +++ libtomoe-gtk/po/ja.po Fri Dec 22 13:35:20 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-12 11:01+0900\n" +"POT-Creation-Date: 2006-12-22 13:33+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -11,7 +11,7 @@ "Content-Transfer-Encoding: 8bit\n" #: src/tomoe-canvas.c:212 src/tomoe-handwriting.c:116 -#: src/tomoe-reading-search.c:128 +#: src/tomoe-reading-search.c:129 msgid "Tomoe context" msgstr "" @@ -118,7 +118,7 @@ msgid "Basic information" msgstr "ܾ" -#: src/tomoe-details.c:268 src/tomoe-reading-search.c:262 +#: src/tomoe-details.c:268 src/tomoe-reading-search.c:264 msgid "Character" msgstr "ʸ" @@ -158,7 +158,7 @@ msgid "Writing" msgstr "" -#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:129 +#: src/tomoe-handwriting.c:117 src/tomoe-reading-search.c:130 msgid "A TomoeContext which stores handwriting dictionaries." msgstr "" @@ -191,37 +191,41 @@ msgid "Select the file name for dump" msgstr "" -#: src/tomoe-reading-search.c:160 +#: src/tomoe-reading-search.c:161 msgid "Reading:" msgstr "ɤ:" #. stroke count area -#: src/tomoe-reading-search.c:187 +#: src/tomoe-reading-search.c:188 msgid "More options" msgstr "¾θ" -#: src/tomoe-reading-search.c:196 +#: src/tomoe-reading-search.c:197 msgid "Stroke count:" msgstr ":" -#: src/tomoe-reading-search.c:200 +#: src/tomoe-reading-search.c:201 msgid "Min" msgstr "Ǿ" -#: src/tomoe-reading-search.c:214 +#: src/tomoe-reading-search.c:215 msgid "Max" msgstr "" #. gtk_widget_show (spin); -#: src/tomoe-reading-search.c:228 +#: src/tomoe-reading-search.c:229 msgid "Specify range" msgstr "ϰϤ" -#: src/tomoe-reading-search.c:271 +#: src/tomoe-reading-search.c:272 +msgid "Code point" +msgstr "ɥݥ" + +#: src/tomoe-reading-search.c:281 msgid "Stroke count" msgstr "" -#: src/tomoe-reading-search.c:280 +#: src/tomoe-reading-search.c:290 msgid "Reading" msgstr "ɤ" From makeinu users.sourceforge.jp Fri Dec 22 13:47:10 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:47:10 +0900 Subject: [Tomoe-cvs 2008] CVS update: libtomoe-gtk Message-ID: <20061222044710.64B962AC0CA@users.sourceforge.jp> Index: libtomoe-gtk/NEWS diff -u libtomoe-gtk/NEWS:1.4 libtomoe-gtk/NEWS:1.5 --- libtomoe-gtk/NEWS:1.4 Tue Nov 28 12:23:39 2006 +++ libtomoe-gtk/NEWS Fri Dec 22 13:47:10 2006 @@ -1,10 +1,13 @@ +Overview of Changes from libtomoegtk-0.4.0 to libtomoegtk-0.5.0 +=============================================================== + Overview of Changes from libtomoegtk-0.3.0 to libtomoegtk-0.4.0 -============================================================== +=============================================================== * Adaptation to TOMOE-0.4.0. * Removed dictionary pages. It will be provided as separated tools later. Overview of Changes from libtomoegtk-0.1.0 to libtomoegtk-0.3.0 -============================================================== +=============================================================== * Adaptation to TOMOE-0.3.0. * List view of the contents of each dictionary. * Searching the characters which has the readings you specify. From makeinu users.sourceforge.jp Fri Dec 22 13:48:38 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 13:48:38 +0900 Subject: [Tomoe-cvs 2009] CVS update: libtomoe-gtk Message-ID: <20061222044838.23F3F2AC0CA@users.sourceforge.jp> Index: libtomoe-gtk/NEWS diff -u libtomoe-gtk/NEWS:1.5 libtomoe-gtk/NEWS:1.6 --- libtomoe-gtk/NEWS:1.5 Fri Dec 22 13:47:10 2006 +++ libtomoe-gtk/NEWS Fri Dec 22 13:48:38 2006 @@ -1,5 +1,6 @@ Overview of Changes from libtomoegtk-0.4.0 to libtomoegtk-0.5.0 =============================================================== +* Search characters by stroke count. Overview of Changes from libtomoegtk-0.3.0 to libtomoegtk-0.4.0 =============================================================== From kous users.sourceforge.jp Fri Dec 22 14:01:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:01:02 +0900 Subject: [Tomoe-cvs 2010] CVS update: tomoe/test Message-ID: <20061222050102.7AE272AC106@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.30 tomoe/test/dict_spec.rb:1.31 --- tomoe/test/dict_spec.rb:1.30 Fri Dec 22 13:19:34 2006 +++ tomoe/test/dict_spec.rb Fri Dec 22 14:01:02 2006 @@ -171,6 +171,23 @@ end end + specify "should support variant search" do + make_temporary_dict(@original) do |dict| + hashigo_daka = ucs4_to_utf8(39641) # ?????? + char = Tomoe::Char.new + char.utf8 = "? + char.variant = hashigo_daka + + dict.register(char).should == true + + query = Tomoe::Query.new + query.variant = hashigo_daka + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["?] + end + end + def setup_strokes @strokes = [ [ From kous users.sourceforge.jp Fri Dec 22 14:01:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:01:02 +0900 Subject: [Tomoe-cvs 2011] CVS update: tomoe/lib Message-ID: <20061222050102.A7EE72AC107@users.sourceforge.jp> Index: tomoe/lib/tomoe-query.c diff -u tomoe/lib/tomoe-query.c:1.8 tomoe/lib/tomoe-query.c:1.9 --- tomoe/lib/tomoe-query.c:1.8 Thu Dec 21 17:18:17 2006 +++ tomoe/lib/tomoe-query.c Fri Dec 22 14:01:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.c,v 1.8 2006/12/21 08:18:17 kous Exp $ + * $Id: tomoe-query.c,v 1.9 2006/12/22 05:01:02 kous Exp $ */ #include @@ -41,7 +41,7 @@ GList *readings; GList *radicals; TomoeWriting *writing; - TomoeChar *variant; + gchar *variant; }; enum @@ -149,7 +149,7 @@ g_list_free (priv->radicals); } if (priv->variant) - g_object_unref (priv->variant); + g_free (priv->variant); if (priv->writing) g_object_unref (priv->writing); @@ -296,7 +296,7 @@ priv->radicals = g_list_prepend (priv->radicals, g_strdup (radical)); } -TomoeChar * +const gchar * tomoe_query_get_variant (TomoeQuery *query) { TomoeQueryPrivate *priv; @@ -309,7 +309,7 @@ } void -tomoe_query_set_variant (TomoeQuery *query, TomoeChar *variant) +tomoe_query_set_variant (TomoeQuery *query, const gchar *variant) { TomoeQueryPrivate *priv; @@ -318,8 +318,8 @@ priv = TOMOE_QUERY_GET_PRIVATE (query); if (priv->variant) - g_object_unref (G_OBJECT (priv->variant)); - priv->variant = g_object_ref (variant); + g_free (priv->variant); + priv->variant = variant ? g_strdup (variant) : NULL; } void Index: tomoe/lib/tomoe-query.h diff -u tomoe/lib/tomoe-query.h:1.8 tomoe/lib/tomoe-query.h:1.9 --- tomoe/lib/tomoe-query.h:1.8 Thu Dec 21 17:18:17 2006 +++ tomoe/lib/tomoe-query.h Fri Dec 22 14:01:02 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-query.h,v 1.8 2006/12/21 08:18:17 kous Exp $ + * $Id: tomoe-query.h,v 1.9 2006/12/22 05:01:02 kous Exp $ */ #ifndef __TOMOE_QUERY_H__ @@ -68,8 +68,8 @@ const GList *tomoe_query_get_radicals (TomoeQuery *query); void tomoe_query_set_variant (TomoeQuery *query, - TomoeChar *chr); -TomoeChar *tomoe_query_get_variant (TomoeQuery *query); + const gchar *variant); +const gchar *tomoe_query_get_variant (TomoeQuery *query); void tomoe_query_set_min_n_strokes (TomoeQuery *query, gint n_strokes); From kous users.sourceforge.jp Fri Dec 22 14:01:02 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:01:02 +0900 Subject: [Tomoe-cvs 2012] CVS update: tomoe/ext/ruby Message-ID: <20061222050102.D0E932AC106@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-query.c diff -u tomoe/ext/ruby/tomoe-rb-query.c:1.4 tomoe/ext/ruby/tomoe-rb-query.c:1.5 --- tomoe/ext/ruby/tomoe-rb-query.c:1.4 Thu Dec 21 17:18:17 2006 +++ tomoe/ext/ruby/tomoe-rb-query.c Fri Dec 22 14:01:02 2006 @@ -19,6 +19,13 @@ } static VALUE +tq_set_variant(VALUE self, VALUE variant) +{ + tomoe_query_set_variant(_SELF(self), RVAL2CSTR(variant)); + return Qnil; +} + +static VALUE tq_set_writing(VALUE self, VALUE writing) { tomoe_query_set_writing(_SELF(self), RVAL2TWTG(writing)); @@ -34,7 +41,7 @@ rb_define_method(cTomoeQuery, "add_reading", tq_add_reading, 1); rb_define_method(cTomoeQuery, "add_radical", tq_add_radical, 1); -/* rb_define_method(cTomoeQuery, "add_variant", tq_add_variant, 1); */ + rb_define_method(cTomoeQuery, "set_variant", tq_set_variant, 1); rb_define_method(cTomoeQuery, "set_writing", tq_set_writing, 1); G_DEF_SETTERS(cTomoeQuery); From makeinu users.sourceforge.jp Fri Dec 22 14:15:40 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Fri, 22 Dec 2006 14:15:40 +0900 Subject: [Tomoe-cvs 2013] CVS update: libtomoe-gtk/src Message-ID: <20061222051540.B04582AC022@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.31 libtomoe-gtk/src/tomoe-reading-search.c:1.32 --- libtomoe-gtk/src/tomoe-reading-search.c:1.31 Fri Dec 22 13:32:26 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Fri Dec 22 14:15:40 2006 @@ -431,7 +431,7 @@ utf8_len = g_utf8_strlen (utf8, -1); for (i = 0; i < utf8_len; i++) { g_string_append_printf (code_point_text, - "U+%d ", g_utf8_get_char (utf8)); + "U+%X", g_utf8_get_char (utf8)); utf8 = g_utf8_next_char (utf8); } if (code_point_text->len > 0) From kous users.sourceforge.jp Fri Dec 22 14:20:00 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:20:00 +0900 Subject: [Tomoe-cvs 2014] CVS update: tomoe Message-ID: <20061222052000.906542AC0FC@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.481 tomoe/ChangeLog:1.482 --- tomoe/ChangeLog:1.481 Fri Dec 22 13:19:33 2006 +++ tomoe/ChangeLog Fri Dec 22 14:20:00 2006 @@ -1,5 +1,12 @@ 2006-12-22 Kouhei Sutou + * module/dict/tomoe-dict-mysql.c: supported variant search. + + * test/dict_spec.rb: added tests for variant search. + * ext/ruby/tomoe-rb-query.c: added Tomoe::Query#set_variant. + * lib/tomoe-query.[ch]: fixed variant type to gchar * from + TomoeChar *. + * data/dict.dtd: added radicals. * test/char_spec.rb: added tests for load/dump XML with radicals. * lib/tomoe-xml-parser.c: supported parsing radicals. From kous users.sourceforge.jp Fri Dec 22 14:20:00 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:20:00 +0900 Subject: [Tomoe-cvs 2015] CVS update: tomoe/module/dict Message-ID: <20061222052000.B4E142AC107@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.20 tomoe/module/dict/tomoe-dict-mysql.c:1.21 --- tomoe/module/dict/tomoe-dict-mysql.c:1.20 Fri Dec 22 10:22:54 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Fri Dec 22 14:20:00 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.20 2006/12/22 01:22:54 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.21 2006/12/22 05:20:00 kous Exp $ */ #include @@ -598,9 +598,10 @@ variant = tomoe_char_get_variant (chr); if (variant) - g_string_append_printf (sql, "%d)", g_utf8_get_char (variant)); + append_string_value (dict, sql, variant); else - g_string_append (sql, "NULL)"); + g_string_append (sql, "NULL"); + g_string_append_printf (sql, ")"); success = execute_query (dict, sql->str); g_string_free (sql, TRUE); @@ -677,6 +678,20 @@ } static void +append_sql_condition_variant (TomoeDictMySQL *dict, GString *sql, + TomoeQuery *query) +{ + const gchar *variant; + + variant = tomoe_query_get_variant (query); + if (variant) { + g_string_append (sql, " AND variant = "); + append_string_value (dict, sql, variant); + g_string_append (sql, "\n"); + } +} + +static void append_sql_condition_min_n_strokes (TomoeDictMySQL *dict, GString *sql, TomoeQuery *query) { @@ -769,6 +784,7 @@ "SELECT utf8 FROM chars\n" "WHERE TRUE = TRUE\n"); append_sql_condition_utf8 (dict, sql, query); + append_sql_condition_variant (dict, sql, query); append_sql_condition_min_n_strokes (dict, sql, query); append_sql_condition_max_n_strokes (dict, sql, query); From kous users.sourceforge.jp Fri Dec 22 14:26:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:26:03 +0900 Subject: [Tomoe-cvs 2016] CVS update: tomoe Message-ID: <20061222052603.28C0A2AC0FB@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.482 tomoe/ChangeLog:1.483 --- tomoe/ChangeLog:1.482 Fri Dec 22 14:20:00 2006 +++ tomoe/ChangeLog Fri Dec 22 14:26:02 2006 @@ -1,5 +1,10 @@ 2006-12-22 Kouhei Sutou + * data/dict.dtd: added variant. + * test/char_spec.rb: added tests for load/dump XML with variant. + * lib/tomoe-xml-parser.c: supported parsing variant. + * lib/tomoe-char.c: supported outputting variant to XML. + * module/dict/tomoe-dict-mysql.c: supported variant search. * test/dict_spec.rb: added tests for variant search. From kous users.sourceforge.jp Fri Dec 22 14:26:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:26:03 +0900 Subject: [Tomoe-cvs 2017] CVS update: tomoe/test Message-ID: <20061222052603.6F8312AC0FB@users.sourceforge.jp> Index: tomoe/test/tomoe-spec-utils.rb diff -u tomoe/test/tomoe-spec-utils.rb:1.31 tomoe/test/tomoe-spec-utils.rb:1.32 --- tomoe/test/tomoe-spec-utils.rb:1.31 Thu Dec 21 11:55:11 2006 +++ tomoe/test/tomoe-spec-utils.rb Fri Dec 22 14:26:03 2006 @@ -27,25 +27,6 @@ class Context include TomoeSpecSetup end - - class ContextRunner - def run(exit_when_done) - @reporter.start(number_of_specs) - begin - @contexts.each do |context| - context.run(@reporter, @dry_run) - end - rescue Interrupt - ensure - @reporter.end - end - failure_count = @reporter.dump - if(exit_when_done) - exit_code = (failure_count == 0) ? 0 : 1 - exit(exit_code) - end - end - end end end Index: tomoe/test/char_spec.rb diff -u tomoe/test/char_spec.rb:1.8 tomoe/test/char_spec.rb:1.9 --- tomoe/test/char_spec.rb:1.8 Fri Dec 22 13:19:34 2006 +++ tomoe/test/char_spec.rb Fri Dec 22 14:26:03 2006 @@ -6,7 +6,7 @@ char.to_xml.should_empty end - specify "should dump XML with code-point" do + specify "should dump XML with UTF8" do char = Tomoe::Char.new char.utf8 = "?? xml = " \n" @@ -15,6 +15,18 @@ char.to_xml.should == xml end + specify "should dump XML with variant" do + hashigo_daka = ucs4_to_utf8(39641) # ?????? + char = Tomoe::Char.new + char.utf8 = "? + char.variant = hashigo_daka + xml = " \n" + xml << " ?/utf8>\n" + xml << " #{hashigo_daka}\n" + xml << " \n" + char.to_xml.should == xml + end + specify "should dump XML with radicals" do sanzui = ucs4_to_utf8(27701) # ?????? char = Tomoe::Char.new @@ -36,6 +48,17 @@ new_char.utf8.should == char.utf8 end + specify "should load from dumped XML with variant" do + hashigo_daka = ucs4_to_utf8(39641) # ?????? + char = Tomoe::Char.new + char.utf8 = "? + char.variant = hashigo_daka + + new_char = Tomoe::Char.new(char.to_xml) + new_char.utf8.should == char.utf8 + new_char.variant.should == hashigo_daka + end + specify "should load from dumped XML with radicals" do sanzui = ucs4_to_utf8(27701) # ?????? char = Tomoe::Char.new From kous users.sourceforge.jp Fri Dec 22 14:26:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:26:03 +0900 Subject: [Tomoe-cvs 2018] CVS update: tomoe/data Message-ID: <20061222052603.B78EB2AC0FB@users.sourceforge.jp> Index: tomoe/data/dict.dtd diff -u tomoe/data/dict.dtd:1.2 tomoe/data/dict.dtd:1.3 --- tomoe/data/dict.dtd:1.2 Fri Dec 22 13:19:34 2006 +++ tomoe/data/dict.dtd Fri Dec 22 14:26:03 2006 @@ -2,9 +2,10 @@ - + From kous users.sourceforge.jp Fri Dec 22 14:26:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:26:03 +0900 Subject: [Tomoe-cvs 2019] CVS update: tomoe/lib Message-ID: <20061222052603.DF53D2AC0FC@users.sourceforge.jp> Index: tomoe/lib/tomoe-char.c diff -u tomoe/lib/tomoe-char.c:1.61 tomoe/lib/tomoe-char.c:1.62 --- tomoe/lib/tomoe-char.c:1.61 Fri Dec 22 13:19:34 2006 +++ tomoe/lib/tomoe-char.c Fri Dec 22 14:26:03 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-char.c,v 1.61 2006/12/22 04:19:34 kous Exp $ + * $Id: tomoe-char.c,v 1.62 2006/12/22 05:26:03 kous Exp $ */ #include @@ -461,6 +461,20 @@ } static void +tomoe_char_to_xml_variant (TomoeChar *chr, TomoeCharPrivate *priv, + GString *output) +{ + gchar *xml; + + if (!priv->variant) return; + + xml = g_markup_printf_escaped (" %s\n", + priv->variant); + g_string_append (output, xml); + g_free (xml); +} + +static void tomoe_char_to_xml_readings (TomoeChar *chr, TomoeCharPrivate *priv, GString *output) { @@ -555,6 +569,7 @@ output = g_string_new (""); tomoe_char_to_xml_utf8 (chr, priv, output); + tomoe_char_to_xml_variant (chr, priv, output); tomoe_char_to_xml_readings (chr, priv, output); tomoe_char_to_xml_radicals (chr, priv, output); tomoe_char_to_xml_writing (chr, priv, output); Index: tomoe/lib/tomoe-xml-parser.c diff -u tomoe/lib/tomoe-xml-parser.c:1.3 tomoe/lib/tomoe-xml-parser.c:1.4 --- tomoe/lib/tomoe-xml-parser.c:1.3 Fri Dec 22 13:19:34 2006 +++ tomoe/lib/tomoe-xml-parser.c Fri Dec 22 14:26:03 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-xml-parser.c,v 1.3 2006/12/22 04:19:34 kous Exp $ + * $Id: tomoe-xml-parser.c,v 1.4 2006/12/22 05:26:03 kous Exp $ */ #include @@ -34,6 +34,7 @@ typedef enum { STATE_NONE, STATE_UTF8, + STATE_VARIANT, STATE_N_STROKES, STATE_STROKES, STATE_READINGS, @@ -127,6 +128,11 @@ return; } + if (!strcmp ("variant", element_name)) { + data->state = STATE_VARIANT; + return; + } + if (!strcmp ("number-of-strokes", element_name)) { data->state = STATE_N_STROKES; return; @@ -265,6 +271,11 @@ return; } + if (!strcmp("variant", element_name)) { + data->state = STATE_NONE; + return; + } + if (!strcmp ("number-of-strokes", element_name)) { data->state = STATE_NONE; return; @@ -340,6 +351,11 @@ tomoe_char_set_utf8 (data->chr, text); return; } + case STATE_VARIANT: + { + tomoe_char_set_variant (data->chr, text); + return; + } case STATE_N_STROKES: { tomoe_char_set_n_strokes (data->chr, atoi (text)); From kous users.sourceforge.jp Fri Dec 22 14:26:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:26:54 +0900 Subject: [Tomoe-cvs 2020] CVS update: tomoe Message-ID: <20061222052654.8EF732AC106@users.sourceforge.jp> Index: tomoe/TODO diff -u tomoe/TODO:1.14 tomoe/TODO:1.15 --- tomoe/TODO:1.14 Mon Dec 11 16:17:43 2006 +++ tomoe/TODO Fri Dec 22 14:26:54 2006 @@ -4,7 +4,6 @@ * Implement advanced searching. * Add modulized dictionary types. - CHISE? -* Add radicals and variant element into tomoe-dict.dtd. * Asynchronous dictionary loading? * Asynchronous searching? * Prepare character data base. Index: tomoe/NEWS diff -u tomoe/NEWS:1.9 tomoe/NEWS:1.10 --- tomoe/NEWS:1.9 Tue Dec 12 15:21:01 2006 +++ tomoe/NEWS Fri Dec 22 14:26:54 2006 @@ -4,6 +4,7 @@ - Hyper Estraier - Unihan database - MySQL +* Add radicals and variant element into dict.dtd. Overview of Changes from libtomoe-0.3.0 to libtomoe-0.4.0 ============================================================== From kous users.sourceforge.jp Fri Dec 22 14:40:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:40:41 +0900 Subject: [Tomoe-cvs 2021] CVS update: tomoe Message-ID: <20061222054041.7A4C12AC0FE@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.483 tomoe/ChangeLog:1.484 --- tomoe/ChangeLog:1.483 Fri Dec 22 14:26:02 2006 +++ tomoe/ChangeLog Fri Dec 22 14:40:41 2006 @@ -1,5 +1,8 @@ 2006-12-22 Kouhei Sutou + * module/dict/tomoe-dict-ptr-array.c: supported variant search and + utf8 search. + * data/dict.dtd: added variant. * test/char_spec.rb: added tests for load/dump XML with variant. * lib/tomoe-xml-parser.c: supported parsing variant. From kous users.sourceforge.jp Fri Dec 22 14:40:41 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:40:41 +0900 Subject: [Tomoe-cvs 2022] CVS update: tomoe/module/dict Message-ID: <20061222054041.A87512AC100@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-ptr-array.c diff -u tomoe/module/dict/tomoe-dict-ptr-array.c:1.5 tomoe/module/dict/tomoe-dict-ptr-array.c:1.6 --- tomoe/module/dict/tomoe-dict-ptr-array.c:1.5 Fri Dec 22 11:50:33 2006 +++ tomoe/module/dict/tomoe-dict-ptr-array.c Fri Dec 22 14:40:41 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ptr-array.c,v 1.5 2006/12/22 02:50:33 kous Exp $ + * $Id: tomoe-dict-ptr-array.c,v 1.6 2006/12/22 05:40:41 kous Exp $ */ #include @@ -101,6 +101,30 @@ } static gboolean +does_match_char_with_utf8 (TomoeChar *chr, const gchar *utf8) +{ + if (!utf8) + return TRUE; + + return g_utf8_collate (tomoe_char_get_utf8 (chr), utf8) == 0; +} + +static gboolean +does_match_char_with_variant (TomoeChar *chr, const gchar *variant) +{ + const gchar *chr_variant; + + if (!variant) + return TRUE; + + chr_variant = tomoe_char_get_variant (chr); + if (!chr_variant) + return FALSE; + + return g_utf8_collate (chr_variant, variant) == 0; +} + +static gboolean does_match_char_with_n_strokes (TomoeChar *chr, gint min, gint max) { TomoeWriting *writing; @@ -191,23 +215,19 @@ { TomoeChar *chr = data; TomoeDictSearchContext *context = user_data; - TomoeQuery *query; - - query = context->query; - - if (!does_match_char_with_n_strokes (chr, - tomoe_query_get_min_n_strokes (query), - tomoe_query_get_max_n_strokes (query))) - return; + TomoeQuery *q; - if (!does_match_char_with_readings (chr, tomoe_query_get_readings (query))) - return; - - if (!does_match_char_with_radicals (chr, tomoe_query_get_radicals (query))) - return; - - context->results = g_list_prepend (context->results, - tomoe_candidate_new (chr)); + q = context->query; + if (does_match_char_with_utf8 (chr, tomoe_query_get_utf8 (q)) && + does_match_char_with_variant (chr, tomoe_query_get_variant (q)) && + does_match_char_with_n_strokes (chr, + tomoe_query_get_min_n_strokes (q), + tomoe_query_get_max_n_strokes (q)) && + does_match_char_with_readings (chr, tomoe_query_get_readings (q)) && + does_match_char_with_radicals (chr, tomoe_query_get_radicals (q))) { + context->results = g_list_prepend (context->results, + tomoe_candidate_new (chr)); + } } static void From kous users.sourceforge.jp Fri Dec 22 14:43:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:43:03 +0900 Subject: [Tomoe-cvs 2023] CVS update: tomoe Message-ID: <20061222054303.3F1B82AC0FB@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.484 tomoe/ChangeLog:1.485 --- tomoe/ChangeLog:1.484 Fri Dec 22 14:40:41 2006 +++ tomoe/ChangeLog Fri Dec 22 14:43:03 2006 @@ -1,5 +1,7 @@ 2006-12-22 Kouhei Sutou + * module/dict/tomoe-dict-est.c: supported variant search. + * module/dict/tomoe-dict-ptr-array.c: supported variant search and utf8 search. From kous users.sourceforge.jp Fri Dec 22 14:43:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:43:03 +0900 Subject: [Tomoe-cvs 2024] CVS update: tomoe/module/dict Message-ID: <20061222054303.700562AC106@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.17 tomoe/module/dict/tomoe-dict-est.c:1.18 --- tomoe/module/dict/tomoe-dict-est.c:1.17 Fri Dec 22 13:19:34 2006 +++ tomoe/module/dict/tomoe-dict-est.c Fri Dec 22 14:43:03 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.17 2006/12/22 04:19:34 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.18 2006/12/22 05:43:03 kous Exp $ */ #include @@ -482,7 +482,6 @@ ESTCOND *cond; GString *attr, *phrase; int i, *results, n_results; - gint min_n_strokes, max_n_strokes; g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), candidates); @@ -496,6 +495,14 @@ g_string_assign (phrase, "[UVSET]"); } else { GList *node; + gint min_n_strokes, max_n_strokes; + const gchar *variant; + + variant = tomoe_query_get_variant (query); + if (variant) { + g_string_printf (attr, "variant STREQ %s", variant); + est_cond_add_attr (cond, attr->str); + } min_n_strokes = tomoe_query_get_min_n_strokes (query); if (min_n_strokes >= 0) { From kous users.sourceforge.jp Fri Dec 22 14:45:03 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:45:03 +0900 Subject: [Tomoe-cvs 2025] CVS update: tomoe Message-ID: <20061222054504.ECFDF2AC100@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.485 tomoe/ChangeLog:1.486 --- tomoe/ChangeLog:1.485 Fri Dec 22 14:43:03 2006 +++ tomoe/ChangeLog Fri Dec 22 14:45:03 2006 @@ -1,5 +1,7 @@ 2006-12-22 Kouhei Sutou + * test/dict_spec.rb: added tests for searching by UTF8. + * module/dict/tomoe-dict-est.c: supported variant search. * module/dict/tomoe-dict-ptr-array.c: supported variant search and From kous users.sourceforge.jp Fri Dec 22 14:45:05 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:45:05 +0900 Subject: [Tomoe-cvs 2026] CVS update: tomoe/test Message-ID: <20061222054505.319F62AC101@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.31 tomoe/test/dict_spec.rb:1.32 --- tomoe/test/dict_spec.rb:1.31 Fri Dec 22 14:01:02 2006 +++ tomoe/test/dict_spec.rb Fri Dec 22 14:45:05 2006 @@ -188,6 +188,21 @@ end end + specify "should support UTF8 search" do + make_temporary_dict(@original) do |dict| + char = Tomoe::Char.new + char.utf8 = "?? + + dict.register(char).should == true + + query = Tomoe::Query.new + query.utf8 = "?? + dict.search(query).collect do |cand| + cand.char.utf8 + end.should == ["??] + end + end + def setup_strokes @strokes = [ [ From kous users.sourceforge.jp Fri Dec 22 14:47:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:47:25 +0900 Subject: [Tomoe-cvs 2027] CVS update: tomoe Message-ID: <20061222054725.5376A2AC0FB@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.486 tomoe/ChangeLog:1.487 --- tomoe/ChangeLog:1.486 Fri Dec 22 14:45:03 2006 +++ tomoe/ChangeLog Fri Dec 22 14:47:25 2006 @@ -1,5 +1,7 @@ 2006-12-22 Kouhei Sutou + * module/dict/tomoe-dict-est.c: supported UTF8 search. + * test/dict_spec.rb: added tests for searching by UTF8. * module/dict/tomoe-dict-est.c: supported variant search. From kous users.sourceforge.jp Fri Dec 22 14:47:25 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:47:25 +0900 Subject: [Tomoe-cvs 2028] CVS update: tomoe/module/dict Message-ID: <20061222054725.7DF772AC0FE@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.18 tomoe/module/dict/tomoe-dict-est.c:1.19 --- tomoe/module/dict/tomoe-dict-est.c:1.18 Fri Dec 22 14:43:03 2006 +++ tomoe/module/dict/tomoe-dict-est.c Fri Dec 22 14:47:25 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.18 2006/12/22 05:43:03 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.19 2006/12/22 05:47:25 kous Exp $ */ #include @@ -496,12 +496,25 @@ } else { GList *node; gint min_n_strokes, max_n_strokes; - const gchar *variant; + const gchar *utf8, *variant; + + utf8 = tomoe_query_get_utf8 (query); + if (utf8) { + gchar *escaped_utf8; + + escaped_utf8 = g_markup_escape_text (utf8, -1); + g_string_append_printf (phrase, " %s", escaped_utf8); + g_free (escaped_utf8); + } variant = tomoe_query_get_variant (query); if (variant) { - g_string_printf (attr, "variant STREQ %s", variant); - est_cond_add_attr (cond, attr->str); + gchar *escaped_variant; + + escaped_variant = g_markup_escape_text (variant, -1); + g_string_append_printf (phrase, " %s", + escaped_variant); + g_free (escaped_variant); } min_n_strokes = tomoe_query_get_min_n_strokes (query); From kous users.sourceforge.jp Fri Dec 22 14:59:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:59:33 +0900 Subject: [Tomoe-cvs 2029] CVS update: tomoe Message-ID: <20061222055933.9C0862AC100@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.487 tomoe/ChangeLog:1.488 --- tomoe/ChangeLog:1.487 Fri Dec 22 14:47:25 2006 +++ tomoe/ChangeLog Fri Dec 22 14:59:33 2006 @@ -1,6 +1,8 @@ 2006-12-22 Kouhei Sutou - * module/dict/tomoe-dict-est.c: supported UTF8 search. + * module/dict/tomoe-dict-est.c: + - supported UTF8 search. + - cleanup. * test/dict_spec.rb: added tests for searching by UTF8. From kous users.sourceforge.jp Fri Dec 22 14:59:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Fri, 22 Dec 2006 14:59:33 +0900 Subject: [Tomoe-cvs 2030] CVS update: tomoe/module/dict Message-ID: <20061222055933.C8B062AC1DA@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.19 tomoe/module/dict/tomoe-dict-est.c:1.20 --- tomoe/module/dict/tomoe-dict-est.c:1.19 Fri Dec 22 14:47:25 2006 +++ tomoe/module/dict/tomoe-dict-est.c Fri Dec 22 14:59:33 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.19 2006/12/22 05:47:25 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.20 2006/12/22 05:59:33 kous Exp $ */ #include @@ -474,13 +474,94 @@ return chr; } +static void +append_search_cond_utf8 (TomoeDictEst *dict, ESTCOND *cond, GString *phrase, + const gchar *utf8) +{ + if (utf8) { + gchar *escaped_utf8; + + escaped_utf8 = g_markup_escape_text (utf8, -1); + g_string_append_printf (phrase, " %s", escaped_utf8); + g_free (escaped_utf8); + } +} + +static void +append_search_cond_variant (TomoeDictEst *dict, ESTCOND *cond, GString *phrase, + const gchar *variant) +{ + if (variant) { + gchar *escaped_variant; + + escaped_variant = g_markup_escape_text (variant, -1); + g_string_append_printf (phrase, + " %s", escaped_variant); + g_free (escaped_variant); + } +} + +static void +append_search_cond_n_strokes (TomoeDictEst *dict, ESTCOND *cond, + GString *phrase, + gint min_n_strokes, + gint max_n_strokes) +{ + gchar *attr; + + if (min_n_strokes >= 0) { + attr = g_strdup_printf ("n-strokes NUMGE %d", min_n_strokes); + est_cond_add_attr (cond, attr); + g_free (attr); + } + + if (max_n_strokes >= 0) { + attr = g_strdup_printf ("n-strokes NUMLE %d", max_n_strokes); + est_cond_add_attr (cond, attr); + g_free (attr); + } +} + +static void +append_search_cond_readings (TomoeDictEst *dict, ESTCOND *cond, GString *phrase, + const GList *readings) +{ + GList *node; + for (node = (GList *)readings; node; node = g_list_next (node)) { + TomoeReading *reading = node->data; + gchar *xml; + + xml = tomoe_reading_to_xml (reading); + g_string_append_printf (phrase, " %s", xml); + g_free (xml); + } +} + +static void +append_search_cond_radicals (TomoeDictEst *dict, ESTCOND *cond, GString *phrase, + const GList *radicals) +{ + GList *node; + for (node = (GList *)radicals; node; node = g_list_next (node)) { + const gchar *radical = node->data; + gchar *escaped_radical; + + escaped_radical = g_markup_escape_text (radical, -1); + g_string_append_printf (phrase, + " %s", + escaped_radical); + g_free (escaped_radical); + } +} + + static GList * search (TomoeDict *_dict, TomoeQuery *query) { TomoeDictEst *dict = TOMOE_DICT_EST (_dict); GList *candidates = NULL; ESTCOND *cond; - GString *attr, *phrase; + GString *phrase; int i, *results, n_results; g_return_val_if_fail (TOMOE_IS_DICT_EST (dict), candidates); @@ -488,76 +569,26 @@ cond = est_cond_new (); est_cond_set_order (cond, "utf8 STRA"); - attr = g_string_new (""); phrase = g_string_new (""); if (tomoe_query_is_empty (query)) { g_string_assign (phrase, "[UVSET]"); } else { - GList *node; - gint min_n_strokes, max_n_strokes; - const gchar *utf8, *variant; - - utf8 = tomoe_query_get_utf8 (query); - if (utf8) { - gchar *escaped_utf8; - - escaped_utf8 = g_markup_escape_text (utf8, -1); - g_string_append_printf (phrase, " %s", escaped_utf8); - g_free (escaped_utf8); - } - - variant = tomoe_query_get_variant (query); - if (variant) { - gchar *escaped_variant; - - escaped_variant = g_markup_escape_text (variant, -1); - g_string_append_printf (phrase, " %s", - escaped_variant); - g_free (escaped_variant); - } - - min_n_strokes = tomoe_query_get_min_n_strokes (query); - if (min_n_strokes >= 0) { - g_string_printf (attr, "n-strokes NUMGE %d", min_n_strokes); - est_cond_add_attr (cond, attr->str); - } - - max_n_strokes = tomoe_query_get_max_n_strokes (query); - if (max_n_strokes >= 0) { - g_string_printf (attr, "n-strokes NUMLE %d", max_n_strokes); - est_cond_add_attr (cond, attr->str); - } - - for (node = (GList *)tomoe_query_get_readings (query); - node; - node = g_list_next (node)) { - TomoeReading *reading = node->data; - gchar *xml; - - xml = tomoe_reading_to_xml (reading); - g_string_append_printf (phrase, " %s", xml); - g_free (xml); - } - - for (node = (GList *)tomoe_query_get_radicals (query); - node; - node = g_list_next (node)) { - const gchar *radical = node->data; - gchar *escaped_radical; - - escaped_radical = g_markup_escape_text (radical, -1); - g_string_append_printf (phrase, - " %s", - escaped_radical); - g_free (escaped_radical); - } + append_search_cond_utf8 (dict, cond, phrase, + tomoe_query_get_utf8 (query)); + append_search_cond_variant (dict, cond, phrase, + tomoe_query_get_variant (query)); + append_search_cond_n_strokes (dict, cond, phrase, + tomoe_query_get_min_n_strokes (query), + tomoe_query_get_max_n_strokes (query)); + append_search_cond_readings (dict, cond, phrase, + tomoe_query_get_readings (query)); + append_search_cond_radicals (dict, cond, phrase, + tomoe_query_get_radicals (query)); } if (phrase->len > 0) est_cond_set_phrase (cond, phrase->str); - - g_string_free (attr, TRUE); g_string_free (phrase, TRUE); results = est_db_search (dict->db, cond, &n_results, NULL); From kous users.sourceforge.jp Mon Dec 25 10:37:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:57 +0900 Subject: [Tomoe-cvs 2031] CVS update: tomoe/benchmark Message-ID: <20061225013757.7BA892AC05B@users.sourceforge.jp> Index: tomoe/benchmark/.cvsignore diff -u /dev/null tomoe/benchmark/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:57 2006 +++ tomoe/benchmark/.cvsignore Mon Dec 25 10:37:57 2006 @@ -0,0 +1,2 @@ +Makefile +Makefile.in From kous users.sourceforge.jp Mon Dec 25 10:37:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:57 +0900 Subject: [Tomoe-cvs 2032] CVS update: tomoe/data Message-ID: <20061225013757.A89BF2AC0F5@users.sourceforge.jp> Index: tomoe/data/.cvsignore diff -u tomoe/data/.cvsignore:1.1 tomoe/data/.cvsignore:1.2 --- tomoe/data/.cvsignore:1.1 Tue Dec 14 22:40:21 2004 +++ tomoe/data/.cvsignore Mon Dec 25 10:37:57 2006 @@ -1,2 +1,3 @@ Makefile Makefile.in +kanjidic2.xml From kous users.sourceforge.jp Mon Dec 25 10:37:57 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:57 +0900 Subject: [Tomoe-cvs 2033] CVS update: tomoe/db Message-ID: <20061225013757.D5D752AC05B@users.sourceforge.jp> Index: tomoe/db/.cvsignore diff -u /dev/null tomoe/db/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:57 2006 +++ tomoe/db/.cvsignore Mon Dec 25 10:37:57 2006 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +config.yml From kous users.sourceforge.jp Mon Dec 25 10:37:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:58 +0900 Subject: [Tomoe-cvs 2034] CVS update: tomoe/ext Message-ID: <20061225013758.106282AC0F5@users.sourceforge.jp> Index: tomoe/ext/.cvsignore diff -u /dev/null tomoe/ext/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:58 2006 +++ tomoe/ext/.cvsignore Mon Dec 25 10:37:57 2006 @@ -0,0 +1,2 @@ +Makefile +Makefile.in From kous users.sourceforge.jp Mon Dec 25 10:37:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:58 +0900 Subject: [Tomoe-cvs 2035] CVS update: tomoe/ext/ruby Message-ID: <20061225013758.3C71A2AC05B@users.sourceforge.jp> Index: tomoe/ext/ruby/.cvsignore diff -u /dev/null tomoe/ext/ruby/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:58 2006 +++ tomoe/ext/ruby/.cvsignore Mon Dec 25 10:37:58 2006 @@ -0,0 +1,7 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la + From kous users.sourceforge.jp Mon Dec 25 10:37:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:58 +0900 Subject: [Tomoe-cvs 2036] CVS update: tomoe/module Message-ID: <20061225013758.688202AC0F5@users.sourceforge.jp> Index: tomoe/module/.cvsignore diff -u /dev/null tomoe/module/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:58 2006 +++ tomoe/module/.cvsignore Mon Dec 25 10:37:58 2006 @@ -0,0 +1,3 @@ +Makefile +Makefile.in + From kous users.sourceforge.jp Mon Dec 25 10:37:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:58 +0900 Subject: [Tomoe-cvs 2037] CVS update: tomoe/module/dict Message-ID: <20061225013758.9375E2AC05B@users.sourceforge.jp> Index: tomoe/module/dict/.cvsignore diff -u tomoe/module/dict/.cvsignore:1.1 tomoe/module/dict/.cvsignore:1.2 --- tomoe/module/dict/.cvsignore:1.1 Mon Dec 4 10:27:46 2006 +++ tomoe/module/dict/.cvsignore Mon Dec 25 10:37:58 2006 @@ -1,2 +1,11 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la +tomoe-unihan-data.h +Unihan.stamp Unihan.txt +Unihan.txt.cache Unihan.zip From kous users.sourceforge.jp Mon Dec 25 10:37:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:58 +0900 Subject: [Tomoe-cvs 2038] CVS update: tomoe/module/recognizer Message-ID: <20061225013758.BE3412AC0F5@users.sourceforge.jp> Index: tomoe/module/recognizer/.cvsignore diff -u /dev/null tomoe/module/recognizer/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:58 2006 +++ tomoe/module/recognizer/.cvsignore Mon Dec 25 10:37:58 2006 @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la From kous users.sourceforge.jp Mon Dec 25 10:37:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 10:37:58 +0900 Subject: [Tomoe-cvs 2039] CVS update: tomoe/test/data Message-ID: <20061225013758.ECEB42AC05B@users.sourceforge.jp> Index: tomoe/test/data/.cvsignore diff -u /dev/null tomoe/test/data/.cvsignore:1.1 --- /dev/null Mon Dec 25 10:37:58 2006 +++ tomoe/test/data/.cvsignore Mon Dec 25 10:37:58 2006 @@ -0,0 +1,2 @@ +Makefile +Makefile.in From kous users.sourceforge.jp Mon Dec 25 11:11:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:11:58 +0900 Subject: [Tomoe-cvs 2040] CVS update: tomoe/spec Message-ID: <20061225021158.E83372AC05B@users.sourceforge.jp> From kous users.sourceforge.jp Mon Dec 25 11:12:09 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:12:09 +0900 Subject: [Tomoe-cvs 2041] CVS update: tomoe/spec/turbo-linux Message-ID: <20061225021209.2B2A62AC05B@users.sourceforge.jp> From kous users.sourceforge.jp Mon Dec 25 11:16:24 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:16:24 +0900 Subject: [Tomoe-cvs 2042] CVS update: tomoe/spec/miracle-linux Message-ID: <20061225021624.1E7E02AC160@users.sourceforge.jp> From kous users.sourceforge.jp Mon Dec 25 11:17:52 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:17:52 +0900 Subject: [Tomoe-cvs 2043] CVS update: tomoe Message-ID: <20061225021752.8FD772AC062@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.488 tomoe/ChangeLog:1.489 --- tomoe/ChangeLog:1.488 Fri Dec 22 14:59:33 2006 +++ tomoe/ChangeLog Mon Dec 25 11:17:52 2006 @@ -1,3 +1,9 @@ +2006-12-25 Kouhei Sutou + + * configure.in, Makefile.am, spec/: moved tomoe.spec.in to + spec/turbo-linux/. + * doc/: updated. + 2006-12-22 Kouhei Sutou * module/dict/tomoe-dict-est.c: Index: tomoe/Makefile.am diff -u tomoe/Makefile.am:1.19 tomoe/Makefile.am:1.20 --- tomoe/Makefile.am:1.19 Wed Dec 6 18:00:59 2006 +++ tomoe/Makefile.am Mon Dec 25 11:17:52 2006 @@ -18,7 +18,7 @@ ## Free Software Foundation, Inc., 59 Temple Place, Suite 330, ## Boston, MA 02111-1307 USA -SUBDIRS = lib ext module data test benchmark doc +SUBDIRS = lib ext module data test benchmark doc spec EXTRA_DIST = autogen.sh tomoe.pc Index: tomoe/configure.in diff -u tomoe/configure.in:1.51 tomoe/configure.in:1.52 --- tomoe/configure.in:1.51 Mon Dec 18 15:45:03 2006 +++ tomoe/configure.in Mon Dec 25 11:17:52 2006 @@ -410,7 +410,11 @@ doc/reference/Makefile doc/reference/version.xml tomoe.pc -tomoe.spec +spec/Makefile +spec/turbo-linux/Makefile +spec/turbo-linux/tomoe.spec +spec/miracle-linux/Makefile +spec/miracle-linux/tomoe.spec ]) AC_OUTPUT Index: tomoe/tomoe.spec.in diff -u tomoe/tomoe.spec.in:1.3 tomoe/tomoe.spec.in:removed --- tomoe/tomoe.spec.in:1.3 Thu Dec 21 15:09:25 2006 +++ tomoe/tomoe.spec.in Mon Dec 25 11:17:52 2006 @@ -1,96 +0,0 @@ -# -*- coding:utf-8-unix -*- -# -# $Id: tomoe.spec.in,v 1.3 2006/12/21 06:09:25 kous Exp $ -# -# Copyright (c) 2006 Kouhei Sutou -# This file and all modifications and/or additions are under -# the same license as package itself. -# - -Name: tomoe -Version: @VERSION@ -Release: 0 -Serial: 2006121801 - -Summary: Tegaki Online MOji-ninshiki Engine -Summary(ja_JP.utf8): ??????????????Tomoe -URL: http://tomoe.sourceforge.jp/ -Source0: %{name}-%{version}.tar.gz -License: LGPL -Group: System Environment/Libraries -BuildRoot: %{_tmppath}/%{name}-%{version}-root - -Requires: /sbin/ldconfig -Requires: mysql-client -BuildRequires: pkgconfig -BuildRequires: glib2-devel -BuildRequires: mysql-devel - -%description -Tomoe provides a handwriting recognition engine and its user -interface on open source desktop environment. - - -%description -l ja_JP.utf8 -Tomoe????????????????????????????????? -??????????????- -%package devel -Summary: Tomoe developmental libraries and header files -Summary(ja_JP.utf8): Tomoe?????????????????????? -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} -Requires: glib2-devel -Requires: mysql-devel - -%description devel -Developmental libraries and header files required for developing or -compiling software which links to the Tomoe library, which is an open -source handwriting recognition engine. - -%description devel -l ja_JP.utf8 -Tomoe????????????????????????????????????????????????? -??????????????Tomoe????????????????????????????- -%prep -%setup -q - -%build -%configure --without-ruby --enable-mysql -make - -%install -rm -rf $RPM_BUILD_ROOT - -%makeinstall -rm $RPM_BUILD_ROOT%{_libdir}/*.la -rm $RPM_BUILD_ROOT%{_libdir}/*.a - -%clean -rm -rf $RPM_BUILD_ROOT - -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig - -%files -%defattr(-,root,root,-) -#%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO -%doc AUTHORS ChangeLog COPYING NEWS TODO - -%{_libdir}/libtomoe*.so.* -%{_libdir}/tomoe/module/dict/* -%{_libdir}/tomoe/module/recognizer/* -%{_sysconfdir}/tomoe/* -%{_datadir}/tomoe/dict.dtd -%{_datadir}/tomoe/recognizer/* - -%files devel -%defattr(-,root,root,-) -%{_includedir}/* -%{_libdir}/libtomoe*.so -%{_libdir}/pkgconfig/* -%{_datadir}/gtk-doc/* - -%changelog -* Mon Dec 18 2006 Kouhei Sutou - 0.5.0-0 -- initial release. From kous users.sourceforge.jp Mon Dec 25 11:17:52 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:17:52 +0900 Subject: [Tomoe-cvs 2044] CVS update: tomoe/doc/reference/tmpl Message-ID: <20061225021752.C38AE2AC113@users.sourceforge.jp> Index: tomoe/doc/reference/tmpl/tomoe-char.sgml diff -u tomoe/doc/reference/tmpl/tomoe-char.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-char.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-char.sgml:1.3 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-char.sgml Mon Dec 25 11:17:52 2006 @@ -17,6 +17,20 @@ + + + + + + + + + + + + + + The #TomoeChar struct contains only @@ -52,6 +66,16 @@ @Returns: + + + + + + data: + len: + Returns: + + Index: tomoe/doc/reference/tmpl/tomoe-config.sgml diff -u tomoe/doc/reference/tmpl/tomoe-config.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-config.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-config.sgml:1.3 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-config.sgml Mon Dec 25 11:17:52 2006 @@ -4,7 +4,6 @@ An object of configuration file. - @@ -39,15 +38,16 @@ @Returns: - + @config: + Returns: - + Index: tomoe/doc/reference/tmpl/tomoe-context.sgml diff -u tomoe/doc/reference/tmpl/tomoe-context.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-context.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-context.sgml:1.3 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-context.sgml Mon Dec 25 11:17:52 2006 @@ -4,7 +4,6 @@ An object of... - @@ -25,6 +24,11 @@ + + + + + @@ -62,3 +66,33 @@ @Returns: + + + + + + ctx: + utf8: + Returns: + + + + + + + + ctx: + chr: + Returns: + + + + + + + + ctx: + utf8: + Returns: + + Index: tomoe/doc/reference/tmpl/tomoe-dict.sgml diff -u tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.4 tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.5 --- tomoe/doc/reference/tmpl/tomoe-dict.sgml:1.4 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-dict.sgml Mon Dec 25 11:17:52 2006 @@ -4,7 +4,6 @@ An object of dictionary. - @@ -25,6 +24,29 @@ + + + + + + base_dir: + + + + + + + + + + + + + + + Returns: + + @@ -75,3 +97,40 @@ @Returns: + + + + + + dict: + query: + Returns: + + + + + + + + dict: + Returns: + + + + + + + + dict: + Returns: + + + + + + + + dict: + Returns: + + Index: tomoe/doc/reference/tmpl/tomoe-module.sgml diff -u tomoe/doc/reference/tmpl/tomoe-module.sgml:1.1 tomoe/doc/reference/tmpl/tomoe-module.sgml:1.2 --- tomoe/doc/reference/tmpl/tomoe-module.sgml:1.1 Thu Nov 30 18:19:07 2006 +++ tomoe/doc/reference/tmpl/tomoe-module.sgml Mon Dec 25 11:17:52 2006 @@ -22,5 +22,42 @@ - object: + + + + + + + base_dir: + Returns: + + + + + + + + modules: + name: + first_property: + var_args: + Returns: + + + + + + + + modules: + Returns: + + + + + + + + module: + Index: tomoe/doc/reference/tmpl/tomoe-query.sgml diff -u tomoe/doc/reference/tmpl/tomoe-query.sgml:1.4 tomoe/doc/reference/tmpl/tomoe-query.sgml:1.5 --- tomoe/doc/reference/tmpl/tomoe-query.sgml:1.4 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-query.sgml Mon Dec 25 11:17:52 2006 @@ -4,7 +4,6 @@ An object for representing search conditions. - @@ -25,6 +24,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -33,6 +52,24 @@ @Returns: + + + + + + query: + Returns: + + + + + + + + query: + utf8: + + @@ -57,7 +94,70 @@ @query: - chr: + radical: + + + + + + + + query: + Returns: + + + + + + + + query: + variant: + + + + + + + + query: + Returns: + + + + + + + + query: + n_strokes: + + + + + + + + query: + Returns: + + + + + + + + query: + n_strokes: + + + + + + + + query: + Returns: @@ -78,3 +178,12 @@ @Returns: + + + + + + query: + Returns: + + Index: tomoe/doc/reference/tmpl/tomoe-reading.sgml diff -u tomoe/doc/reference/tmpl/tomoe-reading.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-reading.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-reading.sgml:1.3 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-reading.sgml Mon Dec 25 11:17:52 2006 @@ -4,7 +4,6 @@ An object of reading data of #TomoeChar. - @@ -73,3 +72,12 @@ @Returns: + + + + + + reading: + Returns: + + Index: tomoe/doc/reference/tmpl/tomoe-recognizer.sgml diff -u tomoe/doc/reference/tmpl/tomoe-recognizer.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-recognizer.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-recognizer.sgml:1.2 Fri Dec 1 11:15:55 2006 +++ tomoe/doc/reference/tmpl/tomoe-recognizer.sgml Mon Dec 25 11:17:52 2006 @@ -24,6 +24,29 @@ + + + + + + base_dir: + + + + + + + + + + + + + + + Returns: + + @@ -41,7 +64,6 @@ @recognizer: - dict: @input: @Returns: Index: tomoe/doc/reference/tmpl/tomoe-shelf.sgml diff -u tomoe/doc/reference/tmpl/tomoe-shelf.sgml:1.3 tomoe/doc/reference/tmpl/tomoe-shelf.sgml:1.4 --- tomoe/doc/reference/tmpl/tomoe-shelf.sgml:1.3 Fri Dec 1 11:26:49 2006 +++ tomoe/doc/reference/tmpl/tomoe-shelf.sgml Mon Dec 25 11:17:52 2006 @@ -4,7 +4,6 @@ An object of dictionaries. - @@ -33,26 +32,27 @@ @Returns: - + @shelf: - dict: + name: + Returns: - + @shelf: @name: - Returns: + dict: - + Index: tomoe/doc/reference/tmpl/tomoe-unused.sgml diff -u tomoe/doc/reference/tmpl/tomoe-unused.sgml:1.2 tomoe/doc/reference/tmpl/tomoe-unused.sgml:1.3 --- tomoe/doc/reference/tmpl/tomoe-unused.sgml:1.2 Fri Dec 1 11:05:04 2006 +++ tomoe/doc/reference/tmpl/tomoe-unused.sgml Mon Dec 25 11:17:52 2006 @@ -22,28 +22,28 @@ tomoe-dict-impl - + - + - + - + - -TomoeModule + +tomoe-recognizer-impl @@ -212,13 +212,6 @@ @utf8: @Returns: - - - - - - object: - @@ -275,23 +268,21 @@ @input: @Returns: - + - ctx: - base_dir: - name: + config: - + - dict: - query: - Returns: + ctx: + base_dir: + name: @@ -328,59 +319,20 @@ @module: - - - - - - query: - Returns: - - - - - - - query: - Returns: - - + - query: - Returns: + shelf: + dict: - + - query: + shelf: + name: @Returns: - - - - - - query: - n_strokes: - - - - - - - query: - n_strokes: - - - - - - - query: - chr: - From kous users.sourceforge.jp Mon Dec 25 11:17:52 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:17:52 +0900 Subject: [Tomoe-cvs 2045] CVS update: tomoe/spec Message-ID: <20061225021752.E7E5D2AC062@users.sourceforge.jp> Index: tomoe/spec/.cvsignore diff -u /dev/null tomoe/spec/.cvsignore:1.1 --- /dev/null Mon Dec 25 11:17:52 2006 +++ tomoe/spec/.cvsignore Mon Dec 25 11:17:52 2006 @@ -0,0 +1,2 @@ +Makefile +Makefile.in Index: tomoe/spec/Makefile.am diff -u /dev/null tomoe/spec/Makefile.am:1.1 --- /dev/null Mon Dec 25 11:17:52 2006 +++ tomoe/spec/Makefile.am Mon Dec 25 11:17:52 2006 @@ -0,0 +1,3 @@ +# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- + +SUBDIRS = turbo-linux miracle-linux From kous users.sourceforge.jp Mon Dec 25 11:17:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:17:53 +0900 Subject: [Tomoe-cvs 2046] CVS update: tomoe/spec/miracle-linux Message-ID: <20061225021753.176752AC113@users.sourceforge.jp> Index: tomoe/spec/miracle-linux/.cvsignore diff -u /dev/null tomoe/spec/miracle-linux/.cvsignore:1.1 --- /dev/null Mon Dec 25 11:17:53 2006 +++ tomoe/spec/miracle-linux/.cvsignore Mon Dec 25 11:17:52 2006 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +tomoe.spec Index: tomoe/spec/miracle-linux/Makefile.am diff -u /dev/null tomoe/spec/miracle-linux/Makefile.am:1.1 --- /dev/null Mon Dec 25 11:17:53 2006 +++ tomoe/spec/miracle-linux/Makefile.am Mon Dec 25 11:17:52 2006 @@ -0,0 +1,3 @@ +# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- + +EXTRA_DIST = tomoe.spec Index: tomoe/spec/miracle-linux/tomoe.spec.in diff -u /dev/null tomoe/spec/miracle-linux/tomoe.spec.in:1.1 --- /dev/null Mon Dec 25 11:17:53 2006 +++ tomoe/spec/miracle-linux/tomoe.spec.in Mon Dec 25 11:17:52 2006 @@ -0,0 +1,8 @@ +# -*- coding:utf-8-unix -*- +# +# $Id: tomoe.spec.in,v 1.1 2006/12/25 02:17:52 kous Exp $ +# +# Copyright (c) 2006 Kouhei Sutou +# This file and all modifications and/or additions are under +# the same license as package itself. +# From kous users.sourceforge.jp Mon Dec 25 11:17:53 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:17:53 +0900 Subject: [Tomoe-cvs 2047] CVS update: tomoe/spec/turbo-linux Message-ID: <20061225021753.3DD272AC062@users.sourceforge.jp> Index: tomoe/spec/turbo-linux/.cvsignore diff -u /dev/null tomoe/spec/turbo-linux/.cvsignore:1.1 --- /dev/null Mon Dec 25 11:17:53 2006 +++ tomoe/spec/turbo-linux/.cvsignore Mon Dec 25 11:17:53 2006 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +tomoe.spec Index: tomoe/spec/turbo-linux/Makefile.am diff -u /dev/null tomoe/spec/turbo-linux/Makefile.am:1.1 --- /dev/null Mon Dec 25 11:17:53 2006 +++ tomoe/spec/turbo-linux/Makefile.am Mon Dec 25 11:17:53 2006 @@ -0,0 +1,3 @@ +# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- + +EXTRA_DIST = tomoe.spec Index: tomoe/spec/turbo-linux/tomoe.spec.in diff -u /dev/null tomoe/spec/turbo-linux/tomoe.spec.in:1.1 --- /dev/null Mon Dec 25 11:17:53 2006 +++ tomoe/spec/turbo-linux/tomoe.spec.in Mon Dec 25 11:17:53 2006 @@ -0,0 +1,96 @@ +# -*- coding:utf-8-unix -*- +# +# $Id: tomoe.spec.in,v 1.1 2006/12/25 02:17:53 kous Exp $ +# +# Copyright (c) 2006 Kouhei Sutou +# This file and all modifications and/or additions are under +# the same license as package itself. +# + +Name: tomoe +Version: @VERSION@ +Release: 0 +Serial: 2006121801 + +Summary: Tegaki Online MOji-ninshiki Engine +Summary(ja_JP.utf8): ??????????????Tomoe +URL: http://tomoe.sourceforge.jp/ +Source0: %{name}-%{version}.tar.gz +License: LGPL +Group: System Environment/Libraries +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +Requires: /sbin/ldconfig +Requires: mysql-client +BuildRequires: pkgconfig +BuildRequires: glib2-devel +BuildRequires: mysql-devel + +%description +Tomoe provides a handwriting recognition engine and its user +interface on open source desktop environment. + + +%description -l ja_JP.utf8 +Tomoe????????????????????????????????? +??????????????+ +%package devel +Summary: Tomoe developmental libraries and header files +Summary(ja_JP.utf8): Tomoe?????????????????????? +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: glib2-devel +Requires: mysql-devel + +%description devel +Developmental libraries and header files required for developing or +compiling software which links to the Tomoe library, which is an open +source handwriting recognition engine. + +%description devel -l ja_JP.utf8 +Tomoe????????????????????????????????????????????????? +??????????????Tomoe????????????????????????????+ +%prep +%setup -q + +%build +%configure --without-ruby --enable-mysql +make + +%install +rm -rf $RPM_BUILD_ROOT + +%makeinstall +rm $RPM_BUILD_ROOT%{_libdir}/*.la +rm $RPM_BUILD_ROOT%{_libdir}/*.a + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root,-) +#%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO +%doc AUTHORS ChangeLog COPYING NEWS TODO + +%{_libdir}/libtomoe*.so.* +%{_libdir}/tomoe/module/dict/* +%{_libdir}/tomoe/module/recognizer/* +%{_sysconfdir}/tomoe/* +%{_datadir}/tomoe/dict.dtd +%{_datadir}/tomoe/recognizer/* + +%files devel +%defattr(-,root,root,-) +%{_includedir}/* +%{_libdir}/libtomoe*.so +%{_libdir}/pkgconfig/* +%{_datadir}/gtk-doc/* + +%changelog +* Mon Dec 18 2006 Kouhei Sutou - 0.5.0-0 +- initial release. From kous users.sourceforge.jp Mon Dec 25 11:41:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:41:48 +0900 Subject: [Tomoe-cvs 2048] CVS update: tomoe Message-ID: <20061225024148.D413C2AC2C1@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.489 tomoe/ChangeLog:1.490 --- tomoe/ChangeLog:1.489 Mon Dec 25 11:17:52 2006 +++ tomoe/ChangeLog Mon Dec 25 11:41:48 2006 @@ -1,5 +1,8 @@ 2006-12-25 Kouhei Sutou + * lib/Makefile.am, lib/glib-compat-file-utilities.[ch]: split from + lib/glib-utils.[ch]. + * configure.in, Makefile.am, spec/: moved tomoe.spec.in to spec/turbo-linux/. * doc/: updated. From kous users.sourceforge.jp Mon Dec 25 11:41:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:41:49 +0900 Subject: [Tomoe-cvs 2049] CVS update: tomoe/lib Message-ID: <20061225024149.17C922AC2CA@users.sourceforge.jp> Index: tomoe/lib/Makefile.am diff -u tomoe/lib/Makefile.am:1.46 tomoe/lib/Makefile.am:1.47 --- tomoe/lib/Makefile.am:1.46 Tue Dec 5 14:51:42 2006 +++ tomoe/lib/Makefile.am Mon Dec 25 11:41:48 2006 @@ -59,6 +59,8 @@ libtomoe_la_SOURCES = \ glib-utils.c \ glib-utils.h \ + glib-compat-file-utilities.c \ + glib-compat-file-utilities.h \ tomoe-enum-types.c \ tomoe.c \ tomoe-candidate.c \ Index: tomoe/lib/glib-compat-file-utilities.c diff -u /dev/null tomoe/lib/glib-compat-file-utilities.c:1.1 --- /dev/null Mon Dec 25 11:41:49 2006 +++ tomoe/lib/glib-compat-file-utilities.c Mon Dec 25 11:41:48 2006 @@ -0,0 +1,323 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: glib-compat-file-utilities.c,v 1.1 2006/12/25 02:41:48 kous Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include "glib-utils.h" + +#if !GLIB_CHECK_VERSION(2, 8, 0) +/* copied from GLib. */ + +/* + * create_temp_file based on the mkstemp implementation from the GNU C library. + * Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc. + */ +static gint +create_temp_file (gchar *tmpl, + int permissions) +{ + char *XXXXXX; + int count, fd; + static const char letters[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + static const int NLETTERS = sizeof (letters) - 1; + glong value; + GTimeVal tv; + static int counter = 0; + + /* find the last occurrence of "XXXXXX" */ + XXXXXX = g_strrstr (tmpl, "XXXXXX"); + + if (!XXXXXX || strncmp (XXXXXX, "XXXXXX", 6)) + { + errno = EINVAL; + return -1; + } + + /* Get some more or less random data. */ + g_get_current_time (&tv); + value = (tv.tv_usec ^ tv.tv_sec) + counter++; + + for (count = 0; count < 100; value += 7777, ++count) + { + glong v = value; + + /* Fill in the random bits. */ + XXXXXX[0] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[1] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[2] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[3] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[4] = letters[v % NLETTERS]; + v /= NLETTERS; + XXXXXX[5] = letters[v % NLETTERS]; + + /* tmpl is in UTF-8 on Windows, thus use g_open() */ + fd = g_open (tmpl, O_RDWR | O_CREAT | O_EXCL | O_BINARY, permissions); + + if (fd >= 0) + return fd; + else if (errno != EEXIST) + /* Any other error will apply also to other names we might + * try, and there are 2^32 or so of them, so give up now. + */ + return -1; + } + + /* We got out of the loop because we ran out of combinations to try. */ + errno = EEXIST; + return -1; +} + +static gchar * +write_to_temp_file (const gchar *contents, + gssize length, + const gchar *template, + GError **err) +{ + gchar *tmp_name; + gchar *display_name; + gchar *retval; + FILE *file; + gint fd; + int save_errno; + + retval = NULL; + + tmp_name = g_strdup_printf ("%s.XXXXXX", template); + + errno = 0; + fd = create_temp_file (tmp_name, 0666); + display_name = g_filename_display_name (tmp_name); + + if (fd == -1) + { + save_errno = errno; + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to create file '%s': %s"), + display_name, g_strerror (save_errno)); + + goto out; + } + + errno = 0; + file = fdopen (fd, "wb"); + if (!file) + { + save_errno = errno; + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to open file '%s' for writing: fdopen() failed: %s"), + display_name, + g_strerror (save_errno)); + + close (fd); + g_unlink (tmp_name); + + goto out; + } + + if (length > 0) + { + size_t n_written; + + errno = 0; + + n_written = fwrite (contents, 1, length, file); + + if (n_written < length) + { + save_errno = errno; + + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to write file '%s': fwrite() failed: %s"), + display_name, + g_strerror (save_errno)); + + fclose (file); + g_unlink (tmp_name); + + goto out; + } + } + + errno = 0; + if (fclose (file) == EOF) + { + save_errno = 0; + + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to close file '%s': fclose() failed: %s"), + display_name, + g_strerror (save_errno)); + + g_unlink (tmp_name); + + goto out; + } + + retval = g_strdup (tmp_name); + + out: + g_free (tmp_name); + g_free (display_name); + + return retval; +} + +static gboolean +rename_file (const char *old_name, + const char *new_name, + GError **err) +{ + errno = 0; + if (g_rename (old_name, new_name) == -1) + { + int save_errno = errno; + gchar *display_old_name = g_filename_display_name (old_name); + gchar *display_new_name = g_filename_display_name (new_name); + + g_set_error (err, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Failed to rename file '%s' to '%s': g_rename() failed: %s"), + display_old_name, + display_new_name, + g_strerror (save_errno)); + + g_free (display_old_name); + g_free (display_new_name); + + return FALSE; + } + + return TRUE; +} + +gboolean +g_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + GError **error) +{ + gchar *tmp_filename; + gboolean retval; + GError *rename_error = NULL; + + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + g_return_val_if_fail (contents != NULL || length == 0, FALSE); + g_return_val_if_fail (length >= -1, FALSE); + + if (length == -1) + length = strlen (contents); + + tmp_filename = write_to_temp_file (contents, length, filename, error); + + if (!tmp_filename) + { + retval = FALSE; + goto out; + } + + if (!rename_file (tmp_filename, filename, &rename_error)) + { +#ifndef G_OS_WIN32 + + g_unlink (tmp_filename); + g_propagate_error (error, rename_error); + retval = FALSE; + goto out; + +#else /* G_OS_WIN32 */ + + /* Renaming failed, but on Windows this may just mean + * the file already exists. So if the target file + * exists, try deleting it and do the rename again. + */ + if (!g_file_test (filename, G_FILE_TEST_EXISTS)) + { + g_unlink (tmp_filename); + g_propagate_error (error, rename_error); + retval = FALSE; + goto out; + } + + g_error_free (rename_error); + + if (g_unlink (filename) == -1) + { + gchar *display_filename = g_filename_display_name (filename); + + int save_errno = errno; + + g_set_error (error, + G_FILE_ERROR, + g_file_error_from_errno (save_errno), + _("Existing file '%s' could not be removed: g_unlink() failed: %s"), + display_filename, + g_strerror (save_errno)); + + g_free (display_filename); + g_unlink (tmp_filename); + retval = FALSE; + goto out; + } + + if (!rename_file (tmp_filename, filename, error)) + { + g_unlink (tmp_filename); + retval = FALSE; + goto out; + } + +#endif + } + + retval = TRUE; + + out: + g_free (tmp_filename); + return retval; +} +#endif + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/lib/glib-compat-file-utilities.h diff -u /dev/null tomoe/lib/glib-compat-file-utilities.h:1.1 --- /dev/null Mon Dec 25 11:41:49 2006 +++ tomoe/lib/glib-compat-file-utilities.h Mon Dec 25 11:41:48 2006 @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: glib-compat-file-utilities.h,v 1.1 2006/12/25 02:41:48 kous Exp $ + */ + +#ifndef __GLIB_COMPAT_FILE_UTILITIES_H__ +#define __GLIB_COMPAT_FILE_UTILITIES_H__ + +#include + +#if GLIB_CHECK_VERSION(2, 6, 0) +# include +#else +# include +# define g_open(filename, flags, mode) open(filename, flags, mode) +# define g_filename_display_name(name) (name) +# define g_unlink(filename) unlink(filename) +# define g_mkdir(filename, mode) mkdir(filename, mode) +# define g_rename(old_filename, new_filename) \ + rename(old_filename, new_filename) +#endif + +#ifndef O_BINARY +# define O_BINARY 0 +#endif + +G_BEGIN_DECLS + +G_END_DECLS + +#endif /* __GLIB_COMPAT_FILE_UTILITIES_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/lib/glib-utils.c diff -u tomoe/lib/glib-utils.c:1.4 tomoe/lib/glib-utils.c:1.5 --- tomoe/lib/glib-utils.c:1.4 Mon Dec 18 11:29:07 2006 +++ tomoe/lib/glib-utils.c Mon Dec 25 11:41:48 2006 @@ -17,25 +17,10 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.c,v 1.4 2006/12/18 02:29:07 kous Exp $ + * $Id: glib-utils.c,v 1.5 2006/12/25 02:41:48 kous Exp $ */ -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - #include -#include -#include - #include "glib-utils.h" void @@ -51,293 +36,6 @@ } } -#if !GLIB_CHECK_VERSION(2, 8, 0) -/* copied from GLib. */ - -/* - * create_temp_file based on the mkstemp implementation from the GNU C library. - * Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc. - */ -static gint -create_temp_file (gchar *tmpl, - int permissions) -{ - char *XXXXXX; - int count, fd; - static const char letters[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static const int NLETTERS = sizeof (letters) - 1; - glong value; - GTimeVal tv; - static int counter = 0; - - /* find the last occurrence of "XXXXXX" */ - XXXXXX = g_strrstr (tmpl, "XXXXXX"); - - if (!XXXXXX || strncmp (XXXXXX, "XXXXXX", 6)) - { - errno = EINVAL; - return -1; - } - - /* Get some more or less random data. */ - g_get_current_time (&tv); - value = (tv.tv_usec ^ tv.tv_sec) + counter++; - - for (count = 0; count < 100; value += 7777, ++count) - { - glong v = value; - - /* Fill in the random bits. */ - XXXXXX[0] = letters[v % NLETTERS]; - v /= NLETTERS; - XXXXXX[1] = letters[v % NLETTERS]; - v /= NLETTERS; - XXXXXX[2] = letters[v % NLETTERS]; - v /= NLETTERS; - XXXXXX[3] = letters[v % NLETTERS]; - v /= NLETTERS; - XXXXXX[4] = letters[v % NLETTERS]; - v /= NLETTERS; - XXXXXX[5] = letters[v % NLETTERS]; - - /* tmpl is in UTF-8 on Windows, thus use g_open() */ - fd = g_open (tmpl, O_RDWR | O_CREAT | O_EXCL | O_BINARY, permissions); - - if (fd >= 0) - return fd; - else if (errno != EEXIST) - /* Any other error will apply also to other names we might - * try, and there are 2^32 or so of them, so give up now. - */ - return -1; - } - - /* We got out of the loop because we ran out of combinations to try. */ - errno = EEXIST; - return -1; -} - -static gchar * -write_to_temp_file (const gchar *contents, - gssize length, - const gchar *template, - GError **err) -{ - gchar *tmp_name; - gchar *display_name; - gchar *retval; - FILE *file; - gint fd; - int save_errno; - - retval = NULL; - - tmp_name = g_strdup_printf ("%s.XXXXXX", template); - - errno = 0; - fd = create_temp_file (tmp_name, 0666); - display_name = g_filename_display_name (tmp_name); - - if (fd == -1) - { - save_errno = errno; - g_set_error (err, - G_FILE_ERROR, - g_file_error_from_errno (save_errno), - _("Failed to create file '%s': %s"), - display_name, g_strerror (save_errno)); - - goto out; - } - - errno = 0; - file = fdopen (fd, "wb"); - if (!file) - { - save_errno = errno; - g_set_error (err, - G_FILE_ERROR, - g_file_error_from_errno (save_errno), - _("Failed to open file '%s' for writing: fdopen() failed: %s"), - display_name, - g_strerror (save_errno)); - - close (fd); - g_unlink (tmp_name); - - goto out; - } - - if (length > 0) - { - size_t n_written; - - errno = 0; - - n_written = fwrite (contents, 1, length, file); - - if (n_written < length) - { - save_errno = errno; - - g_set_error (err, - G_FILE_ERROR, - g_file_error_from_errno (save_errno), - _("Failed to write file '%s': fwrite() failed: %s"), - display_name, - g_strerror (save_errno)); - - fclose (file); - g_unlink (tmp_name); - - goto out; - } - } - - errno = 0; - if (fclose (file) == EOF) - { - save_errno = 0; - - g_set_error (err, - G_FILE_ERROR, - g_file_error_from_errno (save_errno), - _("Failed to close file '%s': fclose() failed: %s"), - display_name, - g_strerror (save_errno)); - - g_unlink (tmp_name); - - goto out; - } - - retval = g_strdup (tmp_name); - - out: - g_free (tmp_name); - g_free (display_name); - - return retval; -} - -static gboolean -rename_file (const char *old_name, - const char *new_name, - GError **err) -{ - errno = 0; - if (g_rename (old_name, new_name) == -1) - { - int save_errno = errno; - gchar *display_old_name = g_filename_display_name (old_name); - gchar *display_new_name = g_filename_display_name (new_name); - - g_set_error (err, - G_FILE_ERROR, - g_file_error_from_errno (save_errno), - _("Failed to rename file '%s' to '%s': g_rename() failed: %s"), - display_old_name, - display_new_name, - g_strerror (save_errno)); - - g_free (display_old_name); - g_free (display_new_name); - - return FALSE; - } - - return TRUE; -} - -gboolean -g_file_set_contents (const gchar *filename, - const gchar *contents, - gssize length, - GError **error) -{ - gchar *tmp_filename; - gboolean retval; - GError *rename_error = NULL; - - g_return_val_if_fail (filename != NULL, FALSE); - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - g_return_val_if_fail (contents != NULL || length == 0, FALSE); - g_return_val_if_fail (length >= -1, FALSE); - - if (length == -1) - length = strlen (contents); - - tmp_filename = write_to_temp_file (contents, length, filename, error); - - if (!tmp_filename) - { - retval = FALSE; - goto out; - } - - if (!rename_file (tmp_filename, filename, &rename_error)) - { -#ifndef G_OS_WIN32 - - g_unlink (tmp_filename); - g_propagate_error (error, rename_error); - retval = FALSE; - goto out; - -#else /* G_OS_WIN32 */ - - /* Renaming failed, but on Windows this may just mean - * the file already exists. So if the target file - * exists, try deleting it and do the rename again. - */ - if (!g_file_test (filename, G_FILE_TEST_EXISTS)) - { - g_unlink (tmp_filename); - g_propagate_error (error, rename_error); - retval = FALSE; - goto out; - } - - g_error_free (rename_error); - - if (g_unlink (filename) == -1) - { - gchar *display_filename = g_filename_display_name (filename); - - int save_errno = errno; - - g_set_error (error, - G_FILE_ERROR, - g_file_error_from_errno (save_errno), - _("Existing file '%s' could not be removed: g_unlink() failed: %s"), - display_filename, - g_strerror (save_errno)); - - g_free (display_filename); - g_unlink (tmp_filename); - retval = FALSE; - goto out; - } - - if (!rename_file (tmp_filename, filename, error)) - { - g_unlink (tmp_filename); - retval = FALSE; - goto out; - } - -#endif - } - - retval = TRUE; - - out: - g_free (tmp_filename); - return retval; -} -#endif - /* vi:ts=4:nowrap:ai:expandtab */ Index: tomoe/lib/glib-utils.h diff -u tomoe/lib/glib-utils.h:1.7 tomoe/lib/glib-utils.h:1.8 --- tomoe/lib/glib-utils.h:1.7 Mon Dec 18 11:29:07 2006 +++ tomoe/lib/glib-utils.h Mon Dec 25 11:41:48 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.h,v 1.7 2006/12/18 02:29:07 kous Exp $ + * $Id: glib-utils.h,v 1.8 2006/12/25 02:41:48 kous Exp $ */ @@ -25,6 +25,8 @@ #define __GLIB_UTILS_H__ #include +#include +#include "glib-compat-file-utilities.h" G_BEGIN_DECLS Index: tomoe/lib/tomoe-context.c diff -u tomoe/lib/tomoe-context.c:1.54 tomoe/lib/tomoe-context.c:1.55 --- tomoe/lib/tomoe-context.c:1.54 Mon Dec 18 15:26:41 2006 +++ tomoe/lib/tomoe-context.c Mon Dec 25 11:41:48 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-context.c,v 1.54 2006/12/18 06:26:41 kous Exp $ + * $Id: tomoe-context.c,v 1.55 2006/12/25 02:41:48 kous Exp $ */ #include @@ -32,8 +32,6 @@ #include "tomoe-candidate.h" #include "glib-utils.h" -#include - #define DEFAULT_USER_DICT_CONTENT \ "\n" \ "\n" \ From kous users.sourceforge.jp Mon Dec 25 11:55:32 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:55:32 +0900 Subject: [Tomoe-cvs 2050] CVS update: tomoe Message-ID: <20061225025532.9EC682AC2C1@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.490 tomoe/ChangeLog:1.491 --- tomoe/ChangeLog:1.490 Mon Dec 25 11:41:48 2006 +++ tomoe/ChangeLog Mon Dec 25 11:55:32 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * configure.in: removed needless code. + * lib/Makefile.am, lib/glib-compat-file-utilities.[ch]: split from lib/glib-utils.[ch]. Index: tomoe/configure.in diff -u tomoe/configure.in:1.52 tomoe/configure.in:1.53 --- tomoe/configure.in:1.52 Mon Dec 25 11:17:52 2006 +++ tomoe/configure.in Mon Dec 25 11:55:32 2006 @@ -130,7 +130,6 @@ dnl Check for GLib. dnl ************************************************************** AM_PATH_GLIB_2_0(2.4.0, [], [], [gmodule gobject]) -AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums) dnl ************************************************************** dnl Check for Hyper Estraier. From kous users.sourceforge.jp Mon Dec 25 11:58:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:58:30 +0900 Subject: [Tomoe-cvs 2051] CVS update: tomoe Message-ID: <20061225025830.189072AC06F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.491 tomoe/ChangeLog:1.492 --- tomoe/ChangeLog:1.491 Mon Dec 25 11:55:32 2006 +++ tomoe/ChangeLog Mon Dec 25 11:58:29 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * lib/Makefile.am: removed needless dependencies. + * configure.in: removed needless code. * lib/Makefile.am, lib/glib-compat-file-utilities.[ch]: split from From kous users.sourceforge.jp Mon Dec 25 11:58:30 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 11:58:30 +0900 Subject: [Tomoe-cvs 2052] CVS update: tomoe/lib Message-ID: <20061225025830.4232A2AC2CA@users.sourceforge.jp> Index: tomoe/lib/Makefile.am diff -u tomoe/lib/Makefile.am:1.47 tomoe/lib/Makefile.am:1.48 --- tomoe/lib/Makefile.am:1.47 Mon Dec 25 11:41:48 2006 +++ tomoe/lib/Makefile.am Mon Dec 25 11:58:30 2006 @@ -99,7 +99,7 @@ $(enum_source_prefix).c: stamp-$(enum_source_prefix)-c $(enum_source_prefix).h @true -stamp-$(enum_source_prefix)-c: $(enum_sources_h) Makefile $(GLIB_MKENUMS) +stamp-$(enum_source_prefix)-c: $(enum_sources_h) Makefile (cd $(srcdir) && \ include_headers="" && \ for h in $(enum_sources_h); do \ @@ -120,7 +120,7 @@ $(enum_source_prefix).h: stamp-$(enum_source_prefix)-h @true -stamp-$(enum_source_prefix)-h: $(enum_sources_h) Makefile $(GLIB_MKENUMS) +stamp-$(enum_source_prefix)-h: $(enum_sources_h) Makefile (cd $(srcdir) && \ mark="__`echo $(enum_source_prefix) | sed -e 's/-/_/g' | tr a-z A-Z`_H__" && \ $(GLIB_MKENUMS) \ From kous users.sourceforge.jp Mon Dec 25 12:30:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 12:30:54 +0900 Subject: [Tomoe-cvs 2053] CVS update: tomoe Message-ID: <20061225033054.B14182AC16C@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.492 tomoe/ChangeLog:1.493 --- tomoe/ChangeLog:1.492 Mon Dec 25 11:58:29 2006 +++ tomoe/ChangeLog Mon Dec 25 12:30:54 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * lib/glib-compat-file-utilities.h: included headers for mkdir(). + * lib/Makefile.am: removed needless dependencies. * configure.in: removed needless code. From kous users.sourceforge.jp Mon Dec 25 12:30:54 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 12:30:54 +0900 Subject: [Tomoe-cvs 2054] CVS update: tomoe/lib Message-ID: <20061225033054.DCBCA2AC173@users.sourceforge.jp> Index: tomoe/lib/glib-compat-file-utilities.h diff -u tomoe/lib/glib-compat-file-utilities.h:1.1 tomoe/lib/glib-compat-file-utilities.h:1.2 --- tomoe/lib/glib-compat-file-utilities.h:1.1 Mon Dec 25 11:41:48 2006 +++ tomoe/lib/glib-compat-file-utilities.h Mon Dec 25 12:30:54 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-compat-file-utilities.h,v 1.1 2006/12/25 02:41:48 kous Exp $ + * $Id: glib-compat-file-utilities.h,v 1.2 2006/12/25 03:30:54 kous Exp $ */ #ifndef __GLIB_COMPAT_FILE_UTILITIES_H__ @@ -28,7 +28,14 @@ #if GLIB_CHECK_VERSION(2, 6, 0) # include #else +# include "config.h" # include +# ifdef HAVE_SYS_STAT_H +# include +# endif +# ifdef HAVE_SYS_TYPES_H +# include +# endif # define g_open(filename, flags, mode) open(filename, flags, mode) # define g_filename_display_name(name) (name) # define g_unlink(filename) unlink(filename) From kous users.sourceforge.jp Mon Dec 25 12:32:50 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 12:32:50 +0900 Subject: [Tomoe-cvs 2055] CVS update: tomoe Message-ID: <20061225033250.1DFF42AC16C@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.493 tomoe/ChangeLog:1.494 --- tomoe/ChangeLog:1.493 Mon Dec 25 12:30:54 2006 +++ tomoe/ChangeLog Mon Dec 25 12:32:49 2006 @@ -1,5 +1,9 @@ 2006-12-25 Kouhei Sutou + * lib/Makefile.am, lib/glib-utils.h, + lib/glib-compat-key-file.[ch]: added GKeyFile implementation to + work on GLib 2.4.x environment. + * lib/glib-compat-file-utilities.h: included headers for mkdir(). * lib/Makefile.am: removed needless dependencies. From kous users.sourceforge.jp Mon Dec 25 12:32:50 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 12:32:50 +0900 Subject: [Tomoe-cvs 2056] CVS update: tomoe/lib Message-ID: <20061225033250.59C4A2AC173@users.sourceforge.jp> Index: tomoe/lib/Makefile.am diff -u tomoe/lib/Makefile.am:1.48 tomoe/lib/Makefile.am:1.49 --- tomoe/lib/Makefile.am:1.48 Mon Dec 25 11:58:30 2006 +++ tomoe/lib/Makefile.am Mon Dec 25 12:32:50 2006 @@ -61,6 +61,8 @@ glib-utils.h \ glib-compat-file-utilities.c \ glib-compat-file-utilities.h \ + glib-compat-key-file.c \ + glib-compat-key-file.h \ tomoe-enum-types.c \ tomoe.c \ tomoe-candidate.c \ Index: tomoe/lib/glib-compat-key-file.c diff -u /dev/null tomoe/lib/glib-compat-key-file.c:1.1 --- /dev/null Mon Dec 25 12:32:50 2006 +++ tomoe/lib/glib-compat-key-file.c Mon Dec 25 12:32:50 2006 @@ -0,0 +1,3348 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: glib-compat-key-file.c,v 1.1 2006/12/25 03:32:50 kous Exp $ + */ + +#include "glib-utils.h" + +#if !GLIB_CHECK_VERSION(2, 6, 0) +/* gkeyfile.c - key file parser + * + * Copyright 2004 Red Hat, Inc. + * + * Written by Ray Strode + * Matthias Clasen + * + * GLib is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * GLib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with GLib; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef G_OS_WIN32 +#include + +#ifndef S_ISREG +#define S_ISREG(mode) ((mode)&_S_IFREG) +#endif + +#endif /* G_OS_WIN23 */ + +typedef struct _GKeyFileGroup GKeyFileGroup; + +struct _GKeyFile +{ + GList *groups; + + GKeyFileGroup *start_group; + GKeyFileGroup *current_group; + + GString *parse_buffer; /* Holds up to one line of not-yet-parsed data */ + + /* Used for sizing the output buffer during serialization + */ + gsize approximate_size; + + gchar list_separator; + + GKeyFileFlags flags; +}; + +typedef struct _GKeyFileKeyValuePair GKeyFileKeyValuePair; + +struct _GKeyFileGroup +{ + const gchar *name; /* NULL for above first group (which will be comments) */ + + GKeyFileKeyValuePair *comment; /* Special comment that is stuck to the top of a group */ + + GList *key_value_pairs; + + /* Used in parallel with key_value_pairs for + * increased lookup performance + */ + GHashTable *lookup_map; +}; + +struct _GKeyFileKeyValuePair +{ + gchar *key; /* NULL for comments */ + gchar *value; +}; + +static gboolean g_key_file_load_from_fd (GKeyFile *key_file, + gint fd, + GKeyFileFlags flags, + GError **error); +static GList *g_key_file_lookup_group_node (GKeyFile *key_file, + const gchar *group_name); +static GKeyFileGroup *g_key_file_lookup_group (GKeyFile *key_file, + const gchar *group_name); + +static GList *g_key_file_lookup_key_value_pair_node (GKeyFile *key_file, + GKeyFileGroup *group, + const gchar *key); +static GKeyFileKeyValuePair *g_key_file_lookup_key_value_pair (GKeyFile *key_file, + GKeyFileGroup *group, + const gchar *key); + +static void g_key_file_remove_group_node (GKeyFile *key_file, + GList *group_node); +static void g_key_file_remove_key_value_pair_node (GKeyFile *key_file, + GKeyFileGroup *group, + GList *pair_node); + +static void g_key_file_add_key (GKeyFile *key_file, + GKeyFileGroup *group, + const gchar *key, + const gchar *value); +static void g_key_file_add_group (GKeyFile *key_file, + const gchar *group_name); +static gboolean g_key_file_is_group_name (const gchar *name); +static gboolean g_key_file_is_key_name (const gchar *name); +static void g_key_file_key_value_pair_free (GKeyFileKeyValuePair *pair); +static gboolean g_key_file_line_is_comment (const gchar *line); +static gboolean g_key_file_line_is_group (const gchar *line); +static gboolean g_key_file_line_is_key_value_pair (const gchar *line); +static gchar *g_key_file_parse_value_as_string (GKeyFile *key_file, + const gchar *value, + GSList **separators, + GError **error); +static gchar *g_key_file_parse_string_as_value (GKeyFile *key_file, + const gchar *string, + gboolean escape_separator); +static gint g_key_file_parse_value_as_integer (GKeyFile *key_file, + const gchar *value, + GError **error); +static gchar *g_key_file_parse_integer_as_value (GKeyFile *key_file, + gint value); +static gdouble g_key_file_parse_value_as_double (GKeyFile *key_file, + const gchar *value, + GError **error); +static gboolean g_key_file_parse_value_as_boolean (GKeyFile *key_file, + const gchar *value, + GError **error); +static gchar *g_key_file_parse_boolean_as_value (GKeyFile *key_file, + gboolean value); +static gchar *g_key_file_parse_value_as_comment (GKeyFile *key_file, + const gchar *value); +static gchar *g_key_file_parse_comment_as_value (GKeyFile *key_file, + const gchar *comment); +static void g_key_file_parse_key_value_pair (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error); +static void g_key_file_parse_comment (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error); +static void g_key_file_parse_group (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error); +static gchar *key_get_locale (const gchar *key); +static void g_key_file_parse_data (GKeyFile *key_file, + const gchar *data, + gsize length, + GError **error); +static void g_key_file_flush_parse_buffer (GKeyFile *key_file, + GError **error); + + +GQuark +g_key_file_error_quark (void) +{ + return g_quark_from_static_string ("g-key-file-error-quark"); +} + +static void +g_key_file_init (GKeyFile *key_file) +{ + key_file->current_group = g_new0 (GKeyFileGroup, 1); + key_file->groups = g_list_prepend (NULL, key_file->current_group); + key_file->start_group = NULL; + key_file->parse_buffer = g_string_sized_new (128); + key_file->approximate_size = 0; + key_file->list_separator = ';'; + key_file->flags = 0; +} + +static void +g_key_file_clear (GKeyFile *key_file) +{ + GList *tmp, *group_node; + + if (key_file->parse_buffer) + g_string_free (key_file->parse_buffer, TRUE); + + tmp = key_file->groups; + while (tmp != NULL) + { + group_node = tmp; + tmp = tmp->next; + g_key_file_remove_group_node (key_file, group_node); + } + + g_assert (key_file->groups == NULL); +} + + +/** + * g_key_file_new: + * + * Creates a new empty #GKeyFile object. Use g_key_file_load_from_file(), + * g_key_file_load_from_data() or g_key_file_load_from_data_dirs() to + * read an existing key file. + * + * Return value: an empty #GKeyFile. + * + * Since: 2.6 + **/ +GKeyFile * +g_key_file_new (void) +{ + GKeyFile *key_file; + + key_file = g_new0 (GKeyFile, 1); + g_key_file_init (key_file); + + return key_file; +} + +/** + * g_key_file_set_list_separator: + * @key_file: a #GKeyFile + * @separator: the separator + * + * Sets the character which is used to separate + * values in lists. Typically ';' or ',' are used + * as separators. The default list separator is ';'. + * + * Since: 2.6 + */ +void +g_key_file_set_list_separator (GKeyFile *key_file, + gchar separator) +{ + g_return_if_fail (key_file != NULL); + + key_file->list_separator = separator; +} + + +static gboolean +g_key_file_load_from_fd (GKeyFile *key_file, + gint fd, + GKeyFileFlags flags, + GError **error) +{ + GError *key_file_error = NULL; + gssize bytes_read; + struct stat stat_buf; + gchar read_buf[4096]; + + if (fstat (fd, &stat_buf) < 0) + { + g_set_error (error, G_FILE_ERROR, + g_file_error_from_errno (errno), + "%s", g_strerror (errno)); + return FALSE; + } + + if (!S_ISREG (stat_buf.st_mode)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_PARSE, + _("Not a regular file")); + return FALSE; + } + + if (stat_buf.st_size == 0) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_PARSE, + _("File is empty")); + return FALSE; + } + + if (key_file->approximate_size > 0) + { + g_key_file_clear (key_file); + g_key_file_init (key_file); + } + key_file->flags = flags; + + bytes_read = 0; + do + { + bytes_read = read (fd, read_buf, 4096); + + if (bytes_read == 0) /* End of File */ + break; + + if (bytes_read < 0) + { + if (errno == EINTR || errno == EAGAIN) + continue; + + g_set_error (error, G_FILE_ERROR, + g_file_error_from_errno (errno), + "%s", g_strerror (errno)); + return FALSE; + } + + g_key_file_parse_data (key_file, + read_buf, bytes_read, + &key_file_error); + } + while (!key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return FALSE; + } + + g_key_file_flush_parse_buffer (key_file, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return FALSE; + } + + return TRUE; +} + +/** + * g_key_file_load_from_file: + * @key_file: an empty #GKeyFile struct + * @file: the path of a filename to load, in the GLib file name encoding + * @flags: flags from #GKeyFileFlags + * @error: return location for a #GError, or %NULL + * + * Loads a key file into an empty #GKeyFile structure. + * If the file could not be loaded then %error is set to + * either a #GFileError or #GKeyFileError. + * + * Return value: %TRUE if a key file could be loaded, %FALSE othewise + * Since: 2.6 + **/ +gboolean +g_key_file_load_from_file (GKeyFile *key_file, + const gchar *file, + GKeyFileFlags flags, + GError **error) +{ + GError *key_file_error = NULL; + gint fd; + + g_return_val_if_fail (key_file != NULL, FALSE); + g_return_val_if_fail (file != NULL, FALSE); + + fd = g_open (file, O_RDONLY, 0); + + if (fd < 0) + { + g_set_error (error, G_FILE_ERROR, + g_file_error_from_errno (errno), + "%s", g_strerror (errno)); + return FALSE; + } + + g_key_file_load_from_fd (key_file, fd, flags, &key_file_error); + close (fd); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return FALSE; + } + + return TRUE; +} + +/** + * g_key_file_load_from_data: + * @key_file: an empty #GKeyFile struct + * @data: key file loaded in memory. + * @length: the length of @data in bytes + * @flags: flags from #GKeyFileFlags + * @error: return location for a #GError, or %NULL + * + * Loads a key file from memory into an empty #GKeyFile structure. If + * the object cannot be created then %error is set to a + * #GKeyFileError. + * + * Return value: %TRUE if a key file could be loaded, %FALSE othewise + * Since: 2.6 + **/ +gboolean +g_key_file_load_from_data (GKeyFile *key_file, + const gchar *data, + gsize length, + GKeyFileFlags flags, + GError **error) +{ + GError *key_file_error = NULL; + + g_return_val_if_fail (key_file != NULL, FALSE); + g_return_val_if_fail (data != NULL, FALSE); + g_return_val_if_fail (length != 0, FALSE); + + if (length == (gsize)-1) + length = strlen (data); + + if (key_file->approximate_size > 0) + { + g_key_file_clear (key_file); + g_key_file_init (key_file); + } + key_file->flags = flags; + + g_key_file_parse_data (key_file, data, length, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return FALSE; + } + + g_key_file_flush_parse_buffer (key_file, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return FALSE; + } + + return TRUE; +} + +/** + * g_key_file_free: + * @key_file: a #GKeyFile + * + * Frees a #GKeyFile. + * + * Since: 2.6 + **/ +void +g_key_file_free (GKeyFile *key_file) +{ + g_return_if_fail (key_file != NULL); + + g_key_file_clear (key_file); + g_free (key_file); +} + +/* If G_KEY_FILE_KEEP_TRANSLATIONS is not set, only returns + * true for locales that match those in g_get_language_names(). + */ +static gboolean +g_key_file_locale_is_interesting (GKeyFile *key_file, + const gchar *locale) +{ + if (key_file->flags & G_KEY_FILE_KEEP_TRANSLATIONS) + return TRUE; + + return FALSE; +} + +static gchar * +_g_utf8_make_valid (const gchar *name) +{ + GString *string; + const gchar *remainder, *invalid; + gint remaining_bytes, valid_bytes; + + string = NULL; + remainder = name; + remaining_bytes = strlen (name); + + while (remaining_bytes != 0) + { + if (g_utf8_validate (remainder, remaining_bytes, &invalid)) + break; + valid_bytes = invalid - remainder; + + if (string == NULL) + string = g_string_sized_new (remaining_bytes); + + g_string_append_len (string, remainder, valid_bytes); + /* append U+FFFD REPLACEMENT CHARACTER */ + g_string_append (string, "\357\277\275"); + + remaining_bytes -= valid_bytes + 1; + remainder = invalid + 1; + } + + if (string == NULL) + return g_strdup (name); + + g_string_append (string, remainder); + + g_assert (g_utf8_validate (string->str, -1, NULL)); + + return g_string_free (string, FALSE); +} + +static void +g_key_file_parse_line (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error) +{ + GError *parse_error = NULL; + gchar *line_start; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (line != NULL); + + line_start = (gchar *) line; + while (g_ascii_isspace (*line_start)) + line_start++; + + if (g_key_file_line_is_comment (line_start)) + g_key_file_parse_comment (key_file, line, length, &parse_error); + else if (g_key_file_line_is_group (line_start)) + g_key_file_parse_group (key_file, line_start, + length - (line_start - line), + &parse_error); + else if (g_key_file_line_is_key_value_pair (line_start)) + g_key_file_parse_key_value_pair (key_file, line_start, + length - (line_start - line), + &parse_error); + else + { + gchar *line_utf8 = _g_utf8_make_valid (line); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_PARSE, + _("Key file contains line '%s' which is not " + "a key-value pair, group, or comment"), + line_utf8); + g_free (line_utf8); + + return; + } + + if (parse_error) + g_propagate_error (error, parse_error); +} + +static void +g_key_file_parse_comment (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error) +{ + GKeyFileKeyValuePair *pair; + + if (!(key_file->flags & G_KEY_FILE_KEEP_COMMENTS)) + return; + + g_assert (key_file->current_group != NULL); + + pair = g_new0 (GKeyFileKeyValuePair, 1); + + pair->key = NULL; + pair->value = g_strndup (line, length); + + key_file->current_group->key_value_pairs = + g_list_prepend (key_file->current_group->key_value_pairs, pair); +} + +static void +g_key_file_parse_group (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error) +{ + gchar *group_name; + const gchar *group_name_start, *group_name_end; + + /* advance past opening '[' + */ + group_name_start = line + 1; + group_name_end = line + length - 1; + + while (*group_name_end != ']') + group_name_end--; + + group_name = g_strndup (group_name_start, + group_name_end - group_name_start); + + if (!g_key_file_is_group_name (group_name)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_PARSE, + _("Invalid group name: %s"), group_name); + g_free (group_name); + return; + } + + g_key_file_add_group (key_file, group_name); + g_free (group_name); +} + +static void +g_key_file_parse_key_value_pair (GKeyFile *key_file, + const gchar *line, + gsize length, + GError **error) +{ + gchar *key, *value, *key_end, *value_start, *locale; + gsize key_len, value_len; + + if (key_file->current_group == NULL || key_file->current_group->name == NULL) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not start with a group")); + return; + } + + key_end = value_start = strchr (line, '='); + + g_assert (key_end != NULL); + + key_end--; + value_start++; + + /* Pull the key name from the line (chomping trailing whitespace) + */ + while (g_ascii_isspace (*key_end)) + key_end--; + + key_len = key_end - line + 2; + + g_assert (key_len <= length); + + key = g_strndup (line, key_len - 1); + + if (!g_key_file_is_key_name (key)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_PARSE, + _("Invalid key name: %s"), key); + g_free (key); + return; + } + + /* Pull the value from the line (chugging leading whitespace) + */ + while (g_ascii_isspace (*value_start)) + value_start++; + + value_len = line + length - value_start + 1; + + value = g_strndup (value_start, value_len); + + g_assert (key_file->start_group != NULL); + + if (key_file->current_group + && key_file->current_group->name + && strcmp (key_file->start_group->name, + key_file->current_group->name) == 0 + && strcmp (key, "Encoding") == 0) + { + if (g_ascii_strcasecmp (value, "UTF-8") != 0) + { + gchar *value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_UNKNOWN_ENCODING, + _("Key file contains unsupported " + "encoding '%s'"), value_utf8); + g_free (value_utf8); + + g_free (key); + g_free (value); + return; + } + } + + /* Is this key a translation? If so, is it one that we care about? + */ + locale = key_get_locale (key); + + if (locale == NULL || g_key_file_locale_is_interesting (key_file, locale)) + g_key_file_add_key (key_file, key_file->current_group, key, value); + + g_free (locale); + g_free (key); + g_free (value); +} + +static gchar * +key_get_locale (const gchar *key) +{ + gchar *locale; + + locale = g_strrstr (key, "["); + + if (locale && strlen (locale) <= 2) + locale = NULL; + + if (locale) + locale = g_strndup (locale + 1, strlen (locale) - 2); + + return locale; +} + +static void +g_key_file_parse_data (GKeyFile *key_file, + const gchar *data, + gsize length, + GError **error) +{ + GError *parse_error; + gsize i; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (data != NULL); + + parse_error = NULL; + + for (i = 0; i < length; i++) + { + if (data[i] == '\n') + { + if (i > 0 && data[i - 1] == '\r') + g_string_erase (key_file->parse_buffer, + key_file->parse_buffer->len - 1, + 1); + + /* When a newline is encountered flush the parse buffer so that the + * line can be parsed. Note that completely blank lines won't show + * up in the parse buffer, so they get parsed directly. + */ + if (key_file->parse_buffer->len > 0) + g_key_file_flush_parse_buffer (key_file, &parse_error); + else + g_key_file_parse_comment (key_file, "", 1, &parse_error); + + if (parse_error) + { + g_propagate_error (error, parse_error); + return; + } + } + else + g_string_append_c (key_file->parse_buffer, data[i]); + } + + key_file->approximate_size += length; +} + +static void +g_key_file_flush_parse_buffer (GKeyFile *key_file, + GError **error) +{ + GError *file_error = NULL; + + g_return_if_fail (key_file != NULL); + + file_error = NULL; + + if (key_file->parse_buffer->len > 0) + { + g_key_file_parse_line (key_file, key_file->parse_buffer->str, + key_file->parse_buffer->len, + &file_error); + g_string_erase (key_file->parse_buffer, 0, -1); + + if (file_error) + { + g_propagate_error (error, file_error); + return; + } + } +} + +/** + * g_key_file_to_data: + * @key_file: a #GKeyFile + * @length: return location for the length of the + * returned string, or %NULL + * @error: return location for a #GError, or %NULL + * + * This function outputs @key_file as a string. + * + * Return value: a newly allocated string holding + * the contents of the #GKeyFile + * + * Since: 2.6 + **/ +gchar * +g_key_file_to_data (GKeyFile *key_file, + gsize *length, + GError **error) +{ + GString *data_string; + GList *group_node, *key_file_node; + + g_return_val_if_fail (key_file != NULL, NULL); + + data_string = g_string_sized_new (2 * key_file->approximate_size); + + for (group_node = g_list_last (key_file->groups); + group_node != NULL; + group_node = group_node->prev) + { + GKeyFileGroup *group; + + group = (GKeyFileGroup *) group_node->data; + + if (group->comment != NULL) + g_string_append_printf (data_string, "%s\n", group->comment->value); + else if (group_node->next) /* separate groups by at least an empty line */ + g_string_append_c (data_string, '\n'); + + if (group->name != NULL) + g_string_append_printf (data_string, "[%s]\n", group->name); + + for (key_file_node = g_list_last (group->key_value_pairs); + key_file_node != NULL; + key_file_node = key_file_node->prev) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) key_file_node->data; + + if (pair->key != NULL) + g_string_append_printf (data_string, "%s=%s\n", pair->key, pair->value); + else + g_string_append_printf (data_string, "%s\n", pair->value); + } + } + + if (length) + *length = data_string->len; + + return g_string_free (data_string, FALSE); +} + +/** + * g_key_file_get_keys: + * @key_file: a #GKeyFile + * @group_name: a group name + * @length: return location for the number of keys returned, or %NULL + * @error: return location for a #GError, or %NULL + * + * Returns all keys for the group name @group_name. The array of + * returned keys will be %NULL-terminated, so @length may + * optionally be %NULL. In the event that the @group_name cannot + * be found, %NULL is returned and @error is set to + * #G_KEY_FILE_ERROR_GROUP_NOT_FOUND. + * + * Return value: a newly-allocated %NULL-terminated array of + * strings. Use g_strfreev() to free it. + * + * Since: 2.6 + **/ +gchar ** +g_key_file_get_keys (GKeyFile *key_file, + const gchar *group_name, + gsize *length, + GError **error) +{ + GKeyFileGroup *group; + GList *tmp; + gchar **keys; + gsize i, num_keys; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + + group = g_key_file_lookup_group (key_file, group_name); + + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + return NULL; + } + + num_keys = 0; + for (tmp = group->key_value_pairs; tmp; tmp = tmp->next) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) tmp->data; + + if (pair->key) + num_keys++; + } + + keys = g_new0 (gchar *, num_keys + 1); + + i = num_keys - 1; + for (tmp = group->key_value_pairs; tmp; tmp = tmp->next) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) tmp->data; + + if (pair->key) + { + keys[i] = g_strdup (pair->key); + i--; + } + } + + keys[num_keys] = NULL; + + if (length) + *length = num_keys; + + return keys; +} + +/** + * g_key_file_get_start_group: + * @key_file: a #GKeyFile + * + * Returns the name of the start group of the file. + * + * Return value: The start group of the key file. + * + * Since: 2.6 + **/ +gchar * +g_key_file_get_start_group (GKeyFile *key_file) +{ + g_return_val_if_fail (key_file != NULL, NULL); + + if (key_file->start_group) + return g_strdup (key_file->start_group->name); + + return NULL; +} + +/** + * g_key_file_get_groups: + * @key_file: a #GKeyFile + * @length: return location for the number of returned groups, or %NULL + * + * Returns all groups in the key file loaded with @key_file. The + * array of returned groups will be %NULL-terminated, so @length may + * optionally be %NULL. + * + * Return value: a newly-allocated %NULL-terminated array of strings. + * Use g_strfreev() to free it. + * Since: 2.6 + **/ +gchar ** +g_key_file_get_groups (GKeyFile *key_file, + gsize *length) +{ + GList *group_node; + gchar **groups; + gsize i, num_groups; + + g_return_val_if_fail (key_file != NULL, NULL); + + num_groups = g_list_length (key_file->groups); + + g_assert (num_groups > 0); + + /* Only need num_groups instead of num_groups + 1 + * because the first group of the file (last in the + * list) is always the comment group at the top, + * which we skip + */ + groups = g_new0 (gchar *, num_groups); + + group_node = g_list_last (key_file->groups); + + g_assert (((GKeyFileGroup *) group_node->data)->name == NULL); + + i = 0; + for (group_node = group_node->prev; + group_node != NULL; + group_node = group_node->prev) + { + GKeyFileGroup *group; + + group = (GKeyFileGroup *) group_node->data; + + g_assert (group->name != NULL); + + groups[i++] = g_strdup (group->name); + } + groups[i] = NULL; + + if (length) + *length = i; + + return groups; +} + +/** + * g_key_file_get_value: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @error: return location for a #GError, or %NULL + * + * Returns the value associated with @key under @group_name. + * + * In the event the key cannot be found, %NULL is returned and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the + * event that the @group_name cannot be found, %NULL is returned + * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND. + * + * Return value: a newly allocated string or %NULL if the specified + * key cannot be found. + * + * Since: 2.6 + **/ +gchar * +g_key_file_get_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GKeyFileGroup *group; + GKeyFileKeyValuePair *pair; + gchar *value = NULL; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + group = g_key_file_lookup_group (key_file, group_name); + + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + return NULL; + } + + pair = g_key_file_lookup_key_value_pair (key_file, group, key); + + if (pair) + value = g_strdup (pair->value); + else + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + _("Key file does not have key '%s'"), key); + + return value; +} + +/** + * g_key_file_set_value: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @value: a string + * + * Associates a new value with @key under @group_name. If @key + * cannot be found then it is created. If @group_name cannot be + * found then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *value) +{ + GKeyFileGroup *group; + GKeyFileKeyValuePair *pair; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (g_key_file_is_group_name (group_name)); + g_return_if_fail (g_key_file_is_key_name (key)); + g_return_if_fail (value != NULL); + + group = g_key_file_lookup_group (key_file, group_name); + + if (!group) + { + g_key_file_add_group (key_file, group_name); + group = (GKeyFileGroup *) key_file->groups->data; + + g_key_file_add_key (key_file, group, key, value); + } + else + { + pair = g_key_file_lookup_key_value_pair (key_file, group, key); + + if (!pair) + g_key_file_add_key (key_file, group, key, value); + else + { + g_free (pair->value); + pair->value = g_strdup (value); + } + } +} + +/** + * g_key_file_get_string: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @error: return location for a #GError, or %NULL + * + * Returns the value associated with @key under @group_name. + * + * In the event the key cannot be found, %NULL is returned and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the + * event that the @group_name cannot be found, %NULL is returned + * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND. + * + * Return value: a newly allocated string or %NULL if the specified + * key cannot be found. + * + * Since: 2.6 + **/ +gchar * +g_key_file_get_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + gchar *value, *string_value; + GError *key_file_error; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + key_file_error = NULL; + + value = g_key_file_get_value (key_file, group_name, key, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return NULL; + } + + if (!g_utf8_validate (value, -1, NULL)) + { + gchar *value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_UNKNOWN_ENCODING, + _("Key file contains key '%s' with value '%s' " + "which is not UTF-8"), key, value_utf8); + g_free (value_utf8); + g_free (value); + + return NULL; + } + + string_value = g_key_file_parse_value_as_string (key_file, value, NULL, + &key_file_error); + g_free (value); + + if (key_file_error) + { + if (g_error_matches (key_file_error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains key '%s' " + "which has value that cannot be interpreted."), + key); + g_error_free (key_file_error); + } + else + g_propagate_error (error, key_file_error); + } + + return string_value; +} + +/** + * g_key_file_set_string: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @string: a string + * + * Associates a new string value with @key under @group_name. If + * @key cannot be found then it is created. If @group_name + * cannot be found then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *string) +{ + gchar *value; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (string != NULL); + + value = g_key_file_parse_string_as_value (key_file, string, FALSE); + g_key_file_set_value (key_file, group_name, key, value); + g_free (value); +} + +/** + * g_key_file_get_string_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @length: return location for the number of returned strings, or %NULL + * @error: return location for a #GError, or %NULL + * + * Returns the values associated with @key under @group_name. + * + * In the event the key cannot be found, %NULL is returned and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. In the + * event that the @group_name cannot be found, %NULL is returned + * and @error is set to #G_KEY_FILE_ERROR_GROUP_NOT_FOUND. + * + * Return value: a %NULL-terminated string array or %NULL if the specified + * key cannot be found. The array should be freed with g_strfreev(). + * + * Since: 2.6 + **/ +gchar ** +g_key_file_get_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) +{ + GError *key_file_error = NULL; + gchar *value, *string_value, **values; + gint i, len; + GSList *p, *pieces = NULL; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + value = g_key_file_get_value (key_file, group_name, key, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return NULL; + } + + if (!g_utf8_validate (value, -1, NULL)) + { + gchar *value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_UNKNOWN_ENCODING, + _("Key file contains key '%s' with value '%s' " + "which is not UTF-8"), key, value_utf8); + g_free (value_utf8); + g_free (value); + + return NULL; + } + + string_value = g_key_file_parse_value_as_string (key_file, value, &pieces, &key_file_error); + g_free (value); + g_free (string_value); + + if (key_file_error) + { + if (g_error_matches (key_file_error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains key '%s' " + "which has value that cannot be interpreted."), + key); + g_error_free (key_file_error); + } + else + g_propagate_error (error, key_file_error); + } + + len = g_slist_length (pieces); + values = g_new0 (gchar *, len + 1); + for (p = pieces, i = 0; p; p = p->next) + values[i++] = p->data; + values[len] = NULL; + + g_slist_free (pieces); + + if (length) + *length = len; + + return values; +} + +/** + * g_key_file_set_string_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @list: an array of locale string values + * @length: number of locale string values in @list + * + * Associates a list of string values for @key under @group_name. + * If @key cannot be found then it is created. If @group_name + * cannot be found then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar * const list[], + gsize length) +{ + GString *value_list; + gsize i; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (list != NULL); + + value_list = g_string_sized_new (length * 128); + for (i = 0; i < length && list[i] != NULL; i++) + { + gchar *value; + + value = g_key_file_parse_string_as_value (key_file, list[i], TRUE); + g_string_append (value_list, value); + g_string_append_c (value_list, key_file->list_separator); + + g_free (value); + } + + g_key_file_set_value (key_file, group_name, key, value_list->str); + g_string_free (value_list, TRUE); +} + +/** + * g_key_file_set_locale_string: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @locale: a locale + * @string: a string + * + * Associates a string value for @key and @locale under + * @group_name. If the translation for @key cannot be found + * then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_locale_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar *string) +{ + gchar *full_key, *value; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (key != NULL); + g_return_if_fail (locale != NULL); + g_return_if_fail (string != NULL); + + value = g_key_file_parse_string_as_value (key_file, string, FALSE); + full_key = g_strdup_printf ("%s[%s]", key, locale); + g_key_file_set_value (key_file, group_name, full_key, value); + g_free (full_key); + g_free (value); +} + +extern GSList *_g_compute_locale_variants (const gchar *locale); + +/** + * g_key_file_set_locale_string_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @locale: a locale + * @list: a %NULL-terminated array of locale string values + * @length: the length of @list + * + * Associates a list of string values for @key and @locale under + * @group_name. If the translation for @key cannot be found then + * it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_locale_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar * const list[], + gsize length) +{ + GString *value_list; + gchar *full_key; + gsize i; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (key != NULL); + g_return_if_fail (locale != NULL); + g_return_if_fail (length != 0); + + value_list = g_string_sized_new (length * 128); + for (i = 0; i < length && list[i] != NULL; i++) + { + gchar *value; + + value = g_key_file_parse_string_as_value (key_file, list[i], TRUE); + + g_string_append (value_list, value); + g_string_append_c (value_list, ';'); + + g_free (value); + } + + full_key = g_strdup_printf ("%s[%s]", key, locale); + g_key_file_set_value (key_file, group_name, full_key, value_list->str); + g_free (full_key); + g_string_free (value_list, TRUE); +} + +/** + * g_key_file_get_boolean: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @error: return location for a #GError + * + * Returns the value associated with @key under @group_name as a + * boolean. + * + * If @key cannot be found then the return value is undefined and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if + * the value associated with @key cannot be interpreted as a boolean + * then the return value is also undefined and @error is set to + * #G_KEY_FILE_ERROR_INVALID_VALUE. + * + * Return value: the value associated with the key as a boolean + * Since: 2.6 + **/ +gboolean +g_key_file_get_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GError *key_file_error = NULL; + gchar *value; + gboolean bool_value; + + g_return_val_if_fail (key_file != NULL, FALSE); + g_return_val_if_fail (group_name != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); + + value = g_key_file_get_value (key_file, group_name, key, &key_file_error); + + if (!value) + { + g_propagate_error (error, key_file_error); + return FALSE; + } + + bool_value = g_key_file_parse_value_as_boolean (key_file, value, + &key_file_error); + g_free (value); + + if (key_file_error) + { + if (g_error_matches (key_file_error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains key '%s' " + "which has value that cannot be interpreted."), + key); + g_error_free (key_file_error); + } + else + g_propagate_error (error, key_file_error); + } + + return bool_value; +} + +/** + * g_key_file_set_boolean: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @value: %TRUE or %FALSE + * + * Associates a new boolean value with @key under @group_name. + * If @key cannot be found then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean value) +{ + gchar *result; + + g_return_if_fail (key_file != NULL); + + result = g_key_file_parse_boolean_as_value (key_file, value); + g_key_file_set_value (key_file, group_name, key, result); + g_free (result); +} + +/** + * g_key_file_get_boolean_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @length: the number of booleans returned + * @error: return location for a #GError + * + * Returns the values associated with @key under @group_name as + * booleans. If @group_name is %NULL, the start_group is used. + * + * If @key cannot be found then the return value is undefined and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if + * the values associated with @key cannot be interpreted as booleans + * then the return value is also undefined and @error is set to + * #G_KEY_FILE_ERROR_INVALID_VALUE. + * + * Return value: the values associated with the key as a boolean + * + * Since: 2.6 + **/ +gboolean * +g_key_file_get_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) +{ + GError *key_file_error; + gchar **values; + gboolean *bool_values; + gsize i, num_bools; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + key_file_error = NULL; + + values = g_key_file_get_string_list (key_file, group_name, key, + &num_bools, &key_file_error); + + if (key_file_error) + g_propagate_error (error, key_file_error); + + if (!values) + return NULL; + + bool_values = g_new0 (gboolean, num_bools); + + for (i = 0; i < num_bools; i++) + { + bool_values[i] = g_key_file_parse_value_as_boolean (key_file, + values[i], + &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + g_strfreev (values); + g_free (bool_values); + + return NULL; + } + } + g_strfreev (values); + + if (length) + *length = num_bools; + + return bool_values; +} + +/** + * g_key_file_set_boolean_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @list: an array of boolean values + * @length: length of @list + * + * Associates a list of boolean values with @key under + * @group_name. If @key cannot be found then it is created. + * If @group_name is %NULL, the start_group is used. + * + * Since: 2.6 + **/ +void +g_key_file_set_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean list[], + gsize length) +{ + GString *value_list; + gsize i; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (list != NULL); + + value_list = g_string_sized_new (length * 8); + for (i = 0; i < length; i++) + { + gchar *value; + + value = g_key_file_parse_boolean_as_value (key_file, list[i]); + + g_string_append (value_list, value); + g_string_append_c (value_list, key_file->list_separator); + + g_free (value); + } + + g_key_file_set_value (key_file, group_name, key, value_list->str); + g_string_free (value_list, TRUE); +} + +/** + * g_key_file_get_integer: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @error: return location for a #GError + * + * Returns the value associated with @key under @group_name as an + * integer. If @group_name is %NULL, the start_group is used. + * + * If @key cannot be found then the return value is undefined and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if + * the value associated with @key cannot be interpreted as an integer + * then the return value is also undefined and @error is set to + * #G_KEY_FILE_ERROR_INVALID_VALUE. + * + * Return value: the value associated with the key as an integer. + * + * Since: 2.6 + **/ +gint +g_key_file_get_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GError *key_file_error; + gchar *value; + gint int_value; + + g_return_val_if_fail (key_file != NULL, -1); + g_return_val_if_fail (group_name != NULL, -1); + g_return_val_if_fail (key != NULL, -1); + + key_file_error = NULL; + + value = g_key_file_get_value (key_file, group_name, key, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return 0; + } + + int_value = g_key_file_parse_value_as_integer (key_file, value, + &key_file_error); + g_free (value); + + if (key_file_error) + { + if (g_error_matches (key_file_error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains key '%s' in group '%s' " + "which has value that cannot be interpreted."), key, + group_name); + g_error_free (key_file_error); + } + else + g_propagate_error (error, key_file_error); + } + + return int_value; +} + +/** + * g_key_file_set_integer: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @value: an integer value + * + * Associates a new integer value with @key under @group_name. + * If @key cannot be found then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint value) +{ + gchar *result; + + g_return_if_fail (key_file != NULL); + + result = g_key_file_parse_integer_as_value (key_file, value); + g_key_file_set_value (key_file, group_name, key, result); + g_free (result); +} + +/** + * g_key_file_get_integer_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @length: the number of integers returned + * @error: return location for a #GError + * + * Returns the values associated with @key under @group_name as + * integers. + * + * If @key cannot be found then the return value is undefined and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if + * the values associated with @key cannot be interpreted as integers + * then the return value is also undefined and @error is set to + * #G_KEY_FILE_ERROR_INVALID_VALUE. + * + * Return value: the values associated with the key as a integer + * + * Since: 2.6 + **/ +gint * +g_key_file_get_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) +{ + GError *key_file_error = NULL; + gchar **values; + gint *int_values; + gsize i, num_ints; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + values = g_key_file_get_string_list (key_file, group_name, key, + &num_ints, &key_file_error); + + if (key_file_error) + g_propagate_error (error, key_file_error); + + if (!values) + return NULL; + + int_values = g_new0 (gint, num_ints); + + for (i = 0; i < num_ints; i++) + { + int_values[i] = g_key_file_parse_value_as_integer (key_file, + values[i], + &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + g_strfreev (values); + g_free (int_values); + + return NULL; + } + } + g_strfreev (values); + + if (length) + *length = num_ints; + + return int_values; +} + +/** + * g_key_file_set_integer_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @list: an array of integer values + * @length: number of integer values in @list + * + * Associates a list of integer values with @key under + * @group_name. If @key cannot be found then it is created. + * + * Since: 2.6 + **/ +void +g_key_file_set_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint list[], + gsize length) +{ + GString *values; + gsize i; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (list != NULL); + + values = g_string_sized_new (length * 16); + for (i = 0; i < length; i++) + { + gchar *value; + + value = g_key_file_parse_integer_as_value (key_file, list[i]); + + g_string_append (values, value); + g_string_append_c (values, ';'); + + g_free (value); + } + + g_key_file_set_value (key_file, group_name, key, values->str); + g_string_free (values, TRUE); +} + +/** + * g_key_file_get_double: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @error: return location for a #GError + * + * Returns the value associated with @key under @group_name as an + * integer. If @group_name is %NULL, the start_group is used. + * + * If @key cannot be found then the return value is undefined and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if + * the value associated with @key cannot be interpreted as a double + * then the return value is also undefined and @error is set to + * #G_KEY_FILE_ERROR_INVALID_VALUE. + * + * Return value: the value associated with the key as a double. + * + * Since: 2.12 + **/ +gdouble +g_key_file_get_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GError *key_file_error; + gchar *value; + gdouble double_value; + + g_return_val_if_fail (key_file != NULL, -1); + g_return_val_if_fail (group_name != NULL, -1); + g_return_val_if_fail (key != NULL, -1); + + key_file_error = NULL; + + value = g_key_file_get_value (key_file, group_name, key, &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + return 0; + } + + double_value = g_key_file_parse_value_as_double (key_file, value, + &key_file_error); + g_free (value); + + if (key_file_error) + { + if (g_error_matches (key_file_error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE)) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains key '%s' in group '%s' " + "which has value that cannot be interpreted."), key, + group_name); + g_error_free (key_file_error); + } + else + g_propagate_error (error, key_file_error); + } + + return double_value; +} + +/** + * g_key_file_set_double: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @value: an double value + * + * Associates a new double value with @key under @group_name. + * If @key cannot be found then it is created. If @group_name + * is %NULL, the start group is used. + * + * Since: 2.12 + **/ +void +g_key_file_set_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble value) +{ + gchar result[G_ASCII_DTOSTR_BUF_SIZE]; + + g_return_if_fail (key_file != NULL); + + g_ascii_dtostr (result, sizeof (result), value); + g_key_file_set_value (key_file, group_name, key, result); +} + +/** + * g_key_file_get_double_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @length: the number of doubles returned + * @error: return location for a #GError + * + * Returns the values associated with @key under @group_name as + * doubles. If @group_name is %NULL, the start group is used. + * + * If @key cannot be found then the return value is undefined and + * @error is set to #G_KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if + * the values associated with @key cannot be interpreted as doubles + * then the return value is also undefined and @error is set to + * #G_KEY_FILE_ERROR_INVALID_VALUE. + * + * Return value: the values associated with the key as a double + * + * Since: 2.12 + **/ +gdouble * +g_key_file_get_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) +{ + GError *key_file_error = NULL; + gchar **values; + gdouble *double_values; + gsize i, num_doubles; + + g_return_val_if_fail (key_file != NULL, NULL); + g_return_val_if_fail (group_name != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + values = g_key_file_get_string_list (key_file, group_name, key, + &num_doubles, &key_file_error); + + if (key_file_error) + g_propagate_error (error, key_file_error); + + if (!values) + return NULL; + + double_values = g_new0 (gdouble, num_doubles); + + for (i = 0; i < num_doubles; i++) + { + double_values[i] = g_key_file_parse_value_as_double (key_file, + values[i], + &key_file_error); + + if (key_file_error) + { + g_propagate_error (error, key_file_error); + g_strfreev (values); + g_free (double_values); + + return NULL; + } + } + g_strfreev (values); + + if (length) + *length = num_doubles; + + return double_values; +} + +/** + * g_key_file_set_double_list: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key + * @list: an array of double values + * @length: number of double values in @list + * + * Associates a list of double values with @key under + * @group_name. If @key cannot be found then it is created. + * If @group_name is %NULL the start group is used. + * + * Since: 2.12 + **/ +void +g_key_file_set_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble list[], + gsize length) +{ + GString *values; + gsize i; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (list != NULL); + + values = g_string_sized_new (length * 16); + for (i = 0; i < length; i++) + { + gchar result[G_ASCII_DTOSTR_BUF_SIZE]; + + g_ascii_dtostr( result, sizeof (result), list[i] ); + + g_string_append (values, result); + g_string_append_c (values, ';'); + } + + g_key_file_set_value (key_file, group_name, key, values->str); + g_string_free (values, TRUE); +} + +static void +g_key_file_set_key_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *comment, + GError **error) +{ + GKeyFileGroup *group; + GKeyFileKeyValuePair *pair; + GList *key_node, *comment_node, *tmp; + + group = g_key_file_lookup_group (key_file, group_name); + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + + return; + } + + /* First find the key the comments are supposed to be + * associated with + */ + key_node = g_key_file_lookup_key_value_pair_node (key_file, group, key); + + if (key_node == NULL) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + _("Key file does not have key '%s' in group '%s'"), + key, group->name); + return; + } + + /* Then find all the comments already associated with the + * key and free them + */ + tmp = key_node->next; + while (tmp != NULL) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) tmp->data; + + if (pair->key != NULL) + break; + + comment_node = tmp; + tmp = tmp->next; + g_key_file_remove_key_value_pair_node (key_file, group, + comment_node); + } + + if (comment == NULL) + return; + + /* Now we can add our new comment + */ + pair = g_new0 (GKeyFileKeyValuePair, 1); + + pair->key = NULL; + pair->value = g_key_file_parse_comment_as_value (key_file, comment); + + key_node = g_list_insert (key_node, pair, 1); +} + +static void +g_key_file_set_group_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *comment, + GError **error) +{ + GKeyFileGroup *group; + + g_return_if_fail (g_key_file_is_group_name (group_name)); + + group = g_key_file_lookup_group (key_file, group_name); + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + + return; + } + + /* First remove any existing comment + */ + if (group->comment) + { + g_key_file_key_value_pair_free (group->comment); + group->comment = NULL; + } + + if (comment == NULL) + return; + + /* Now we can add our new comment + */ + group->comment = g_new0 (GKeyFileKeyValuePair, 1); + + group->comment->key = NULL; + group->comment->value = g_key_file_parse_comment_as_value (key_file, comment); +} + +static void +g_key_file_set_top_comment (GKeyFile *key_file, + const gchar *comment, + GError **error) +{ + GList *group_node; + GKeyFileGroup *group; + GKeyFileKeyValuePair *pair; + + /* The last group in the list should be the top (comments only) + * group in the file + */ + g_assert (key_file->groups != NULL); + group_node = g_list_last (key_file->groups); + group = (GKeyFileGroup *) group_node->data; + g_assert (group->name == NULL); + + /* Note all keys must be comments at the top of + * the file, so we can just free it all. + */ + if (group->key_value_pairs != NULL) + { + g_list_foreach (group->key_value_pairs, + (GFunc) g_key_file_key_value_pair_free, + NULL); + g_list_free (group->key_value_pairs); + group->key_value_pairs = NULL; + } + + if (comment == NULL) + return; + + pair = g_new0 (GKeyFileKeyValuePair, 1); + + pair->key = NULL; + pair->value = g_key_file_parse_comment_as_value (key_file, comment); + + group->key_value_pairs = + g_list_prepend (group->key_value_pairs, pair); +} + +/** + * g_key_file_set_comment: + * @key_file: a #GKeyFile + * @group_name: a group name, or %NULL + * @key: a key + * @comment: a comment + * @error: return location for a #GError + * + * Places a comment above @key from @group_name. + * @group_name. If @key is %NULL then @comment will + * be written above @group_name. If both @key + * and @group_name are NULL, then @comment will + * be written above the first group in the file. + * + * Since: 2.6 + **/ +void +g_key_file_set_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *comment, + GError **error) +{ + g_return_if_fail (key_file != NULL); + + if (group_name != NULL && key != NULL) + g_key_file_set_key_comment (key_file, group_name, key, comment, error); + else if (group_name != NULL) + g_key_file_set_group_comment (key_file, group_name, comment, error); + else + g_key_file_set_top_comment (key_file, comment, error); + + if (comment != NULL) + key_file->approximate_size += strlen (comment); +} + +static gchar * +g_key_file_get_key_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GKeyFileGroup *group; + GKeyFileKeyValuePair *pair; + GList *key_node, *tmp; + GString *string; + gchar *comment; + + g_return_val_if_fail (g_key_file_is_group_name (group_name), NULL); + + group = g_key_file_lookup_group (key_file, group_name); + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + + return NULL; + } + + /* First find the key the comments are supposed to be + * associated with + */ + key_node = g_key_file_lookup_key_value_pair_node (key_file, group, key); + + if (key_node == NULL) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + _("Key file does not have key '%s' in group '%s'"), + key, group->name); + return NULL; + } + + string = NULL; + + /* Then find all the comments already associated with the + * key and concatentate them. + */ + tmp = key_node->next; + if (!key_node->next) + return NULL; + + pair = (GKeyFileKeyValuePair *) tmp->data; + if (pair->key != NULL) + return NULL; + + while (tmp->next) + { + pair = (GKeyFileKeyValuePair *) tmp->next->data; + + if (pair->key != NULL) + break; + + tmp = tmp->next; + } + + while (tmp != key_node) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) tmp->data; + + if (string == NULL) + string = g_string_sized_new (512); + + comment = g_key_file_parse_value_as_comment (key_file, pair->value); + g_string_append (string, comment); + g_free (comment); + + tmp = tmp->prev; + } + + if (string != NULL) + { + comment = string->str; + g_string_free (string, FALSE); + } + else + comment = NULL; + + return comment; +} + +static gchar * +get_group_comment (GKeyFile *key_file, + GKeyFileGroup *group, + GError **error) +{ + GString *string; + GList *tmp; + gchar *comment; + + string = NULL; + + tmp = group->key_value_pairs; + while (tmp) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) tmp->data; + + if (pair->key != NULL) + { + tmp = tmp->prev; + break; + } + + if (tmp->next == NULL) + break; + + tmp = tmp->next; + } + + while (tmp != NULL) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) tmp->data; + + if (string == NULL) + string = g_string_sized_new (512); + + comment = g_key_file_parse_value_as_comment (key_file, pair->value); + g_string_append (string, comment); + g_free (comment); + + tmp = tmp->prev; + } + + if (string != NULL) + return g_string_free (string, FALSE); + + return NULL; +} + +static gchar * +g_key_file_get_group_comment (GKeyFile *key_file, + const gchar *group_name, + GError **error) +{ + GList *group_node; + GKeyFileGroup *group; + + group_node = g_key_file_lookup_group_node (key_file, group_name); + if (!group_node) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + + return NULL; + } + + group = (GKeyFileGroup *)group_node->data; + if (group->comment) + return g_strdup (group->comment->value); + + group_node = group_node->next; + group = (GKeyFileGroup *)group_node->data; + return get_group_comment (key_file, group, error); +} + +static gchar * +g_key_file_get_top_comment (GKeyFile *key_file, + GError **error) +{ + GList *group_node; + GKeyFileGroup *group; + + /* The last group in the list should be the top (comments only) + * group in the file + */ + g_assert (key_file->groups != NULL); + group_node = g_list_last (key_file->groups); + group = (GKeyFileGroup *) group_node->data; + g_assert (group->name == NULL); + + return get_group_comment (key_file, group, error); +} + +/** + * g_key_file_get_comment: + * @key_file: a #GKeyFile + * @group_name: a group name, or %NULL + * @key: a key + * @error: return location for a #GError + * + * Retrieves a comment above @key from @group_name. + * @group_name. If @key is %NULL then @comment will + * be read from above @group_name. If both @key + * and @group_name are NULL, then @comment will + * be read from above the first group in the file. + * + * Returns: a comment that should be freed with g_free() + * + * Since: 2.6 + **/ +gchar * +g_key_file_get_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + g_return_val_if_fail (key_file != NULL, NULL); + + if (group_name != NULL && key != NULL) + return g_key_file_get_key_comment (key_file, group_name, key, error); + else if (group_name != NULL) + return g_key_file_get_group_comment (key_file, group_name, error); + else + return g_key_file_get_top_comment (key_file, error); +} + +/** + * g_key_file_remove_comment: + * @key_file: a #GKeyFile + * @group_name: a group name, or %NULL + * @key: a key + * @error: return location for a #GError + * + * Removes a comment above @key from @group_name. + * @group_name. If @key is %NULL then @comment will + * be written above @group_name. If both @key + * and @group_name are NULL, then @comment will + * be written above the first group in the file. + * + * Since: 2.6 + **/ + +void +g_key_file_remove_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + g_return_if_fail (key_file != NULL); + + if (group_name != NULL && key != NULL) + g_key_file_set_key_comment (key_file, group_name, key, NULL, error); + else if (group_name != NULL) + g_key_file_set_group_comment (key_file, group_name, NULL, error); + else + g_key_file_set_top_comment (key_file, NULL, error); +} + +/** + * g_key_file_has_group: + * @key_file: a #GKeyFile + * @group_name: a group name + * + * Looks whether the key file has the group @group_name. + * + * Return value: %TRUE if @group_name is a part of @key_file, %FALSE + * otherwise. + * Since: 2.6 + **/ +gboolean +g_key_file_has_group (GKeyFile *key_file, + const gchar *group_name) +{ + g_return_val_if_fail (key_file != NULL, FALSE); + g_return_val_if_fail (group_name != NULL, FALSE); + + return g_key_file_lookup_group_node (key_file, group_name) != NULL; +} + +/** + * g_key_file_has_key: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key name + * @error: return location for a #GError + * + * Looks whether the key file has the key @key in the group + * @group_name. + * + * Return value: %TRUE if @key is a part of @group_name, %FALSE + * otherwise. + * + * Since: 2.6 + **/ +gboolean +g_key_file_has_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GKeyFileKeyValuePair *pair; + GKeyFileGroup *group; + + g_return_val_if_fail (key_file != NULL, FALSE); + g_return_val_if_fail (group_name != NULL, FALSE); + g_return_val_if_fail (key != NULL, FALSE); + + group = g_key_file_lookup_group (key_file, group_name); + + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + + return FALSE; + } + + pair = g_key_file_lookup_key_value_pair (key_file, group, key); + + return pair != NULL; +} + +static void +g_key_file_add_group (GKeyFile *key_file, + const gchar *group_name) +{ + GKeyFileGroup *group; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (g_key_file_is_group_name (group_name)); + + group = g_key_file_lookup_group (key_file, group_name); + if (group != NULL) + { + key_file->current_group = group; + return; + } + + group = g_new0 (GKeyFileGroup, 1); + group->name = g_strdup (group_name); + group->lookup_map = g_hash_table_new (g_str_hash, g_str_equal); + key_file->groups = g_list_prepend (key_file->groups, group); + key_file->approximate_size += strlen (group_name) + 3; + key_file->current_group = group; + + if (key_file->start_group == NULL) + key_file->start_group = group; +} + +static void +g_key_file_key_value_pair_free (GKeyFileKeyValuePair *pair) +{ + if (pair != NULL) + { + g_free (pair->key); + g_free (pair->value); + g_free (pair); + } +} + +/* Be careful not to call this function on a node with data in the + * lookup map without removing it from the lookup map, first. + * + * Some current cases where this warning is not a concern are + * when: + * - the node being removed is a comment node + * - the entire lookup map is getting destroyed soon after + * anyway. + */ +static void +g_key_file_remove_key_value_pair_node (GKeyFile *key_file, + GKeyFileGroup *group, + GList *pair_node) +{ + + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) pair_node->data; + + group->key_value_pairs = g_list_remove_link (group->key_value_pairs, pair_node); + + if (pair->key != NULL) + key_file->approximate_size -= strlen (pair->key) + 1; + + g_assert (pair->value != NULL); + key_file->approximate_size -= strlen (pair->value); + + g_key_file_key_value_pair_free (pair); + + g_list_free_1 (pair_node); +} + +static void +g_key_file_remove_group_node (GKeyFile *key_file, + GList *group_node) +{ + GKeyFileGroup *group; + GList *tmp; + + group = (GKeyFileGroup *) group_node->data; + + /* If the current group gets deleted make the current group the last + * added group. + */ + if (key_file->current_group == group) + { + /* groups should always contain at least the top comment group, + * unless g_key_file_clear has been called + */ + if (key_file->groups) + key_file->current_group = (GKeyFileGroup *) key_file->groups->data; + else + key_file->current_group = NULL; + } + + /* If the start group gets deleted make the start group the first + * added group. + */ + if (key_file->start_group == group) + { + tmp = g_list_last (key_file->groups); + while (tmp != NULL) + { + if (tmp != group_node && + ((GKeyFileGroup *) tmp->data)->name != NULL) + break; + + tmp = tmp->prev; + } + + if (tmp) + key_file->start_group = (GKeyFileGroup *) tmp->data; + else + key_file->start_group = NULL; + } + + key_file->groups = g_list_remove_link (key_file->groups, group_node); + + if (group->name != NULL) + key_file->approximate_size -= strlen (group->name) + 3; + + tmp = group->key_value_pairs; + while (tmp != NULL) + { + GList *pair_node; + + pair_node = tmp; + tmp = tmp->next; + g_key_file_remove_key_value_pair_node (key_file, group, pair_node); + } + + g_assert (group->key_value_pairs == NULL); + + if (group->lookup_map) + { + g_hash_table_destroy (group->lookup_map); + group->lookup_map = NULL; + } + + g_free ((gchar *) group->name); + g_free (group); + g_list_free_1 (group_node); +} + +/** + * g_key_file_remove_group: + * @key_file: a #GKeyFile + * @group_name: a group name + * @error: return location for a #GError or %NULL + * + * Removes the specified group, @group_name, + * from the key file. + * + * Since: 2.6 + **/ +void +g_key_file_remove_group (GKeyFile *key_file, + const gchar *group_name, + GError **error) +{ + GList *group_node; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (group_name != NULL); + + group_node = g_key_file_lookup_group_node (key_file, group_name); + + if (!group_node) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name); + return; + } + + g_key_file_remove_group_node (key_file, group_node); +} + +static void +g_key_file_add_key (GKeyFile *key_file, + GKeyFileGroup *group, + const gchar *key, + const gchar *value) +{ + GKeyFileKeyValuePair *pair; + + pair = g_new0 (GKeyFileKeyValuePair, 1); + + pair->key = g_strdup (key); + pair->value = g_strdup (value); + + g_hash_table_replace (group->lookup_map, pair->key, pair); + group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair); + key_file->approximate_size += strlen (key) + strlen (value) + 2; +} + +/** + * g_key_file_remove_key: + * @key_file: a #GKeyFile + * @group_name: a group name + * @key: a key name to remove + * @error: return location for a #GError or %NULL + * + * Removes @key in @group_name from the key file. + * + * Since: 2.6 + **/ +void +g_key_file_remove_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) +{ + GKeyFileGroup *group; + GKeyFileKeyValuePair *pair; + + g_return_if_fail (key_file != NULL); + g_return_if_fail (group_name != NULL); + g_return_if_fail (key != NULL); + + pair = NULL; + + group = g_key_file_lookup_group (key_file, group_name); + if (!group) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + _("Key file does not have group '%s'"), + group_name ? group_name : "(null)"); + return; + } + + pair = g_key_file_lookup_key_value_pair (key_file, group, key); + + if (!pair) + { + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + _("Key file does not have key '%s' in group '%s'"), + key, group->name); + return; + } + + key_file->approximate_size -= strlen (pair->key) + strlen (pair->value) + 2; + + group->key_value_pairs = g_list_remove (group->key_value_pairs, pair); + g_hash_table_remove (group->lookup_map, pair->key); + g_key_file_key_value_pair_free (pair); +} + +static GList * +g_key_file_lookup_group_node (GKeyFile *key_file, + const gchar *group_name) +{ + GKeyFileGroup *group; + GList *tmp; + + for (tmp = key_file->groups; tmp != NULL; tmp = tmp->next) + { + group = (GKeyFileGroup *) tmp->data; + + if (group && group->name && strcmp (group->name, group_name) == 0) + break; + } + + return tmp; +} + +static GKeyFileGroup * +g_key_file_lookup_group (GKeyFile *key_file, + const gchar *group_name) +{ + GList *group_node; + + group_node = g_key_file_lookup_group_node (key_file, group_name); + + if (group_node != NULL) + return (GKeyFileGroup *) group_node->data; + + return NULL; +} + +static GList * +g_key_file_lookup_key_value_pair_node (GKeyFile *key_file, + GKeyFileGroup *group, + const gchar *key) +{ + GList *key_node; + + for (key_node = group->key_value_pairs; + key_node != NULL; + key_node = key_node->next) + { + GKeyFileKeyValuePair *pair; + + pair = (GKeyFileKeyValuePair *) key_node->data; + + if (pair->key && strcmp (pair->key, key) == 0) + break; + } + + return key_node; +} + +static GKeyFileKeyValuePair * +g_key_file_lookup_key_value_pair (GKeyFile *key_file, + GKeyFileGroup *group, + const gchar *key) +{ + return (GKeyFileKeyValuePair *) g_hash_table_lookup (group->lookup_map, key); +} + +/* Lines starting with # or consisting entirely of whitespace are merely + * recorded, not parsed. This function assumes all leading whitespace + * has been stripped. + */ +static gboolean +g_key_file_line_is_comment (const gchar *line) +{ + return (*line == '#' || *line == '\0' || *line == '\n'); +} + +static gboolean +g_key_file_is_group_name (const gchar *name) +{ + gchar *p, *q; + + if (name == NULL) + return FALSE; + + p = q = (gchar *) name; + while (*q && *q != ']' && *q != '[' && !g_ascii_iscntrl (*q)) + q = g_utf8_next_char (q); + + if (*q != '\0' || q == p) + return FALSE; + + return TRUE; +} + +static gboolean +g_key_file_is_key_name (const gchar *name) +{ + gchar *p, *q; + + if (name == NULL) + return FALSE; + + p = q = (gchar *) name; + /* We accept a little more than the desktop entry spec says, + * since gnome-vfs uses mime-types as keys in its cache. + */ + while (*q && (g_unichar_isalnum (g_utf8_get_char (q)) || + *q == '-' || *q == '_' || *q == '/' || *q == '+' || *q == '.')) + q = g_utf8_next_char (q); + + if (*q == '[') + { + q++; + while (*q && (g_unichar_isalnum (g_utf8_get_char (q)) || *q == '-' || *q == '_' || *q == '.' || *q == '@')) + q = g_utf8_next_char (q); + + if (*q != ']') + return FALSE; + + q++; + } + + if (*q != '\0' || q == p) + return FALSE; + + return TRUE; +} + +/* A group in a key file is made up of a starting '[' followed by one + * or more letters making up the group name followed by ']'. + */ +static gboolean +g_key_file_line_is_group (const gchar *line) +{ + gchar *p; + + p = (gchar *) line; + if (*p != '[') + return FALSE; + + p++; + + while (*p && *p != ']') + p = g_utf8_next_char (p); + + if (!*p) + return FALSE; + + return TRUE; +} + +static gboolean +g_key_file_line_is_key_value_pair (const gchar *line) +{ + gchar *p; + + p = (gchar *) g_utf8_strchr (line, -1, '='); + + if (!p) + return FALSE; + + /* Key must be non-empty + */ + if (*p == line[0]) + return FALSE; + + return TRUE; +} + +static gchar * +g_key_file_parse_value_as_string (GKeyFile *key_file, + const gchar *value, + GSList **pieces, + GError **error) +{ + gchar *string_value, *p, *q0, *q; + + string_value = g_new0 (gchar, strlen (value) + 1); + + p = (gchar *) value; + q0 = q = string_value; + while (*p) + { + if (*p == '\\') + { + p++; + + switch (*p) + { + case 's': + *q = ' '; + break; + + case 'n': + *q = '\n'; + break; + + case 't': + *q = '\t'; + break; + + case 'r': + *q = '\r'; + break; + + case '\\': + *q = '\\'; + break; + + case '\0': + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains escape character " + "at end of line")); + break; + + default: + if (pieces && *p == key_file->list_separator) + *q = key_file->list_separator; + else + { + *q++ = '\\'; + *q = *p; + + if (*error == NULL) + { + gchar sequence[3]; + + sequence[0] = '\\'; + sequence[1] = *p; + sequence[2] = '\0'; + + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Key file contains invalid escape " + "sequence '%s'"), sequence); + } + } + break; + } + } + else + { + *q = *p; + if (pieces && (*p == key_file->list_separator)) + { + *pieces = g_slist_prepend (*pieces, g_strndup (q0, q - q0)); + q0 = q + 1; + } + } + + if (*p == '\0') + break; + + q++; + p++; + } + + *q = '\0'; + if (pieces) + { + if (q0 < q) + *pieces = g_slist_prepend (*pieces, g_strndup (q0, q - q0)); + *pieces = g_slist_reverse (*pieces); + } + + return string_value; +} + +static gchar * +g_key_file_parse_string_as_value (GKeyFile *key_file, + const gchar *string, + gboolean escape_separator) +{ + gchar *value, *p, *q; + gsize length; + gboolean parsing_leading_space; + + length = strlen (string) + 1; + + /* Worst case would be that every character needs to be escaped. + * In other words every character turns to two characters + */ + value = g_new0 (gchar, 2 * length); + + p = (gchar *) string; + q = value; + parsing_leading_space = TRUE; + while (p < (string + length - 1)) + { + gchar escaped_character[3] = { '\\', 0, 0 }; + + switch (*p) + { + case ' ': + if (parsing_leading_space) + { + escaped_character[1] = 's'; + strcpy (q, escaped_character); + q += 2; + } + else + { + *q = *p; + q++; + } + break; + case '\t': + if (parsing_leading_space) + { + escaped_character[1] = 't'; + strcpy (q, escaped_character); + q += 2; + } + else + { + *q = *p; + q++; + } + break; + case '\n': + escaped_character[1] = 'n'; + strcpy (q, escaped_character); + q += 2; + break; + case '\r': + escaped_character[1] = 'r'; + strcpy (q, escaped_character); + q += 2; + break; + case '\\': + escaped_character[1] = '\\'; + strcpy (q, escaped_character); + q += 2; + parsing_leading_space = FALSE; + break; + default: + if (escape_separator && *p == key_file->list_separator) + { + escaped_character[1] = key_file->list_separator; + strcpy (q, escaped_character); + q += 2; + parsing_leading_space = TRUE; + } + else + { + *q = *p; + q++; + parsing_leading_space = FALSE; + } + break; + } + p++; + } + *q = '\0'; + + return value; +} + +static gint +g_key_file_parse_value_as_integer (GKeyFile *key_file, + const gchar *value, + GError **error) +{ + gchar *end_of_valid_int; + glong long_value; + gint int_value; + + errno = 0; + long_value = strtol (value, &end_of_valid_int, 10); + + if (*value == '\0' || *end_of_valid_int != '\0') + { + gchar *value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Value '%s' cannot be interpreted " + "as a number."), value_utf8); + g_free (value_utf8); + + return 0; + } + + int_value = long_value; + if (int_value != long_value || errno == ERANGE) + { + gchar *value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, + G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Integer value '%s' out of range"), + value_utf8); + g_free (value_utf8); + + return 0; + } + + return int_value; +} + +static gchar * +g_key_file_parse_integer_as_value (GKeyFile *key_file, + gint value) + +{ + return g_strdup_printf ("%d", value); +} + +static gdouble +g_key_file_parse_value_as_double (GKeyFile *key_file, + const gchar *value, + GError **error) +{ + gchar *end_of_valid_d; + gdouble double_value = 0; + + double_value = g_ascii_strtod (value, &end_of_valid_d); + + if (*end_of_valid_d != '\0' || end_of_valid_d == value) + { + gchar *value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Value '%s' cannot be interpreted " + "as a float number."), + value_utf8); + g_free (value_utf8); + } + + return double_value; +} + +static gboolean +g_key_file_parse_value_as_boolean (GKeyFile *key_file, + const gchar *value, + GError **error) +{ + gchar *value_utf8; + + if (value) + { + if (strcmp (value, "true") == 0 || strcmp (value, "1") == 0) + return TRUE; + else if (strcmp (value, "false") == 0 || strcmp (value, "0") == 0) + return FALSE; + } + + value_utf8 = _g_utf8_make_valid (value); + g_set_error (error, G_KEY_FILE_ERROR, + G_KEY_FILE_ERROR_INVALID_VALUE, + _("Value '%s' cannot be interpreted " + "as a boolean."), value_utf8); + g_free (value_utf8); + + return FALSE; +} + +static gchar * +g_key_file_parse_boolean_as_value (GKeyFile *key_file, + gboolean value) +{ + if (value) + return g_strdup ("true"); + else + return g_strdup ("false"); +} + +static gchar * +g_key_file_parse_value_as_comment (GKeyFile *key_file, + const gchar *value) +{ + GString *string; + gchar **lines; + gsize i; + + string = g_string_sized_new (512); + + lines = g_strsplit (value, "\n", 0); + + for (i = 0; lines[i] != NULL; i++) + { + if (lines[i][0] != '#') + g_string_append_printf (string, "%s\n", lines[i]); + else + g_string_append_printf (string, "%s\n", lines[i] + 1); + } + g_strfreev (lines); + + return g_string_free (string, FALSE); +} + +static gchar * +g_key_file_parse_comment_as_value (GKeyFile *key_file, + const gchar *comment) +{ + GString *string; + gchar **lines; + gsize i; + + string = g_string_sized_new (512); + + lines = g_strsplit (comment, "\n", 0); + + for (i = 0; lines[i] != NULL; i++) + g_string_append_printf (string, "#%s%s", lines[i], + lines[i + 1] == NULL? "" : "\n"); + g_strfreev (lines); + + return g_string_free (string, FALSE); +} +#endif + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/lib/glib-compat-key-file.h diff -u /dev/null tomoe/lib/glib-compat-key-file.h:1.1 --- /dev/null Mon Dec 25 12:32:50 2006 +++ tomoe/lib/glib-compat-key-file.h Mon Dec 25 12:32:50 2006 @@ -0,0 +1,232 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2006 Kouhei Sutou + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * $Id: glib-compat-key-file.h,v 1.1 2006/12/25 03:32:50 kous Exp $ + */ + +#ifndef __GLIB_COMPAT_KEY_FILE_H__ +#define __GLIB_COMPAT_KEY_FILE_H__ + +#include + +#if !GLIB_CHECK_VERSION(2, 6, 0) +/* gkeyfile.h - desktop entry file parser + * + * Copyright 2004 Red Hat, Inc. + * + * Ray Strode + * + * GLib is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * GLib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with GLib; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __G_KEY_FILE_H__ +#define __G_KEY_FILE_H__ + +#include + +G_BEGIN_DECLS + +typedef enum +{ + G_KEY_FILE_ERROR_UNKNOWN_ENCODING, + G_KEY_FILE_ERROR_PARSE, + G_KEY_FILE_ERROR_NOT_FOUND, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + G_KEY_FILE_ERROR_INVALID_VALUE +} GKeyFileError; + +#define G_KEY_FILE_ERROR g_key_file_error_quark() + +GQuark g_key_file_error_quark (void); + +typedef struct _GKeyFile GKeyFile; + +typedef enum +{ + G_KEY_FILE_NONE = 0, + G_KEY_FILE_KEEP_COMMENTS = 1 << 0, + G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1 +} GKeyFileFlags; + +GKeyFile *g_key_file_new (void); +void g_key_file_free (GKeyFile *key_file); +void g_key_file_set_list_separator (GKeyFile *key_file, + gchar separator); +gboolean g_key_file_load_from_file (GKeyFile *key_file, + const gchar *file, + GKeyFileFlags flags, + GError **error); +gboolean g_key_file_load_from_data (GKeyFile *key_file, + const gchar *data, + gsize length, + GKeyFileFlags flags, + GError **error); +gchar *g_key_file_to_data (GKeyFile *key_file, + gsize *length, + GError **error); +gchar *g_key_file_get_start_group (GKeyFile *key_file); +gchar **g_key_file_get_groups (GKeyFile *key_file, + gsize *length); +gchar **g_key_file_get_keys (GKeyFile *key_file, + const gchar *group_name, + gsize *length, + GError **error); +gboolean g_key_file_has_group (GKeyFile *key_file, + const gchar *group_name); +gboolean g_key_file_has_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +gchar *g_key_file_get_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_set_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *value); +gchar *g_key_file_get_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_set_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *string); +void g_key_file_set_locale_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar *string); +gboolean g_key_file_get_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_set_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean value); +gint g_key_file_get_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_set_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint value); +gdouble g_key_file_get_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_set_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble value); +gchar **g_key_file_get_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error); +void g_key_file_set_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar * const list[], + gsize length); +void g_key_file_set_locale_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar * const list[], + gsize length); +gboolean *g_key_file_get_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error); +void g_key_file_set_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean list[], + gsize length); +gint *g_key_file_get_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error); +void g_key_file_set_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble list[], + gsize length); +gdouble *g_key_file_get_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error); +void g_key_file_set_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint list[], + gsize length); +void g_key_file_set_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *comment, + GError **error); +gchar *g_key_file_get_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); + +void g_key_file_remove_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_remove_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +void g_key_file_remove_group (GKeyFile *key_file, + const gchar *group_name, + GError **error); + +G_END_DECLS + +#endif /* __G_KEY_FILE_H__ */ +#endif + +#endif /* __GLIB_COMPAT_KEY_FILE_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab +*/ Index: tomoe/lib/glib-utils.h diff -u tomoe/lib/glib-utils.h:1.8 tomoe/lib/glib-utils.h:1.9 --- tomoe/lib/glib-utils.h:1.8 Mon Dec 25 11:41:48 2006 +++ tomoe/lib/glib-utils.h Mon Dec 25 12:32:50 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-utils.h,v 1.8 2006/12/25 02:41:48 kous Exp $ + * $Id: glib-utils.h,v 1.9 2006/12/25 03:32:50 kous Exp $ */ @@ -27,6 +27,7 @@ #include #include #include "glib-compat-file-utilities.h" +#include "glib-compat-key-file.h" G_BEGIN_DECLS From kous users.sourceforge.jp Mon Dec 25 12:43:34 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 12:43:34 +0900 Subject: [Tomoe-cvs 2057] CVS update: tomoe Message-ID: <20061225034334.D15722AC0EB@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.494 tomoe/ChangeLog:1.495 --- tomoe/ChangeLog:1.494 Mon Dec 25 12:32:49 2006 +++ tomoe/ChangeLog Mon Dec 25 12:43:34 2006 @@ -1,5 +1,8 @@ 2006-12-25 Kouhei Sutou + * lib/glib-compat-file-utilities.h: used g_strdup () for + g_filename_display_name() alternate. + * lib/Makefile.am, lib/glib-utils.h, lib/glib-compat-key-file.[ch]: added GKeyFile implementation to work on GLib 2.4.x environment. From kous users.sourceforge.jp Mon Dec 25 12:43:35 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 12:43:35 +0900 Subject: [Tomoe-cvs 2058] CVS update: tomoe/lib Message-ID: <20061225034335.0C5CE2AC134@users.sourceforge.jp> Index: tomoe/lib/glib-compat-file-utilities.h diff -u tomoe/lib/glib-compat-file-utilities.h:1.2 tomoe/lib/glib-compat-file-utilities.h:1.3 --- tomoe/lib/glib-compat-file-utilities.h:1.2 Mon Dec 25 12:30:54 2006 +++ tomoe/lib/glib-compat-file-utilities.h Mon Dec 25 12:43:34 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: glib-compat-file-utilities.h,v 1.2 2006/12/25 03:30:54 kous Exp $ + * $Id: glib-compat-file-utilities.h,v 1.3 2006/12/25 03:43:34 kous Exp $ */ #ifndef __GLIB_COMPAT_FILE_UTILITIES_H__ @@ -36,12 +36,12 @@ # ifdef HAVE_SYS_TYPES_H # include # endif -# define g_open(filename, flags, mode) open(filename, flags, mode) -# define g_filename_display_name(name) (name) -# define g_unlink(filename) unlink(filename) -# define g_mkdir(filename, mode) mkdir(filename, mode) +# define g_open(filename, flags, mode) open (filename, flags, mode) +# define g_filename_display_name(name) g_strdup (name) +# define g_unlink(filename) unlink (filename) +# define g_mkdir(filename, mode) mkdir (filename, mode) # define g_rename(old_filename, new_filename) \ - rename(old_filename, new_filename) + rename (old_filename, new_filename) #endif #ifndef O_BINARY From kous users.sourceforge.jp Mon Dec 25 14:55:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 14:55:51 +0900 Subject: [Tomoe-cvs 2059] CVS update: tomoe Message-ID: <20061225055551.0DCC52AC0E7@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.495 tomoe/ChangeLog:1.496 --- tomoe/ChangeLog:1.495 Mon Dec 25 12:43:34 2006 +++ tomoe/ChangeLog Mon Dec 25 14:55:50 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * db/search.rb: removed needless file. + * lib/glib-compat-file-utilities.h: used g_strdup () for g_filename_display_name() alternate. From kous users.sourceforge.jp Mon Dec 25 14:55:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 14:55:51 +0900 Subject: [Tomoe-cvs 2060] CVS update: tomoe/db Message-ID: <20061225055551.3C0062AC17E@users.sourceforge.jp> Index: tomoe/db/search.rb diff -u tomoe/db/search.rb:1.3 tomoe/db/search.rb:removed --- tomoe/db/search.rb:1.3 Mon Dec 11 13:39:42 2006 +++ tomoe/db/search.rb Mon Dec 25 14:55:51 2006 @@ -1,65 +0,0 @@ -#!/usr/bin/env ruby - -top = File.expand_path(File.join(File.dirname(__FILE__), "..")) -base = File.join(top, File.dirname(__FILE__)) -require File.join(base, "init") - -ActiveRecord::Base.logger.level = Logger::INFO - -$LOAD_PATH.unshift(File.join(top, "test")) -$LOAD_PATH.unshift(File.join(top, "ext", "ruby", ".libs")) -$LOAD_PATH.unshift(File.join(top, "ext", "ruby")) - -require 'tomoe-spec-utils' - -def utf8_to_ucs4(utf8) - TomoeSpecUtils::Unicode.utf8_to_ucs4(utf8) -end - -def ucs4_to_utf8(ucs4) - TomoeSpecUtils::Unicode.ucs4_to_utf8(ucs4) -end - -$LOAD_PATH.unshift(File.join(base, "lib")) - -query = Tomoe::Query.new -query.min_n_strokes = 0 -query.max_n_strokes = 10 - -dict = Tomoe::Dict.new("unihan", {}) -cands = dict.search(Tomoe::Query.new).find_all do |cand| - n_strokes = cand.char.n_strokes - 0 <= n_strokes and - query.min_n_strokes <= n_strokes and - n_strokes <= query.max_n_strokes -end - -puts cands.size -cands.each do |cand| - char = cand.char - unless char.readings.empty? - p [utf8_to_ucs4(char.utf8), char.readings.collect {|x| [x.type, x.reading]}] - end - p [utf8_to_ucs4(char.utf8), char.radicals] unless char.radicals.empty? - p [utf8_to_ucs4(char.utf8), char.collect] unless char.collect.empty? -end - -ActiveRecord::Base.logger.level = Logger::DEBUG -chars = Char.find(:all, - :conditions => ["? <= n_strokes AND n_strokes <= ?", - query.min_n_strokes, - query.max_n_strokes], - :include => [:readings, :radicals]) -ActiveRecord::Base.logger.level = Logger::INFO -puts chars.size - -puts Reading.count -puts Radical.count - -chars.each do |char| - p [utf8_to_ucs4(char.utf8), char.readings] unless char.readings.empty? - p [utf8_to_ucs4(char.utf8), char.radicals] unless char.radicals.empty? - unless char.meta_data.empty? - p [utf8_to_ucs4(char.utf8), char.meta_data.collect {|x| [x.key, x.value]}] - end -end From kous users.sourceforge.jp Mon Dec 25 15:02:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:02:51 +0900 Subject: [Tomoe-cvs 2061] CVS update: tomoe Message-ID: <20061225060251.1C4F72AC00F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.496 tomoe/ChangeLog:1.497 --- tomoe/ChangeLog:1.496 Mon Dec 25 14:55:50 2006 +++ tomoe/ChangeLog Mon Dec 25 15:02:50 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * configure.in, Makefile.am, db/: added db/ to distributed files. + * db/search.rb: removed needless file. * lib/glib-compat-file-utilities.h: used g_strdup () for Index: tomoe/configure.in diff -u tomoe/configure.in:1.53 tomoe/configure.in:1.54 --- tomoe/configure.in:1.53 Mon Dec 25 11:55:32 2006 +++ tomoe/configure.in Mon Dec 25 15:02:50 2006 @@ -402,6 +402,9 @@ data/Makefile ext/Makefile ext/ruby/Makefile +db/Makefile +db/lib/Makefile +db/migrate/Makefile test/Makefile test/data/Makefile benchmark/Makefile Index: tomoe/Makefile.am diff -u tomoe/Makefile.am:1.20 tomoe/Makefile.am:1.21 --- tomoe/Makefile.am:1.20 Mon Dec 25 11:17:52 2006 +++ tomoe/Makefile.am Mon Dec 25 15:02:50 2006 @@ -18,7 +18,7 @@ ## Free Software Foundation, Inc., 59 Temple Place, Suite 330, ## Boston, MA 02111-1307 USA -SUBDIRS = lib ext module data test benchmark doc spec +SUBDIRS = lib ext module data db test benchmark doc spec EXTRA_DIST = autogen.sh tomoe.pc From kous users.sourceforge.jp Mon Dec 25 15:02:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:02:51 +0900 Subject: [Tomoe-cvs 2062] CVS update: tomoe/db/lib Message-ID: <20061225060251.6A3DE2AC00F@users.sourceforge.jp> Index: tomoe/db/lib/.cvsignore diff -u /dev/null tomoe/db/lib/.cvsignore:1.1 --- /dev/null Mon Dec 25 15:02:51 2006 +++ tomoe/db/lib/.cvsignore Mon Dec 25 15:02:51 2006 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +config.yml Index: tomoe/db/lib/Makefile.am diff -u /dev/null tomoe/db/lib/Makefile.am:1.1 --- /dev/null Mon Dec 25 15:02:51 2006 +++ tomoe/db/lib/Makefile.am Mon Dec 25 15:02:51 2006 @@ -0,0 +1,3 @@ +# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- + +EXTRA_DIST = char.rb radical.rb reading.rb meta_datum.rb From kous users.sourceforge.jp Mon Dec 25 15:02:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:02:51 +0900 Subject: [Tomoe-cvs 2063] CVS update: tomoe/db Message-ID: <20061225060251.3E9ED2AC0E7@users.sourceforge.jp> Index: tomoe/db/Makefile.am diff -u /dev/null tomoe/db/Makefile.am:1.1 --- /dev/null Mon Dec 25 15:02:51 2006 +++ tomoe/db/Makefile.am Mon Dec 25 15:02:51 2006 @@ -0,0 +1,5 @@ +# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- + +SUBDIRS = lib migrate + +EXTRA_DIST = config.yml.example init.rb migrate.rb xml2db.rb From kous users.sourceforge.jp Mon Dec 25 15:02:51 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:02:51 +0900 Subject: [Tomoe-cvs 2064] CVS update: tomoe/db/migrate Message-ID: <20061225060251.96FD92AC171@users.sourceforge.jp> Index: tomoe/db/migrate/.cvsignore diff -u /dev/null tomoe/db/migrate/.cvsignore:1.1 --- /dev/null Mon Dec 25 15:02:51 2006 +++ tomoe/db/migrate/.cvsignore Mon Dec 25 15:02:51 2006 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +config.yml Index: tomoe/db/migrate/Makefile.am diff -u /dev/null tomoe/db/migrate/Makefile.am:1.1 --- /dev/null Mon Dec 25 15:02:51 2006 +++ tomoe/db/migrate/Makefile.am Mon Dec 25 15:02:51 2006 @@ -0,0 +1,7 @@ +# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- + +EXTRA_DIST = \ + 001_create_chars.rb \ + 002_create_readings.rb \ + 003_create_radicals.rb \ + 004_create_meta_data.rb From kous users.sourceforge.jp Mon Dec 25 15:05:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:05:29 +0900 Subject: [Tomoe-cvs 2065] CVS update: tomoe Message-ID: <20061225060529.57A012AC00F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.497 tomoe/ChangeLog:1.498 --- tomoe/ChangeLog:1.497 Mon Dec 25 15:02:50 2006 +++ tomoe/ChangeLog Mon Dec 25 15:05:29 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * test/Makefile.am (EXTRA_DIST): added a missing file. + * configure.in, Makefile.am, db/: added db/ to distributed files. * db/search.rb: removed needless file. From kous users.sourceforge.jp Mon Dec 25 15:05:29 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:05:29 +0900 Subject: [Tomoe-cvs 2066] CVS update: tomoe/test Message-ID: <20061225060529.82FC12AC154@users.sourceforge.jp> Index: tomoe/test/Makefile.am diff -u tomoe/test/Makefile.am:1.18 tomoe/test/Makefile.am:1.19 --- tomoe/test/Makefile.am:1.18 Mon Dec 18 10:02:07 2006 +++ tomoe/test/Makefile.am Mon Dec 25 15:05:29 2006 @@ -22,13 +22,14 @@ SUBDIRS = data -EXTRA_DIST = \ - run-spec.rb \ - run-test.sh \ - tomoe-spec-utils.rb \ - char_spec.rb \ - context_spec.rb \ - dict_spec.rb \ +EXTRA_DIST = \ + run-spec.rb \ + run-specs.rb \ + run-test.sh \ + tomoe-spec-utils.rb \ + char_spec.rb \ + context_spec.rb \ + dict_spec.rb \ writing_spec.rb dict_modules = xml From kous users.sourceforge.jp Mon Dec 25 15:05:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:05:58 +0900 Subject: [Tomoe-cvs 2067] CVS update: tomoe/test Message-ID: <20061225060558.BC1EE2AC163@users.sourceforge.jp> Index: tomoe/test/Makefile.am diff -u tomoe/test/Makefile.am:1.19 tomoe/test/Makefile.am:1.20 --- tomoe/test/Makefile.am:1.19 Mon Dec 25 15:05:29 2006 +++ tomoe/test/Makefile.am Mon Dec 25 15:05:58 2006 @@ -24,7 +24,7 @@ EXTRA_DIST = \ run-spec.rb \ - run-specs.rb \ + run-specs.sh \ run-test.sh \ tomoe-spec-utils.rb \ char_spec.rb \ From kous users.sourceforge.jp Mon Dec 25 15:09:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:09:17 +0900 Subject: [Tomoe-cvs 2068] CVS update: tomoe Message-ID: <20061225060917.235642AC00F@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.498 tomoe/ChangeLog:1.499 --- tomoe/ChangeLog:1.498 Mon Dec 25 15:05:29 2006 +++ tomoe/ChangeLog Mon Dec 25 15:09:16 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * configure.in, Makefile.am, utils/Makefile.am: added utils/. + * test/Makefile.am (EXTRA_DIST): added a missing file. * configure.in, Makefile.am, db/: added db/ to distributed files. Index: tomoe/configure.in diff -u tomoe/configure.in:1.54 tomoe/configure.in:1.55 --- tomoe/configure.in:1.54 Mon Dec 25 15:02:50 2006 +++ tomoe/configure.in Mon Dec 25 15:09:16 2006 @@ -405,6 +405,7 @@ db/Makefile db/lib/Makefile db/migrate/Makefile +utils/Makefile test/Makefile test/data/Makefile benchmark/Makefile Index: tomoe/Makefile.am diff -u tomoe/Makefile.am:1.21 tomoe/Makefile.am:1.22 --- tomoe/Makefile.am:1.21 Mon Dec 25 15:02:50 2006 +++ tomoe/Makefile.am Mon Dec 25 15:09:16 2006 @@ -18,7 +18,7 @@ ## Free Software Foundation, Inc., 59 Temple Place, Suite 330, ## Boston, MA 02111-1307 USA -SUBDIRS = lib ext module data db test benchmark doc spec +SUBDIRS = lib ext module data db utils test benchmark doc spec EXTRA_DIST = autogen.sh tomoe.pc From kous users.sourceforge.jp Mon Dec 25 15:09:17 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:09:17 +0900 Subject: [Tomoe-cvs 2069] CVS update: tomoe/utils Message-ID: <20061225060917.474E92AC163@users.sourceforge.jp> Index: tomoe/utils/Makefile.am diff -u tomoe/utils/Makefile.am:1.2 tomoe/utils/Makefile.am:1.3 --- tomoe/utils/Makefile.am:1.2 Mon Jan 16 16:32:35 2006 +++ tomoe/utils/Makefile.am Mon Dec 25 15:09:17 2006 @@ -20,6 +20,5 @@ CLEANFILES = *~ *.bak -EXTRA_DIST = \ - dictionary.rb \ - gtk2dictview.rb +EXTRA_DIST = \ + xml2est.rb From kous users.sourceforge.jp Mon Dec 25 15:47:27 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:47:27 +0900 Subject: [Tomoe-cvs 2070] CVS update: tomoe Message-ID: <20061225064727.6F3082AC154@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.499 tomoe/ChangeLog:1.500 --- tomoe/ChangeLog:1.499 Mon Dec 25 15:09:16 2006 +++ tomoe/ChangeLog Mon Dec 25 15:47:27 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * spec/: updated. + * configure.in, Makefile.am, utils/Makefile.am: added utils/. * test/Makefile.am (EXTRA_DIST): added a missing file. From kous users.sourceforge.jp Mon Dec 25 15:47:27 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:47:27 +0900 Subject: [Tomoe-cvs 2071] CVS update: tomoe/spec/miracle-linux Message-ID: <20061225064727.9ADE52AC17E@users.sourceforge.jp> Index: tomoe/spec/miracle-linux/tomoe.spec.in diff -u tomoe/spec/miracle-linux/tomoe.spec.in:1.1 tomoe/spec/miracle-linux/tomoe.spec.in:1.2 --- tomoe/spec/miracle-linux/tomoe.spec.in:1.1 Mon Dec 25 11:17:52 2006 +++ tomoe/spec/miracle-linux/tomoe.spec.in Mon Dec 25 15:47:27 2006 @@ -1,8 +1,97 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.1 2006/12/25 02:17:52 kous Exp $ +# $Id: tomoe.spec.in,v 1.2 2006/12/25 06:47:27 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under # the same license as package itself. # + +Name: tomoe +Version: @VERSION@ +Release: 0 +Serial: 2006122501 + +Summary: Tegaki Online MOji-ninshiki Engine +Summary(ja_JP.utf8): ??????????????Tomoe +URL: http://tomoe.sourceforge.jp/ +Source0: %{name}-%{version}.tar.gz +License: LGPL +Group: System Environment/Libraries +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +Requires: /sbin/ldconfig +Requires: mysql +Requires: glib2 +BuildRequires: pkgconfig +BuildRequires: glib2-devel +BuildRequires: mysql-devel + +%description +Tomoe provides a handwriting recognition engine and its user +interface on open source desktop environment. + + +%description -l ja_JP.utf8 +Tomoe????????????????????????????????? +??????????????+ +%package devel +Summary: Tomoe developmental libraries and header files +Summary(ja_JP.utf8): Tomoe?????????????????????? +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: glib2-devel +Requires: mysql-devel + +%description devel +Developmental libraries and header files required for developing or +compiling software which links to the Tomoe library, which is an open +source handwriting recognition engine. + +%description devel -l ja_JP.utf8 +Tomoe????????????????????????????????????????????????? +??????????????Tomoe????????????????????????????+ +%prep +%setup -q + +%build +%configure --without-ruby --enable-mysql +make + +%install +rm -rf $RPM_BUILD_ROOT + +%makeinstall +rm $RPM_BUILD_ROOT%{_libdir}/*.la +rm $RPM_BUILD_ROOT%{_libdir}/*.a + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%files +%defattr(-,root,root,-) +#%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO +%doc AUTHORS ChangeLog COPYING NEWS TODO + +%{_libdir}/libtomoe*.so.* +%{_libdir}/tomoe/module/dict/* +%{_libdir}/tomoe/module/recognizer/* +%{_sysconfdir}/tomoe/* +%{_datadir}/tomoe/dict.dtd +%{_datadir}/tomoe/recognizer/* + +%files devel +%defattr(-,root,root,-) +%{_includedir}/* +%{_libdir}/libtomoe*.so +%{_libdir}/pkgconfig/* +%{_datadir}/gtk-doc/* + +%changelog +* Mon Dec 25 2006 Kouhei Sutou - 0.5.0-0 +- initial release. From kous users.sourceforge.jp Mon Dec 25 15:47:27 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:47:27 +0900 Subject: [Tomoe-cvs 2072] CVS update: tomoe/spec/turbo-linux Message-ID: <20061225064727.BD6782AC154@users.sourceforge.jp> Index: tomoe/spec/turbo-linux/tomoe.spec.in diff -u tomoe/spec/turbo-linux/tomoe.spec.in:1.1 tomoe/spec/turbo-linux/tomoe.spec.in:1.2 --- tomoe/spec/turbo-linux/tomoe.spec.in:1.1 Mon Dec 25 11:17:53 2006 +++ tomoe/spec/turbo-linux/tomoe.spec.in Mon Dec 25 15:47:27 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.1 2006/12/25 02:17:53 kous Exp $ +# $Id: tomoe.spec.in,v 1.2 2006/12/25 06:47:27 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -21,6 +21,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root Requires: /sbin/ldconfig +#Requires: glib2 Requires: mysql-client BuildRequires: pkgconfig BuildRequires: glib2-devel From kous users.sourceforge.jp Mon Dec 25 15:53:47 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:53:47 +0900 Subject: [Tomoe-cvs 2073] CVS update: tomoe Message-ID: <20061225065347.E14352AC171@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.500 tomoe/ChangeLog:1.501 --- tomoe/ChangeLog:1.500 Mon Dec 25 15:47:27 2006 +++ tomoe/ChangeLog Mon Dec 25 15:53:47 2006 @@ -1,5 +1,9 @@ 2006-12-25 Kouhei Sutou + * configure.in, Makefile.am, utils/, data/: + - moved xml2est.rb to data/ from utils/. + - removed utils/. + * spec/: updated. * configure.in, Makefile.am, utils/Makefile.am: added utils/. Index: tomoe/configure.in diff -u tomoe/configure.in:1.55 tomoe/configure.in:1.56 --- tomoe/configure.in:1.55 Mon Dec 25 15:09:16 2006 +++ tomoe/configure.in Mon Dec 25 15:53:47 2006 @@ -405,7 +405,6 @@ db/Makefile db/lib/Makefile db/migrate/Makefile -utils/Makefile test/Makefile test/data/Makefile benchmark/Makefile Index: tomoe/Makefile.am diff -u tomoe/Makefile.am:1.22 tomoe/Makefile.am:1.23 --- tomoe/Makefile.am:1.22 Mon Dec 25 15:09:16 2006 +++ tomoe/Makefile.am Mon Dec 25 15:53:47 2006 @@ -18,7 +18,7 @@ ## Free Software Foundation, Inc., 59 Temple Place, Suite 330, ## Boston, MA 02111-1307 USA -SUBDIRS = lib ext module data db utils test benchmark doc spec +SUBDIRS = lib ext module data db test benchmark doc spec EXTRA_DIST = autogen.sh tomoe.pc From kous users.sourceforge.jp Mon Dec 25 15:53:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:53:48 +0900 Subject: [Tomoe-cvs 2074] CVS update: tomoe/utils Message-ID: <20061225065348.3AEDE2AC171@users.sourceforge.jp> Index: tomoe/utils/.cvsignore diff -u tomoe/utils/.cvsignore:1.1 tomoe/utils/.cvsignore:removed --- tomoe/utils/.cvsignore:1.1 Wed Nov 2 16:28:43 2005 +++ tomoe/utils/.cvsignore Mon Dec 25 15:53:48 2006 @@ -1,7 +0,0 @@ -Makefile -Makefile.in -*.bak -*~ -*.log -*.rej -*.orig Index: tomoe/utils/Makefile.am diff -u tomoe/utils/Makefile.am:1.3 tomoe/utils/Makefile.am:removed --- tomoe/utils/Makefile.am:1.3 Mon Dec 25 15:09:17 2006 +++ tomoe/utils/Makefile.am Mon Dec 25 15:53:48 2006 @@ -1,24 +0,0 @@ -# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- - -## Makefile.am -- Process this file with automake to produce Makefile.in -## Copyright (C) 2005 Takuro Ashie -## -## This library is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2 of the License, or (at your option) any later version. -## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with this program; if not, write to the -## Free Software Foundation, Inc., 59 Temple Place, Suite 330, -## Boston, MA 02111-1307 USA - -CLEANFILES = *~ *.bak - -EXTRA_DIST = \ - xml2est.rb Index: tomoe/utils/xml2est.rb diff -u tomoe/utils/xml2est.rb:1.4 tomoe/utils/xml2est.rb:removed --- tomoe/utils/xml2est.rb:1.4 Thu Dec 21 15:22:58 2006 +++ tomoe/utils/xml2est.rb Mon Dec 25 15:53:48 2006 @@ -1,28 +0,0 @@ -#!/usr/bin/env ruby - -benchmark_dir = File.expand_path(File.dirname(__FILE__)) -top_dir = File.expand_path(File.join(benchmark_dir, "..")) -test_dir = File.join(top_dir, "test") -$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby", ".libs")) -$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby")) -$LOAD_PATH.unshift(File.join(test_dir)) - -require "tomoe-spec-utils" - -dictionary = TomoeSpecUtils::Path.dictionary -print "converting #{dictionary}..." -est_db = dictionary.sub(/\.xml$/, "") -xml_dict = Tomoe::DictXML.new("filename" => dictionary, - "editable" => false) -est_dict = Tomoe::DictEst.new("database" => est_db, - "editable" => true) -xml_dict.search(Tomoe::Query.new).each_with_index do |cand, i| - est_dict.register(cand.char) - if (i % 1000).zero? and !i.zero? - print "#{i}." - $stdout.flush - end -end -puts "done." - -puts "converted characters: #{est_dict.search(Tomoe::Query.new).size}" From kous users.sourceforge.jp Mon Dec 25 15:53:48 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 15:53:48 +0900 Subject: [Tomoe-cvs 2075] CVS update: tomoe/data Message-ID: <20061225065348.636F12AC17E@users.sourceforge.jp> Index: tomoe/data/Makefile.am diff -u tomoe/data/Makefile.am:1.23 tomoe/data/Makefile.am:1.24 --- tomoe/data/Makefile.am:1.23 Mon Dec 18 15:26:41 2006 +++ tomoe/data/Makefile.am Mon Dec 25 15:53:48 2006 @@ -20,7 +20,7 @@ CLEANFILES = *~ *.bak *.valid -pkgdata_DATA = dict.dtd +pkgdata_DATA = dict.dtd xml2est.rb dict_data_DATA = recognizer_data_DATA = handwriting.xml conf_DATA = config Index: tomoe/data/xml2est.rb diff -u /dev/null tomoe/data/xml2est.rb:1.1 --- /dev/null Mon Dec 25 15:53:48 2006 +++ tomoe/data/xml2est.rb Mon Dec 25 15:53:48 2006 @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby + +benchmark_dir = File.expand_path(File.dirname(__FILE__)) +top_dir = File.expand_path(File.join(benchmark_dir, "..")) +test_dir = File.join(top_dir, "test") +$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby", ".libs")) +$LOAD_PATH.unshift(File.join(top_dir, "ext", "ruby")) +$LOAD_PATH.unshift(File.join(test_dir)) + +require "tomoe-spec-utils" + +dictionary = TomoeSpecUtils::Path.dictionary +print "converting #{dictionary}..." +est_db = dictionary.sub(/\.xml$/, "") +xml_dict = Tomoe::DictXML.new("filename" => dictionary, + "editable" => false) +est_dict = Tomoe::DictEst.new("database" => est_db, + "editable" => true) +xml_dict.search(Tomoe::Query.new).each_with_index do |cand, i| + est_dict.register(cand.char) + if (i % 1000).zero? and !i.zero? + print "#{i}." + $stdout.flush + end +end +puts "done." + +puts "converted characters: #{est_dict.search(Tomoe::Query.new).size}" From kous users.sourceforge.jp Mon Dec 25 16:46:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 16:46:42 +0900 Subject: [Tomoe-cvs 2076] CVS update: tomoe Message-ID: <20061225074642.97FBA2AC0CD@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.501 tomoe/ChangeLog:1.502 --- tomoe/ChangeLog:1.501 Mon Dec 25 15:53:47 2006 +++ tomoe/ChangeLog Mon Dec 25 16:46:42 2006 @@ -1,5 +1,7 @@ 2006-12-25 Kouhei Sutou + * spec/: updated. + * configure.in, Makefile.am, utils/, data/: - moved xml2est.rb to data/ from utils/. - removed utils/. From kous users.sourceforge.jp Mon Dec 25 16:46:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 16:46:42 +0900 Subject: [Tomoe-cvs 2077] CVS update: tomoe/spec/miracle-linux Message-ID: <20061225074642.C2FAE2AC105@users.sourceforge.jp> Index: tomoe/spec/miracle-linux/tomoe.spec.in diff -u tomoe/spec/miracle-linux/tomoe.spec.in:1.2 tomoe/spec/miracle-linux/tomoe.spec.in:1.3 --- tomoe/spec/miracle-linux/tomoe.spec.in:1.2 Mon Dec 25 15:47:27 2006 +++ tomoe/spec/miracle-linux/tomoe.spec.in Mon Dec 25 16:46:42 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.2 2006/12/25 06:47:27 kous Exp $ +# $Id: tomoe.spec.in,v 1.3 2006/12/25 07:46:42 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -21,8 +21,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root Requires: /sbin/ldconfig -Requires: mysql Requires: glib2 +Requires: mysql BuildRequires: pkgconfig BuildRequires: glib2-devel BuildRequires: mysql-devel @@ -79,11 +79,9 @@ %doc AUTHORS ChangeLog COPYING NEWS TODO %{_libdir}/libtomoe*.so.* -%{_libdir}/tomoe/module/dict/* -%{_libdir}/tomoe/module/recognizer/* +%{_libdir}/tomoe/* %{_sysconfdir}/tomoe/* -%{_datadir}/tomoe/dict.dtd -%{_datadir}/tomoe/recognizer/* +%{_datadir}/tomoe/* %files devel %defattr(-,root,root,-) From kous users.sourceforge.jp Mon Dec 25 16:46:42 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Mon, 25 Dec 2006 16:46:42 +0900 Subject: [Tomoe-cvs 2078] CVS update: tomoe/spec/turbo-linux Message-ID: <20061225074642.E8C782AC0CD@users.sourceforge.jp> Index: tomoe/spec/turbo-linux/tomoe.spec.in diff -u tomoe/spec/turbo-linux/tomoe.spec.in:1.2 tomoe/spec/turbo-linux/tomoe.spec.in:1.3 --- tomoe/spec/turbo-linux/tomoe.spec.in:1.2 Mon Dec 25 15:47:27 2006 +++ tomoe/spec/turbo-linux/tomoe.spec.in Mon Dec 25 16:46:42 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.2 2006/12/25 06:47:27 kous Exp $ +# $Id: tomoe.spec.in,v 1.3 2006/12/25 07:46:42 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -9,8 +9,8 @@ Name: tomoe Version: @VERSION@ -Release: 0 -Serial: 2006121801 +Release: 1 +Serial: 2006122501 Summary: Tegaki Online MOji-ninshiki Engine Summary(ja_JP.utf8): ??????????????Tomoe @@ -79,11 +79,9 @@ %doc AUTHORS ChangeLog COPYING NEWS TODO %{_libdir}/libtomoe*.so.* -%{_libdir}/tomoe/module/dict/* -%{_libdir}/tomoe/module/recognizer/* +%{_libdir}/tomoe/* %{_sysconfdir}/tomoe/* -%{_datadir}/tomoe/dict.dtd -%{_datadir}/tomoe/recognizer/* +%{_datadir}/tomoe/* %files devel %defattr(-,root,root,-) @@ -93,5 +91,8 @@ %{_datadir}/gtk-doc/* %changelog +* Mon Dec 25 2006 Kouhei Sutou - 0.5.0-1 +- follow the current source. + * Mon Dec 18 2006 Kouhei Sutou - 0.5.0-0 - initial release. From kous users.sourceforge.jp Tue Dec 26 11:00:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:00:49 +0900 Subject: [Tomoe-cvs 2079] CVS update: tomoe Message-ID: <20061226020049.AAA382AC02D@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.502 tomoe/ChangeLog:1.503 --- tomoe/ChangeLog:1.502 Mon Dec 25 16:46:42 2006 +++ tomoe/ChangeLog Tue Dec 26 11:00:49 2006 @@ -1,3 +1,7 @@ +2006-12-26 Kouhei Sutou + + * tomoe.pc.in (Name): Tomoe not TOMOE. + 2006-12-25 Kouhei Sutou * spec/: updated. Index: tomoe/tomoe.pc.in diff -u tomoe/tomoe.pc.in:1.2 tomoe/tomoe.pc.in:1.3 --- tomoe/tomoe.pc.in:1.2 Wed Nov 29 13:17:54 2006 +++ tomoe/tomoe.pc.in Tue Dec 26 11:00:49 2006 @@ -3,7 +3,7 @@ libdir=@libdir@ includedir=@includedir@ -Name: TOMOE +Name: Tomoe Description: Tegaki Online MOji-ninshiki Engine Version: @VERSION@ Requires: glib-2.0 >= 2.4 From kous users.sourceforge.jp Tue Dec 26 11:09:31 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:09:31 +0900 Subject: [Tomoe-cvs 2080] CVS update: tomoe Message-ID: <20061226020931.4D0222AC013@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.503 tomoe/ChangeLog:1.504 --- tomoe/ChangeLog:1.503 Tue Dec 26 11:00:49 2006 +++ tomoe/ChangeLog Tue Dec 26 11:09:31 2006 @@ -1,6 +1,7 @@ 2006-12-26 Kouhei Sutou - * tomoe.pc.in (Name): Tomoe not TOMOE. + * tomoe.pc.in (Name), configure.in, data/handwriting.xml, + doc/reference/tomoe-docs.sgml: Tomoe is not TOMOE. 2006-12-25 Kouhei Sutou Index: tomoe/configure.in diff -u tomoe/configure.in:1.56 tomoe/configure.in:1.57 --- tomoe/configure.in:1.56 Mon Dec 25 15:53:47 2006 +++ tomoe/configure.in Tue Dec 26 11:09:31 2006 @@ -377,7 +377,7 @@ dnl ************************************************************** -dnl Configure for TOMOE. +dnl Configure for Tomoe. dnl ************************************************************** TOMOE_CFLAGS="$TOMOE_CFLAGS \$(GLIB_CFLAGS)" From kous users.sourceforge.jp Tue Dec 26 11:09:31 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:09:31 +0900 Subject: [Tomoe-cvs 2081] CVS update: tomoe/data Message-ID: <20061226020931.E234E2AC013@users.sourceforge.jp> Index: tomoe/data/handwriting.xml diff -u tomoe/data/handwriting.xml:1.2 tomoe/data/handwriting.xml:1.3 --- tomoe/data/handwriting.xml:1.2 Mon Dec 18 15:26:41 2006 +++ tomoe/data/handwriting.xml Tue Dec 26 11:09:31 2006 @@ -1,6 +1,6 @@ - + From kous users.sourceforge.jp Tue Dec 26 11:09:32 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:09:32 +0900 Subject: [Tomoe-cvs 2082] CVS update: tomoe/doc/reference Message-ID: <20061226020932.1B2722AC041@users.sourceforge.jp> Index: tomoe/doc/reference/tomoe-docs.sgml diff -u tomoe/doc/reference/tomoe-docs.sgml:1.3 tomoe/doc/reference/tomoe-docs.sgml:1.4 --- tomoe/doc/reference/tomoe-docs.sgml:1.3 Fri Dec 1 11:05:03 2006 +++ tomoe/doc/reference/tomoe-docs.sgml Tue Dec 26 11:09:31 2006 @@ -19,8 +19,8 @@ ]> - TOMOE Reference Manual - for TOMOE &version; + Tomoe Reference Manual + for Tomoe &version; From kous users.sourceforge.jp Tue Dec 26 11:16:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:16:58 +0900 Subject: [Tomoe-cvs 2083] CVS update: libtomoe-gtk Message-ID: <20061226021658.C3B652AC013@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.257 libtomoe-gtk/ChangeLog:1.258 --- libtomoe-gtk/ChangeLog:1.257 Fri Dec 22 13:35:20 2006 +++ libtomoe-gtk/ChangeLog Tue Dec 26 11:16:58 2006 @@ -1,3 +1,7 @@ +2006-12-26 Kouhei Sutou + + * src/tomoe-window.c (tomoe_window_init): removed needless setlocale(). + 2006-12-22 Takuro Ashie * src/tomoe-reading-search.c: Temporary unset the tree model from tree From kous users.sourceforge.jp Tue Dec 26 11:16:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:16:58 +0900 Subject: [Tomoe-cvs 2084] CVS update: libtomoe-gtk/src Message-ID: <20061226021658.EFA052AC050@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.42 libtomoe-gtk/src/tomoe-window.c:1.43 --- libtomoe-gtk/src/tomoe-window.c:1.42 Thu Dec 7 12:49:19 2006 +++ libtomoe-gtk/src/tomoe-window.c Tue Dec 26 11:16:58 2006 @@ -145,7 +145,6 @@ TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); #ifdef ENABLE_NLS - setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LIBTOMOE_GTK_LOCALEDIR); textdomain (GETTEXT_PACKAGE); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); From kous users.sourceforge.jp Tue Dec 26 11:36:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:36:33 +0900 Subject: [Tomoe-cvs 2085] CVS update: tomoe Message-ID: <20061226023633.792722AC121@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.504 tomoe/ChangeLog:1.505 --- tomoe/ChangeLog:1.504 Tue Dec 26 11:09:31 2006 +++ tomoe/ChangeLog Tue Dec 26 11:36:33 2006 @@ -1,5 +1,7 @@ 2006-12-26 Kouhei Sutou + * module/dict/Makefile.am: cleanup build dependencies. + * tomoe.pc.in (Name), configure.in, data/handwriting.xml, doc/reference/tomoe-docs.sgml: Tomoe is not TOMOE. From kous users.sourceforge.jp Tue Dec 26 11:36:33 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:36:33 +0900 Subject: [Tomoe-cvs 2086] CVS update: tomoe/module/dict Message-ID: <20061226023633.A76492AC1B7@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.30 tomoe/module/dict/Makefile.am:1.31 --- tomoe/module/dict/Makefile.am:1.30 Mon Dec 18 10:40:53 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 26 11:36:33 2006 @@ -65,10 +65,12 @@ unihan_built_sources = tomoe-unihan-data.h -CLEANFILES += Unihan.stamp Unihan.txt Unihan.txt.cache +CLEANFILES += Unihan.txt.cache +MAINTAINERCLEANFILES = Unihan.stamp Unihan.txt +DISTCLEANFILES = Unihan.zip BUILT_SOURCES = $(unihan_built_sources) -EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) Unihan.stamp +EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ @@ -90,8 +92,11 @@ Unihan_URL = ftp://ftp.unicode.org/Public/UNIDATA/Unihan.zip Unihan.stamp: - $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" > Unihan.zip || exit 1; - $(UNZIP) -o Unihan.zip || exit 1; + if test ! -f Unihan.txt; then \ + $(RUBY) -r open-uri -e "print open('$(Unihan_URL)').read" \ + > Unihan.zip || exit 1; \ + $(UNZIP) -o Unihan.zip || exit 1; \ + fi touch $@ endif From kous users.sourceforge.jp Tue Dec 26 11:50:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:50:49 +0900 Subject: [Tomoe-cvs 2087] CVS update: tomoe Message-ID: <20061226025049.2012B2AC013@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.505 tomoe/ChangeLog:1.506 --- tomoe/ChangeLog:1.505 Tue Dec 26 11:36:33 2006 +++ tomoe/ChangeLog Tue Dec 26 11:50:48 2006 @@ -1,5 +1,8 @@ 2006-12-26 Kouhei Sutou + * lib/Makefile.am, module/dict/Makefile.am, + module/recognizer/Makefile.am: cleanup G_LOG_DOMAIN. + * module/dict/Makefile.am: cleanup build dependencies. * tomoe.pc.in (Name), configure.in, data/handwriting.xml, From kous users.sourceforge.jp Tue Dec 26 11:50:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:50:49 +0900 Subject: [Tomoe-cvs 2088] CVS update: tomoe/lib Message-ID: <20061226025049.4D0352AC1CB@users.sourceforge.jp> Index: tomoe/lib/Makefile.am diff -u tomoe/lib/Makefile.am:1.49 tomoe/lib/Makefile.am:1.50 --- tomoe/lib/Makefile.am:1.49 Mon Dec 25 12:32:50 2006 +++ tomoe/lib/Makefile.am Tue Dec 26 11:50:49 2006 @@ -20,7 +20,7 @@ CLEANFILES = *~ *.bak -AM_CPPFLAGS = -DG_LOG_DOMAIN=\"TOMOE\" +AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe\" INCLUDES = $(TOMOE_CFLAGS) tomoe_public_h_sources = \ From kous users.sourceforge.jp Tue Dec 26 11:50:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:50:49 +0900 Subject: [Tomoe-cvs 2089] CVS update: tomoe/module/dict Message-ID: <20061226025049.773312AC013@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.31 tomoe/module/dict/Makefile.am:1.32 --- tomoe/module/dict/Makefile.am:1.31 Tue Dec 26 11:36:33 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 26 11:50:49 2006 @@ -21,7 +21,6 @@ CLEANFILES = *~ *.bak AM_CPPFLAGS = \ - -DG_LOG_DOMAIN=\"TOMOE-DICT\" \ -DRUBY_EXTDIR=\""$(ruby_extdir)"\" \ -DRUBY_LIBDIR=\""$(ruby_libdir)"\" @@ -44,11 +43,13 @@ dict_module_LTLIBRARIES = libxml.la +libxml_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:XML\" $(AM_CPPFLAGS) libxml_la_SOURCES = tomoe-dict-xml.c $(ptr_array_based_dict_sources) if WITH_EST dict_module_LTLIBRARIES += libest.la +libest_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:Est\" $(AM_CPPFLAGS) libest_la_SOURCES = tomoe-dict-est.c libest_la_LIBADD = $(EST_LIBS) endif @@ -56,6 +57,7 @@ if ENABLE_DICT_RUBY dict_module_LTLIBRARIES += libruby.la +libruby_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:Ruby\" $(AM_CPPFLAGS) libruby_la_SOURCES = tomoe-dict-ruby.c libruby_la_LIBADD = $(RUBY_LIBS) endif @@ -72,6 +74,7 @@ EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) +libunihan_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:Unihan\" $(AM_CPPFLAGS) libunihan_la_SOURCES = \ tomoe-dict-unihan.c \ tomoe-unihan.c \ @@ -103,6 +106,7 @@ if WITH_SVN dict_module_LTLIBRARIES += libsvn.la +libsvn_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:Svn\" $(AM_CPPFLAGS) libsvn_la_SOURCES = tomoe-dict-svn.c libsvn_la_LIBADD = $(SVN_LIBS) endif @@ -110,6 +114,7 @@ if WITH_MYSQL dict_module_LTLIBRARIES += libmysql.la +libmysql_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:MySQL\" $(AM_CPPFLAGS) libmysql_la_SOURCES = tomoe-dict-mysql.c libmysql_la_LIBADD = $(MYSQL_LIBS) endif From kous users.sourceforge.jp Tue Dec 26 11:50:49 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 11:50:49 +0900 Subject: [Tomoe-cvs 2090] CVS update: tomoe/module/recognizer Message-ID: <20061226025049.9A9C42AC1CB@users.sourceforge.jp> Index: tomoe/module/recognizer/Makefile.am diff -u tomoe/module/recognizer/Makefile.am:1.3 tomoe/module/recognizer/Makefile.am:1.4 --- tomoe/module/recognizer/Makefile.am:1.3 Tue Dec 5 14:51:42 2006 +++ tomoe/module/recognizer/Makefile.am Tue Dec 26 11:50:49 2006 @@ -20,11 +20,12 @@ CLEANFILES = *~ *.bak -AM_CPPFLAGS = -DG_LOG_DOMAIN=\"TOMOE-RECOGNIZER\" +AM_CPPFLAGS = INCLUDES = $(TOMOE_CFLAGS) recognizer_module_LTLIBRARIES = libsimple.la +libsimple_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Recognizer:Simple\" $(AM_CPPFLAGS) libsimple_la_SOURCES = \ tomoe-recognizer-simple.c \ tomoe-recognizer-simple-logic.c \ From kous users.sourceforge.jp Tue Dec 26 12:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 12:00:59 +0900 Subject: [Tomoe-cvs 2091] CVS update: tomoe/module/dict Message-ID: <20061226030059.CDD972AC121@users.sourceforge.jp> Index: tomoe/module/dict/Makefile.am diff -u tomoe/module/dict/Makefile.am:1.32 tomoe/module/dict/Makefile.am:1.33 --- tomoe/module/dict/Makefile.am:1.32 Tue Dec 26 11:50:49 2006 +++ tomoe/module/dict/Makefile.am Tue Dec 26 12:00:59 2006 @@ -72,7 +72,7 @@ DISTCLEANFILES = Unihan.zip BUILT_SOURCES = $(unihan_built_sources) -EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) +EXTRA_DIST = unihan-compiler.rb $(BUILT_SOURCES) Unihan.stamp libunihan_la_CPPFLAGS = -DG_LOG_DOMAIN=\"Tomoe/Dict:Unihan\" $(AM_CPPFLAGS) libunihan_la_SOURCES = \ From kous users.sourceforge.jp Tue Dec 26 12:00:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 12:00:59 +0900 Subject: [Tomoe-cvs 2092] CVS update: tomoe Message-ID: <20061226030059.002CE2AC1D7@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.506 tomoe/ChangeLog:1.507 --- tomoe/ChangeLog:1.506 Tue Dec 26 11:50:48 2006 +++ tomoe/ChangeLog Tue Dec 26 12:00:59 2006 @@ -1,5 +1,7 @@ 2006-12-26 Kouhei Sutou + * module/dict/Makefile.am (EXTRA_DIST): added missing Unihan.stamp. + * lib/Makefile.am, module/dict/Makefile.am, module/recognizer/Makefile.am: cleanup G_LOG_DOMAIN. From kous users.sourceforge.jp Tue Dec 26 12:03:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 12:03:58 +0900 Subject: [Tomoe-cvs 2093] CVS update: tomoe Message-ID: <20061226030358.2A26A2AC121@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.507 tomoe/ChangeLog:1.508 --- tomoe/ChangeLog:1.507 Tue Dec 26 12:00:59 2006 +++ tomoe/ChangeLog Tue Dec 26 12:03:58 2006 @@ -1,5 +1,8 @@ 2006-12-26 Kouhei Sutou + * module/dict/tomoe-dict-ruby.c (TOMOE_MODULE_IMPL_INIT): added + initialization check. + * module/dict/Makefile.am (EXTRA_DIST): added missing Unihan.stamp. * lib/Makefile.am, module/dict/Makefile.am, From kous users.sourceforge.jp Tue Dec 26 12:03:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 12:03:58 +0900 Subject: [Tomoe-cvs 2094] CVS update: tomoe/module/dict Message-ID: <20061226030358.560082AC1D7@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-ruby.c diff -u tomoe/module/dict/tomoe-dict-ruby.c:1.3 tomoe/module/dict/tomoe-dict-ruby.c:1.4 --- tomoe/module/dict/tomoe-dict-ruby.c:1.3 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/tomoe-dict-ruby.c Tue Dec 26 12:03:58 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ruby.c,v 1.3 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict-ruby.c,v 1.4 2006/12/26 03:03:58 kous Exp $ */ #include @@ -195,6 +195,7 @@ { GList *registered_types = NULL; static gchar *argv[] = {G_STRINGIFY (PACKAGE)}; + static gboolean initialized = FALSE; register_type (type_module); if (tomoe_type_dict_ruby) @@ -211,7 +212,10 @@ if (RARRAY(rb_load_path)->len == 0) { ruby_init_loadpath (); } + } + if (!initialized) { + initialized = TRUE; rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_EXTDIR)); rb_ary_unshift (rb_load_path, rb_str_new2 (RUBY_LIBDIR)); } From kous users.sourceforge.jp Tue Dec 26 12:05:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 12:05:59 +0900 Subject: [Tomoe-cvs 2095] CVS update: tomoe Message-ID: <20061226030559.778D02AC1D7@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.508 tomoe/ChangeLog:1.509 --- tomoe/ChangeLog:1.508 Tue Dec 26 12:03:58 2006 +++ tomoe/ChangeLog Tue Dec 26 12:05:59 2006 @@ -1,5 +1,7 @@ 2006-12-26 Kouhei Sutou + * lib/Makefile.am: cleanup stamp related built system. + * module/dict/tomoe-dict-ruby.c (TOMOE_MODULE_IMPL_INIT): added initialization check. From kous users.sourceforge.jp Tue Dec 26 12:05:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Tue, 26 Dec 2006 12:05:59 +0900 Subject: [Tomoe-cvs 2096] CVS update: tomoe/lib Message-ID: <20061226030559.A475A2AC342@users.sourceforge.jp> Index: tomoe/lib/Makefile.am diff -u tomoe/lib/Makefile.am:1.50 tomoe/lib/Makefile.am:1.51 --- tomoe/lib/Makefile.am:1.50 Tue Dec 26 11:50:49 2006 +++ tomoe/lib/Makefile.am Tue Dec 26 12:05:59 2006 @@ -48,7 +48,6 @@ $(enum_source_prefix).h BUILT_SOURCES = $(enum_sources) -CLEANFILES += $(enum_sources) pkginclude_HEADERS = \ $(tomoe_public_h_sources) \ @@ -89,13 +88,8 @@ libtomoe_la_LIBADD = $(TOMOE_LIBS) - -BUILT_SOURCES += \ - stamp-$(enum_source_prefix)-c \ - stamp-$(enum_source_prefix)-h - -CLEANFILES += \ - stamp-$(enum_source_prefix)-c \ +MAINTAINERCLEANFILES = \ + stamp-$(enum_source_prefix)-c \ stamp-$(enum_source_prefix)-h $(enum_source_prefix).c: stamp-$(enum_source_prefix)-c $(enum_source_prefix).h From kous users.sourceforge.jp Wed Dec 27 15:50:45 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:50:45 +0900 Subject: [Tomoe-cvs 2097] CVS update: tomoe Message-ID: <20061227065045.CE8522AC0FC@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.509 tomoe/ChangeLog:1.510 --- tomoe/ChangeLog:1.509 Tue Dec 26 12:05:59 2006 +++ tomoe/ChangeLog Wed Dec 27 15:50:45 2006 @@ -1,3 +1,11 @@ +2006-12-27 Kouhei Sutou + + * lib/tomoe-module-impl.h, lib/tomoe-module.c, + lib/tomoe-recognizer.[ch], lib/tomoe-dict.[ch], + module/dict/tomoe-dict-*.c, + module/recognizer/tomoe-recognizer-*.c: exported G_LOG_DOMAINS. + * ext/ruby/: set LOG_DOMAIN. + 2006-12-26 Kouhei Sutou * lib/Makefile.am: cleanup stamp related built system. From kous users.sourceforge.jp Wed Dec 27 15:50:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:50:46 +0900 Subject: [Tomoe-cvs 2098] CVS update: tomoe/lib Message-ID: <20061227065046.0E86C2AC0FD@users.sourceforge.jp> Index: tomoe/lib/tomoe-dict.c diff -u tomoe/lib/tomoe-dict.c:1.136 tomoe/lib/tomoe-dict.c:1.137 --- tomoe/lib/tomoe-dict.c:1.136 Mon Dec 18 10:02:06 2006 +++ tomoe/lib/tomoe-dict.c Wed Dec 27 15:50:45 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.c,v 1.136 2006/12/18 01:02:06 kous Exp $ + * $Id: tomoe-dict.c,v 1.137 2006/12/27 06:50:45 kous Exp $ */ #include "tomoe-dict.h" @@ -50,6 +50,12 @@ return tomoe_module_collect_registered_types (dicts); } +GList * +tomoe_dict_get_log_domains (void) +{ + return tomoe_module_collect_log_domains (dicts); +} + G_DEFINE_ABSTRACT_TYPE (TomoeDict, tomoe_dict, G_TYPE_OBJECT) static void Index: tomoe/lib/tomoe-dict.h diff -u tomoe/lib/tomoe-dict.h:1.57 tomoe/lib/tomoe-dict.h:1.58 --- tomoe/lib/tomoe-dict.h:1.57 Tue Dec 12 18:29:56 2006 +++ tomoe/lib/tomoe-dict.h Wed Dec 27 15:50:45 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict.h,v 1.57 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict.h,v 1.58 2006/12/27 06:50:45 kous Exp $ */ #ifndef __TOMOE_DICT_H__ @@ -72,6 +72,7 @@ void tomoe_dict_load (const gchar *base_dir); void tomoe_dict_unload (void); GList *tomoe_dict_get_registered_types (void); +GList *tomoe_dict_get_log_domains (void); TomoeDict *tomoe_dict_new (const gchar *name, const gchar *first_property, Index: tomoe/lib/tomoe-module-impl.h diff -u tomoe/lib/tomoe-module-impl.h:1.3 tomoe/lib/tomoe-module-impl.h:1.4 --- tomoe/lib/tomoe-module-impl.h:1.3 Tue Dec 12 18:29:56 2006 +++ tomoe/lib/tomoe-module-impl.h Wed Dec 27 15:50:45 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module-impl.h,v 1.3 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-module-impl.h,v 1.4 2006/12/27 06:50:45 kous Exp $ */ #ifndef __TOMOE_MODULE_IMPL_H__ @@ -33,16 +33,19 @@ typedef void (*TomoeModuleExitFunc) (void); typedef GObject *(*TomoeModuleInstantiateFunc) (const gchar *first_property, va_list var_args); +typedef gchar *(*TomoeModuleGetLogDomainFunc) (void); -#define TOMOE_MODULE_IMPL_INIT tomoe_module_impl_init -#define TOMOE_MODULE_IMPL_EXIT tomoe_module_impl_exit -#define TOMOE_MODULE_IMPL_INSTANTIATE tomoe_module_impl_instantiate +#define TOMOE_MODULE_IMPL_INIT tomoe_module_impl_init +#define TOMOE_MODULE_IMPL_EXIT tomoe_module_impl_exit +#define TOMOE_MODULE_IMPL_INSTANTIATE tomoe_module_impl_instantiate +#define TOMOE_MODULE_IMPL_GET_LOG_DOMAIN tomoe_module_impl_get_log_domain -GList *TOMOE_MODULE_IMPL_INIT (GTypeModule *module); -void TOMOE_MODULE_IMPL_EXIT (void); -GObject *TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, - va_list var_args); +GList *TOMOE_MODULE_IMPL_INIT (GTypeModule *module); +void TOMOE_MODULE_IMPL_EXIT (void); +GObject *TOMOE_MODULE_IMPL_INSTANTIATE (const gchar *first_property, + va_list var_args); +gchar *TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void); G_END_DECLS Index: tomoe/lib/tomoe-module.c diff -u tomoe/lib/tomoe-module.c:1.9 tomoe/lib/tomoe-module.c:1.10 --- tomoe/lib/tomoe-module.c:1.9 Thu Dec 14 17:52:57 2006 +++ tomoe/lib/tomoe-module.c Wed Dec 27 15:50:45 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.c,v 1.9 2006/12/14 08:52:57 kous Exp $ + * $Id: tomoe-module.c,v 1.10 2006/12/27 06:50:45 kous Exp $ */ #include @@ -38,9 +38,10 @@ gchar *mod_path; GList *registered_types; - TomoeModuleInitFunc init; - TomoeModuleExitFunc exit; - TomoeModuleInstantiateFunc instantiate; + TomoeModuleInitFunc init; + TomoeModuleExitFunc exit; + TomoeModuleInstantiateFunc instantiate; + TomoeModuleGetLogDomainFunc get_log_domain; }; G_DEFINE_TYPE (TomoeModule, tomoe_module, G_TYPE_TYPE_MODULE) @@ -114,7 +115,10 @@ (gpointer )&priv->exit) || !_tomoe_module_load_func (priv->library, G_STRINGIFY (TOMOE_MODULE_IMPL_INSTANTIATE), - (gpointer )&priv->instantiate)) { + (gpointer )&priv->instantiate) || + !_tomoe_module_load_func (priv->library, + G_STRINGIFY (TOMOE_MODULE_IMPL_GET_LOG_DOMAIN), + (gpointer )&priv->get_log_domain)) { _tomoe_module_close (priv->library); priv->library = NULL; return FALSE; @@ -139,6 +143,7 @@ priv->init = NULL; priv->exit = NULL; priv->instantiate = NULL; + priv->get_log_domain = NULL; g_list_free (priv->registered_types); priv->registered_types = NULL; @@ -173,6 +178,34 @@ return results; } +GList * +tomoe_module_collect_log_domains (GList *modules) +{ + GList *results = NULL; + GList *node; + + for (node = modules; node; node = g_list_next (node)) { + TomoeModule *module = node->data; + GTypeModule *g_type_module; + + g_type_module = G_TYPE_MODULE (module); + if (g_type_module_use (g_type_module)) { + gchar *log_domain; + TomoeModulePrivate *priv; + + priv = TOMOE_MODULE_GET_PRIVATE (module); + log_domain = priv->get_log_domain (); + if (log_domain) { + results = g_list_prepend (results, log_domain); + } + + g_type_module_unuse (g_type_module); + } + } + + return results; +} + static void _tomoe_module_show_error (GModule *module) { Index: tomoe/lib/tomoe-module.h diff -u tomoe/lib/tomoe-module.h:1.7 tomoe/lib/tomoe-module.h:1.8 --- tomoe/lib/tomoe-module.h:1.7 Thu Dec 14 17:46:21 2006 +++ tomoe/lib/tomoe-module.h Wed Dec 27 15:50:45 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-module.h,v 1.7 2006/12/14 08:46:21 kous Exp $ + * $Id: tomoe-module.h,v 1.8 2006/12/27 06:50:45 kous Exp $ */ #ifndef __TOMOE_MODULE_H__ @@ -58,6 +58,7 @@ va_list var_args); GList *tomoe_module_collect_registered_types (GList *modules); +GList *tomoe_module_collect_log_domains (GList *modules); void tomoe_module_unload (TomoeModule *module); Index: tomoe/lib/tomoe-recognizer.c diff -u tomoe/lib/tomoe-recognizer.c:1.26 tomoe/lib/tomoe-recognizer.c:1.27 --- tomoe/lib/tomoe-recognizer.c:1.26 Thu Dec 14 17:46:21 2006 +++ tomoe/lib/tomoe-recognizer.c Wed Dec 27 15:50:45 2006 @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.c,v 1.26 2006/12/14 08:46:21 kous Exp $ + * $Id: tomoe-recognizer.c,v 1.27 2006/12/27 06:50:45 kous Exp $ */ #include @@ -54,6 +54,12 @@ return tomoe_module_collect_registered_types (recognizers); } +GList * +tomoe_recognizer_get_log_domains (void) +{ + return tomoe_module_collect_log_domains (recognizers); +} + G_DEFINE_ABSTRACT_TYPE (TomoeRecognizer, tomoe_recognizer, G_TYPE_OBJECT) static void Index: tomoe/lib/tomoe-recognizer.h diff -u tomoe/lib/tomoe-recognizer.h:1.21 tomoe/lib/tomoe-recognizer.h:1.22 --- tomoe/lib/tomoe-recognizer.h:1.21 Tue Dec 12 18:55:59 2006 +++ tomoe/lib/tomoe-recognizer.h Wed Dec 27 15:50:45 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer.h,v 1.21 2006/12/12 09:55:59 kous Exp $ + * $Id: tomoe-recognizer.h,v 1.22 2006/12/27 06:50:45 kous Exp $ */ #ifndef __TOMOE_RECOGNIZER_H__ @@ -59,6 +59,7 @@ void tomoe_recognizer_load (const gchar *base_dir); void tomoe_recognizer_unload (void); GList *tomoe_recognizer_get_registered_types (void); +GList *tomoe_recognizer_get_log_domains (void); TomoeRecognizer *tomoe_recognizer_new (const gchar *name, const gchar *first_property, From kous users.sourceforge.jp Wed Dec 27 15:50:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:50:46 +0900 Subject: [Tomoe-cvs 2099] CVS update: tomoe/module/dict Message-ID: <20061227065046.3ECF82AC0FC@users.sourceforge.jp> Index: tomoe/module/dict/tomoe-dict-est.c diff -u tomoe/module/dict/tomoe-dict-est.c:1.20 tomoe/module/dict/tomoe-dict-est.c:1.21 --- tomoe/module/dict/tomoe-dict-est.c:1.20 Fri Dec 22 14:59:33 2006 +++ tomoe/module/dict/tomoe-dict-est.c Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-est.c,v 1.20 2006/12/22 05:59:33 kous Exp $ + * $Id: tomoe-dict-est.c,v 1.21 2006/12/27 06:50:46 kous Exp $ */ #include @@ -216,6 +216,12 @@ return g_object_new_valist (TOMOE_TYPE_DICT_EST, first_property, var_args); } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) Index: tomoe/module/dict/tomoe-dict-mysql.c diff -u tomoe/module/dict/tomoe-dict-mysql.c:1.21 tomoe/module/dict/tomoe-dict-mysql.c:1.22 --- tomoe/module/dict/tomoe-dict-mysql.c:1.21 Fri Dec 22 14:20:00 2006 +++ tomoe/module/dict/tomoe-dict-mysql.c Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-mysql.c,v 1.21 2006/12/22 05:20:00 kous Exp $ + * $Id: tomoe-dict-mysql.c,v 1.22 2006/12/27 06:50:46 kous Exp $ */ #include @@ -288,6 +288,12 @@ return g_object_new_valist (TOMOE_TYPE_DICT_MYSQL, first_property, var_args); } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) Index: tomoe/module/dict/tomoe-dict-ruby.c diff -u tomoe/module/dict/tomoe-dict-ruby.c:1.4 tomoe/module/dict/tomoe-dict-ruby.c:1.5 --- tomoe/module/dict/tomoe-dict-ruby.c:1.4 Tue Dec 26 12:03:58 2006 +++ tomoe/module/dict/tomoe-dict-ruby.c Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-ruby.c,v 1.4 2006/12/26 03:03:58 kous Exp $ + * $Id: tomoe-dict-ruby.c,v 1.5 2006/12/27 06:50:46 kous Exp $ */ #include @@ -238,6 +238,12 @@ return object; } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) { Index: tomoe/module/dict/tomoe-dict-svn.c diff -u tomoe/module/dict/tomoe-dict-svn.c:1.7 tomoe/module/dict/tomoe-dict-svn.c:1.8 --- tomoe/module/dict/tomoe-dict-svn.c:1.7 Tue Dec 12 18:29:56 2006 +++ tomoe/module/dict/tomoe-dict-svn.c Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-svn.c,v 1.7 2006/12/12 09:29:56 kous Exp $ + * $Id: tomoe-dict-svn.c,v 1.8 2006/12/27 06:50:46 kous Exp $ */ #include @@ -225,6 +225,13 @@ return g_object_new_valist (TOMOE_TYPE_DICT_SVN, first_property, var_args); } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) { Index: tomoe/module/dict/tomoe-dict-unihan.c diff -u tomoe/module/dict/tomoe-dict-unihan.c:1.7 tomoe/module/dict/tomoe-dict-unihan.c:1.8 --- tomoe/module/dict/tomoe-dict-unihan.c:1.7 Fri Dec 15 11:14:36 2006 +++ tomoe/module/dict/tomoe-dict-unihan.c Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-unihan.c,v 1.7 2006/12/15 02:14:36 kous Exp $ + * $Id: tomoe-dict-unihan.c,v 1.8 2006/12/27 06:50:46 kous Exp $ */ #include @@ -178,6 +178,12 @@ return g_object_new_valist (TOMOE_TYPE_DICT_UNIHAN, first_property, args); } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) Index: tomoe/module/dict/tomoe-dict-xml.c diff -u tomoe/module/dict/tomoe-dict-xml.c:1.16 tomoe/module/dict/tomoe-dict-xml.c:1.17 --- tomoe/module/dict/tomoe-dict-xml.c:1.16 Fri Dec 22 11:50:33 2006 +++ tomoe/module/dict/tomoe-dict-xml.c Wed Dec 27 15:50:46 2006 @@ -21,7 +21,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-dict-xml.c,v 1.16 2006/12/22 02:50:33 kous Exp $ + * $Id: tomoe-dict-xml.c,v 1.17 2006/12/27 06:50:46 kous Exp $ */ #include @@ -204,6 +204,12 @@ return g_object_new_valist (TOMOE_TYPE_DICT_XML, first_property, args); } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) From kous users.sourceforge.jp Wed Dec 27 15:50:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:50:46 +0900 Subject: [Tomoe-cvs 2100] CVS update: tomoe/module/recognizer Message-ID: <20061227065046.625102AC0FD@users.sourceforge.jp> Index: tomoe/module/recognizer/tomoe-recognizer-simple.c diff -u tomoe/module/recognizer/tomoe-recognizer-simple.c:1.9 tomoe/module/recognizer/tomoe-recognizer-simple.c:1.10 --- tomoe/module/recognizer/tomoe-recognizer-simple.c:1.9 Tue Dec 12 18:55:59 2006 +++ tomoe/module/recognizer/tomoe-recognizer-simple.c Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-recognizer-simple.c,v 1.9 2006/12/12 09:55:59 kous Exp $ + * $Id: tomoe-recognizer-simple.c,v 1.10 2006/12/27 06:50:46 kous Exp $ */ #include @@ -153,6 +153,13 @@ first_property, var_args); } +G_MODULE_EXPORT gchar * +TOMOE_MODULE_IMPL_GET_LOG_DOMAIN (void) +{ + return g_strdup (G_LOG_DOMAIN); +} + + static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) From kous users.sourceforge.jp Wed Dec 27 15:50:46 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:50:46 +0900 Subject: [Tomoe-cvs 2101] CVS update: tomoe/ext/ruby Message-ID: <20061227065046.B07D32AC0FC@users.sourceforge.jp> Index: tomoe/ext/ruby/tomoe-rb-dict.c diff -u tomoe/ext/ruby/tomoe-rb-dict.c:1.28 tomoe/ext/ruby/tomoe-rb-dict.c:1.29 --- tomoe/ext/ruby/tomoe-rb-dict.c:1.28 Thu Dec 21 15:09:26 2006 +++ tomoe/ext/ruby/tomoe-rb-dict.c Wed Dec 27 15:50:46 2006 @@ -10,7 +10,7 @@ _tomoe_rb_dict_module_load(void) { _tomoe_rb_module_load(tomoe_dict_get_registered_types(), mTomoe, - DICT_PREFIX); + tomoe_dict_get_log_domains(), DICT_PREFIX); } static void Index: tomoe/ext/ruby/tomoe-rb-module.c diff -u tomoe/ext/ruby/tomoe-rb-module.c:1.2 tomoe/ext/ruby/tomoe-rb-module.c:1.3 --- tomoe/ext/ruby/tomoe-rb-module.c:1.2 Tue Dec 12 22:42:51 2006 +++ tomoe/ext/ruby/tomoe-rb-module.c Wed Dec 27 15:50:46 2006 @@ -4,7 +4,7 @@ void _tomoe_rb_module_load (GList *registered_types, VALUE klass, - const gchar *prefix) + GList *log_domains, const gchar *prefix) { GList *node; gchar *full_prefix; @@ -12,17 +12,24 @@ full_prefix = g_strconcat(TOMOE_PREFIX, prefix, NULL); tomoe_prefix_len = strlen(TOMOE_PREFIX); - for (node = registered_types; node; node = g_list_next (node)) { + for (node = registered_types; node; node = g_list_next(node)) { const gchar *name = node->data; GType type; - type = g_type_from_name (name); - if (type && g_str_has_prefix (name, full_prefix)) { + type = g_type_from_name(name); + if (type && g_str_has_prefix(name, full_prefix)) { G_DEF_CLASS(type, name + tomoe_prefix_len, klass); } } g_free(full_prefix); - g_list_free (registered_types); + g_list_free(registered_types); + + for (node = log_domains; node; node = g_list_next(node)) { + gchar *log_domain = node->data; + _tomoe_rb_set_log_domain(log_domain); + g_free(log_domain); + } + g_list_free(log_domains); } void Index: tomoe/ext/ruby/tomoe-rb-recognizer.c diff -u tomoe/ext/ruby/tomoe-rb-recognizer.c:1.9 tomoe/ext/ruby/tomoe-rb-recognizer.c:1.10 --- tomoe/ext/ruby/tomoe-rb-recognizer.c:1.9 Thu Dec 14 17:46:21 2006 +++ tomoe/ext/ruby/tomoe-rb-recognizer.c Wed Dec 27 15:50:46 2006 @@ -7,15 +7,16 @@ void _tomoe_rb_recognizer_module_load(void) { - _tomoe_rb_module_load(tomoe_recognizer_get_registered_types(), - mTomoe, RECOGNIZER_PREFIX); + _tomoe_rb_module_load(tomoe_recognizer_get_registered_types(), mTomoe, + tomoe_recognizer_get_log_domains(), + RECOGNIZER_PREFIX); } static void _tomoe_rb_recognizer_module_unload(void) { - _tomoe_rb_module_unload(tomoe_recognizer_get_registered_types(), - mTomoe, RECOGNIZER_PREFIX); + _tomoe_rb_module_unload(tomoe_recognizer_get_registered_types(), mTomoe, + RECOGNIZER_PREFIX); } static VALUE Index: tomoe/ext/ruby/tomoe-rb.c diff -u tomoe/ext/ruby/tomoe-rb.c:1.7 tomoe/ext/ruby/tomoe-rb.c:1.8 --- tomoe/ext/ruby/tomoe-rb.c:1.7 Thu Dec 14 17:46:21 2006 +++ tomoe/ext/ruby/tomoe-rb.c Wed Dec 27 15:50:46 2006 @@ -2,6 +2,9 @@ #include "tomoe-rb.h" +static ID set_log_domain; +static VALUE mGLibLog; + #ifndef HAVE_GOBJ2RVALU VALUE _tomoe_ruby_object_from_instance_with_unref(gpointer instance) @@ -14,6 +17,12 @@ #endif void +_tomoe_rb_set_log_domain (const gchar *domain) +{ + rb_funcall(mGLibLog, set_log_domain, 1, rb_str_new2(domain)); +} + +void Init_tomoe(void) { VALUE mTomoe; @@ -34,6 +43,9 @@ tomoe_init(); atexit(tomoe_quit); + mGLibLog = rb_const_get(mGLib, rb_intern("Log")); + set_log_domain = rb_intern("set_log_domain"); + _tomoe_rb_dict_module_load(); _tomoe_rb_recognizer_module_load(); } Index: tomoe/ext/ruby/tomoe-rb.h diff -u tomoe/ext/ruby/tomoe-rb.h:1.15 tomoe/ext/ruby/tomoe-rb.h:1.16 --- tomoe/ext/ruby/tomoe-rb.h:1.15 Mon Dec 18 10:35:40 2006 +++ tomoe/ext/ruby/tomoe-rb.h Wed Dec 27 15:50:46 2006 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * - * $Id: tomoe-rb.h,v 1.15 2006/12/18 01:35:40 kous Exp $ + * $Id: tomoe-rb.h,v 1.16 2006/12/27 06:50:46 kous Exp $ */ #ifndef __TOMOE_RB_H__ @@ -52,9 +52,10 @@ void _tomoe_rb_init_tomoe_recognizer(VALUE mTomoe); void _tomoe_rb_init_tomoe_writing(VALUE mTomoe); +void _tomoe_rb_set_log_domain(const gchar *domain); void _tomoe_rb_module_load (GList *registered_types, VALUE klass, - const gchar *prefix); + GList *log_domains, const gchar *prefix); void _tomoe_rb_module_unload (GList *registered_types, VALUE klass, const gchar *prefix); Index: tomoe/ext/ruby/tomoe.rb diff -u tomoe/ext/ruby/tomoe.rb:1.1 tomoe/ext/ruby/tomoe.rb:1.2 --- tomoe/ext/ruby/tomoe.rb:1.1 Mon Nov 20 15:47:09 2006 +++ tomoe/ext/ruby/tomoe.rb Wed Dec 27 15:50:46 2006 @@ -1,2 +1,8 @@ require 'glib2' require 'tomoe.so' + +module Tomoe + LOG_DOMAIN = "Tomoe" +end + +GLib::Log.set_log_domain(Tomoe::LOG_DOMAIN) From kous users.sourceforge.jp Wed Dec 27 15:54:58 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:54:58 +0900 Subject: [Tomoe-cvs 2102] CVS update: tomoe Message-ID: <20061227065458.D649C2AC022@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.510 tomoe/ChangeLog:1.511 --- tomoe/ChangeLog:1.510 Wed Dec 27 15:50:45 2006 +++ tomoe/ChangeLog Wed Dec 27 15:54:58 2006 @@ -1,5 +1,7 @@ 2006-12-27 Kouhei Sutou + * test/dict_spec.rb: added tests for auto inserting to PUA. + * lib/tomoe-module-impl.h, lib/tomoe-module.c, lib/tomoe-recognizer.[ch], lib/tomoe-dict.[ch], module/dict/tomoe-dict-*.c, From kous users.sourceforge.jp Wed Dec 27 15:54:59 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Wed, 27 Dec 2006 15:54:59 +0900 Subject: [Tomoe-cvs 2103] CVS update: tomoe/test Message-ID: <20061227065459.0EBAC2AC0FD@users.sourceforge.jp> Index: tomoe/test/dict_spec.rb diff -u tomoe/test/dict_spec.rb:1.32 tomoe/test/dict_spec.rb:1.33 --- tomoe/test/dict_spec.rb:1.32 Fri Dec 22 14:45:05 2006 +++ tomoe/test/dict_spec.rb Wed Dec 27 15:54:58 2006 @@ -77,6 +77,29 @@ end end + specify "should fail after PUA is full" do + make_temporary_dict(@original) do |dict| + pua_start = Tomoe::Char::PRIVATE_USE_AREA_START + pua_end = Tomoe::Char::PRIVATE_USE_AREA_END + + utf8_to_ucs4(dict.available_private_utf8).should == pua_start + pua_start.upto(pua_end - 1) do |i| + char = Tomoe::Char.new + char.utf8 = ucs4_to_utf8(i) + dict.register(char).should == true + end + utf8_to_ucs4(dict.available_private_utf8).should == pua_end + + char = Tomoe::Char.new + char.utf8 = ucs4_to_utf8(pua_end) + dict.register(char).should == true + dict.available_private_utf8.should_nil + + char = Tomoe::Char.new + dict.register(char).should == false + end + end + specify "should save/restore meta data" do make_temporary_dict(@original) do |dict| char = Tomoe::Char.new From makeinu users.sourceforge.jp Thu Dec 28 12:46:31 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 12:46:31 +0900 Subject: [Tomoe-cvs 2104] CVS update: libtomoe-gtk/po Message-ID: <20061228034631.72EF92AC058@users.sourceforge.jp> Index: libtomoe-gtk/po/ja.po diff -u libtomoe-gtk/po/ja.po:1.16 libtomoe-gtk/po/ja.po:1.17 --- libtomoe-gtk/po/ja.po:1.16 Fri Dec 22 13:35:20 2006 +++ libtomoe-gtk/po/ja.po Thu Dec 28 12:46:31 2006 @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: libtomoe-gtk 0.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-12-22 13:33+0900\n" +"POT-Creation-Date: 2006-12-28 11:42+0900\n" "PO-Revision-Date: 2005-10-11 18:15+0900\n" "Last-Translator: HIGUCHI Daisuke \n" "Language-Team: Japanese \n" @@ -253,19 +253,19 @@ msgid "The TomoeGucharmap widget inside of the TomoeWindow." msgstr "" -#: src/tomoe-window.c:165 src/tomoe-window.c:197 +#: src/tomoe-window.c:164 src/tomoe-window.c:196 msgid "Handwriting recognition" msgstr "ǧ" -#: src/tomoe-window.c:208 +#: src/tomoe-window.c:207 msgid "Search with reading" msgstr "ɤߤǸ" -#: src/tomoe-window.c:219 +#: src/tomoe-window.c:218 msgid "Unicode table" msgstr "Unicodeɽ" -#: src/tomoe-window.c:411 +#: src/tomoe-window.c:410 msgid "Tomoe" msgstr "" From makeinu users.sourceforge.jp Thu Dec 28 13:12:15 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 13:12:15 +0900 Subject: [Tomoe-cvs 2105] CVS update: libtomoe-gtk Message-ID: <20061228041215.AFB292AC0A9@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.258 libtomoe-gtk/ChangeLog:1.259 --- libtomoe-gtk/ChangeLog:1.258 Tue Dec 26 11:16:58 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 28 13:12:15 2006 @@ -1,3 +1,7 @@ +2006-12-28 Takuro Ashie + + * src/tomoe-reading-search.c: Fix format string for Unicode point. + 2006-12-26 Kouhei Sutou * src/tomoe-window.c (tomoe_window_init): removed needless setlocale(). From makeinu users.sourceforge.jp Thu Dec 28 13:12:15 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 13:12:15 +0900 Subject: [Tomoe-cvs 2106] CVS update: libtomoe-gtk/src Message-ID: <20061228041215.DF78F2AC10A@users.sourceforge.jp> Index: libtomoe-gtk/src/tomoe-reading-search.c diff -u libtomoe-gtk/src/tomoe-reading-search.c:1.32 libtomoe-gtk/src/tomoe-reading-search.c:1.33 --- libtomoe-gtk/src/tomoe-reading-search.c:1.32 Fri Dec 22 14:15:40 2006 +++ libtomoe-gtk/src/tomoe-reading-search.c Thu Dec 28 13:12:15 2006 @@ -430,8 +430,15 @@ utf8 = (gchar *)tomoe_char_get_utf8 (c); utf8_len = g_utf8_strlen (utf8, -1); for (i = 0; i < utf8_len; i++) { - g_string_append_printf (code_point_text, - "U+%X", g_utf8_get_char (utf8)); + char *format; + gunichar c = g_utf8_get_char (utf8); + if (c > 0xFFFFF) + format = "U+%X6"; + else if (c > 0xFFFF) + format = "U+%X5"; + else + format = "U+%X4"; + g_string_append_printf (code_point_text, format, c); utf8 = g_utf8_next_char (utf8); } if (code_point_text->len > 0) From makeinu users.sourceforge.jp Thu Dec 28 13:16:18 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 13:16:18 +0900 Subject: [Tomoe-cvs 2107] CVS update: tomoe Message-ID: <20061228041618.4E3802AC118@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.511 tomoe/ChangeLog:1.512 --- tomoe/ChangeLog:1.511 Wed Dec 27 15:54:58 2006 +++ tomoe/ChangeLog Thu Dec 28 13:16:18 2006 @@ -1,3 +1,7 @@ +2006-12-29 Takuro Ashie + + * Version-0.5.0. + 2006-12-27 Kouhei Sutou * test/dict_spec.rb: added tests for auto inserting to PUA. From makeinu users.sourceforge.jp Thu Dec 28 13:16:56 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 13:16:56 +0900 Subject: [Tomoe-cvs 2108] CVS update: libtomoe-gtk Message-ID: <20061228041656.DCE612AC10A@users.sourceforge.jp> Index: libtomoe-gtk/ChangeLog diff -u libtomoe-gtk/ChangeLog:1.259 libtomoe-gtk/ChangeLog:1.260 --- libtomoe-gtk/ChangeLog:1.259 Thu Dec 28 13:12:15 2006 +++ libtomoe-gtk/ChangeLog Thu Dec 28 13:16:56 2006 @@ -1,3 +1,7 @@ +2006-12-29 Takuro Ashie + + * Version-0.5.0. + 2006-12-28 Takuro Ashie * src/tomoe-reading-search.c: Fix format string for Unicode point. From makeinu users.sourceforge.jp Thu Dec 28 13:18:03 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 13:18:03 +0900 Subject: [Tomoe-cvs 2109] CVS update: uim-tomoe-gtk Message-ID: <20061228041803.092AA2AC10A@users.sourceforge.jp> Index: uim-tomoe-gtk/ChangeLog diff -u uim-tomoe-gtk/ChangeLog:1.19 uim-tomoe-gtk/ChangeLog:1.20 --- uim-tomoe-gtk/ChangeLog:1.19 Wed Dec 6 15:48:57 2006 +++ uim-tomoe-gtk/ChangeLog Thu Dec 28 13:18:02 2006 @@ -1,3 +1,7 @@ +2006-12-29 Takuro Ashie + + * Version-0.5.0. + 2006-12-06 Takuro Ashie * src/uim-tomoe-gtk.c: Follow libtomoe-gtk. From makeinu users.sourceforge.jp Thu Dec 28 13:39:47 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 13:39:47 +0900 Subject: [Tomoe-cvs 2110] CVS update: tomoe Message-ID: <20061228043947.749872AC0F9@users.sourceforge.jp> Index: tomoe/README diff -u /dev/null tomoe/README:1.1 --- /dev/null Thu Dec 28 13:39:47 2006 +++ tomoe/README Thu Dec 28 13:39:47 2006 @@ -0,0 +1,13 @@ +1. What's this? +=============== + +Tomoe is originally a handwriting character recognition engine. + +Current Tomoe does not only provide handwriting recognition engine but also +provide other character searching API such as searching by readings, stroke +counts, radicals, valiations and so on. + +2. Requirements +=============== + +glib-2.4 or later From kous users.sourceforge.jp Thu Dec 28 13:45:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 28 Dec 2006 13:45:36 +0900 Subject: [Tomoe-cvs 2111] CVS update: tomoe Message-ID: <20061228044536.5F5332AC118@users.sourceforge.jp> Index: tomoe/ChangeLog diff -u tomoe/ChangeLog:1.512 tomoe/ChangeLog:1.513 --- tomoe/ChangeLog:1.512 Thu Dec 28 13:16:18 2006 +++ tomoe/ChangeLog Thu Dec 28 13:45:36 2006 @@ -2,6 +2,11 @@ * Version-0.5.0. +2006-12-28 Kouhei Sutou + + * spec/turbo-linux/tomoe.spec.in, + spec/miracle-linux/tomoe.spec.in: added README to doc. + 2006-12-27 Kouhei Sutou * test/dict_spec.rb: added tests for auto inserting to PUA. From kous users.sourceforge.jp Thu Dec 28 13:45:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 28 Dec 2006 13:45:36 +0900 Subject: [Tomoe-cvs 2112] CVS update: tomoe/spec/miracle-linux Message-ID: <20061228044536.8BA182AC11D@users.sourceforge.jp> Index: tomoe/spec/miracle-linux/tomoe.spec.in diff -u tomoe/spec/miracle-linux/tomoe.spec.in:1.3 tomoe/spec/miracle-linux/tomoe.spec.in:1.4 --- tomoe/spec/miracle-linux/tomoe.spec.in:1.3 Mon Dec 25 16:46:42 2006 +++ tomoe/spec/miracle-linux/tomoe.spec.in Thu Dec 28 13:45:36 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.3 2006/12/25 07:46:42 kous Exp $ +# $Id: tomoe.spec.in,v 1.4 2006/12/28 04:45:36 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -9,8 +9,8 @@ Name: tomoe Version: @VERSION@ -Release: 0 -Serial: 2006122501 +Release: 1 +Serial: 2006122801 Summary: Tegaki Online MOji-ninshiki Engine Summary(ja_JP.utf8): ??????????????Tomoe @@ -76,7 +76,7 @@ %files %defattr(-,root,root,-) #%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO -%doc AUTHORS ChangeLog COPYING NEWS TODO +%doc AUTHORS ChangeLog COPYING NEWS README TODO %{_libdir}/libtomoe*.so.* %{_libdir}/tomoe/* @@ -91,5 +91,8 @@ %{_datadir}/gtk-doc/* %changelog +* Mon Dec 28 2006 Kouhei Sutou - 0.5.0-2 +- add README + * Mon Dec 25 2006 Kouhei Sutou - 0.5.0-0 - initial release. From kous users.sourceforge.jp Thu Dec 28 13:45:36 2006 From: kous users.sourceforge.jp (Kouhei Sutou) Date: Thu, 28 Dec 2006 13:45:36 +0900 Subject: [Tomoe-cvs 2113] CVS update: tomoe/spec/turbo-linux Message-ID: <20061228044536.B393B2AC131@users.sourceforge.jp> Index: tomoe/spec/turbo-linux/tomoe.spec.in diff -u tomoe/spec/turbo-linux/tomoe.spec.in:1.3 tomoe/spec/turbo-linux/tomoe.spec.in:1.4 --- tomoe/spec/turbo-linux/tomoe.spec.in:1.3 Mon Dec 25 16:46:42 2006 +++ tomoe/spec/turbo-linux/tomoe.spec.in Thu Dec 28 13:45:36 2006 @@ -1,6 +1,6 @@ # -*- coding:utf-8-unix -*- # -# $Id: tomoe.spec.in,v 1.3 2006/12/25 07:46:42 kous Exp $ +# $Id: tomoe.spec.in,v 1.4 2006/12/28 04:45:36 kous Exp $ # # Copyright (c) 2006 Kouhei Sutou # This file and all modifications and/or additions are under @@ -9,8 +9,8 @@ Name: tomoe Version: @VERSION@ -Release: 1 -Serial: 2006122501 +Release: 2 +Serial: 2006122801 Summary: Tegaki Online MOji-ninshiki Engine Summary(ja_JP.utf8): ??????????????Tomoe @@ -76,7 +76,7 @@ %files %defattr(-,root,root,-) #%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO -%doc AUTHORS ChangeLog COPYING NEWS TODO +%doc AUTHORS ChangeLog COPYING NEWS README TODO %{_libdir}/libtomoe*.so.* %{_libdir}/tomoe/* @@ -91,6 +91,9 @@ %{_datadir}/gtk-doc/* %changelog +* Mon Dec 28 2006 Kouhei Sutou - 0.5.0-2 +- added README + * Mon Dec 25 2006 Kouhei Sutou - 0.5.0-1 - follow the current source. From makeinu users.sourceforge.jp Thu Dec 28 16:01:28 2006 From: makeinu users.sourceforge.jp (Takuro Ashie) Date: Thu, 28 Dec 2006 16:01:28 +0900 Subject: [Tomoe-cvs 2114] CVS update: uim-tomoe-gtk Message-ID: <20061228070128.EB5A32AC086@users.sourceforge.jp> Index: uim-tomoe-gtk/ChangeLog diff -u uim-tomoe-gtk/ChangeLog:1.20 uim-tomoe-gtk/ChangeLog:1.21 --- uim-tomoe-gtk/ChangeLog:1.20 Thu Dec 28 13:18:02 2006 +++ uim-tomoe-gtk/ChangeLog Thu Dec 28 16:01:28 2006 @@ -2,6 +2,10 @@ * Version-0.5.0. +2006-12-29 Takuro Ashie + + * configure.in: Bump version number. + 2006-12-06 Takuro Ashie * src/uim-tomoe-gtk.c: Follow libtomoe-gtk. Index: uim-tomoe-gtk/configure.in diff -u uim-tomoe-gtk/configure.in:1.6 uim-tomoe-gtk/configure.in:1.7 --- uim-tomoe-gtk/configure.in:1.6 Tue Nov 28 13:26:46 2006 +++ uim-tomoe-gtk/configure.in Thu Dec 28 16:01:28 2006 @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) -AC_INIT(uim-tomoe-gtk, 0.4.0) +AC_INIT(uim-tomoe-gtk, 0.5.0) AM_INIT_AUTOMAKE(1.6) AM_CONFIG_HEADER(config.h)