[gedit] Reset the spell checker language from the metadata when the doc is loaded.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Reset the spell checker language from the metadata when the doc is loaded.
- Date: Sat, 17 Apr 2010 19:19:05 +0000 (UTC)
commit 7eafaef57d79216e19323f930bd91676f4b08d8c
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Apr 17 19:45:51 2010 +0200
Reset the spell checker language from the metadata when the doc is loaded.
plugins/spell/gedit-spell-plugin.c | 55 ++++++++++++++++++++++++------------
1 files changed, 37 insertions(+), 18 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 1faf3b3..d20e6b0 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -157,6 +157,29 @@ set_spell_language_cb (GeditSpellChecker *spell,
key, NULL);
}
+static void
+set_language_from_metadata (GeditSpellChecker *spell,
+ GeditDocument *doc)
+{
+ const GeditSpellCheckerLanguage *lang = NULL;
+ gchar *value = NULL;
+
+ value = gedit_document_get_metadata (doc, GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE);
+
+ if (value != NULL)
+ {
+ lang = gedit_spell_checker_language_from_key (value);
+ g_free (value);
+ }
+
+ if (lang != NULL)
+ {
+ g_signal_handlers_block_by_func (spell, set_spell_language_cb, doc);
+ gedit_spell_checker_set_language (spell, lang);
+ g_signal_handlers_unblock_by_func (spell, set_spell_language_cb, doc);
+ }
+}
+
static GeditSpellChecker *
get_spell_checker_from_document (GeditDocument *doc)
{
@@ -171,23 +194,9 @@ get_spell_checker_from_document (GeditDocument *doc)
if (data == NULL)
{
- const GeditSpellCheckerLanguage *lang = NULL;
- gchar *value = NULL;
-
spell = gedit_spell_checker_new ();
- value = gedit_document_get_metadata (doc, GEDIT_METADATA_ATTRIBUTE_SPELL_LANGUAGE);
-
- if (value != NULL)
- {
- lang = gedit_spell_checker_language_from_key (value);
- g_free (value);
- }
-
- if (lang != NULL)
- {
- gedit_spell_checker_set_language (spell, lang);
- }
+ set_language_from_metadata (spell, doc);
g_object_set_qdata_full (G_OBJECT (doc),
spell_checker_id,
@@ -969,9 +978,19 @@ on_document_loaded (GeditDocument *doc,
{
if (error == NULL)
{
- WindowData *data = g_object_get_data (G_OBJECT (window),
- WINDOW_DATA_KEY);
-
+ WindowData *data;
+ GeditSpellChecker *spell;
+
+ spell = GEDIT_SPELL_CHECKER (g_object_get_qdata (G_OBJECT (doc),
+ spell_checker_id));
+ if (spell != NULL)
+ {
+ set_language_from_metadata (spell, doc);
+ }
+
+ data = g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+
set_auto_spell_from_metadata (window, doc, data->action_group);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]