re-add Colin's attach pasted files commit, with the necessary fix
[claws.git] / src / gtk / gtkaspell.h
1 /*
2     Stuphead: (C) 2000,2001 Grigroy Bakunov, Sergey Pinaev
3  */
4 /* gtkaspell - 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 3 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, see <http://www.gnu.org/licenses/>.
19  */
20
21 /*
22  * Adapted by the Claws Mail Team.
23  */
24
25 /*
26  *  Adapted for pspell (c) 2001-2002 Melvin Hadasht
27  *  Adapted for GNU/aspell (c) 2002 Melvin Hadasht
28  *
29  */
30
31 #ifndef __GTKENCHANT_H__
32 #define __GTKENCHANT_H__
33
34 #ifdef HAVE_CONFIG_H
35 #include "claws-features.h"
36 #endif
37
38 #ifdef USE_ENCHANT
39
40 #include <gtk/gtk.h>
41 #include <enchant.h>
42
43 #define GTKASPELLWORDSIZE 1024
44
45 typedef struct _Dictionary {
46         gchar *fullname;
47         gchar *dictname;
48 } Dictionary;
49
50 typedef struct _GtkAspeller {
51         Dictionary      *dictionary;
52         EnchantBroker   *broker;
53         EnchantDict     *speller;
54 } GtkAspeller;
55
56 typedef void (*ContCheckFunc) (gpointer *gtkaspell);
57
58 struct _WidgetContext
59 {
60         void            (*set_position)(gpointer data, gint pos);
61         void            (*set_menu_pos)(GtkMenu *menu, gint *x, gint *y,
62                                 gboolean *push_in, gpointer user_data);
63         gboolean        (*find_misspelled)(gpointer data, gboolean forward);
64         gboolean        (*check_word)(gpointer data);
65         void            (*replace_word)(gpointer data, const gchar *newword);
66         gpointer        *data; 
67 };
68
69 typedef struct _WidgetContext WidgetContext;
70
71 struct _GtkAspell
72 {
73         GtkAspeller     *gtkaspeller;
74         GtkAspeller     *alternate_speller;
75         gchar            theword[GTKASPELLWORDSIZE];
76         gint             start_pos;
77         gint             end_pos;
78         gint             orig_pos;
79         gint             end_check_pos;
80         gboolean         misspelled;
81         gboolean         check_while_typing;
82         gboolean         recheck_when_changing_dict;
83         gboolean         use_alternate;
84         gboolean         use_both_dicts;
85
86         ContCheckFunc    continue_check; 
87
88         GtkWidget       *replace_entry;
89         GtkWidget       *parent_window;
90
91         gint             max_sug;
92         GList           *suggestions_list;
93
94         GtkTextView     *gtktext;
95         GdkColor         highlight;
96         GtkAccelGroup   *accel_group;
97         void            (*dict_changed_cb)(void *data);
98         void            (*menu_changed_cb)(void *data);
99         void            *menu_changed_data;
100         
101         WidgetContext   ctx;
102 };
103
104 typedef struct _GtkAspell GtkAspell;
105
106
107 void            gtkaspell_checkers_init         (void);
108
109 void            gtkaspell_checkers_quit         (void);
110
111 const char *    gtkaspell_checkers_strerror     (void);
112
113 void            gtkaspell_checkers_reset_error  (void);
114
115 GtkAspell*      gtkaspell_new                   (const gchar *dictionary, 
116                                                  const gchar *alt_dictionary, 
117                                                  const gchar *encoding,
118                                                  gint  misspelled_color,
119                                                  gboolean check_while_typing,
120                                                  gboolean recheck_when_changing_dict,
121                                                  gboolean use_alternate,  
122                                                  gboolean use_both_dicts,  
123                                                  GtkTextView *gtktext,
124                                                  GtkWindow *parent_win,
125                                                  void (*dict_changed_cd)(void *data), 
126                                                  void (*spell_menu_cb)(void *data),
127                                                  void *data);
128
129 void            gtkaspell_delete                (GtkAspell *gtkaspell); 
130
131
132 gboolean        gtkaspell_change_dict           (GtkAspell *gtkaspell,
133                                                  const gchar* dictionary,
134                                                          gboolean always_set_alt_dict);
135
136 gboolean        gtkaspell_change_alt_dict       (GtkAspell *gtkaspell,
137                                                  const gchar* alt_dictionary);
138 void            gtkaspell_use_alternate_dict    (GtkAspell *gtkaspell);
139
140 gboolean        gtkaspell_check_next_prev       (GtkAspell *gtkaspell,
141                                                  gboolean forward);
142 void            gtkaspell_check_forwards_go     (GtkAspell *gtkaspell);
143 void            gtkaspell_check_backwards       (GtkAspell *gtkaspell);
144
145 void            gtkaspell_check_all             (GtkAspell *gtkaspell);
146 void            gtkaspell_highlight_all         (GtkAspell *gtkaspell);
147
148 GtkWidget*      gtkaspell_dictionary_combo_new  (const gboolean refresh);
149
150 GtkTreeModel*   gtkaspell_dictionary_store_new  (void);
151 GtkTreeModel*   gtkaspell_dictionary_store_new_with_refresh
152                                                         (gboolean     refresh);
153
154 gchar*          gtkaspell_get_dictionary_menu_active_item
155                                                         (GtkComboBox *combo);
156 gint            gtkaspell_set_dictionary_menu_active_item
157                                                         (GtkComboBox *combo, 
158                                                          const gchar *dictionary);
159
160 GSList*         gtkaspell_make_config_menu              (GtkAspell      *gtkaspell);
161
162 gchar*          gtkaspell_get_default_dictionary        (GtkAspell *gtkaspell);
163
164 void            gtkaspell_make_context_menu             (GtkMenu        *menu,
165                                                          GtkAspell      *gtkaspell);
166
167 int             gtkaspell_misspelled_test               (GtkAspell *gtkaspell,
168                                                          char *word);
169 void            gtkaspell_dict_changed                  (GtkAspell *gtkaspell);
170 void            gtkaspell_context_set                   (GtkAspell *gtkaspell);
171 void            gtkaspell_free_suggestions_list         (GtkAspell *gtkaspell);
172 void            gtkaspell_block_check                   (GtkAspell *gtkaspell);
173 void            gtkaspell_unblock_check                 (GtkAspell *gtkaspell);
174
175
176 #endif /* USE_ENCHANT */
177 #endif /* __GTKENCHANT_H__ */