[gedit] Make "Check Spelling" unsensitive when there are no words



commit be7089b4e5e5d6135baf42263f04ad8db8ce588e
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Mar 4 16:20:56 2012 +0100

    Make "Check Spelling" unsensitive when there are no words
    
    We already refuse to show the dialog so better to make the menu itm
    insensitive.

 plugins/spell/gedit-spell-plugin.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index f48a74e..89ba0b4 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -925,7 +925,6 @@ update_ui (GeditSpellPlugin *plugin)
 {
 	GeditSpellPluginPrivate *priv;
 	GeditView *view;
-	GtkAction *action;
 
 	gedit_debug (DEBUG_PLUGINS);
 
@@ -933,12 +932,17 @@ update_ui (GeditSpellPlugin *plugin)
 
 	view = gedit_window_get_active_view (priv->window);
 
+	gtk_action_group_set_sensitive (priv->action_group,
+					(view != NULL) &&
+					gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
+
 	if (view != NULL)
 	{
 		GeditDocument *doc;
 		GeditTab *tab;
 		GeditTabState state;
 		gboolean autospell;
+		GtkAction *action;
 
 		doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
 		tab = gedit_window_get_active_tab (priv->window);
@@ -952,7 +956,7 @@ update_ui (GeditSpellPlugin *plugin)
 		{
 			action = gtk_action_group_get_action (priv->action_group,
 							      "AutoSpell");
-	
+
 			g_signal_handlers_block_by_func (action, auto_spell_cb,
 							 priv->window);
 			set_auto_spell (priv->window, view, autospell);
@@ -961,11 +965,12 @@ update_ui (GeditSpellPlugin *plugin)
 			g_signal_handlers_unblock_by_func (action, auto_spell_cb,
 							   priv->window);
 		}
-	}
 
-	gtk_action_group_set_sensitive (priv->action_group,
-					(view != NULL) &&
-					gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
+		action = gtk_action_group_get_action (priv->action_group,
+						      "CheckSpell");
+		gtk_action_set_sensitive (action,
+					  gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc)) > 0);
+	}
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]