almanah r148 - in trunk: . src
- From: pwithnall svn gnome org
- To: svn-commits-list gnome org
- Subject: almanah r148 - in trunk: . src
- Date: Fri, 10 Apr 2009 07:54:15 +0000 (UTC)
Author: pwithnall
Date: Fri Apr 10 07:54:15 2009
New Revision: 148
URL: http://svn.gnome.org/viewvc/almanah?rev=148&view=rev
Log:
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)
Modified:
trunk/ChangeLog
trunk/src/interface.c
trunk/src/main-window.c
Modified: trunk/src/interface.c
==============================================================================
--- trunk/src/interface.c (original)
+++ trunk/src/interface.c Fri Apr 10 07:54:15 2009
@@ -90,6 +90,14 @@
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,
Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c (original)
+++ trunk/src/main-window.c Fri Apr 10 07:54:15 2009
@@ -186,15 +186,16 @@
priv->delete_action = GTK_ACTION (gtk_builder_get_object (builder, "almanah_ui_delete"));
priv->important_action = GTK_ACTION (gtk_builder_get_object (builder, "almanah_ui_important"));
- /* 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);
@@ -1109,7 +1110,20 @@
{
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 */
@@ -1130,11 +1144,20 @@
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]