commit: 6402dd8a8b7117da2a87a9fbceac68f9ce8b179f
parent: 2425cad5171932d32b96752fc15c608ab3944227
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2019 02:38:30 +0200
Add setting spell checking via BADWOLF_L10N
Diffstat:
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/badwolf.1 b/badwolf.1
@@ -55,6 +55,13 @@ When the search box is focused it goes to the Next/Previous search term.
.It search Escape
Cancels current search
.El
+.Sh ENVIRONMENT
+.Bl -width Ds -tag
+.It Ev BADWOLF_L10N
+A colon-separated list in the form lang_COUNTRY where lang is in ISO-639 and COUNTRY in ISO-3166. For example
+.Ic BADWOLF_L10N="en_GB:fr_FR:de_DE" .
+When this variable isn't set, spelling isn't activated. A more generic variable name is also intended to be used in the future.
+.El
.Sh BUGS
You can submit contributions or tickets to
.Lk https://gitlab.com/lanodan/badwolf
diff --git a/badwolf.c b/badwolf.c
@@ -547,7 +547,7 @@ downloadCb_decide_destination(WebKitDownload *download,
gint chooser_response;
GtkWindow *parent_window = GTK_WINDOW(browser->window->main_window);
- GtkWidget *file_dialog = gtk_file_chooser_dialog_new(NULL,
+ GtkWidget *file_dialog = gtk_file_chooser_dialog_new(NULL,
parent_window,
GTK_FILE_CHOOSER_ACTION_SAVE,
_("_Cancel"),
@@ -654,6 +654,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
{
struct Client *browser = g_try_malloc(sizeof(struct Client));
target_url = ensure_uri_scheme(target_url, (related_web_view == NULL));
+ char *badwolf_l10n = NULL;
if(browser == NULL) return NULL;
@@ -671,6 +672,19 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
webkit_web_context_set_process_model(web_context,
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+ badwolf_l10n = getenv("BADWOLF_L10N");
+ g_fprintf(stderr, "BADWOLF_L10N: %s\n", badwolf_l10n);
+
+ if(badwolf_l10n != NULL)
+ {
+ gchar **languages = g_strsplit(badwolf_l10n, ":", -1);
+ webkit_web_context_set_spell_checking_languages(web_context, (const gchar* const *)languages);
+ g_strfreev(languages);
+
+ webkit_web_context_set_spell_checking_enabled(web_context, TRUE);
+ g_fprintf(stderr, "spell_checking_enabled: %d\n", webkit_web_context_get_spell_checking_enabled(web_context));
+ }
+
WebKitSettings *settings = webkit_settings_new_with_settings(BADWOLF_WEBKIT_SETTINGS);
browser->webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,