[almanah/almanah-0-6: 3/5] Ensure we only enable spell checking once, and tidy up handling of
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Subject: [almanah/almanah-0-6: 3/5] Ensure we only enable spell checking once, and tidy up handling of
- Date: Mon, 1 Jun 2009 05:29:34 -0400 (EDT)
commit e0a027c7cc54b9b57b46135a4ad6db4f9b4558f0
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jun 1 10:09:53 2009 +0100
Ensure we only enable spell checking once, and tidy up handling of
2009-04-10 Philip Withnall <philip tecnocode co uk>
* src/interface.c (almanah_interface_create_text_tags):
* src/main-window.c (almanah_main_window_new),
(almanah_main_window_enable_spell_checking),
(almanah_main_window_disable_spell_checking): Ensure we only
enable
spell checking once, and tidy up handling of spelling errors
once
spell checking has been disabled. (Closes: #578559)
svn path=/trunk/; revision=148
---
ChangeLog | 9 +++++++++
src/interface.c | 8 ++++++++
src/main-window.c | 35 +++++++++++++++++++++++++++++------
3 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8a47389..c4bb5a3 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-10 Philip Withnall <philip tecnocode co uk>
+
+ * src/interface.c (almanah_interface_create_text_tags):
+ * src/main-window.c (almanah_main_window_new),
+ (almanah_main_window_enable_spell_checking),
+ (almanah_main_window_disable_spell_checking): Ensure we only enable
+ spell checking once, and tidy up handling of spelling errors once
+ spell checking has been disabled. (Closes: #578559)
+
2009-03-01 Philip Withnall <philip tecnocode co uk>
* src/main-window.c: Added some missing #includes.
diff --git a/src/interface.c b/src/interface.c
index d6ed95b..32e74f0 100755
--- a/src/interface.c
+++ b/src/interface.c
@@ -90,6 +90,14 @@ void
almanah_interface_create_text_tags (GtkTextBuffer *text_buffer, gboolean connect_events)
{
GtkTextTag *tag;
+ GtkTextTagTable *table;
+
+ table = gtk_text_buffer_get_tag_table (text_buffer);
+ if (gtk_text_tag_table_lookup (table, "gtkspell-misspelled") == NULL) {
+ /* Create a dummy gtkspell-misspelled tag to stop errors about an unknown tag appearing
+ * when deserialising content which has misspellings highlighted, but without GtkSpell enabled */
+ gtk_text_buffer_create_tag (text_buffer, "gtkspell-misspelled", NULL);
+ }
gtk_text_buffer_create_tag (text_buffer, "bold",
"weight", PANGO_WEIGHT_BOLD,
diff --git a/src/main-window.c b/src/main-window.c
index 33e88a1..6c1dea2 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -183,15 +183,16 @@ almanah_main_window_new (void)
priv->copy_action = GTK_ACTION (gtk_builder_get_object (builder, "almanah_ui_copy"));
priv->delete_action = GTK_ACTION (gtk_builder_get_object (builder, "almanah_ui_delete"));
- /* Set up text formatting */
- almanah_interface_create_text_tags (priv->entry_buffer, TRUE);
-
#ifdef ENABLE_SPELL_CHECKING
/* Set up spell checking, if it's enabled */
if (gconf_client_get_bool (almanah->gconf_client, "/apps/almanah/spell_checking_enabled", NULL) == TRUE)
almanah_main_window_enable_spell_checking (main_window, NULL);
#endif /* ENABLE_SPELL_CHECKING */
+ /* Set up text formatting. It's important this is done after setting up GtkSpell, so that we know whether to
+ * create a dummy gtkspell-misspelled text tag. */
+ almanah_interface_create_text_tags (priv->entry_buffer, TRUE);
+
/* Make sure we're notified if the cursor moves position so we can check the tag stack */
g_signal_connect (priv->entry_buffer, "notify::cursor-position", G_CALLBACK (mw_entry_buffer_cursor_position_cb), main_window);
@@ -1084,7 +1085,20 @@ almanah_main_window_enable_spell_checking (AlmanahMainWindow *self, GError **err
{
GtkSpell *gtkspell;
gchar *spelling_language;
+ GtkTextTagTable *table;
+ GtkTextTag *tag;
+
+ /* Bail out if spell checking's already enabled */
+ if (gtkspell_get_from_text_view (self->priv->entry_view) != NULL)
+ return TRUE;
+ /* If spell checking wasn't already enabled, we have a dummy gtkspell-misspelled text tag to destroy */
+ table = gtk_text_buffer_get_tag_table (self->priv->entry_buffer);
+ tag = gtk_text_tag_table_lookup (table, "gtkspell-misspelled");
+ if (tag != NULL)
+ gtk_text_tag_table_remove (table, tag);
+
+ /* Get the spell checking language */
spelling_language = gconf_client_get_string (almanah->gconf_client, "/apps/almanah/spelling_language", NULL);
/* Make sure it's either NULL or a proper locale specifier */
@@ -1105,11 +1119,20 @@ void
almanah_main_window_disable_spell_checking (AlmanahMainWindow *self)
{
GtkSpell *gtkspell;
+ GtkTextTagTable *table;
+ GtkTextTag *tag;
gtkspell = gtkspell_get_from_text_view (self->priv->entry_view);
- if (gtkspell != NULL) {
+ if (gtkspell != NULL)
gtkspell_detach (gtkspell);
- g_object_unref (gtkspell);
- }
+
+ /* Remove the old gtkspell-misspelling text tag */
+ table = gtk_text_buffer_get_tag_table (self->priv->entry_buffer);
+ tag = gtk_text_tag_table_lookup (table, "gtkspell-misspelled");
+ if (tag != NULL)
+ gtk_text_tag_table_remove (table, tag);
+
+ /* Create a dummy gtkspell-misspelling text tag */
+ gtk_text_buffer_create_tag (self->priv->entry_buffer, "gtkspell-misspelled", NULL);
}
#endif /* ENABLE_SPELL_CHECKING */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]