SF.net SVN: geany-plugins: [102] trunk/spellcheck

eht16 at users.sourceforge.net eht16 at xxxxx
Thu Jul 3 13:26:22 UTC 2008


Revision: 102
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=102&view=rev
Author:   eht16
Date:     2008-07-03 06:26:21 -0700 (Thu, 03 Jul 2008)

Log Message:
-----------
Create a new dict object when the default language in the preferences dialog was changed to actually use the new language.

Modified Paths:
--------------
    trunk/spellcheck/ChangeLog
    trunk/spellcheck/src/spellcheck.c

Modified: trunk/spellcheck/ChangeLog
===================================================================
--- trunk/spellcheck/ChangeLog	2008-07-02 17:05:48 UTC (rev 101)
+++ trunk/spellcheck/ChangeLog	2008-07-03 13:26:21 UTC (rev 102)
@@ -1,3 +1,10 @@
+2008-07-03  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/spellcheck.c:
+   Create a new dict object when the default language in the preferences
+   dialog was changed to actually use the new language.
+
+
 2008-06-28  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * src/spellcheck.c:
@@ -24,7 +31,7 @@
  * src/spellcheck.c:
    Compilation fixes.
  * Makefile.am:
-   Add html target.
+   Add HTML target.
 
 
 2008-05-20  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/spellcheck/src/spellcheck.c
===================================================================
--- trunk/spellcheck/src/spellcheck.c	2008-07-02 17:05:48 UTC (rev 101)
+++ trunk/spellcheck/src/spellcheck.c	2008-07-03 13:26:21 UTC (rev 102)
@@ -74,12 +74,15 @@
 } SpellCheck;
 static SpellCheck *sc;
 
+
 #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;
@@ -229,7 +232,7 @@
 
 		/* TODO do we need more than 10 suggestions? gtkspell offers additional suggestions
 		 * in another sub menu, should we too? */
-		for (i = 0; i < MIN(n_suggs, 10); i++)
+		for (i = 0; i < MIN(n_suggs, MAX_MENU_SUGGESTIONS); i++)
 		{
 			/* keep the suggestions in a static array for the callback function */
 			g_free(clickinfo.suggs[i]);
@@ -451,23 +454,31 @@
 }
 
 
-static void on_menu_item_activate(GtkMenuItem *menuitem, gpointer gdata)
+static void init_enchant_dict()
 {
-	GeanyDocument *doc = p_document->get_current();
+	/* Request new dict object */
+	if (sc->dict != NULL)
+		enchant_broker_free_dict(sc->broker, sc->dict);
 
-	/* Another language was chosen from the menu item, so make it default for this session. */
-    if (gdata != NULL)
-		setptr(sc->default_language, g_strdup(gdata));
-
-	/* Request new dict object */
-	enchant_broker_free_dict(sc->broker, sc->dict);
 	sc->dict = enchant_broker_request_dict(sc->broker, sc->default_language);
 	if (sc->dict == NULL)
 	{
 		broker_init_failed();
 		return;
 	}
+}
 
+
+static void on_menu_item_activate(GtkMenuItem *menuitem, gpointer gdata)
+{
+	GeanyDocument *doc = p_document->get_current();
+
+	/* Another language was chosen from the menu item, so make it default for this session. */
+    if (gdata != NULL)
+		setptr(sc->default_language, g_strdup(gdata));
+
+	init_enchant_dict();
+
 	perform_check(doc);
 }
 
@@ -557,6 +568,7 @@
 
 		setptr(sc->default_language, gtk_combo_box_get_active_text(GTK_COMBO_BOX(
 			g_object_get_data(G_OBJECT(dialog), "combo"))));
+		init_enchant_dict();
 
 		sc->check_while_typing = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
 			g_object_get_data(G_OBJECT(dialog), "check"))));
@@ -666,12 +678,7 @@
 	locale_init();
 
 	sc->broker = enchant_broker_init();
-	sc->dict = enchant_broker_request_dict(sc->broker, sc->default_language);
-	if (sc->dict == NULL)
-	{
-		broker_init_failed();
-		return;
-	}
+	init_enchant_dict();
 
 	for (i = 0; i < MAX_MENU_SUGGESTIONS; i++)
 	{


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list