Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

gtkspell.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define GTKSPELL_VERSION   "0.3.1"

Functions

int gtkspell_start (char *path, char *args[])
void gtkspell_stop ()
int gtkspell_running ()
void gtkspell_attach (GtkText *text)
void gtkspell_detach (GtkText *gtktext)
void gtkspell_check_all (GtkText *gtktext)
void gtkspell_uncheck_all (GtkText *gtktext)


Define Documentation

#define GTKSPELL_VERSION   "0.3.1"
 

Definition at line 23 of file gtkspell.h.


Function Documentation

void gtkspell_attach GtkText *    text
 

Definition at line 590 of file gtkspell.c.

References button_press_intercept_cb(), entry_delete_cb(), and entry_insert_cb().

Referenced by eb_chat_window_new().

00590                                        {
00591     gtk_signal_connect(GTK_OBJECT(gtktext), "insert-text",
00592         GTK_SIGNAL_FUNC(entry_insert_cb), NULL);
00593     gtk_signal_connect_after(GTK_OBJECT(gtktext), "delete-text",
00594         GTK_SIGNAL_FUNC(entry_delete_cb), NULL);
00595     gtk_signal_connect(GTK_OBJECT(gtktext), "button-press-event",
00596             GTK_SIGNAL_FUNC(button_press_intercept_cb), NULL);
00597 }

void gtkspell_check_all GtkText *    gtktext
 

Definition at line 367 of file gtkspell.c.

References check_at(), gtkspell_running(), and iswordsep().

00367                                           {
00368     guint origpos;
00369     guint pos = 0;
00370     guint len;
00371     float adj_value;
00372     
00373     if (!gtkspell_running()) return;
00374     
00375     len = gtk_text_get_length(gtktext);
00376 
00377     adj_value = gtktext->vadj->value;
00378     gtk_text_freeze(gtktext);
00379     origpos = gtk_editable_get_position(GTK_EDITABLE(gtktext));
00380     while (pos < len) {
00381         while (pos < len && iswordsep(GTK_TEXT_INDEX(gtktext, pos)))
00382             pos++;
00383         while (pos < len && !iswordsep(GTK_TEXT_INDEX(gtktext, pos)))
00384             pos++;
00385         if (pos > 0)
00386             check_at(gtktext, pos-1);
00387     }
00388     gtk_text_thaw(gtktext);
00389     gtk_editable_set_position(GTK_EDITABLE(gtktext), origpos);
00390 }

void gtkspell_detach GtkText *    gtktext
 

Definition at line 599 of file gtkspell.c.

References button_press_intercept_cb(), entry_delete_cb(), entry_insert_cb(), and gtkspell_uncheck_all().

00599                                        {
00600     gtk_signal_disconnect_by_func(GTK_OBJECT(gtktext),
00601         GTK_SIGNAL_FUNC(entry_insert_cb), NULL);
00602     gtk_signal_disconnect_by_func(GTK_OBJECT(gtktext),
00603         GTK_SIGNAL_FUNC(entry_delete_cb), NULL);
00604     gtk_signal_disconnect_by_func(GTK_OBJECT(gtktext), 
00605             GTK_SIGNAL_FUNC(button_press_intercept_cb), NULL);
00606 
00607     gtkspell_uncheck_all(gtktext);
00608 }

int gtkspell_running  
 

Definition at line 63 of file gtkspell.c.

References spell_pid.

Referenced by button_press_intercept_cb(), destroy(), eb_chat_window_new(), entry_delete_cb(), entry_insert_cb(), gtkspell_check_all(), gtkspell_start(), gtkspell_stop(), and sigchld().

00063                        {
00064     return (spell_pid > 0);
00065 }

int gtkspell_start char *    path,
char *    args[]
 

Definition at line 127 of file gtkspell.c.

References BUFSIZE, error_print(), fd_read, fd_write, gtkspell_running(), gtkspell_stop(), readline(), set_up_signal(), signal_set_up, spell_pid, and writetext().

Referenced by eb_chat_window_new().

00127                                               {
00128 #ifndef __MINGW32__
00129     int fd_error[2];
00130     char buf[BUFSIZE];
00131 
00132     if (gtkspell_running()) {
00133         error_print("gtkspell_start called while already running.\n");
00134         gtkspell_stop();
00135     }
00136 
00137     if (!signal_set_up) {
00138         set_up_signal();
00139         signal_set_up = 1;
00140     }
00141 
00142     pipe(fd_write);
00143     pipe(fd_read);
00144     pipe(fd_error);
00145 
00146     spell_pid = fork();
00147     if (spell_pid < 0) {
00148         error_print("fork: %s\n", strerror(errno));
00149         return -1;
00150     } else if (spell_pid == 0) {
00151         dup2(fd_write[0], 0);
00152         dup2(fd_read[1], 1);
00153         dup2(fd_error[1], 2);
00154         close(fd_read[0]);
00155         close(fd_error[0]);
00156         close(fd_write[1]);
00157 
00158         if (path == NULL) {
00159             if (execvp(args[0], args) < 0) 
00160                 error_print("execvp('%s'): %s\n", args[0], strerror(errno));
00161         } else {
00162             if (execv(path, args) < 0) 
00163                 error_print("execv('%s'): %s\n", path, strerror(errno));
00164         }
00165         /* if we get here, we failed.
00166          * send some text on the pipe to indicate status.
00167          */
00168         write(fd_read[1], "!", 1);
00169 
00170         _exit(0);
00171     } else {
00172         /* there are at least two ways to fail:
00173          * - the exec() can fail
00174          * - the exec() can succeed, but the program can dump the help screen
00175          * we must check for both.
00176          */
00177 
00178         #if HAVE_POLL_H
00179         struct pollfd fds[2];
00180 
00181         fds[0].fd = fd_error[0];
00182         fds[0].events = POLLIN | POLLERR;
00183         fds[1].fd = fd_read[0];
00184         fds[1].events = POLLIN | POLLERR;
00185         if (poll(fds, 2, 2000) <= 0) {
00186             /* FIXME: is this needed? */
00187             error_print("Timed out waiting for spell command.\n");
00188             gtkspell_stop();
00189             return -1;
00190         }
00191         
00192 
00193         if (fds[0].revents) { /* stderr readable? */
00194             error_print("Spell command printed on stderr -- probably failed.\n");
00195             gtkspell_stop();
00196             return -1;
00197         }
00198         
00199         #endif
00200         
00201         readline(buf);
00202         /* ispell should print something like this:
00203          * @(#) International Ispell Version 3.1.20 10/10/95
00204          * if it doesn't, it's an error. */
00205         if (buf[0] != '@') {
00206             gtkspell_stop();
00207             return -1;
00208         }
00209     }
00210 
00211     /* put ispell into terse mode.  
00212      * this makes it not respond on correctly spelled words. */
00213     sprintf(buf, "!\n");
00214     writetext(buf);
00215 #endif
00216     return 0;
00217 }

void gtkspell_stop  
 

Definition at line 118 of file gtkspell.c.

References gtkspell_running(), and spell_pid.

Referenced by destroy(), and gtkspell_start().

00118                      {
00119 #ifndef __MINGW32__
00120     if (gtkspell_running()) {
00121         kill(spell_pid, SIGQUIT); /* FIXME: is this the correct signal? */
00122         spell_pid = -1;
00123     }
00124 #endif
00125 }

void gtkspell_uncheck_all GtkText *    gtktext
 

Definition at line 572 of file gtkspell.c.

Referenced by gtkspell_detach().

00572                                             {
00573     int origpos;
00574     char *text;
00575     float adj_value;
00576 
00577     adj_value = gtktext->vadj->value;
00578     gtk_text_freeze(gtktext);
00579     origpos = gtk_editable_get_position(GTK_EDITABLE(gtktext));
00580     text = gtk_editable_get_chars(GTK_EDITABLE(gtktext), 0, -1);
00581     gtk_text_set_point(gtktext, 0);
00582     gtk_text_forward_delete(gtktext, gtk_text_get_length(gtktext));
00583     gtk_text_insert(gtktext, NULL, NULL, NULL, text, strlen(text));
00584     gtk_text_thaw(gtktext);
00585 
00586     gtk_editable_set_position(GTK_EDITABLE(gtktext), origpos);
00587     gtk_adjustment_set_value(gtktext->vadj, adj_value);
00588 }


Contact: Andy Maloney     [Documentation generated by doxygen]