[geany/geany-plugins] 0df700: SpellCheck: Remember 'Check while typing' setting between sessions
Enrico Tröger
git-noreply at xxxxx
Sun Jan 21 12:12:15 UTC 2018
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger at uvena.de>
Committer: Enrico Tröger <enrico.troeger at uvena.de>
Date: Sun, 21 Jan 2018 12:12:15 UTC
Commit: 0df700b4df836e881e6c6daa2c59da5af3a17eb8
https://github.com/geany/geany-plugins/commit/0df700b4df836e881e6c6daa2c59da5af3a17eb8
Log Message:
-----------
SpellCheck: Remember 'Check while typing' setting between sessions
To do so, we need to always save the config file on plugin
cleanup/shutdown and move the configuration save logic to
its own function.
Closes #667.
Modified Paths:
--------------
spellcheck/src/scplugin.c
Modified: spellcheck/src/scplugin.c
77 lines changed, 43 insertions(+), 34 deletions(-)
===================================================================
@@ -93,39 +93,11 @@ static void populate_dict_combo(GtkComboBox *combo)
}
-static void configure_response_cb(GtkDialog *dialog, gint response, gpointer user_data)
+static void save_config(void)
{
- if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
- {
GKeyFile *config = g_key_file_new();
gchar *data;
gchar *config_dir = g_path_get_dirname(sc_info->config_file);
- GtkComboBox *combo = GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dialog), "combo"));
-
- setptr(sc_info->default_language, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo)));
-#ifdef HAVE_ENCHANT_1_5
- setptr(sc_info->dictionary_dir, g_strdup(gtk_entry_get_text(GTK_ENTRY(
- g_object_get_data(G_OBJECT(dialog), "dict_dir")))));
-#endif
- sc_speller_reinit_enchant_dict();
-
- 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"))));
-
- sc_info->show_toolbar_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- g_object_get_data(G_OBJECT(dialog), "check_toolbar"))));
-
- sc_info->show_editor_menu_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- g_object_get_data(G_OBJECT(dialog), "check_editor_menu"))));
-
- sc_info->show_editor_menu_item_sub_menu = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- g_object_get_data(G_OBJECT(dialog), "check_editor_menu_sub_menu"))));
g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL);
if (sc_info->default_language != NULL) /* lang may be NULL */
@@ -146,11 +118,6 @@ static void configure_response_cb(GtkDialog *dialog, gint response, gpointer use
g_key_file_set_string(config, "spellcheck", "dictionary_dir",
sc_info->dictionary_dir);
- sc_gui_recreate_editor_menu();
- sc_gui_update_toolbar();
- sc_gui_update_menu();
- populate_dict_combo(combo);
-
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
@@ -165,6 +132,46 @@ static void configure_response_cb(GtkDialog *dialog, gint response, gpointer use
}
g_free(config_dir);
g_key_file_free(config);
+}
+
+
+static void configure_response_cb(GtkDialog *dialog, gint response, gpointer user_data)
+{
+ if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY)
+ {
+ GtkComboBox *combo = GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dialog), "combo"));
+
+ setptr(sc_info->default_language, gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo)));
+#ifdef HAVE_ENCHANT_1_5
+ setptr(sc_info->dictionary_dir, g_strdup(gtk_entry_get_text(GTK_ENTRY(
+ g_object_get_data(G_OBJECT(dialog), "dict_dir")))));
+#endif
+ sc_speller_reinit_enchant_dict();
+
+ 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"))));
+
+ sc_info->show_toolbar_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ g_object_get_data(G_OBJECT(dialog), "check_toolbar"))));
+
+ sc_info->show_editor_menu_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ g_object_get_data(G_OBJECT(dialog), "check_editor_menu"))));
+
+ sc_info->show_editor_menu_item_sub_menu = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
+ g_object_get_data(G_OBJECT(dialog), "check_editor_menu_sub_menu"))));
+
+ save_config();
+
+ sc_gui_recreate_editor_menu();
+ sc_gui_update_toolbar();
+ sc_gui_update_menu();
+ populate_dict_combo(combo);
}
}
@@ -428,6 +435,8 @@ void plugin_help(void)
void plugin_cleanup(void)
{
+ save_config();
+
sc_gui_free();
sc_speller_free();
--------------
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