[geany/geany-plugins] 5a94d9: Add option to perform a spell check on document open (closes SF #137)

Enrico Tröger git-noreply at xxxxx
Sun Sep 28 10:14:02 UTC 2014


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 28 Sep 2014 10:14:02 UTC
Commit:      5a94d9561ceee5628742bb90d279e49858586e5d
             https://github.com/geany/geany-plugins/commit/5a94d9561ceee5628742bb90d279e49858586e5d

Log Message:
-----------
Add option to perform a spell check on document open (closes SF #137)


Modified Paths:
--------------
    spellcheck/src/gui.c
    spellcheck/src/gui.h
    spellcheck/src/scplugin.c
    spellcheck/src/scplugin.h

Modified: spellcheck/src/gui.c
14 lines changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -272,6 +272,20 @@ static void perform_spell_check_cb(GtkWidget *menu_item, GeanyDocument *doc)
 }
 
 
+static gboolean perform_check_delayed_cb(gpointer doc)
+{
+	perform_check((GeanyDocument*)doc);
+	return FALSE;
+}
+
+
+void sc_gui_document_open_cb(GObject *obj, GeanyDocument *doc, gpointer user_data)
+{
+	if (sc_info->check_on_document_open && main_is_realized())
+		g_idle_add(perform_check_delayed_cb, doc);
+}
+
+
 void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos,
 								  GeanyDocument *doc, gpointer user_data)
 {


Modified: spellcheck/src/gui.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -39,6 +39,8 @@ void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos,
 gboolean sc_gui_editor_notify(GObject *object, GeanyEditor *editor,
 							  SCNotification *nt, gpointer data);
 
+void sc_gui_document_open_cb(GObject *obj, GeanyDocument *doc, gpointer user_data);
+
 void sc_gui_update_toolbar(void);
 
 void sc_gui_update_menu(void);


Modified: spellcheck/src/scplugin.c
21 lines changed, 19 insertions(+), 2 deletions(-)
===================================================================
@@ -69,7 +69,8 @@ PLUGIN_KEY_GROUP(spellcheck, KB_COUNT)
 PluginCallback plugin_callbacks[] =
 {
 	{ "update-editor-menu", (GCallback) &sc_gui_update_editor_menu_cb, FALSE, NULL },
-	{ "editor-notify", (GCallback) &sc_gui_editor_notify, FALSE, NULL },
+	{ "document-open", (GCallback) &sc_gui_document_open_cb, FALSE, NULL },
+	{ "document-reload", (GCallback) &sc_gui_document_open_cb, FALSE, NULL },
 	{ NULL, NULL, FALSE, NULL }
 };
 
@@ -112,6 +113,9 @@ static void configure_response_cb(GtkDialog *dialog, gint response, gpointer use
 		sc_info->check_while_typing = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
 			g_object_get_data(G_OBJECT(dialog), "check_type"))));
 
+		sc_info->check_on_document_open = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+			g_object_get_data(G_OBJECT(dialog), "check_on_open"))));
+
 		sc_info->use_msgwin = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
 			g_object_get_data(G_OBJECT(dialog), "check_msgwin"))));
 
@@ -126,6 +130,8 @@ static void configure_response_cb(GtkDialog *dialog, gint response, gpointer use
 			g_key_file_set_string(config, "spellcheck", "language", sc_info->default_language);
 		g_key_file_set_boolean(config, "spellcheck", "check_while_typing",
 			sc_info->check_while_typing);
+		g_key_file_set_boolean(config, "spellcheck", "check_on_document_open",
+			sc_info->check_on_document_open);
 		g_key_file_set_boolean(config, "spellcheck", "use_msgwin",
 			sc_info->use_msgwin);
 		g_key_file_set_boolean(config, "spellcheck", "show_toolbar_item",
@@ -175,6 +181,8 @@ void plugin_init(GeanyData *data)
 		"spellcheck", "language", default_lang);
 	sc_info->check_while_typing = utils_get_setting_boolean(config,
 		"spellcheck", "check_while_typing", FALSE);
+	sc_info->check_on_document_open = utils_get_setting_boolean(config,
+		"spellcheck", "check_on_document_open", FALSE);
 	sc_info->show_toolbar_item = utils_get_setting_boolean(config,
 		"spellcheck", "show_toolbar_item", TRUE);
 	sc_info->show_editor_menu_item = utils_get_setting_boolean(config,
@@ -243,7 +251,8 @@ static void dictionary_dir_button_clicked_cb(GtkButton *button, gpointer item)
 
 GtkWidget *plugin_configure(GtkDialog *dialog)
 {
-	GtkWidget *label, *vbox, *combo, *check_type, *check_msgwin, *check_toolbar, *check_editor_menu;
+	GtkWidget *label, *vbox, *combo, *check_type, *check_on_open,
+			  *check_msgwin, *check_toolbar, *check_editor_menu;
 #ifdef HAVE_ENCHANT_1_5
 	GtkWidget *entry_dir, *hbox, *button, *image;
 #endif
@@ -254,6 +263,13 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_type), sc_info->check_while_typing);
 	gtk_box_pack_start(GTK_BOX(vbox), check_type, FALSE, FALSE, 6);
 
+	check_on_open = gtk_check_button_new_with_label(_("Check spelling when opening a document"));
+	ui_widget_set_tooltip_text(check_on_open,
+		_("Enabling this option will check every document after it is opened in Geany. "
+		  "Reloading a document will also trigger a re-check."));
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_on_open), sc_info->check_on_document_open);
+	gtk_box_pack_start(GTK_BOX(vbox), check_on_open, FALSE, FALSE, 6);
+
 	check_toolbar = gtk_check_button_new_with_label(
 		_("Show toolbar item to toggle spell checking"));
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_toolbar), sc_info->show_toolbar_item);
@@ -314,6 +330,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 #endif
 	g_object_set_data(G_OBJECT(dialog), "combo", combo);
 	g_object_set_data(G_OBJECT(dialog), "check_type", check_type);
+	g_object_set_data(G_OBJECT(dialog), "check_on_open", check_on_open);
 	g_object_set_data(G_OBJECT(dialog), "check_msgwin", check_msgwin);
 	g_object_set_data(G_OBJECT(dialog), "check_toolbar", check_toolbar);
 	g_object_set_data(G_OBJECT(dialog), "check_editor_menu", check_editor_menu);


Modified: spellcheck/src/scplugin.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -35,6 +35,7 @@ typedef struct
 	gchar *dictionary_dir;
 	gboolean use_msgwin;
 	gboolean check_while_typing;
+	gboolean check_on_document_open;
 	gboolean show_toolbar_item;
 	gboolean show_editor_menu_item;
 	GPtrArray *dicts;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list