pan-devel
[Top][All Lists]
Advanced

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

[Pan-devel] Spellcheck in news posts via gtkspell


From: Michael Alger
Subject: [Pan-devel] Spellcheck in news posts via gtkspell
Date: Thu, 4 Jul 2002 14:43:00 +0800
User-agent: Mutt/1.3.28i

In one of the newsgroups I inhabit, somebody commented that Pan doesn't
have any built-in spell checking ability.   I thought it might be a bit
of a challenge to implement it, so I had a go - and it turned out to be
disappointingly simple (read: trivial), using gtkspell.

For those who prefer to read diff's to see what was modified, see after
this part.  Summary: install gtkspell, make some minor changes, and you
are done.  This assumes you already have pspell available, I guess.

1. Download and install gtkspell; <http://gtkspell.sourceforge.net/>

This was just a ./configure && make && sudo make install job for me.

2. Add #include <gtkspell/gtkspell.h> to pan.c and message-window.c

This might need some tweaking;  when I installed it, gtkspell's headers
ended up in /usr/local/include/gtkspell-2.0/gtkspell.   This is what is
in the diff below, so watch for that.

3. Add a call to gtkspell_init() to main() in pan.c,  after the call to
   gtk_init().

4. Add a call to gtkspell_attach() after the GTK text view gets created
   in create_body_pane_nolock() in message-window.c.

5. Add -lgtkspell to the Makefile.   Obviously this needs to be done in
   the configure script,  but I'm not an autoconf guru so I just hacked
   the Makefile directly.

That's it.  Recompile and enjoy.

What's the likelihood of this being added to Pan in a later release?  I
know you try to keep the dependencies to a minimum,  but it could be of
use to many people.  Or at least, a few. :-)

You can see a screenshot of it here:

  <http://salsa.ii.net/~rapacity/stuff/pan-gtkspell.png>  [84 kb]

Finally, here's the diff:

-----------------------------------------------------------------------

diff -ru pan-0.12.0/pan/message-window.c 
pan-0.12.0-gtkspell/pan/message-window.c
--- pan-0.12.0/pan/message-window.c     Wed Jun 12 23:16:09 2002
+++ pan-0.12.0-gtkspell/pan/message-window.c    Thu Jul  4 13:14:58 2002
@@ -59,6 +59,8 @@
 
 #include <pan/xpm/pan-pixbufs.h>
 
+#include <gtkspell-2.0/gtkspell/gtkspell.h>
+
 /* #define ATTACHMENTS */
 
 typedef struct
@@ -2032,6 +2034,9 @@
        g_return_val_if_fail (mw!=NULL, NULL);
 
        mw->body_view = gtk_text_view_new ();
+
+       gtkspell_attach (GTK_TEXT_VIEW(mw->body_view));
+
        mw->body_buffer = buf = gtk_text_view_get_buffer 
(GTK_TEXT_VIEW(mw->body_view));
        gtk_text_buffer_create_tag (buf, "url", "underline", 
PANGO_UNDERLINE_SINGLE, "foreground_gdk", &text_url_color, NULL);
        gtk_text_buffer_create_tag (buf, "quote_0", "foreground_gdk", 
&text_fg_color, NULL);
diff -ru pan-0.12.0/pan/pan.c pan-0.12.0-gtkspell/pan/pan.c
--- pan-0.12.0/pan/pan.c        Fri May 31 04:15:03 2002
+++ pan-0.12.0-gtkspell/pan/pan.c       Thu Jul  4 11:47:19 2002
@@ -51,6 +51,8 @@
 #include <pan/thread-watch.h>
 #include <pan/util.h>
 
+#include <gtkspell-2.0/gtkspell/gtkspell.h>
+
 extern char *
 bind_textdomain_codeset (const char * domainname,
                          const char * codeset);
@@ -157,6 +159,10 @@
        g_thread_init (NULL);
        gdk_threads_init ();
        gtk_init (&argc, &argv);
+
+       if (gtkspell_init() < 0)
+               g_message ("gtkspell_init() failed!");
+
        g_mime_init (GMIME_INIT_FLAG_UTF8);
 
        /* parse arguments  */
-- 
Mike.  /* remove "-spam" to mail me */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]