Branch: refs/heads/master Author: Frank Lanitz frank@frank.uvena.de Committer: GitHub noreply@github.com Date: Thu, 25 Jan 2018 20:14:21 UTC Commit: 8db63429505bd2deff14754eaa4e0afdffa2e3cf https://github.com/geany/geany-plugins/commit/8db63429505bd2deff14754eaa4e0a...
Log Message: ----------- Merge pull request #680 from eht16/spellcheck_issue_667
SpellCheck: Remember 'Check while typing' setting between sessions
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).
plugins-commits@lists.geany.org