empathy r1031 - in trunk: . libempathy-gtk



Author: xclaesse
Date: Tue Apr 22 10:18:11 2008
New Revision: 1031
URL: http://svn.gnome.org/viewvc/empathy?rev=1031&view=rev

Log:
Cleanup the spell code.


Modified:
   trunk/configure.ac
   trunk/libempathy-gtk/Makefile.am
   trunk/libempathy-gtk/empathy-spell.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Tue Apr 22 10:18:11 2008
@@ -32,6 +32,8 @@
 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 @@
 
 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

Modified: trunk/libempathy-gtk/Makefile.am
==============================================================================
--- trunk/libempathy-gtk/Makefile.am	(original)
+++ trunk/libempathy-gtk/Makefile.am	Tue Apr 22 10:18:11 2008
@@ -3,6 +3,7 @@
 	-I$(top_srcdir)                                 \
 	-DDATADIR=\""$(datadir)"\"              	\
 	$(EMPATHY_CFLAGS)				\
+	$(ENCHANT_CFLAGS)				\
 	$(WARN_CFLAGS)
 
 BUILT_SOURCES = 					\
@@ -54,6 +55,7 @@
 
 libempathy_gtk_la_LIBADD =			\
 	$(EMPATHY_LIBS)				\
+	$(ENCHANT_LIBS)				\
 	$(top_builddir)/libempathy/libempathy.la
 
 libempathy_gtk_la_LDFLAGS =                \

Modified: trunk/libempathy-gtk/empathy-spell.c
==============================================================================
--- trunk/libempathy-gtk/empathy-spell.c	(original)
+++ trunk/libempathy-gtk/empathy-spell.c	Tue Apr 22 10:18:11 2008
@@ -232,8 +232,8 @@
 	}
 }
 
-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 @@
 }
 
 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 @@
 		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 @@
 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 @@
 GList *
 empathy_spell_get_suggestions (const gchar *word)
 {
-	gint                     len;
+	gint   len;
 	GList *l1;
 	GList *suggestion_list = NULL;
 
@@ -358,20 +357,22 @@
 
 	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 @@
 	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");
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]