+2003-06-12 [melvin] 0.9.0claws29
+
+ * src/compose.c
+ Use new gtkaspell_checkers_strerror() to get the speller's
+ error message instead of accessing the (now private)
+ checkers structure.
+ Minor code clean up
+
+ * src/main.c
+ Use #ifdef instead of #if for USE_ASPELL
+ Use the new spell checkers init/quit functions
+
+ * src/gtk/gtkaspell.c
+ Use #ifdef instead of #if for USE_ASPELL
+ Moved in the majority of GtkAspell structures that were
+ exported before by gtkaspell.h
+
+ * src/gtk/gktaspell.h
+ Made gtkaspell.h contain only the necessary data to be
+ publicized by moving many structures to gtkaspell.c.
+ Enclosed all the declaration in a #ifdef USE_ASPELL #endif
+ gtkaspell_checkers_new(): replaced by...
+ gtkaspell_checkers_init(): new function for initialization
+ gtkaspell_checkers_delete(): replaced by...
+ gtkaspell_checkers_quit(): new function
+ gtkaspell_checkers_strerror(): new function that returns
+ the checker's last error message.
+
2003-06-11 [melvin] 0.9.0claws28
* po/POTFILES.in
# include "config.h"
#endif
-#if USE_ASPELL
+#ifdef USE_ASPELL
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtkmenuitem.h>
#include <gdk/gdkkeysyms.h>
+#include <aspell.h>
+
#include "intl.h"
#include "gtkstext.h"
#include "utils.h"
+
#include "gtkaspell.h"
+#define ASPELL_FASTMODE 1
+#define ASPELL_NORMALMODE 2
+#define ASPELL_BADSPELLERMODE 3
+
+#define GTKASPELLWORDSIZE 1024
/* size of the text buffer used in various word-processing routines. */
#define BUFSIZE 1024
RETURN_FALSE_IF_CONFIG_ERROR(); \
}
+typedef struct _GtkAspellCheckers {
+ GSList *checkers;
+ GSList *dictionary_list;
+ gchar *error_message;
+} GtkAspellCheckers;
+
+typedef struct _Dictionary {
+ gchar *fullname;
+ gchar *dictname;
+ gchar *encoding;
+} Dictionary;
+
+typedef struct _GtkAspeller {
+ Dictionary *dictionary;
+ gint sug_mode;
+ AspellConfig *config;
+ AspellSpeller *checker;
+} GtkAspeller;
+
+typedef void (*ContCheckFunc) (gpointer *gtkaspell);
+
+struct _GtkAspell
+{
+ GtkAspeller *gtkaspeller;
+ GtkAspeller *alternate_speller;
+ gchar *dictionary_path;
+ gchar theword[GTKASPELLWORDSIZE];
+ gint start_pos;
+ gint end_pos;
+ gint orig_pos;
+ gint end_check_pos;
+ gboolean misspelled;
+ gboolean check_while_typing;
+ gboolean use_alternate;
+
+ ContCheckFunc continue_check;
+
+ GtkWidget *config_menu;
+ GtkWidget *popup_config_menu;
+ GtkWidget *sug_menu;
+ GtkWidget *replace_entry;
+
+ gint default_sug_mode;
+ gint max_sug;
+ GList *suggestions_list;
+
+ GtkSText *gtktext;
+ GdkColor highlight;
+};
+
+typedef AspellConfig GtkAspellConfig;
+
/******************************************************************************/
-GtkAspellCheckers *gtkaspellcheckers;
+static GtkAspellCheckers *gtkaspellcheckers;
/* Error message storage */
static void gtkaspell_checkers_error_message (gchar *message);
/******************************************************************************/
-GtkAspellCheckers *gtkaspell_checkers_new(void)
+void gtkaspell_checkers_init(void)
{
- GtkAspellCheckers *gtkaspellcheckers;
-
gtkaspellcheckers = g_new(GtkAspellCheckers, 1);
gtkaspellcheckers->checkers = NULL;
gtkaspellcheckers->dictionary_list = NULL;
gtkaspellcheckers->error_message = NULL;
-
- return gtkaspellcheckers;
}
-GtkAspellCheckers *gtkaspell_checkers_delete(void)
+void gtkaspell_checkers_quit(void)
{
GSList *checkers;
GSList *dict_list;
if (gtkaspellcheckers == NULL)
- return NULL;
+ return;
if ((checkers = gtkaspellcheckers->checkers)) {
debug_print("Aspell: number of running checkers to delete %d\n",
g_free(gtkaspellcheckers->error_message);
- return NULL;
+ return;
}
static void gtkaspell_checkers_error_message (gchar *message)
gtkaspellcheckers->error_message = message;
}
+const char *gtkaspell_checkers_strerror(void)
+{
+ g_return_if_fail(gtkaspellcheckers);
+ return gtkaspellcheckers->error_message;
+}
+
void gtkaspell_checkers_reset_error(void)
{
g_return_if_fail(gtkaspellcheckers);
const AspellDictInfo *entry;
if (!gtkaspellcheckers)
- gtkaspellcheckers = gtkaspell_checkers_new();
+ gtkaspell_checkers_init();
if (gtkaspellcheckers->dictionary_list && !refresh)
return gtkaspellcheckers->dictionary_list;
#ifndef __GTKASPELL_H__
#define __GTKASPELL_H__
-#include <gtk/gtkoptionmenu.h>
-#include <aspell.h>
-
-#include "gtkstext.h"
-
-#define ASPELL_FASTMODE 1
-#define ASPELL_NORMALMODE 2
-#define ASPELL_BADSPELLERMODE 3
-
-#define GTKASPELLWORDSIZE 1024
-
-typedef struct _GtkAspellCheckers
-{
- GSList *checkers;
- GSList *dictionary_list;
- gchar *error_message;
-} GtkAspellCheckers;
-
-typedef struct _Dictionary {
- gchar *fullname;
- gchar *dictname;
- gchar *encoding;
-} Dictionary;
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
-typedef struct _GtkAspeller {
- Dictionary *dictionary;
- gint sug_mode;
- AspellConfig *config;
- AspellSpeller *checker;
-} GtkAspeller;
+#ifdef USE_ASPELL
-typedef void (*ContCheckFunc) (gpointer *gtkaspell);
-
-typedef struct _GtkAspell
-{
- const gchar *dictionary_path;
-
- GtkAspeller *gtkaspeller;
- GtkAspeller *alternate_speller;
- gchar theword[GTKASPELLWORDSIZE];
- gint start_pos;
- gint end_pos;
- gint orig_pos;
- gint end_check_pos;
- gboolean misspelled;
- gboolean check_while_typing;
- gboolean use_alternate;
-
- ContCheckFunc continue_check;
-
- GtkWidget *config_menu;
- GtkWidget *popup_config_menu;
- GtkWidget *sug_menu;
- GtkWidget *replace_entry;
+#include <gtk/gtkoptionmenu.h>
- gint default_sug_mode;
- gint max_sug;
- GList *suggestions_list;
+#include "gtkstext.h"
- GtkSText *gtktext;
- GdkColor highlight;
-} GtkAspell;
+typedef struct _GtkAspell GtkAspell; /* Defined in gtkaspell.c */
-typedef AspellConfig GtkAspellConfig;
+void gtkaspell_checkers_init (void);
-extern GtkAspellCheckers *gtkaspellcheckers;
+void gtkaspell_checkers_quit (void);
-GtkAspellCheckers* gtkaspell_checkers_new (void);
+const char * gtkaspell_checkers_strerror (void);
-GtkAspellCheckers* gtkaspell_checkers_delete (void);
+void gtkaspell_checkers_reset_error (void);
-void gtkaspell_checkers_reset_error (void);
+GtkAspell* gtkaspell_new (const gchar *dictionary_path,
+ const gchar *dictionary,
+ const gchar *encoding,
+ gint misspelled_color,
+ gboolean check_while_typing,
+ gboolean use_alternate,
+ GtkSText *gtktext);
-GtkAspell* gtkaspell_new (const gchar *dictionary_path,
- const gchar *dictionary,
- const gchar *encoding,
- gint misspelled_color,
- gboolean check_while_typing,
- gboolean use_alternate,
- GtkSText *gtktext);
+void gtkaspell_delete (GtkAspell *gtkaspell);
-void gtkaspell_delete (GtkAspell *gtkaspell);
+guchar* gtkaspell_get_dict (GtkAspell *gtkaspell);
-guchar* gtkaspell_get_dict (GtkAspell *gtkaspell);
+guchar* gtkaspell_get_path (GtkAspell *gtkaspell);
-guchar* gtkaspell_get_path (GtkAspell *gtkaspell);
+gboolean gtkaspell_set_sug_mode (GtkAspell *gtkaspell,
+ gint themode);
-gboolean gtkaspell_set_sug_mode (GtkAspell *gtkaspell,
- gint themode);
+GSList* gtkaspell_get_dictionary_list (const char *aspell_path,
+ gint refresh);
-GSList* gtkaspell_get_dictionary_list (const char *aspell_path,
- gint refresh);
+void gtkaspell_free_dictionary_list (GSList *list);
-void gtkaspell_free_dictionary_list (GSList *list);
+void gtkaspell_check_forwards_go (GtkAspell *gtkaspell);
+void gtkaspell_check_backwards (GtkAspell *gtkaspell);
-void gtkaspell_check_forwards_go (GtkAspell *gtkaspell);
-void gtkaspell_check_backwards (GtkAspell *gtkaspell);
+void gtkaspell_check_all (GtkAspell *gtkaspell);
+void gtkaspell_uncheck_all (GtkAspell *gtkaspell);
+void gtkaspell_highlight_all (GtkAspell *gtkaspell);
-void gtkaspell_check_all (GtkAspell *gtkaspell);
-void gtkaspell_uncheck_all (GtkAspell *gtkaspell);
-void gtkaspell_highlight_all (GtkAspell *gtkaspell);
+void gtkaspell_populate_submenu (GtkAspell *gtkaspell,
+ GtkWidget *menuitem);
-void gtkaspell_populate_submenu (GtkAspell *gtkaspell,
- GtkWidget *menuitem);
+GtkWidget* gtkaspell_dictionary_option_menu_new (const gchar *aspell_path);
-GtkWidget* gtkaspell_dictionary_option_menu_new
- (const gchar *aspell_path);
-gchar* gtkaspell_get_dictionary_menu_active_item
+gchar* gtkaspell_get_dictionary_menu_active_item
(GtkWidget *menu);
-GtkWidget* gtkaspell_sugmode_option_menu_new
- (gint sugmode);
+GtkWidget* gtkaspell_sugmode_option_menu_new (gint sugmode);
-void gtkaspell_sugmode_option_menu_set
- (GtkOptionMenu *optmenu,
+void gtkaspell_sugmode_option_menu_set (GtkOptionMenu *optmenu,
gint sugmode);
-gint gtkaspell_get_sugmode_from_option_menu
- (GtkOptionMenu *optmenu);
+gint gtkaspell_get_sugmode_from_option_menu (GtkOptionMenu *optmenu);
+#endif /* USE_ASPELL */
#endif /* __GTKASPELL_H__ */