diff options
-rw-r--r-- | configure.ac | 86 | ||||
-rw-r--r-- | libempathy-gtk/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-spell.c | 39 |
3 files changed, 56 insertions, 71 deletions
diff --git a/configure.ac b/configure.ac index 374756a56..f307ffe02 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,8 @@ LIBGLADE_REQUIRED=2.0.0 LIBPANELAPPLET_REQUIRED=2.10.0 TELEPATHY_GLIB_REQUIRED=0.7.3 MISSION_CONTROL_REQUIRED=4.61 +ENCHANT_REQUIRED=1.2.0 +ISO_CODES_REQUIRED=0.35 # Uncomment that to build without deprecated symbols # AC_DEFINE(GTK_DISABLE_DEPRECATED, 1, [Disable deprecated GTK symbols]) @@ -111,63 +113,43 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Gettext package name]) AM_GLIB_GNU_GETTEXT -dnl ================================================================ -dnl spellchecking checks: enchant and iso-codes -dnl ================================================================ - -ENCHANT_REQUIRED=1.2.0 -ISO_CODES_REQUIRED=0.35 +# ----------------------------------------------------------- +# spellchecking checks: enchant and iso-codes +# ----------------------------------------------------------- +AC_ARG_ENABLE(spell, + AS_HELP_STRING([--enable-spell=@<:@no/yes/auto@:>@], + [Enable spell checking]), , + enable_spell=auto) -AC_ARG_ENABLE([spell], - AS_HELP_STRING([--disable-spell],[Disable spell checking (default: enabled)]), - [enable_enchant=$enableval], - [enable_enchant=yes]) - -if test "x$enable_enchant" = "xyes" ; then - - PKG_CHECK_MODULES(ENCHANT, enchant >= $ENCHANT_REQUIRED, \ - have_enchant=yes, have_enchant=no) - - if test "x$have_enchant" = "xyes"; then - - PKG_CHECK_EXISTS([iso-codes >= $ISO_CODES_REQUIRED], - [have_iso_codes=yes],[have_iso_codes=no]) - - if test "x$have_iso_codes" = "xyes"; then - AC_MSG_CHECKING([whether iso-codes has iso-639 and iso-3166 domains]) - if $PKG_CONFIG --variable=domains iso-codes | grep 639 > /dev/null && \ - $PKG_CONFIG --variable=domains iso-codes | grep 3166 > /dev/null ; then - result=yes - else - result=no - have_iso_codes=no - fi - AC_MSG_RESULT([$result]) - fi - - if test "x$have_iso_codes" = "xyes"; then - AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix]) - AC_DEFINE([HAVE_ISO_CODES],[1],[Define if you have the iso-codes package]) - else - AC_MSG_ERROR([iso-codes is required for spellchecking. Use --disable-spell to build without spellchecking support.]) - fi - - enable_enchant=yes - ENCHANT_CFLAGS="${ENCHANT_CFLAGS}" - ENCHANT_LIBS="${ENCHANT_LIBS}" - AC_DEFINE([HAVE_ENCHANT],[1],[Define if you have libenchant]) - else - AC_MSG_ERROR([Enchant library not found or too old. Use --disable-spell to build without spellchecking support.]) - fi +if test "x$enable_spell" != "xno"; then + PKG_CHECK_MODULES(ENCHANT, + [ + enchant >= $ENCHANT_REQUIRED, + iso-codes >= $ISO_CODES_REQUIRED + ], have_enchant="yes", have_enchant="no") + + if test "x$have_enchant" = "xyes"; then + AC_MSG_CHECKING([whether iso-codes has iso-639 and iso-3166 domains]) + if $PKG_CONFIG --variable=domains iso-codes | grep 639 > /dev/null && \ + $PKG_CONFIG --variable=domains iso-codes | grep 3166 > /dev/null ; then + AC_DEFINE_UNQUOTED(ISO_CODES_PREFIX, ["`$PKG_CONFIG --variable=prefix iso-codes`"], [ISO codes prefix]) + AC_DEFINE(HAVE_ENCHANT, 1, [Define if you have libenchant]) + result=yes + else + result=no + have_enchant="no" + fi + AC_MSG_RESULT([$result]) + fi else - enable_enchant=no - ENCHANT_CFLAGS= - ENCHANT_LIBS= + have_enchant=no fi -AC_SUBST(ENCHANT_CFLAGS) -AC_SUBST(ENCHANT_LIBS) +if test "x$enable_spell" = "xyes" -a "x$have_enchant" != "xyes"; then + AC_MSG_ERROR([Couldn't find spell dependencies.]) +fi +AM_CONDITIONAL(HAVE_ENCHANT, test "x$have_enchant" = "xyes") # ----------------------------------------------------------- # Megaphone diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index c4f07cf74..30dfce43f 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -3,6 +3,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -DDATADIR=\""$(datadir)"\" \ $(EMPATHY_CFLAGS) \ + $(ENCHANT_CFLAGS) \ $(WARN_CFLAGS) BUILT_SOURCES = \ @@ -54,6 +55,7 @@ nodist_libempathy_gtk_la_SOURCES =\ libempathy_gtk_la_LIBADD = \ $(EMPATHY_LIBS) \ + $(ENCHANT_LIBS) \ $(top_builddir)/libempathy/libempathy.la libempathy_gtk_la_LDFLAGS = \ diff --git a/libempathy-gtk/empathy-spell.c b/libempathy-gtk/empathy-spell.c index 345dd79ee..422dcfb10 100644 --- a/libempathy-gtk/empathy-spell.c +++ b/libempathy-gtk/empathy-spell.c @@ -232,8 +232,8 @@ spell_setup_languages (void) } } -const char * -empathy_spell_get_language_name (const char *code) +const gchar * +empathy_spell_get_language_name (const gchar *code) { const gchar *name; @@ -252,14 +252,14 @@ empathy_spell_get_language_name (const char *code) } static void -enumerate_dicts (const char * const lang_tag, - const char * const provider_name, - const char * const provider_desc, - const char * const provider_file, - void * user_data) +enumerate_dicts (const gchar * const lang_tag, + const gchar * const provider_name, + const gchar * const provider_desc, + const gchar * const provider_file, + gpointer user_data) { GList **list = user_data; - char *lang = g_strdup(lang_tag); + gchar *lang = g_strdup (lang_tag); if (strchr (lang, '_')) { /* cut country part out of language */ @@ -272,10 +272,9 @@ enumerate_dicts (const char * const lang_tag, return; } - *list = g_list_append (*list, g_strdup(lang)); + *list = g_list_append (*list, g_strdup (lang)); } - GList * empathy_spell_get_language_codes (void) { @@ -299,7 +298,7 @@ empathy_spell_free_language_codes (GList *codes) gboolean empathy_spell_check (const gchar *word) { - int enchant_result = 1; + gint enchant_result = 1; const gchar *p; gboolean digit; gunichar c; @@ -346,7 +345,7 @@ empathy_spell_check (const gchar *word) GList * empathy_spell_get_suggestions (const gchar *word) { - gint len; + gint len; GList *l1; GList *suggestion_list = NULL; @@ -358,20 +357,22 @@ empathy_spell_get_suggestions (const gchar *word) for (l1 = languages; l1; l1 = l1->next) { SpellLanguage *lang; - char **suggestions; - size_t i, number_of_suggestions; + gchar **suggestions; + gsize i, number_of_suggestions; lang = l1->data; suggestions = enchant_dict_suggest (lang->speller, word, len, - &number_of_suggestions); + &number_of_suggestions); for (i = 0; i < number_of_suggestions; i++) { suggestion_list = g_list_append (suggestion_list, - g_strdup(suggestions[i])); + g_strdup (suggestions[i])); } - enchant_dict_free_string_list (lang->speller, suggestions); + if (suggestions) { + enchant_dict_free_string_list (lang->speller, suggestions); + } } return suggestion_list; @@ -412,8 +413,8 @@ empathy_spell_check (const gchar *word) return TRUE; } -const char * -empathy_spell_get_language_name (const char *lang) +const gchar * +empathy_spell_get_language_name (const gchar *lang) { empathy_debug (DEBUG_DOMAIN, "Support disabled, could not get language name"); |