Revision: 299 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=299&view=rev Author: eht16 Date: 2008-11-15 17:59:17 +0000 (Sat, 15 Nov 2008)
Log Message: ----------- Move SpellClickInfo struct into gui.c.
Modified Paths: -------------- trunk/spellcheck/ChangeLog trunk/spellcheck/src/gui.c trunk/spellcheck/src/gui.h trunk/spellcheck/src/scplugin.c trunk/spellcheck/src/scplugin.h trunk/spellcheck/src/speller.c
Modified: trunk/spellcheck/ChangeLog =================================================================== --- trunk/spellcheck/ChangeLog 2008-11-15 17:17:33 UTC (rev 298) +++ trunk/spellcheck/ChangeLog 2008-11-15 17:59:17 UTC (rev 299) @@ -1,3 +1,12 @@ +2008-11-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/speller.c, src/speller.h, src/gui.c: + When replacing a misspelled word with a suggestion, add this + replacement to the spell checker to remember it in further checks. + * src/gui.c, src/scplugin.c, src/speller.c, src/gui.h, src/scplugin.h: + Move SpellClickInfo struct into gui.c. + + 2008-11-12 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/speller.c, src/speller.h, src/gui.c:
Modified: trunk/spellcheck/src/gui.c =================================================================== --- trunk/spellcheck/src/gui.c 2008-11-15 17:17:33 UTC (rev 298) +++ trunk/spellcheck/src/gui.c 2008-11-15 17:59:17 UTC (rev 299) @@ -45,6 +45,19 @@
+#define MAX_MENU_SUGGESTIONS 10 + +typedef struct +{ + gint pos; + GeanyDocument *doc; + /* static array to keep suggestions for use as callback user data for the editing menu items */ + gchar *suggs[MAX_MENU_SUGGESTIONS]; + /* static storage for the misspelled word under the cursor when using the editing menu */ + gchar *word; +} SpellClickInfo; +static SpellClickInfo clickinfo; + /* Flag to indicate that a callback function will be triggered by generating the appropriate event * but the callback should be ignored. */ static gboolean ignore_sc_callback = FALSE; @@ -153,14 +166,14 @@ if (startword != endword) { gchar *word; - + p_sci->set_selection_start(sci, startword); p_sci->set_selection_end(sci, endword); - + /* retrieve the old text */ word = g_malloc(p_sci->get_selected_text_length(sci) + 1); p_sci->get_selected_text(sci, word); - + /* replace the misspelled word with the chosen suggestion */ p_sci->replace_sel(sci, sugg);
@@ -169,7 +182,7 @@
/* remove indicator */ p_sci->indicator_clear(sci, startword, endword - startword); - + g_free(word); } } @@ -439,3 +452,25 @@ }
+void gui_init(void) +{ + guint i; + + for (i = 0; i < MAX_MENU_SUGGESTIONS; i++) + { + clickinfo.suggs[i] = NULL; + } + clickinfo.word = NULL; +} + + +void gui_free(void) +{ + guint i; + + for (i = 0; i < MAX_MENU_SUGGESTIONS; i++) + { + g_free(clickinfo.suggs[i]); + } + g_free(clickinfo.word); +}
Modified: trunk/spellcheck/src/gui.h =================================================================== --- trunk/spellcheck/src/gui.h 2008-11-15 17:17:33 UTC (rev 298) +++ trunk/spellcheck/src/gui.h 2008-11-15 17:59:17 UTC (rev 299) @@ -46,4 +46,8 @@
void gui_toolbar_update(void);
+void gui_init(void); + +void gui_free(void); + #endif
Modified: trunk/spellcheck/src/scplugin.c =================================================================== --- trunk/spellcheck/src/scplugin.c 2008-11-15 17:17:33 UTC (rev 298) +++ trunk/spellcheck/src/scplugin.c 2008-11-15 17:59:17 UTC (rev 299) @@ -60,7 +60,6 @@
SpellCheck *sc = NULL; -SpellClickInfo clickinfo;
@@ -183,7 +182,6 @@ { GtkWidget *sp_item; GKeyFile *config = g_key_file_new(); - guint i; gchar *default_lang;
default_lang = speller_get_default_lang(); @@ -210,14 +208,9 @@
gui_toolbar_update();
+ gui_init(); speller_init();
- for (i = 0; i < MAX_MENU_SUGGESTIONS; i++) - { - clickinfo.suggs[i] = NULL; - } - clickinfo.word = NULL; - gui_create_edit_menu(); sp_item = gui_create_menu(sc->menu_item); gtk_widget_show_all(sp_item); @@ -292,11 +285,7 @@ void plugin_cleanup(void) { guint i; - for (i = 0; i < MAX_MENU_SUGGESTIONS; i++) - { - clickinfo.suggs[i] = NULL; - } - g_free(clickinfo.word); + for (i = 0; i < sc->dicts->len; i++) { g_free(g_ptr_array_index(sc->dicts, i)); @@ -310,6 +299,7 @@ if (sc->toolbar_button != NULL) gtk_widget_destroy(GTK_WIDGET(sc->toolbar_button));
+ gui_free(); speller_free();
g_free(sc->default_language);
Modified: trunk/spellcheck/src/scplugin.h =================================================================== --- trunk/spellcheck/src/scplugin.h 2008-11-15 17:17:33 UTC (rev 298) +++ trunk/spellcheck/src/scplugin.h 2008-11-15 17:59:17 UTC (rev 299) @@ -45,21 +45,7 @@ } SpellCheck;
-#define MAX_MENU_SUGGESTIONS 10 - -typedef struct -{ - gint pos; - GeanyDocument *doc; - /* static array to keep suggestions for use as callback user data for the editing menu items */ - gchar *suggs[MAX_MENU_SUGGESTIONS]; - /* static storage for the misspelled word under the cursor when using the editing menu */ - gchar *word; -} SpellClickInfo; - - extern SpellCheck *sc; -extern SpellClickInfo clickinfo; extern GeanyPlugin *geany_plugin; extern GeanyData *geany_data; extern GeanyFunctions *geany_functions;
Modified: trunk/spellcheck/src/speller.c =================================================================== --- trunk/spellcheck/src/speller.c 2008-11-15 17:17:33 UTC (rev 298) +++ trunk/spellcheck/src/speller.c 2008-11-15 17:59:17 UTC (rev 299) @@ -359,7 +359,7 @@ g_return_if_fail(speller_dict != NULL); g_return_if_fail(word != NULL);
- enchant_dict_add_to_pwl(speller_dict, clickinfo.word, -1); + enchant_dict_add_to_pwl(speller_dict, word, -1); }
gboolean speller_dict_check(const gchar *word)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org