SF.net SVN: geany-plugins:[330] trunk/spellcheck

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Dec 6 17:21:04 UTC 2008


Revision: 330
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=330&view=rev
Author:   eht16
Date:     2008-12-06 17:21:04 +0000 (Sat, 06 Dec 2008)

Log Message:
-----------
Update to Geany API 115 - use geanyfunctions.h, from Nick's patch.

Modified Paths:
--------------
    trunk/spellcheck/ChangeLog
    trunk/spellcheck/src/gui.c
    trunk/spellcheck/src/scplugin.c
    trunk/spellcheck/src/speller.c

Modified: trunk/spellcheck/ChangeLog
===================================================================
--- trunk/spellcheck/ChangeLog	2008-12-05 13:34:41 UTC (rev 329)
+++ trunk/spellcheck/ChangeLog	2008-12-06 17:21:04 UTC (rev 330)
@@ -1,3 +1,9 @@
+2008-12-06  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/scplugin.c, src/gui.c, src/speller.c:
+   Update to Geany API 115 - use geanyfunctions.h, from Nick's patch.
+
+
 2008-11-30  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * src/gui.c:

Modified: trunk/spellcheck/src/gui.c
===================================================================
--- trunk/spellcheck/src/gui.c	2008-12-05 13:34:41 UTC (rev 329)
+++ trunk/spellcheck/src/gui.c	2008-12-06 17:21:04 UTC (rev 330)
@@ -37,7 +37,7 @@
 #include "utils.h"
 #include "ui_utils.h"
 
-#include "pluginmacros.h"
+#include "geanyfunctions.h"
 
 #include "gui.h"
 #include "scplugin.h"
@@ -62,11 +62,11 @@
 
 void gui_perform_check(GeanyDocument *doc)
 {
-	p_editor->indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
+	editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
 	if (sc->use_msgwin)
 	{
-		p_msgwindow->clear_tab(MSG_MESSAGE);
-		p_msgwindow->switch_tab(MSG_MESSAGE, FALSE);
+		msgwin_clear_tab(MSG_MESSAGE);
+		msgwin_switch_tab(MSG_MESSAGE, FALSE);
 	}
 
 	speller_check_document(doc);
@@ -76,9 +76,9 @@
 static void print_typing_changed_message(void)
 {
 	if (sc->check_while_typing)
-		p_ui->set_statusbar(FALSE, _("Spell checking while typing is now enabled"));
+		ui_set_statusbar(FALSE, _("Spell checking while typing is now enabled"));
 	else
-		p_ui->set_statusbar(FALSE, _("Spell checking while typing is now disabled"));
+		ui_set_statusbar(FALSE, _("Spell checking while typing is now disabled"));
 }
 
 
@@ -109,14 +109,14 @@
 	{
 		if (sc->toolbar_button == NULL)
 		{
-			sc->toolbar_button = gtk_toggle_tool_button_new_from_stock("gtk-spell-check");
+			sc->toolbar_button = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_SPELL_CHECK);
 #if GTK_CHECK_VERSION(2, 12, 0)
-			gtk_widget_set_tooltip_text(GTK_WIDGET(sc->toolbar_button),
+			gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(sc->toolbar_button),
 				_("Toggle spell check while typing."));
 #endif
 			gtk_widget_show(GTK_WIDGET(sc->toolbar_button));
-			p_plugin->add_toolbar_item(geany_plugin, sc->toolbar_button);
-			p_ui->add_document_sensitive(GTK_WIDGET(sc->toolbar_button));
+			plugin_add_toolbar_item(geany_plugin, sc->toolbar_button);
+			ui_add_document_sensitive(GTK_WIDGET(sc->toolbar_button));
 
 			g_signal_connect(sc->toolbar_button, "toggled",
 				G_CALLBACK(toolbar_item_toggled_cb), NULL);
@@ -136,10 +136,10 @@
 
 	g_return_if_fail(doc != NULL);
 
-	start_pos = p_sci->get_position_from_line(doc->editor->sci, line_number);
-	length = p_sci->get_line_length(doc->editor->sci, line_number);
+	start_pos = sci_get_position_from_line(doc->editor->sci, line_number);
+	length = sci_get_line_length(doc->editor->sci, line_number);
 
-	p_sci->indicator_clear(doc->editor->sci, start_pos, length);
+	sci_indicator_clear(doc->editor->sci, start_pos, length);
 }
 
 
@@ -152,31 +152,31 @@
 
 	g_return_if_fail(clickinfo.doc != NULL && clickinfo.pos != -1);
 
-	startword = p_sci->send_message(sci, SCI_WORDSTARTPOSITION, clickinfo.pos, 0);
-	endword = p_sci->send_message(sci, SCI_WORDENDPOSITION, clickinfo.pos, 0);
+	startword = scintilla_send_message(sci, SCI_WORDSTARTPOSITION, clickinfo.pos, 0);
+	endword = scintilla_send_message(sci, SCI_WORDENDPOSITION, clickinfo.pos, 0);
 
 	if (startword != endword)
 	{
 		gchar *word;
 
-		p_sci->set_selection_start(sci, startword);
-		p_sci->set_selection_end(sci, endword);
+		sci_set_selection_start(sci, startword);
+		sci_set_selection_end(sci, endword);
 
 		/* retrieve the old text */
-		word = g_malloc(p_sci->get_selected_text_length(sci) + 1);
-		p_sci->get_selected_text(sci, word);
+		word = g_malloc(sci_get_selected_text_length(sci) + 1);
+		sci_get_selected_text(sci, word);
 
 		/* retrieve the new text */
 		sugg = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))));
 
 		/* replace the misspelled word with the chosen suggestion */
-		p_sci->replace_sel(sci, sugg);
+		sci_replace_sel(sci, sugg);
 
 		/* store the replacement for future checks */
 		speller_store_replacement(word, sugg);
 
 		/* remove indicator */
-		p_sci->indicator_clear(sci, startword, endword - startword);
+		sci_indicator_clear(sci, startword, endword - startword);
 
 		g_free(word);
 	}
@@ -204,22 +204,22 @@
 	/* Remove all indicators on the added/ignored word */
 	sci = clickinfo.doc->editor->sci;
 	str = g_string_sized_new(256);
-	doc_len = p_sci->get_length(sci);
+	doc_len = sci_get_length(sci);
 	for (i = 0; i < doc_len; i++)
 	{
-		startword = p_sci->send_message(sci, SCI_INDICATORSTART, 0, i);
+		startword = scintilla_send_message(sci, SCI_INDICATORSTART, 0, i);
 		if (startword >= 0)
 		{
-			endword = p_sci->send_message(sci, SCI_INDICATOREND, 0, startword);
+			endword = scintilla_send_message(sci, SCI_INDICATOREND, 0, startword);
 			if (startword == endword)
 				continue;
 
 			if (str->len < (guint)(endword - startword + 1))
 				str = g_string_set_size(str, endword - startword + 1);
-			p_sci->get_text_range(sci, startword, endword, str->str);
+			sci_get_text_range(sci, startword, endword, str->str);
 
 			if (strcmp(str->str, clickinfo.word) == 0)
-				p_sci->indicator_clear(sci, startword, endword - startword);
+				sci_indicator_clear(sci, startword, endword - startword);
 
 			i = endword;
 		}
@@ -240,11 +240,11 @@
 	gtk_widget_hide(sc->edit_menu_sep);
 
 	/* if we have a selection, prefer it over the current word */
-	if (p_sci->has_selection(doc->editor->sci))
+	if (sci_has_selection(doc->editor->sci))
 	{
-		gint len = p_sci->get_selected_text_length(doc->editor->sci);
+		gint len = sci_get_selected_text_length(doc->editor->sci);
 		search_word = g_malloc(len + 1);
-		p_sci->get_selected_text(doc->editor->sci, search_word);
+		sci_get_selected_text(doc->editor->sci, search_word);
 	}
 	else
 		search_word = g_strdup(word);
@@ -305,12 +305,12 @@
 		gtk_container_add(GTK_CONTAINER(sc->edit_menu_sub), menu_item);
 
 		label = g_strdup_printf(_("Add \"%s\" to Dictionary"), search_word);
-		menu_item = p_ui->image_menu_item_new(GTK_STOCK_ADD, label);
+		menu_item = ui_image_menu_item_new(GTK_STOCK_ADD, label);
 		gtk_container_add(GTK_CONTAINER(sc->edit_menu_sub), menu_item);
 		g_signal_connect((gpointer) menu_item, "activate",
 			G_CALLBACK(on_menu_addword_item_activate), GINT_TO_POINTER(0));
 
-		menu_item = p_ui->image_menu_item_new(GTK_STOCK_REMOVE, _("Ignore All"));
+		menu_item = ui_image_menu_item_new(GTK_STOCK_REMOVE, _("Ignore All"));
 		gtk_container_add(GTK_CONTAINER(sc->edit_menu_sub), menu_item);
 		g_signal_connect((gpointer) menu_item, "activate",
 			G_CALLBACK(on_menu_addword_item_activate), GINT_TO_POINTER(1));
@@ -350,28 +350,28 @@
 	/* set current time for the next key press */
 	time_prev = time_now;
 
-	doc = p_document->get_current();
+	doc = document_get_current();
 	/* bail out if we don't have a document or if we are not in the editor widget */
 	focusw = gtk_window_get_focus(GTK_WINDOW(geany->main_widgets->window));
 	if (doc == NULL || focusw != GTK_WIDGET(doc->editor->sci))
 		return FALSE;
 
 	if (ev->keyval == '\r' &&
-		p_sci->send_message(doc->editor->sci, SCI_GETEOLMODE, 0, 0) == SC_EOL_CRLF)
+		scintilla_send_message(doc->editor->sci, SCI_GETEOLMODE, 0, 0) == SC_EOL_CRLF)
 	{	/* prevent double line checking */
 		return FALSE;
 	}
 
-	line_number = p_sci->get_current_line(doc->editor->sci);
+	line_number = sci_get_current_line(doc->editor->sci);
 	if (ev->keyval == '\n' || ev->keyval == '\r')
 		line_number--; /* check previous line if we start a new one */
-	line = p_sci->get_line(doc->editor->sci, line_number);
+	line = sci_get_line(doc->editor->sci, line_number);
 
 	clear_indicators_on_line(doc, line_number);
 	if (speller_process_line(doc, line_number, line) != 0)
 	{
 		if (sc->use_msgwin)
-			p_msgwindow->switch_tab(MSG_MESSAGE, FALSE);
+			msgwin_switch_tab(MSG_MESSAGE, FALSE);
 	}
 
 	g_string_free(str, TRUE);
@@ -385,7 +385,7 @@
 {
 	GeanyDocument *doc;
 
-	doc = p_document->get_current();
+	doc = document_get_current();
 
 	/* Another language was chosen from the menu item, so make it default for this session. */
     if (gdata != NULL)
@@ -393,11 +393,11 @@
 
 	speller_reinit_enchant_dict();
 
-	p_editor->indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
+	editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
 	if (sc->use_msgwin)
 	{
-		p_msgwindow->clear_tab(MSG_MESSAGE);
-		p_msgwindow->switch_tab(MSG_MESSAGE, FALSE);
+		msgwin_clear_tab(MSG_MESSAGE);
+		msgwin_switch_tab(MSG_MESSAGE, FALSE);
 	}
 
 	speller_check_document(doc);
@@ -422,7 +422,7 @@
 
 void gui_create_edit_menu(void)
 {
-	sc->edit_menu = p_ui->image_menu_item_new(GTK_STOCK_SPELL_CHECK, _("Spelling Suggestions"));
+	sc->edit_menu = ui_image_menu_item_new(GTK_STOCK_SPELL_CHECK, _("Spelling Suggestions"));
 	gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc->edit_menu);
 	gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc->edit_menu, 0);
 

Modified: trunk/spellcheck/src/scplugin.c
===================================================================
--- trunk/spellcheck/src/scplugin.c	2008-12-05 13:34:41 UTC (rev 329)
+++ trunk/spellcheck/src/scplugin.c	2008-12-06 17:21:04 UTC (rev 330)
@@ -42,7 +42,7 @@
 #include "utils.h"
 #include "ui_utils.h"
 
-#include "pluginmacros.h"
+#include "geanyfunctions.h"
 
 #include "scplugin.h"
 #include "gui.h"
@@ -54,7 +54,7 @@
 GeanyFunctions	*geany_functions;
 
 
-PLUGIN_VERSION_CHECK(110)
+PLUGIN_VERSION_CHECK(115)
 PLUGIN_SET_INFO(_("Spell Check"), _("Checks the spelling of the current document."), "0.2",
 			_("The Geany developer team"))
 
@@ -160,16 +160,16 @@
 
 		gui_toolbar_update();
 
-		if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && p_utils->mkdir(config_dir, TRUE) != 0)
+		if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
 		{
-			p_dialogs->show_msgbox(GTK_MESSAGE_ERROR,
+			dialogs_show_msgbox(GTK_MESSAGE_ERROR,
 				_("Plugin configuration directory could not be created."));
 		}
 		else
 		{
 			/* write config to file */
 			data = g_key_file_to_data(config, NULL, NULL);
-			p_utils->write_file(sc->config_file, data);
+			utils_write_file(sc->config_file, data);
 			g_free(data);
 		}
 		g_free(config_dir);
@@ -191,20 +191,20 @@
 		"spellcheck", G_DIR_SEPARATOR_S, "spellcheck.conf", NULL);
 
 	g_key_file_load_from_file(config, sc->config_file, G_KEY_FILE_NONE, NULL);
-	sc->default_language = p_utils->get_setting_string(config,
+	sc->default_language = utils_get_setting_string(config,
 		"spellcheck", "language", default_lang);
-	sc->check_while_typing = p_utils->get_setting_boolean(config,
+	sc->check_while_typing = utils_get_setting_boolean(config,
 		"spellcheck", "check_while_typing", FALSE);
-	sc->show_toolbar_item = p_utils->get_setting_boolean(config,
+	sc->show_toolbar_item = utils_get_setting_boolean(config,
 		"spellcheck", "show_toolbar_item", TRUE);
-	sc->use_msgwin = p_utils->get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE);
+	sc->use_msgwin = utils_get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE);
 	g_key_file_free(config);
 	g_free(default_lang);
 
 	locale_init();
 
 	sc->menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SPELL_CHECK, NULL);
-	p_ui->add_document_sensitive(sc->menu_item);
+	ui_add_document_sensitive(sc->menu_item);
 
 	gui_toolbar_update();
 
@@ -219,9 +219,9 @@
 		"key-release-event", G_CALLBACK(gui_key_release_cb), NULL);
 
 	/* setup keybindings */
-	p_keybindings->set_item(plugin_key_group, KB_SPELL_CHECK, gui_kb_run_activate_cb,
+	keybindings_set_item(plugin_key_group, KB_SPELL_CHECK, gui_kb_run_activate_cb,
 		0, 0, "spell_check", _("Run Spell Check"), NULL);
-	p_keybindings->set_item(plugin_key_group, KB_SPELL_TOOGLE_TYPING,
+	keybindings_set_item(plugin_key_group, KB_SPELL_TOOGLE_TYPING,
 		gui_kb_toggle_typing_activate_cb, 0, 0, "spell_toggle_typing",
 		_("Toggle Check While Typing"), NULL);
 }
@@ -257,7 +257,7 @@
 	{
 		gtk_combo_box_append_text(GTK_COMBO_BOX(combo), g_ptr_array_index(sc->dicts, i));
 
-		if (p_utils->str_equal(g_ptr_array_index(sc->dicts, i), sc->default_language))
+		if (utils_str_equal(g_ptr_array_index(sc->dicts, i), sc->default_language))
 			gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i);
 	}
 	/* if the default language couldn't be selected, select the first available language */

Modified: trunk/spellcheck/src/speller.c
===================================================================
--- trunk/spellcheck/src/speller.c	2008-12-05 13:34:41 UTC (rev 329)
+++ trunk/spellcheck/src/speller.c	2008-12-06 17:21:04 UTC (rev 330)
@@ -36,9 +36,10 @@
 #include "editor.h"
 #include "msgwindow.h"
 #include "utils.h"
+#include "ui_utils.h"
 #include "scintilla/SciLexer.h"
 
-#include "pluginmacros.h"
+#include "geanyfunctions.h"
 
 #include "speller.h"
 #include "scplugin.h"
@@ -83,7 +84,7 @@
 	if (start_pos == -1)
 		start_pos = end_pos - strlen(word);
 
-	p_editor->indicator_set_on_range(doc->editor, GEANY_INDICATOR_ERROR, start_pos, end_pos);
+	editor_indicator_set_on_range(doc->editor, GEANY_INDICATOR_ERROR, start_pos, end_pos);
 
 	if (sc->use_msgwin)
 	{
@@ -106,7 +107,7 @@
 				g_string_append_c(str, ' ');
 			}
 
-			p_msgwindow->msg_add(COLOR_RED, line_number + 1, doc, "%s", str->str);
+			msgwin_msg_add(COLOR_RED, line_number + 1, doc, "%s", str->str);
 
 			if (suggs != NULL && n_suggs > 0)
 				enchant_dict_free_string_list(speller_dict, suggs);
@@ -132,17 +133,17 @@
 
 	str = g_string_sized_new(256);
 
-	pos_start = p_sci->get_position_from_line(doc->editor->sci, line_number);
+	pos_start = sci_get_position_from_line(doc->editor->sci, line_number);
 	/* TODO use SCI_GETLINEENDPOSITION */
-	pos_end = p_sci->get_position_from_line(doc->editor->sci, line_number + 1);
+	pos_end = sci_get_position_from_line(doc->editor->sci, line_number + 1);
 
 	while (pos_start < pos_end)
 	{
-		wstart = p_sci->send_message(doc->editor->sci, SCI_WORDSTARTPOSITION, pos_start, TRUE);
-		wend = p_sci->send_message(doc->editor->sci, SCI_WORDENDPOSITION, wstart, FALSE);
+		wstart = scintilla_send_message(doc->editor->sci, SCI_WORDSTARTPOSITION, pos_start, TRUE);
+		wend = scintilla_send_message(doc->editor->sci, SCI_WORDENDPOSITION, wstart, FALSE);
 		if (wstart == wend)
 			break;
-		c = p_sci->get_char_at(doc->editor->sci, wstart);
+		c = sci_get_char_at(doc->editor->sci, wstart);
 		/* hopefully it's enough to check for these both */
 		if (ispunct(c) || isspace(c))
 		{
@@ -154,7 +155,7 @@
 		if (str->len < (guint)(wend - wstart))
 			g_string_set_size(str, wend - wstart);
 
-		p_sci->get_text_range(doc->editor->sci, wstart, wend, str->str);
+		sci_get_text_range(doc->editor->sci, wstart, wend, str->str);
 
 		suggestions_found += speller_check_word(doc, line_number, str->str, wstart, wend);
 
@@ -179,15 +180,15 @@
 
 	enchant_dict_describe(speller_dict, dict_describe, &dict_string);
 
-	if (p_sci->has_selection(doc->editor->sci))
+	if (sci_has_selection(doc->editor->sci))
 	{
-		first_line = p_sci->get_line_from_position(
-			doc->editor->sci, p_sci->get_selection_start(doc->editor->sci));
-		last_line = p_sci->get_line_from_position(
-			doc->editor->sci, p_sci->get_selection_end(doc->editor->sci));
+		first_line = sci_get_line_from_position(
+			doc->editor->sci, sci_get_selection_start(doc->editor->sci));
+		last_line = sci_get_line_from_position(
+			doc->editor->sci, sci_get_selection_end(doc->editor->sci));
 
 		if (sc->use_msgwin)
-			p_msgwindow->msg_add(COLOR_BLUE, -1, NULL,
+			msgwin_msg_add(COLOR_BLUE, -1, NULL,
 				_("Checking file \"%s\" (lines %d to %d using %s):"),
 				DOC_FILENAME(doc), first_line + 1, last_line + 1, dict_string);
 		g_message("Checking file \"%s\" (lines %d to %d using %s):",
@@ -196,9 +197,9 @@
 	else
 	{
 		first_line = 0;
-		last_line = p_sci->get_line_count(doc->editor->sci);
+		last_line = sci_get_line_count(doc->editor->sci);
 		if (sc->use_msgwin)
-			p_msgwindow->msg_add(COLOR_BLUE, -1, NULL, _("Checking file \"%s\" (using %s):"),
+			msgwin_msg_add(COLOR_BLUE, -1, NULL, _("Checking file \"%s\" (using %s):"),
 				DOC_FILENAME(doc), dict_string);
 		g_message("Checking file \"%s\" (using %s):", DOC_FILENAME(doc), dict_string);
 	}
@@ -206,21 +207,21 @@
 
 	for (i = first_line; i < last_line; i++)
 	{
-		line = p_sci->get_line(doc->editor->sci, i);
+		line = sci_get_line(doc->editor->sci, i);
 
 		suggestions_found += speller_process_line(doc, i, line);
 
 		g_free(line);
 	}
 	if (suggestions_found == 0 && sc->use_msgwin)
-		p_msgwindow->msg_add(COLOR_BLUE, -1, NULL, _("The checked text is spelled correctly."));
+		msgwin_msg_add(COLOR_BLUE, -1, NULL, _("The checked text is spelled correctly."));
 }
 
 
 static void broker_init_failed(void)
 {
 	const gchar *err = enchant_broker_get_error(speller_broker);
-	p_dialogs->show_msgbox(GTK_MESSAGE_ERROR,
+	dialogs_show_msgbox(GTK_MESSAGE_ERROR,
 		_("The Enchant library couldn't be initialized (%s)."),
 		(err != NULL) ? err : _("unknown error (maybe the chosen language is not available)"));
 }
@@ -230,7 +231,7 @@
 {
 	gboolean *supported = user_data;
 
-	if (p_utils->str_equal(sc->default_language, data))
+	if (utils_str_equal(sc->default_language, data))
 		*supported = TRUE;
 }
 
@@ -322,7 +323,7 @@
 	/* find duplicates and skip them */
 	for (i = 0; i < sc->dicts->len; i++)
 	{
-		if (p_utils->str_equal(g_ptr_array_index(sc->dicts, i), result))
+		if (utils_str_equal(g_ptr_array_index(sc->dicts, i), result))
 			return;
 	}
 
@@ -424,8 +425,8 @@
 	g_return_val_if_fail(doc != NULL, FALSE);
 	g_return_val_if_fail(pos >= 0, FALSE);
 
-	lexer = p_sci->send_message(doc->editor->sci, SCI_GETLEXER, 0, 0);
-	style = p_sci->get_style_at(doc->editor->sci, pos);
+	lexer = scintilla_send_message(doc->editor->sci, SCI_GETLEXER, 0, 0);
+	style = sci_get_style_at(doc->editor->sci, pos);
 
 	switch (lexer)
 	{


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list