diff -NurdB gnome-spell-1.0.6/README gnome-spell-1.0.6-patched/README --- gnome-spell-1.0.6/README 2005-01-24 13:06:08.000000000 -0500 +++ gnome-spell-1.0.6-patched/README 2005-07-07 02:22:09.000000000 -0500 @@ -3,7 +3,7 @@ Gnome Spell is GNOME/Bonobo component for spell checking. In current 0.1 version it contains GNOME::Spell::Dictionary object, which provides spell checking dictionary -(see Spell.idl for exact API definition). It's based on pspell package, which is required +(see Spell.idl for exact API definition). It's based on Enchant package, which is required to build gnome-spell. Dictionary object could be used for live spell checking. Look in test-spell.c or @@ -12,19 +12,18 @@ In future it will be expanded by implementation of GNOME::Spell::Checker object (see also Spell.idl) and also by spell checking dialog control with appropriate interface. -Pspell build +Enchant build ------------ -From my experience with pspell I recommend you to build pspell/aspell this way: +From my experience with Enchant I recommend you to build it this way: - 1) build and install pspell - 2) build and install aspell + 1) build and install Pspell, Aspell + 2) build and install Enchant 4) build and install GNOME Spell -You could get Pspell and Aspell from: +You could get Enchant from: - http://pspell.sourceforge.net/ - http://aspell.sourceforge.net/ + http://www.abisource.com/enchant/ End --- diff -NurdB gnome-spell-1.0.6/configure.in gnome-spell-1.0.6-patched/configure.in --- gnome-spell-1.0.6/configure.in 2005-01-24 13:06:08.000000000 -0500 +++ gnome-spell-1.0.6-patched/configure.in 2005-07-07 02:22:09.000000000 -0500 @@ -46,34 +46,6 @@ AC_SUBST(API_VERSION) dnl -dnl aspell -dnl - -AC_ARG_WITH(aspell-prefix, [ --with-aspell-prefix=DIR - specify under which prefix aspell is installed.], with_aspell_prefix="$withval", ) - -if test "x$with_aspell_prefix" != "x"; then - saved_LDFLAGS=$LDFLAGS - LDFLAGS="-L$with_aspell_prefix/lib "$LDFLAGS - ASPELL_INC="-I$with_aspell_prefix/include" - ASPELL_LIBS="-L$with_aspell_prefix/lib -laspell" - ASPELL_DATA="$with_aspell_prefix/lib/aspell" -else - LDFLAGS="-L`aspell config prefix`/lib "$LDFLAGS - ASPELL_INC="-I`aspell config prefix`/include" - ASPELL_LIBS="-L`aspell config prefix`/lib -laspell" - ASPELL_DICT="`aspell config dict-dir`" -fi -AC_CHECK_LIB(aspell,new_aspell_config,,AC_MSG_ERROR([gnome-spell cannot be built without aspell library]),) -if test "x$with_aspell_prefix" != "x"; then - LDFLAGS=$saved_LDFLAGS -fi - -AC_SUBST(ASPELL_DICT) -AC_SUBST(ASPELL_INC) -AC_SUBST(ASPELL_LIBS) - -dnl dnl flags dnl @@ -82,7 +54,7 @@ AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) -GNOME_SPELL_MODULES="libgnomeui-2.0 >= 1.112.1 libbonoboui-2.0 >= 1.112.1 libglade-2.0 >= 1.99.9" +GNOME_SPELL_MODULES="libgnomeui-2.0 >= 1.112.1 libbonoboui-2.0 >= 1.112.1 libglade-2.0 >= 1.99.9 enchant >= 0.4.0 gtk+-2.0 >= 2.3.0" PKG_CHECK_MODULES(GNOME_SPELL, $GNOME_SPELL_MODULES) AC_SUBST(GNOME_SPELL_CFLAGS) AC_SUBST(GNOME_SPELL_LIBS) diff -NurdB gnome-spell-1.0.6/gnome-spell/Makefile.am gnome-spell-1.0.6-patched/gnome-spell/Makefile.am --- gnome-spell-1.0.6/gnome-spell/Makefile.am 2005-01-24 13:58:22.000000000 -0500 +++ gnome-spell-1.0.6-patched/gnome-spell/Makefile.am 2005-07-07 02:31:59.000000000 -0500 @@ -7,12 +7,10 @@ INCLUDES = \ -I$(srcdir) \ - $(ASPELL_INC) \ -DGNOMEDATADIR=\""$(datadir)"\" \ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -DGLADE_DATADIR=\"$(gladedir)\" \ -DPLUGIN_DIR=\""$(PLUGIN_DIR)"\" \ - -DASPELL_DICT=\""$(ASPELL_DICT)"\" \ $(GNOME_SPELL_CFLAGS) \ $(END) @@ -54,7 +52,6 @@ libgnome_spell_component_la_LDFLAGS = -release $(API_VERSION) libgnome_spell_component_la_LIBADD = \ libgnome-spell-idl.la \ - $(ASPELL_LIBS) \ $(GNOME_SPELL_LIBS) \ $(END) @@ -68,7 +65,6 @@ test_gnome_spell_component_LDADD = \ libgnome-spell-idl.la \ - $(ASPELL_LIBS) \ $(GNOME_SPELL_LIBS) \ $(END) diff -NurdB gnome-spell-1.0.6/gnome-spell/dictionary.c gnome-spell-1.0.6-patched/gnome-spell/dictionary.c --- gnome-spell-1.0.6/gnome-spell/dictionary.c 2005-01-24 13:06:09.000000000 -0500 +++ gnome-spell-1.0.6-patched/gnome-spell/dictionary.c 2005-07-07 03:04:01.000000000 -0500 @@ -55,13 +55,30 @@ return (SpellEngine *) language ? g_hash_table_lookup (dict->engines_ht, language) : NULL; } +/* replace any 1 hyphen with an underscore. converts en-US to en_US */ +static gchar * +normalize_language (const gchar * language) +{ + gchar * dup, * hyphen; + + dup = g_strdup (language); + hyphen = strchr (dup, '-'); + if (hyphen) + *hyphen = '_'; + return dup; +} + static void raise_error (CORBA_Environment * ev, const gchar *s) { GNOME_Spell_Dictionary_Error *exception; exception = GNOME_Spell_Dictionary_Error__alloc (); - - exception->error = CORBA_string_dup (s); + + if (s != NULL) + exception->error = CORBA_string_dup (s); + else + exception->error = _("Unknown error"); + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Spell_Dictionary_Error, exception); @@ -76,6 +93,7 @@ dict->engines = NULL; dict->languages = g_hash_table_new (g_str_hash, g_str_equal); dict->engines_ht = g_hash_table_new (NULL, NULL); + dict->broker = enchant_broker_init (); } static void @@ -88,6 +106,7 @@ dictionary->languages = NULL; g_hash_table_destroy (dictionary->engines_ht); dictionary->engines_ht = NULL; + enchant_broker_free (dictionary->broker); G_OBJECT_CLASS (dictionary_parent_class)->finalize (object); } @@ -98,9 +117,7 @@ SpellEngine *se; se = g_new0 (SpellEngine, 1); - se->config = new_aspell_config (); - aspell_config_replace (se->config, "language-tag", language); - aspell_config_replace (se->config, "encoding", "utf-8"); + se->lang = normalize_language (language); se->changed = TRUE; return se; @@ -129,9 +146,9 @@ SpellEngine *se = dict->engines->data; if (se->speller) - delete_aspell_speller (se->speller); - if (se->config) - delete_aspell_config (se->config); + enchant_broker_free_dict (dict->broker, se->speller); + if (se->lang) + g_free (se->lang); g_free (se); dict->engines = g_slist_remove (dict->engines, se); } @@ -190,33 +207,44 @@ NULL }; +static void +dict_describe (const char *lang_tag, const char *provider_name, + const char *provider_desc, const char *provider_file, void *user_data) +{ + printf ("%s | %s | %s | %s\n", lang_tag, provider_name, provider_desc, provider_file); +} + static GSList * get_languages_real (gint *ln) { + EnchantBroker *broker; + gchar *lang; GSList *langs; - AspellCanHaveError *err; - AspellConfig *config; - AspellSpeller *speller; gint i; DICT_DEBUG (printf ("get_languages_real\n")); langs = NULL; *ln = 0; + + broker = enchant_broker_init (); + for (i=0; known_languages [i]; i++) { - config = new_aspell_config (); - aspell_config_replace (config, "language-tag", known_languages [i]); + lang = normalize_language (known_languages [i]); i++; - err = new_aspell_speller (config); - if (aspell_error_number (err) == 0) { - speller = to_aspell_speller (err); - DICT_DEBUG (printf ("Language: %s\n", known_languages [i])); - delete_aspell_speller (speller); + + if (enchant_broker_dict_exists (broker, lang)) { + DICT_DEBUG (enchant_dict_describe (dict, dict_describe, NULL)); + DICT_DEBUG (printf ("Language: %s (%s)\n", known_languages [i], lang)); langs = g_slist_prepend (langs, GINT_TO_POINTER (i - 1)); (*ln) ++; } + + g_free (lang); } + enchant_broker_free (broker); + return langs; } @@ -227,8 +255,6 @@ GSList *langs = NULL; gint i, lang_num; - /* printf ("get_languages_load\n"); */ - str = g_string_new (NULL); *ln = gconf_client_get_int (gc, GNOME_SPELL_GCONF_DIR "/languages", NULL); for (i = 0; i < *ln; i++) { @@ -246,7 +272,6 @@ GSList *langs, *l; GConfClient *gc; time_t mtime; - struct stat buf; gint i, kl; gc = gconf_client_get_default (); @@ -254,7 +279,7 @@ mtime = gconf_client_get_int (gc, GNOME_SPELL_GCONF_DIR "/mtime", NULL); kl = gconf_client_get_int (gc, GNOME_SPELL_GCONF_DIR "/known_languages", NULL); - if (stat (ASPELL_DICT, &buf) || buf.st_mtime != mtime || kl != KNOWN_LANGUAGES) { + if (kl != KNOWN_LANGUAGES) { /* TODO: find a way to get this list generation to happen less often */ GString *str; langs = get_languages_real (ln); @@ -265,7 +290,7 @@ gconf_client_set_int (gc, str->str, GPOINTER_TO_INT (l->data), NULL); l = l->next; } - gconf_client_set_int (gc, GNOME_SPELL_GCONF_DIR "/mtime", buf.st_mtime, NULL); + gconf_client_set_int (gc, GNOME_SPELL_GCONF_DIR "/mtime", time (NULL), NULL); gconf_client_set_int (gc, GNOME_SPELL_GCONF_DIR "/known_languages", KNOWN_LANGUAGES, NULL); g_string_free (str, TRUE); gnome_config_sync (); @@ -355,22 +380,18 @@ } static void -update_engine (SpellEngine *se, CORBA_Environment * ev) +update_engine (GNOMESpellDictionary *dict, SpellEngine *se, CORBA_Environment * ev) { - AspellCanHaveError *err; - - DICT_DEBUG (printf ("Dictionary: creating new aspell speller\n")); + DICT_DEBUG (printf ("Dictionary: creating new enchant speller\n")); if (se->changed) { if (se->speller) - delete_aspell_speller (se->speller); - err = new_aspell_speller (se->config); - if (aspell_error_number (err) != 0) { - g_warning ("aspell error: %s\n", aspell_error_message (err)); - se->speller = NULL; - raise_error (ev, aspell_error_message (err)); + enchant_broker_free_dict (dict->broker, se->speller); + se->speller = enchant_broker_request_dict (dict->broker, se->lang); + if (se->speller == NULL) { + g_warning ("enchant error: %s\n", se->lang); + raise_error (ev, enchant_broker_get_error (dict->broker)); } else { - se->speller = to_aspell_speller (err); se->changed = FALSE; } } @@ -385,7 +406,7 @@ GSList *l; for (l = dict->engines; l; l = l->next) { - update_engine ((SpellEngine *) l->data, ev); + update_engine (dict, (SpellEngine *) l->data, ev); } dict->changed = FALSE; @@ -395,24 +416,16 @@ static CORBA_boolean engine_check_word (SpellEngine *se, const gchar *word, CORBA_Environment *ev) { - CORBA_boolean result = CORBA_TRUE; - gint aspell_result; - #ifndef G_DISABLE_CHECKS g_return_val_if_fail (se->speller, CORBA_TRUE); #else if (!se->speller) return CORBA_TRUE; #endif - aspell_result = aspell_speller_check (se->speller, word, strlen (word)); - if (aspell_result == 0) - result = CORBA_FALSE; - if (aspell_result == -1) { - g_warning ("aspell error: %s\n", aspell_speller_error_message (se->speller)); - raise_error (ev, aspell_speller_error_message (se->speller)); - } - return result; + if (enchant_dict_check (se->speller, word, strlen (word)) == 0) + return CORBA_TRUE; + return CORBA_FALSE; } static CORBA_boolean @@ -465,7 +478,7 @@ DICT_DEBUG (printf ("Dictionary add_word_to_session: %s\n", word)); for (l = dict->engines; l; l = l->next) { if (((SpellEngine *) l->data)->speller) - aspell_speller_add_to_session (((SpellEngine *) l->data)->speller, word, strlen (word)); + enchant_dict_add_to_session (((SpellEngine *) l->data)->speller, word, strlen (word)); } } @@ -487,8 +500,7 @@ se = (SpellEngine *) g_hash_table_lookup (dict->languages, language); if (se && se->speller) { - aspell_speller_add_to_personal (se->speller, word, strlen (word)); - aspell_speller_save_all_word_lists (se->speller); + enchant_dict_add_to_personal (se->speller, word, strlen (word)); DICT_DEBUG (printf ("Added and saved.\n")); } } @@ -511,9 +523,8 @@ se = (SpellEngine *) g_hash_table_lookup (dict->languages, language); if (se && se->speller) { - aspell_speller_store_replacement (se->speller, word, strlen (word), - replacement, strlen (replacement)); - aspell_speller_save_all_word_lists (se->speller); + enchant_dict_store_replacement (se->speller, word, strlen (word), + replacement, strlen (replacement)); DICT_DEBUG (printf ("Set and saved.\n")); } } @@ -523,12 +534,13 @@ const CORBA_char *word, CORBA_Environment *ev) { GNOMESpellDictionary *dict = GNOME_SPELL_DICTIONARY (bonobo_object_from_servant (servant)); - const AspellWordList *suggestions; - AspellStringEnumeration *elements; GNOME_Spell_StringSeq *seq = NULL; GSList *l, *suggestion_list = NULL; gint i, len, pos; + char **suggestions; + size_t n_suggs, total_suggs; + #ifndef G_DISABLE_CHECKS g_return_val_if_fail (word, NULL); #else @@ -539,14 +551,20 @@ update_engines (dict, ev); len = 0; + total_suggs = 0; for (l = dict->engines; l; l = l->next) { SpellEngine *se = (SpellEngine *) l->data; if (se->speller) { - suggestions = aspell_speller_suggest (se->speller, word, strlen (word)); - suggestion_list = g_slist_prepend (suggestion_list, (gpointer) suggestions); - len += 2*aspell_word_list_size (suggestions); - suggestion_list = g_slist_prepend (suggestion_list, engine_to_language (dict, se)); + suggestions = enchant_dict_suggest (se->speller, word, strlen (word), &n_suggs); + if (suggestions && n_suggs) { + total_suggs += n_suggs; + suggestion_list = g_slist_prepend (suggestion_list, (gpointer) suggestions); + suggestion_list = g_slist_prepend (suggestion_list, engine_to_language (dict, se)); + suggestion_list = g_slist_prepend (suggestion_list, GINT_TO_POINTER (n_suggs)); + suggestion_list = g_slist_prepend (suggestion_list, (gpointer) se->speller); + len += 2*n_suggs; + } } } @@ -560,20 +578,25 @@ pos = 0; for (l = suggestion_list; l; l = l->next) { - gint list_len; gchar *language; + EnchantDict * en_dict; + + en_dict = (EnchantDict *)l->data; + l = l->next; + + n_suggs = GPOINTER_TO_INT (l->data); + l = l->next; language = (gchar *) l->data; l = l->next; - suggestions = (const AspellWordList *) l->data; - elements = aspell_word_list_elements (suggestions); - list_len = aspell_word_list_size (suggestions); - for (i = 0; i < list_len; i ++, pos ++) { - seq->_buffer [pos] = CORBA_string_dup (aspell_string_enumeration_next (elements)); + suggestions = (char **) l->data; + + for (i = 0; i < n_suggs; i ++, pos ++) { + seq->_buffer [pos] = CORBA_string_dup (suggestions[i]); pos ++; seq->_buffer [pos] = CORBA_string_dup (language); } - delete_aspell_string_enumeration (elements); + enchant_dict_free_suggestions (en_dict, suggestions); } CORBA_sequence_set_release (seq, CORBA_TRUE); g_slist_free (suggestion_list); diff -NurdB gnome-spell-1.0.6/gnome-spell/dictionary.h gnome-spell-1.0.6-patched/gnome-spell/dictionary.h --- gnome-spell-1.0.6/gnome-spell/dictionary.h 2005-01-24 13:06:09.000000000 -0500 +++ gnome-spell-1.0.6-patched/gnome-spell/dictionary.h 2005-07-07 02:22:09.000000000 -0500 @@ -26,7 +26,7 @@ G_BEGIN_DECLS #include -#include +#include #define GNOME_SPELL_DICTIONARY_TYPE (gnome_spell_dictionary_get_type ()) #define GNOME_SPELL_DICTIONARY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \ @@ -37,8 +37,8 @@ #define IS_GNOME_SPELL_DICTIONARY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_SPELL_DICTIONARY_TYPE)) typedef struct { - AspellConfig *config; - AspellSpeller *speller; + EnchantDict *speller; + gchar *lang; gboolean changed; } SpellEngine; @@ -49,6 +49,8 @@ GSList *engines; GHashTable *languages; GHashTable *engines_ht; + + EnchantBroker * broker; } GNOMESpellDictionary; typedef struct { diff -NurdB gnome-spell-1.0.6/gnome-spell.spec.in gnome-spell-1.0.6-patched/gnome-spell.spec.in --- gnome-spell-1.0.6/gnome-spell.spec.in 2005-01-24 13:06:08.000000000 -0500 +++ gnome-spell-1.0.6-patched/gnome-spell.spec.in 2005-07-07 02:22:09.000000000 -0500 @@ -7,12 +7,10 @@ Source: ftp://ftp.gnome.org/pub/GNOME/unstable/sources/%{name}/%{name}-%{version}.tar.gz Summary: The spelling component for bonobo Group: System Environment/Libraries -Requires: aspell >= 0.28 -Requires: pspell >= 0.12 +Requires: enchant >= 0.3.0 Requires: bonobo >= 0.28 Requires: gal >= 0.7.99.5 -BuildRequires: aspell-devel >= 0.28 -BuildRequires: pspell-devel >= 0.12 +BuildRequires: enchant-devel >= 0.3.0 BuildRequires: bonobo-devel >= 0.28 BuildRequires: libglade-devel BuildRequires: gal-devel >= 0.7.99.5