summaryrefslogtreecommitdiff
path: root/browser.c
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2019-03-31 09:23:25 +0200
committerPeter Hofmann <scm@uninformativ.de>2019-03-31 09:23:25 +0200
commit2f392f33c9366218c12f283b349b8000edf89e0a (patch)
tree2a7be4790c9b8a36e3fa9b7f110c470b67ee8ae8 /browser.c
parent054e92a9688058e15a2fa0af4623e095bb346008 (diff)
downloadlariza-2f392f33c9366218c12f283b349b8000edf89e0a.tar.gz
No longer use WebKit's deprecated JavaScript API
Diffstat (limited to 'browser.c')
-rw-r--r--browser.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/browser.c b/browser.c
index ed14575..6d022e5 100644
--- a/browser.c
+++ b/browser.c
@@ -678,17 +678,18 @@ grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
{
struct Client *c = (struct Client *)data;
WebKitJavascriptResult *js_result;
- JSValueRef value;
- JSGlobalContextRef context;
+ JSCValue *value;
+ JSCException *exception;
GError *err = NULL;
- JSStringRef js_str_value;
- gsize str_length;
+ gchar *str_value;
g_free(c->feed_html);
c->feed_html = NULL;
/* This was taken almost verbatim from the example in WebKit's
- * documentation. */
+ * documentation:
+ *
+ * https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript-finish */
js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object),
result, &err);
@@ -699,16 +700,18 @@ grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
return;
}
- context = webkit_javascript_result_get_global_context(js_result);
- value = webkit_javascript_result_get_value(js_result);
-
- if (JSValueIsString(context, value))
+ value = webkit_javascript_result_get_js_value(js_result);
+ if (jsc_value_is_string(value))
{
- js_str_value = JSValueToStringCopy(context, value, NULL);
- str_length = JSStringGetMaximumUTF8CStringSize(js_str_value);
- c->feed_html = (gchar *)g_malloc(str_length);
- JSStringGetUTF8CString(js_str_value, c->feed_html, str_length);
- JSStringRelease(js_str_value);
+ str_value = jsc_value_to_string(value);
+ exception = jsc_context_get_exception(jsc_value_get_context(value));
+ if (exception != NULL)
+ {
+ fprintf(stderr, __NAME__": Error running javascript: %s\n",
+ jsc_exception_get_message(exception));
+ }
+ else
+ c->feed_html = str_value;
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
GTK_ENTRY_ICON_PRIMARY,