[geany/geany-plugins] aecfa5: spellcheck: Drop use of the most obvious deprecated Geany API

Colomban Wendling git-noreply at xxxxx
Sat Feb 20 21:23:10 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 20 Feb 2016 21:23:10 UTC
Commit:      aecfa59e3262f6e27b3514c426c892941959009c
             https://github.com/geany/geany-plugins/commit/aecfa59e3262f6e27b3514c426c892941959009c

Log Message:
-----------
spellcheck: Drop use of the most obvious deprecated Geany API


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

Modified: spellcheck/src/gui.c
9 lines changed, 2 insertions(+), 7 deletions(-)
===================================================================
@@ -156,8 +156,7 @@ static void menu_suggestion_item_activate_cb(GtkMenuItem *menuitem, gpointer gda
 		sci_set_selection_end(sci, endword);
 
 		/* retrieve the old text */
-		word = g_malloc(sci_get_selected_text_length(sci) + 1);
-		sci_get_selected_text(sci, word);
+		word = sci_get_selection_contents(sci);
 
 		/* retrieve the new text */
 		sugg = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))));
@@ -420,11 +419,7 @@ void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos,
 
 	/* if we have a selection, prefer it over the current word */
 	if (sci_has_selection(doc->editor->sci))
-	{
-		gint len = sci_get_selected_text_length(doc->editor->sci);
-		search_word = g_malloc(len + 1);
-		sci_get_selected_text(doc->editor->sci, search_word);
-	}
+		search_word = sci_get_selection_contents(doc->editor->sci);
 	else
 		search_word = g_strdup(word);
 


Modified: spellcheck/src/scplugin.c
11 lines changed, 6 insertions(+), 5 deletions(-)
===================================================================
@@ -61,7 +61,6 @@ enum
 	KB_SPELL_TOOGLE_TYPING,
 	KB_COUNT
 };
-PLUGIN_KEY_GROUP(spellcheck, KB_COUNT)
 
 
 
@@ -173,6 +172,7 @@ static void configure_response_cb(GtkDialog *dialog, gint response, gpointer use
 
 void plugin_init(GeanyData *data)
 {
+	GeanyKeyGroup *key_group;
 	GKeyFile *config = g_key_file_new();
 	gchar *default_lang;
 
@@ -214,9 +214,10 @@ void plugin_init(GeanyData *data)
 	gtk_widget_show_all(sc_info->menu_item);
 
 	/* setup keybindings */
-	keybindings_set_item(plugin_key_group, KB_SPELL_CHECK, sc_gui_kb_run_activate_cb,
+	key_group = plugin_set_key_group(geany_plugin, "spellcheck", KB_COUNT, NULL);
+	keybindings_set_item(key_group, KB_SPELL_CHECK, sc_gui_kb_run_activate_cb,
 		0, 0, "spell_check", _("Run Spell Check"), sc_info->submenu_item_default);
-	keybindings_set_item(plugin_key_group, KB_SPELL_TOOGLE_TYPING,
+	keybindings_set_item(key_group, KB_SPELL_TOOGLE_TYPING,
 		sc_gui_kb_toggle_typing_activate_cb, 0, 0, "spell_toggle_typing",
 		_("Toggle Check While Typing"), NULL);
 }
@@ -327,7 +328,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_type), sc_info->check_while_typing);
 
 	check_on_open = gtk_check_button_new_with_label(_("Check spelling when opening a document"));
-	ui_widget_set_tooltip_text(check_on_open,
+	gtk_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);
@@ -350,7 +351,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
 	entry_dir = gtk_entry_new();
 	ui_entry_add_clear_icon(GTK_ENTRY(entry_dir));
 	gtk_label_set_mnemonic_widget(GTK_LABEL(label_dir), entry_dir);
-	ui_widget_set_tooltip_text(entry_dir,
+	gtk_widget_set_tooltip_text(entry_dir,
 		_("Read additional dictionary files from this directory. "
 		  "For now, this only works with myspell dictionaries."));
 	if (! EMPTY(sc_info->dictionary_dir))


Modified: spellcheck/src/speller.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -95,7 +95,7 @@ static gchar *strip_word(const gchar *word_to_check, gint *result_offset)
 	g_memmove(word_start, word, new_word_len);
 	word = word_start;
 	word[new_word_len] = '\0';
-	if (! NZV(word))
+	if (EMPTY(word))
 	{
 		g_free(word);
 		return NULL;
@@ -146,7 +146,7 @@ static gint sc_speller_check_word(GeanyDocument *doc, gint line_number, const gc
 
 	/* strip punctuation and white space */
 	word_to_check = strip_word(word, &offset);
-	if (! NZV(word_to_check))
+	if (EMPTY(word_to_check))
 	{
 		g_free(word_to_check);
 		return 0;



--------------
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