switched to pspell and dropped ispell support
[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      
72      GSList * dictionary_list;
73      GtkXText * gtktext;
74
75 } GtkPspell;
76
77 typedef PspellConfig GtkPspellConfig;
78 /* Create a new gtkspell instance to manage one text widget */
79
80 /* These one create and delete a pspell config */
81 GtkPspellConfig * gtkpspell_init();
82 void gtkpspell_finished(GtkPspellConfig * gtkpspellconfig);
83
84 /* These ones create and delete a manager*/
85 GtkPspell * gtkpspell_new(GtkPspellConfig * config);
86
87 GtkPspell *gtkpspell_new_with_config(GtkPspellConfig *gtkpspellconfig, 
88                                      guchar *path, 
89                                      guchar *dict, 
90                                      guint mode, 
91                                      guchar *encoding);
92 GtkPspell * gtkpspell_delete(GtkPspell *gtkpspell);
93
94 int gtkpspell_set_path_and_dict(GtkPspell *gtkpspell, guchar * path,
95                                 guchar * dict);
96 guchar * gtkpspell_get_dict(GtkPspell *gtkpspell);
97
98 guchar * gtkpspell_get_path(GtkPspell *gtkpspell);
99
100 /* This sets suggestion mode "fast" "normal" "bad-spellers" */
101 /* and resets the dict & path (which should be set first)  */
102 /* return 0 on failure and -1 on success */
103 int gtkpspell_set_sug_mode(GtkPspell * gtkpspell, gchar * themode);
104
105 void gtkpspell_attach(GtkPspell *gtkpspell, GtkXText *text_ccc);
106
107 void gtkpspell_detach(GtkPspell *gtkpspell);
108
109 void gtkpspell_check_all(GtkPspell *gtkpspell);
110
111 void gtkpspell_uncheck_all(GtkPspell *gtkpspell);
112
113 GSList *gtkpspell_get_dictionary_list(const char *pspell_path);
114
115 void gtkpspell_free_dictionary_list(GSList *list);
116
117 GtkWidget *gtkpspell_dictionary_option_menu_new(const gchar *pspell_path);
118 gchar *gtkpspell_get_dictionary_menu_active_item(GtkWidget *menu);
119
120 extern GtkPspellConfig * gtkpspellconfig;
121
122 #endif /* __gtkpspell_h__ */