sync with sylpheed 0.7.2cvs21
[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) 2001-2002 Melvin Hadasht
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-2002 Melvin Hadasht
28  *
29  */
30
31 #ifndef __gtkpspell_h__
32 #define __gtkpspell_h__
33
34 #include "gtkstext.h"
35
36 #include <gtk/gtkoptionmenu.h>
37 #include <pspell/pspell.h>
38
39 #define PSPELL_FASTMODE       1
40 #define PSPELL_NORMALMODE     2
41 #define PSPELL_BADSPELLERMODE 3
42
43 typedef struct _GtkPspellCheckers {
44         GSList          *checkers;
45         GSList          *dictionary_list;
46         gchar           *error_message;
47 } GtkPspellCheckers;
48
49 typedef struct _Dictionary {
50         gchar           *fullname;
51         gchar           *dictname; /* dictname points into fullname */
52         gchar           *encoding;
53 } Dictionary;
54
55 typedef struct _GtkPspeller {
56         Dictionary *    dictionary;
57         gint            sug_mode;
58         gint            ispell;
59         PspellConfig  * config;
60         PspellManager * checker;
61 } GtkPspeller;
62
63 typedef void (*ContCheckFunc)   (gpointer *gtkpspell);
64
65 #define GTKPSPELLWORDSIZE 1024
66 typedef struct _GtkPspell {
67         GtkPspeller     *gtkpspeller;
68         GtkPspeller     *alternate_speller;
69         gchar            theword[GTKPSPELLWORDSIZE];
70         gint             start_pos;
71         gint             end_pos;
72         gint             orig_pos;
73         gint             end_check_pos;
74         gboolean         misspelled;
75         gboolean         check_while_typing;
76         gboolean         use_alternate;
77
78         ContCheckFunc    continue_check; 
79 #if 0
80         Dictionary      *dict1;
81         Dictionary      *dict2;
82
83         GtkWidget       *gui;
84         gpointer        *compose;
85 #endif
86         GtkWidget       *config_menu;
87         GtkWidget       *popup_config_menu;
88         GtkWidget       *sug_menu;
89         GtkWidget       *replace_entry;
90
91         gint             default_sug_mode;
92         gint             max_sug;
93         GList           *suggestions_list;
94
95         GtkSText        *gtktext;
96         GdkColor         highlight;
97 } GtkPspell;
98
99 typedef PspellConfig GtkPspellConfig;
100
101 extern GtkPspellCheckers *gtkpspellcheckers;
102
103 GtkPspellCheckers*      gtkpspell_checkers_new          ();
104
105 GtkPspellCheckers*      gtkpspell_checkers_delete       ();
106
107 void                    gtkpspell_checkers_reset_error  ();
108
109 GtkPspell*              gtkpspell_new                   (const gchar *dictionary, 
110                                                          const gchar *encoding,
111                                                          gint  misspelled_color,
112                                                          gboolean check_while_typing,  
113                                                          gboolean use_alternate,  
114                                                          GtkSText *gtktext);
115
116 void                    gtkpspell_delete                (GtkPspell *gtkpspell); 
117
118 guchar*                 gtkpspell_get_dict              (GtkPspell *gtkpspell);
119
120 guchar*                 gtkpspell_get_path              (GtkPspell *gtkpspell);
121
122 gboolean                gtkpspell_set_sug_mode          (GtkPspell *gtkpspell, 
123                                                          gint  themode);
124
125 GSList*                 gtkpspell_get_dictionary_list   (const char *pspell_path,
126                                                          gint refresh);
127
128 void                    gtkpspell_free_dictionary_list  (GSList *list);
129
130 void                    gtkpspell_check_forwards_go     (GtkPspell *gtkpspell);
131 void                    gtkpspell_check_backwards       (GtkPspell *gtkpspell);
132
133 void                    gtkpspell_check_all             (GtkPspell *gtkpspell);
134 void                    gtkpspell_uncheck_all           (GtkPspell *gtkpspell);
135 void                    gtkpspell_highlight_all         (GtkPspell *gtkpspell);
136
137 void                    gtkpspell_populate_submenu      (GtkPspell *gtkpspell, 
138                                                          GtkWidget *menuitem);
139
140 GtkWidget*              gtkpspell_dictionary_option_menu_new
141                                                         (const gchar *pspell_path);
142 gchar*                  gtkpspell_get_dictionary_menu_active_item
143                                                         (GtkWidget *menu);
144
145 GtkWidget*              gtkpspell_sugmode_option_menu_new
146                                                         (gint sugmode);
147
148 void                    gtkpspell_sugmode_option_menu_set
149                                                         (GtkOptionMenu *optmenu, 
150                                                          gint sugmode);
151
152 gint                    gtkpspell_get_sugmode_from_option_menu  
153                                                         (GtkOptionMenu *optmenu);
154
155 #endif /* __gtkpspell_h__ */