Skip to content

Commit

Permalink
spellcheck: Drop use of the most obvious deprecated Geany API
Browse files Browse the repository at this point in the history
  • Loading branch information
b4n committed Feb 20, 2016
1 parent 47d07f6 commit aecfa59
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
9 changes: 2 additions & 7 deletions spellcheck/src/gui.c
Expand Up @@ -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))));
Expand Down Expand Up @@ -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);

Expand Down
11 changes: 6 additions & 5 deletions spellcheck/src/scplugin.c
Expand Up @@ -61,7 +61,6 @@ enum
KB_SPELL_TOOGLE_TYPING,
KB_COUNT
};
PLUGIN_KEY_GROUP(spellcheck, KB_COUNT)



Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions spellcheck/src/speller.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit aecfa59

Please sign in to comment.