From: Melvin Hadasht Date: Thu, 12 Jun 2003 00:18:28 +0000 (+0000) Subject: Privatized most of GtkAspell's structures X-Git-Tag: rel_0_9_3~85 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=73a2b1b27b8d948e0f000390e2f6ca47f1e0095a Privatized most of GtkAspell's structures --- diff --git a/ChangeLog.claws b/ChangeLog.claws index 474a58aff..23b26359d 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,31 @@ +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 diff --git a/configure.ac b/configure.ac index 6d9d96d73..51b6af8cd 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws28 +EXTRA_VERSION=claws29 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/gtk/gtkaspell.c b/src/gtk/gtkaspell.c index efaf39535..cde57ccdf 100644 --- a/src/gtk/gtkaspell.c +++ b/src/gtk/gtkaspell.c @@ -28,7 +28,7 @@ # include "config.h" #endif -#if USE_ASPELL +#ifdef USE_ASPELL #include #include @@ -51,10 +51,18 @@ #include #include +#include + #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 @@ -76,9 +84,61 @@ 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); @@ -191,25 +251,21 @@ GtkAspellConfig * gtkaspellconfig; /******************************************************************************/ -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", @@ -229,7 +285,7 @@ GtkAspellCheckers *gtkaspell_checkers_delete(void) g_free(gtkaspellcheckers->error_message); - return NULL; + return; } static void gtkaspell_checkers_error_message (gchar *message) @@ -245,6 +301,12 @@ 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); @@ -1439,7 +1501,7 @@ GSList *gtkaspell_get_dictionary_list(const gchar *aspell_path, gint refresh) const AspellDictInfo *entry; if (!gtkaspellcheckers) - gtkaspellcheckers = gtkaspell_checkers_new(); + gtkaspell_checkers_init(); if (gtkaspellcheckers->dictionary_list && !refresh) return gtkaspellcheckers->dictionary_list; diff --git a/src/gtk/gtkaspell.h b/src/gtk/gtkaspell.h index 7408f25ef..07ded79ba 100644 --- a/src/gtk/gtkaspell.h +++ b/src/gtk/gtkaspell.h @@ -32,124 +32,69 @@ #ifndef __GTKASPELL_H__ #define __GTKASPELL_H__ -#include -#include - -#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 - 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__ */ diff --git a/src/main.c b/src/main.c index 4ad6e9359..848b13019 100644 --- a/src/main.c +++ b/src/main.c @@ -265,8 +265,8 @@ int main(int argc, char *argv[]) gpgme_register_idle(idle_function_for_gpgme); #endif -#if USE_ASPELL - gtkaspellcheckers = gtkaspell_checkers_new(); +#ifdef USE_ASPELL + gtkaspell_checkers_init(); #endif sock_set_io_timeout(prefs_common.io_timeout_secs); @@ -364,8 +364,8 @@ int main(int argc, char *argv[]) addressbook_destroy(); -#if USE_ASPELL - gtkaspell_checkers_delete(); +#ifdef USE_ASPELL + gtkaspell_checkers_quit(); #endif sylpheed_done();