gtkhtml r8870 - trunk/components/editor
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkhtml r8870 - trunk/components/editor
- Date: Wed, 18 Jun 2008 14:16:51 +0000 (UTC)
Author: mbarnes
Date: Wed Jun 18 14:16:50 2008
New Revision: 8870
URL: http://svn.gnome.org/viewvc/gtkhtml?rev=8870&view=rev
Log:
2008-06-18 Matthew Barnes <mbarnes redhat com>
** Fixes bug #538703
* gtkhtml-spell-checker.c:
Delay calling enchant_broker_request_dict() for as long as possible
to avoid loading all dictionaries when creating a new composer window,
which is very time consuming. Derived from a patch by Wang Xin.
Modified:
trunk/components/editor/ChangeLog
trunk/components/editor/gtkhtml-spell-checker.c
Modified: trunk/components/editor/gtkhtml-spell-checker.c
==============================================================================
--- trunk/components/editor/gtkhtml-spell-checker.c (original)
+++ trunk/components/editor/gtkhtml-spell-checker.c Wed Jun 18 14:16:50 2008
@@ -80,6 +80,37 @@
return TRUE;
}
+static EnchantDict *
+spell_checker_request_dict (GtkhtmlSpellChecker *checker)
+{
+ GtkhtmlSpellCheckerPrivate *priv;
+ const gchar *code;
+
+ /* Loading a dictionary is time-consuming, so delay it until we
+ * really need it. The assumption being that the dictionary
+ * for a particular GtkhtmlSpellChecker instance will only
+ * occasionally be needed. That way we can create as many
+ * instances as we want without a huge performance penalty. */
+
+ priv = checker->priv;
+
+ if (priv->dict != NULL)
+ return priv->dict;
+
+ if (priv->language == NULL)
+ return NULL;
+
+ code = gtkhtml_spell_language_get_code (priv->language);
+ priv->dict = enchant_broker_request_dict (priv->broker, code);
+
+ if (priv->dict == NULL) {
+ priv->language = NULL;
+ g_warning ("Cannot load the dictionary for %s", code);
+ }
+
+ return priv->dict;
+}
+
static GObject *
spell_checker_constructor (GType type,
guint n_construct_properties,
@@ -266,7 +297,7 @@
g_return_val_if_fail (GTKHTML_IS_SPELL_CHECKER (checker), FALSE);
g_return_val_if_fail (word != NULL, FALSE);
- if ((dict = checker->priv->dict) == NULL)
+ if ((dict = spell_checker_request_dict (checker)) == NULL)
return FALSE;
if (length < 0)
@@ -297,7 +328,7 @@
g_return_val_if_fail (GTKHTML_IS_SPELL_CHECKER (checker), NULL);
- if ((dict = checker->priv->dict) == NULL)
+ if ((dict = spell_checker_request_dict (checker)) == NULL)
return NULL;
suggestions = enchant_dict_suggest (
@@ -322,7 +353,7 @@
g_return_if_fail (GTKHTML_IS_SPELL_CHECKER (checker));
- if ((dict = checker->priv->dict) != NULL)
+ if ((dict = spell_checker_request_dict (checker)) == NULL)
return;
enchant_dict_store_replacement (
@@ -338,7 +369,7 @@
g_return_if_fail (GTKHTML_IS_SPELL_CHECKER (checker));
- if ((dict = checker->priv->dict) == NULL)
+ if ((dict = spell_checker_request_dict (checker)) == NULL)
return;
enchant_dict_add_to_pwl (dict, word, length);
@@ -354,7 +385,7 @@
g_return_if_fail (GTKHTML_IS_SPELL_CHECKER (checker));
- if ((dict = checker->priv->dict) == NULL)
+ if ((dict = spell_checker_request_dict (checker)) == NULL)
return;
enchant_dict_add_to_session (dict, word, length);
@@ -378,18 +409,6 @@
if (priv->language == NULL)
priv->language = gtkhtml_spell_language_lookup (NULL);
- if (priv->language != NULL) {
- const gchar *code;
-
- code = gtkhtml_spell_language_get_code (priv->language);
- priv->dict = enchant_broker_request_dict (priv->broker, code);
- }
-
- if (priv->dict == NULL) {
- priv->language = NULL;
- g_warning ("Cannot load the dictionary");
- }
-
g_signal_emit (G_OBJECT (checker), signals[SESSION_CLEARED], 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]