]> git.armaanb.net Git - chorizo.git/commitdiff
Add spell checking capability
authorArmaan Bhojwani <me@armaanb.net>
Sun, 6 Jun 2021 16:34:15 +0000 (12:34 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 6 Jun 2021 16:34:15 +0000 (12:34 -0400)
browser.c

index 3f4765d3d8bb27fc3accde23fd0843a58dbdc230..44506e6a45a9c3df2e435f7e9c16b460ccb2d6f2 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -89,11 +89,13 @@ struct Configuration
        gboolean cooperative_instances;
        gboolean enable_console_to_stdout;
        gboolean javascript_disabled;
+       gboolean spellcheck_disabled;
        gchar *download_dir;
        gchar *fifo_suffix;
        gchar *history_file;
        gchar *home_uri;
        gchar *search_engine;
+       gchar *spellcheck_language;
        gchar *user_agent;
        gdouble global_zoom;
        gint tab_width_chars;
@@ -676,9 +678,17 @@ get_config(void)
        cfg.tab_width_chars = (cfg.tab_width_chars) ? cfg.tab_width_chars : 20;
        cfg.global_zoom = g_key_file_get_double(config, "ui", "zoom_level", NULL);
        cfg.global_zoom = (cfg.global_zoom) ? cfg.global_zoom : 1.0;
-       cfg.search_engine = g_key_file_get_string(config, "ui", "search_engine", NULL);
+       cfg.search_engine = g_key_file_get_string(config, "ui", "search_engine",
+                                                                                                                                                                               NULL);
        cfg.search_engine = (cfg.search_engine) ? cfg.search_engine :
                "https://duckduckgo.com?q=";
+       cfg.spellcheck_disabled = g_key_file_get_boolean(config, "ui",
+                                                                                                                                                                                                        "spellcheck_disabled", NULL);
+       cfg.spellcheck_language = g_key_file_get_string(config, "ui",
+                                                                                                                                                                                                                               "spellcheck_language",
+                                                                                                                                                                                                                               NULL);
+       cfg.spellcheck_language = (cfg.spellcheck_language) ? cfg.spellcheck_language
+               : "en_US";
 }
 
 void
@@ -838,6 +848,11 @@ init_default_web_context(void)
                                                                                                                                                                                                                                                                "cookies.db",
                                                                                                                                                                                                                                                                NULL),
                                                                                                                                                                                         WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
+
+       const gchar * const languages[2] = {(const gchar *)cfg.spellcheck_language,
+               NULL};
+       webkit_web_context_set_spell_checking_languages(wc, languages);
+       webkit_web_context_set_spell_checking_enabled(wc, !cfg.spellcheck_disabled);
 }
 
 void