Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpellCheck: Sync toggle via keybinding and button #1161

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions spellcheck/src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,20 @@ static void clear_spellcheck_error_markers(GeanyDocument *doc)
}


static void print_typing_changed_message(void)
static void perform_spell_check_toggle(void)
{
/* force a rescan of the document if 'check while typing' has been turned on and clean
* errors if it has been turned off */
GeanyDocument *doc = document_get_current();
if (sc_info->check_while_typing)
{
perform_check(doc);
}
else
{
clear_spellcheck_error_markers(doc);
}

if (sc_info->check_while_typing)
ui_set_statusbar(FALSE, _("Spell checking while typing is now enabled"));
else
Expand All @@ -81,27 +93,12 @@ static void print_typing_changed_message(void)

static void toolbar_item_toggled_cb(GtkToggleToolButton *button, gpointer user_data)
{
gboolean check_while_typing_changed, check_while_typing;

if (sc_ignore_callback)
return;

check_while_typing = gtk_toggle_tool_button_get_active(button);
check_while_typing_changed = check_while_typing != sc_info->check_while_typing;
sc_info->check_while_typing = check_while_typing;
sc_info->check_while_typing = gtk_toggle_tool_button_get_active(button);

print_typing_changed_message();

/* force a rescan of the document if 'check while typing' has been turned on and clean
* errors if it has been turned off */
if (check_while_typing_changed)
{
GeanyDocument *doc = document_get_current();
if (sc_info->check_while_typing)
perform_check(doc);
else
clear_spellcheck_error_markers(doc);
}
perform_spell_check_toggle();
}


Expand Down Expand Up @@ -617,7 +614,7 @@ static void update_labels(void)
if (sc_info->toolbar_button != NULL)
{
gchar *text = g_strdup_printf(
_("Toggle spell check while typing (current language: %s)"),
_("Toggle spell check (current language: %s)"),
(sc_info->default_language != NULL) ? sc_info->default_language : _("unknown"));
gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(sc_info->toolbar_button), text);
g_free(text);
Expand Down Expand Up @@ -664,7 +661,7 @@ void sc_gui_kb_toggle_typing_activate_cb(guint key_id)
{
sc_info->check_while_typing = ! sc_info->check_while_typing;

print_typing_changed_message();
perform_spell_check_toggle();

sc_gui_update_toolbar();
}
Expand Down
6 changes: 3 additions & 3 deletions spellcheck/src/scplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ void plugin_init(GeanyData *data)
/* setup keybindings */
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);
0, 0, "spell_check", _("Run spell check once"), sc_info->submenu_item_default);
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);
_("Toggle spell check"), NULL);
}


Expand Down Expand Up @@ -330,7 +330,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
gtk_box_pack_start(GTK_BOX(vbox), frame_interface, FALSE, FALSE, 3);


check_type = gtk_check_button_new_with_label(_("Check spelling while typing"));
check_type = gtk_check_button_new_with_label(_("Toggle spell check"));
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"));
Expand Down