Re: [gedit-list] enable spell check on startup



On Wed, 2007-01-03 at 12:41 +0100, Trond Danielsen wrote:
> Hi!
> 
> This is not possible at the moment, but it should be simple to add
> this option to the plugin. If you are up for hacking, you can take a
> look at gedit-spell-plugin.c (line 93 :) ).

A hackish patch attached for bugzilla #305055
Is this the coding style: http://live.gnome.org/LSR/CodeStyleGuide ?

> 
> 2007/1/3, Ritesh Khadgaray <khadgaray gmail com>:
> > Heya,
> >
> >   Is it possible to enable spell check on startup, and not manually via
> > Tool->Spell check every time i start gedit ?
> >
> > --
> > Ritesh Khadgaray
> > LinuX N Stuff
> > Ph: +919822394463
> > Eat Right, Exercise, Die Anyway.
> >
> >
> > _______________________________________________
> > gedit-list mailing list
> > gedit-list gnome org
> > http://mail.gnome.org/mailman/listinfo/gedit-list
> >
> >
> >
> >
> 
> 
-- 
Ritesh Khadgaray
ॐ मणि पद्मे हूँ
LinuX N Stuff
Ph: +919243176435
Eat Right, Exercise, Die Anyway.
--- gedit-spell-plugin.c.orig	2007-03-18 10:37:13.000000000 +0530
+++ gedit-spell-plugin.c	2007-03-18 11:05:18.000000000 +0530
@@ -20,6 +20,14 @@
  * $Id: gedit-spell-plugin.c 5335 2006-12-04 00:31:27Z paolo $
  */
 
+
+/*
+ * To Do - Write a schema, and probably add a UI ?
+ * As a temporary work to enable auto-init of spell check
+ * gconftool-2 --type bool  --set /apps/gedit-2/plugins/spellcheck/value true
+ *
+ */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -823,6 +831,39 @@
 	g_free (data);
 }
 
+static void 
+enable_autospell(GeditWindow *window,
+					 gpointer       arg1,
+					 gpointer       user_data)
+{	
+	/* copy-paste-modify from auto_spell_cb */
+	GeditAutomaticSpellChecker *autospell;
+	GeditSpellChecker *spell;
+	GeditDocument *doc = gedit_window_get_active_document(window);
+
+	gedit_debug (DEBUG_PLUGINS);
+
+	gedit_debug_message (DEBUG_PLUGINS, "Auto Auto-Spell activated" );
+
+	spell = get_spell_checker_from_document (doc);
+	g_return_if_fail (spell != NULL);
+
+	autospell = gedit_automatic_spell_checker_get_from_document (doc);
+
+	if (autospell == NULL)
+	{
+		GeditView *active_view;
+
+		active_view = gedit_window_get_active_view (window);
+		g_return_if_fail (active_view != NULL);
+
+		autospell = gedit_automatic_spell_checker_new (doc, spell);
+		gedit_automatic_spell_checker_attach_view (autospell, active_view);
+		gedit_automatic_spell_checker_recheck_all (autospell);
+	}
+}
+
+
 static void
 update_ui_real (GeditWindow *window,
 		WindowData *data)
@@ -909,7 +950,16 @@
 			       GTK_UI_MANAGER_MENUITEM, 
 			       FALSE);
 
-	
+	GConfClient *client= gconf_client_get_default();
+	gboolean check = gconf_client_get_bool(client,SPELL_BROWSER_BASE_KEY "value",NULL);
+	g_object_unref(client);
+	if ( check == TRUE )
+	{
+		g_signal_connect_after(window,
+							   "tab_added",
+							   G_CALLBACK(enable_autospell),
+							   NULL);
+	}
 
 	update_ui_real (window, data);
 }
@@ -932,6 +982,12 @@
 	gtk_ui_manager_remove_action_group (manager, data->action_group);
 
 	g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+	
+	/*
+	 * callback un-register . Modeled after mode-line plugin
+	 *    monkey see, monkey do -- khadgaray
+	 */
+	g_signal_handlers_disconnect_by_func(window,enable_autospell,NULL);
 }
 
 static void


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