? aspell.patch
? gnome_spell.patch
? mkinstalldirs
? protocols/Makefile
? protocols/Makefile.in
? src/Spell-common.c
? src/Spell-skels.c
? src/Spell-stubs.c
? src/Spell.h
? src/Spell.idl
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gossip/ChangeLog,v
retrieving revision 1.394
diff -u -b -B -p -r1.394 ChangeLog
--- ChangeLog	28 Sep 2004 18:55:47 -0000	1.394
+++ ChangeLog	19 Oct 2004 20:06:23 -0000
@@ -1,3 +1,11 @@
+2004-10-19  Martyn Russell  <mr@gnome.org>
+
+	* configure.in: 
+	- Added checks for aspell, Gossip does not depend on it.
+	* src/gossip-chat.c:
+	- Added code to call up aspell library and check words typed
+	before sending messages. 
+
 2004-09-28  Abel Cheung  <maddog@linuxhall.org>
 
 	* configure.in: Added "tr" to ALL_LINGUAS.
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gossip/configure.in,v
retrieving revision 1.71
diff -u -b -B -p -r1.71 configure.in
--- configure.in	28 Sep 2004 18:55:47 -0000	1.71
+++ configure.in	19 Oct 2004 20:06:24 -0000
@@ -155,6 +155,31 @@ fi
 AC_DEFINE_UNQUOTED(GOSSIP_LOCALEDIR, "$GOSSIP_LOCALEDIR",[locale directory])
 dnl -----------------------------------------------------------
 
+
+dnl -----------------------------------------------------------
+dnl Pango Version (used for highlighting spelling errors) 
+dnl -----------------------------------------------------------
+PKG_CHECK_MODULES(PANGO, [pango >= 1.3.5],
+   [AC_DEFINE(HAVE_PANGO_UNDERLINE_ERROR, 1, [Define to 1 if PANGO_UNDERLINE_ERROR is available.])],
+   [AC_MSG_WARN([Disabling new error underlining since pango < 1.3.5])])           
+dnl -----------------------------------------------------------
+
+
+dnl -----------------------------------------------------------
+dnl ASpell
+dnl -----------------------------------------------------------
+
+AC_CHECK_LIB(aspell, aspell_speller_check,have_aspell=yes,have_aspell=no,)
+
+if test "x$have_aspell" = "xyes"; then
+  AC_DEFINE(HAVE_ASPELL, 1, [Define if we have aspell])
+
+  GOSSIP_LIBS="$GOSSIP_LIBS -laspell"
+fi
+
+dnl -----------------------------------------------------------
+
+
 CFLAGS="$CFLAGS $WARN_CFLAGS"
 
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
@@ -172,4 +197,5 @@ po/Makefile.in
 echo
 echo "Gossip prefix: $prefix"
 echo "D-BUS        : $have_dbus"
+echo "ASpell       : $have_aspell"
 echo
Index: src/gossip-chat.c
===================================================================
RCS file: /cvs/gnome/gossip/src/gossip-chat.c,v
retrieving revision 1.90
diff -u -b -B -p -r1.90 gossip-chat.c
--- src/gossip-chat.c	16 Sep 2004 14:18:34 -0000	1.90
+++ src/gossip-chat.c	19 Oct 2004 20:06:24 -0000
@@ -19,12 +19,21 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <string.h>
+#include <stdlib.h>
 #include <config.h>
 #include <gtk/gtk.h>
 #include "gossip-chat.h"
 #include "gossip-marshal.h"
 #include "gossip-chat-window.h"
 
+#ifdef HAVE_ASPELL
+#include <aspell.h>
+#endif
+
+#define d(x) x
+
+
 struct _GossipChatPriv {
 	GossipChatWindow *window;
 
@@ -33,6 +42,15 @@ struct _GossipChatPriv {
 	gint              padding_height;
 	gint              default_window_height;
 	gint              last_input_height;
+
+#ifdef HAVE_ASPELL
+	/* aspell */
+	AspellConfig       *spell_config;
+	AspellCanHaveError *spell_possible_err;
+        AspellSpeller      *spell_checker;
+
+	gboolean            using_aspell;
+#endif
 };
 
 static void     chat_class_init                   (GossipChatClass *klass);
@@ -139,6 +157,8 @@ chat_init (GossipChat *chat)
 	GossipChatPriv *priv;
 	GtkTextBuffer  *buffer;
 
+	const gchar    *lang = NULL;
+
 	chat->view = gossip_chat_view_new ();
 	chat->input_text_view = gtk_text_view_new ();
 	chat->is_first_char = TRUE;
@@ -169,6 +189,36 @@ chat_init (GossipChat *chat)
 			  chat);
 
 	gossip_chat_view_set_margin (chat->view, 3);
+
+	/* create misspelt words identification tag */
+	gtk_text_buffer_create_tag (buffer,
+				    "misspelled",
+#ifdef HAVE_PANGO_UNDERLINE_ERROR
+				    "underline", PANGO_UNDERLINE_ERROR,
+#else
+				    "foreground", "red", 
+				    "underline", PANGO_UNDERLINE_SINGLE,
+#endif
+				    NULL);
+
+#ifdef HAVE_ASPELL
+	priv->spell_config = new_aspell_config();
+
+	lang = getenv ("LANG");
+
+	if (!lang) {
+		lang = "en_US";
+	}
+
+	aspell_config_replace (priv->spell_config, "lang", lang);
+	
+	priv->spell_possible_err = new_aspell_speller (priv->spell_config);
+
+	if (aspell_error_number (priv->spell_possible_err) == 0) {
+		priv->spell_checker = to_aspell_speller (priv->spell_possible_err);
+		priv->using_aspell = TRUE;
+	}
+#endif
 }
 
 static void
@@ -182,6 +232,9 @@ chat_finalize (GObject *object)
 	chat = GOSSIP_CHAT (object);
 	priv = chat->priv;
 
+	/* aspell */
+	priv->using_aspell = FALSE;
+
 	g_free (priv);
 
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -193,6 +246,9 @@ chat_input_text_buffer_changed_cb (GtkTe
 {
 	GossipChatPriv *priv;
 
+	GtkTextIter     start, end;
+	gchar          *str;
+
 	priv = chat->priv;
 
 	if (chat->is_first_char) {
@@ -215,6 +271,51 @@ chat_input_text_buffer_changed_cb (GtkTe
 		priv->padding_height = window_height - req.height - allocation->height;
 
 		chat->is_first_char = FALSE;
+	}
+
+	gtk_text_buffer_get_start_iter (buffer, &start);
+	
+	/* NOTE: this is really inefficient, we shouldn't have to
+	   reiterate the whole buffer each time and check each work
+	   every time. */
+	while (priv->using_aspell) {
+		gboolean correct = FALSE;
+
+		/* if at start */
+		if (gtk_text_iter_is_start (&start)) {
+			end = start;
+
+			if (!gtk_text_iter_forward_word_end (&end)) {
+				/* no whole word yet */
+				break;
+			}
+		} else {
+			if (!gtk_text_iter_forward_word_end (&end)) {
+				/* must be the end of the buffer */
+				break;
+			}
+
+			start = end; 
+			gtk_text_iter_backward_word_start (&start);
+		}
+	
+		str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
+#ifdef HAVE_ASPELL	
+		/* spell check string */
+		correct = aspell_speller_check (priv->spell_checker, str, strlen (str));
+#endif
+
+		if (!correct) {
+			gtk_text_buffer_apply_tag_by_name (buffer, "misspelled", &start, &end);
+		} else {
+			gtk_text_buffer_remove_tag_by_name (buffer, "misspelled", &start, &end);
+		}
+
+		g_free (str);
+
+		/* set start iter to the end iters position */
+		start = end; 
 	}
 }
 
