fixed bug about foreground color used by the spell checker.
[claws.git] / src / gtkspell.h
1 /*
2     Stuphead: (C) 2000,2001 Grigroy Bakunov, Sergey Pinaev
3  */
4 /* gtkpspell - a spell-checking addon for GtkText
5  * Copyright (c) 2000 Evan Martin.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  * 
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
20  */
21
22 /*
23  * Adapted by the Sylpheed Claws Team.
24  */
25
26 /*
27  *  Adapted for pspell (c) 2001 Melvin Hadasht
28  *
29  */
30
31  /* first a pspell config must be created (at the beginning of the app)
32  with 
33  GtkPspellConfig gtkpspellconfig = gtkpspell_init();
34  then for each document use this to create a manager
35  GtkPspell = gtkpspell_new(GtkPspellConfig *gtkpspellconfig);
36  Now, path and dict can be set
37  gtkpspell_set_path_and_dict(GtkPspell *gtkpspell, guchar * path, guchar * dict);
38  then attach this to a gtktext widget :
39  gtkpspell_attach(GtkPspell *gtkpspell, GtkXText *gtkxtext);
40  and we can also detach :
41  gtkpspell_deattach(GtkPspell *gtkpspell, GtkXText *gtkxtext);
42  When finished, GtkPspell can be deleted with
43  gtkpspell_delete(GtkPspell * gtkpspell);
44  At the end of the app, GtkPspellConfig should be deleted with :
45  gtkpspell_finished(GtkPspellConfig * gtkpspellconfig);
46 */ 
47
48 #ifndef __gtkpspell_h__
49 #define __gtkpspell_h__
50
51 #include "gtkxtext.h"
52 #include <pspell/pspell.h>
53
54 #define PSPELL_FASTMODE       1
55 #define PSPELL_NORMALMODE     2
56 #define PSPELL_BADSPELLERMODE 3
57
58 typedef struct _Dictionary {
59         gchar *name;
60 } Dictionary;
61
62 typedef struct _GtkPspell 
63 {
64         PspellConfig * config;
65         PspellCanHaveError * possible_err ;
66         PspellManager * checker;
67         gchar theword[1111];
68         gchar *path;
69         gchar *dict;
70         guint mode;
71         guint learn;
72         guint orig_pos;
73
74         GdkColor highlight;
75              
76         GSList * dictionary_list;
77         GtkXText * gtktext;
78
79 } GtkPspell;
80
81 typedef PspellConfig GtkPspellConfig;
82
83 /* Create a new gtkspell instance to manage one text widget */
84
85 /* These one create and delete a pspell config */
86 GtkPspellConfig *gtkpspell_init();
87 void gtkpspell_finished(GtkPspellConfig * gtkpspellconfig);
88
89 /* These ones create and delete a manager*/
90 GtkPspell *gtkpspell_new(GtkPspellConfig * config);
91
92 GtkPspell *gtkpspell_new_with_config(GtkPspellConfig *gtkpspellconfig, 
93                                      guchar *path, 
94                                      guchar *dict, 
95                                      guint mode, 
96                                      const guchar *encoding);
97 GtkPspell *gtkpspell_delete(GtkPspell *gtkpspell);
98
99 int gtkpspell_set_path_and_dict(GtkPspell *gtkpspell, guchar * path,
100                                 guchar * dict);
101 guchar *gtkpspell_get_dict(GtkPspell *gtkpspell);
102
103 guchar *gtkpspell_get_path(GtkPspell *gtkpspell);
104
105 /* This sets suggestion mode "fast" "normal" "bad-spellers" */
106 /* and resets the dict & path (which should be set first)  */
107 /* return 0 on failure and -1 on success */
108 int gtkpspell_set_sug_mode(GtkPspell * gtkpspell, gchar * themode);
109
110 void gtkpspell_attach(GtkPspell *gtkpspell, GtkXText *text_ccc);
111
112 void gtkpspell_detach(GtkPspell *gtkpspell);
113
114 void gtkpspell_check_all(GtkPspell *gtkpspell);
115
116 void gtkpspell_uncheck_all(GtkPspell *gtkpspell);
117
118 GSList *gtkpspell_get_dictionary_list(const char *pspell_path);
119
120 void gtkpspell_free_dictionary_list(GSList *list);
121
122 GtkWidget *gtkpspell_dictionary_option_menu_new(const gchar *pspell_path);
123 gchar *gtkpspell_get_dictionary_menu_active_item(GtkWidget *menu);
124
125 extern GtkPspellConfig * gtkpspellconfig;
126
127 #endif /* __gtkpspell_h__ */