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