+void
+grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
+{
+ struct Client *c = (struct Client *)data;
+ WebKitJavascriptResult *js_result;
+ JSCValue *value;
+ JSCException *exception;
+ GError *err = NULL;
+ gchar *str_value;
+
+ g_free(c->feed_html);
+ c->feed_html = NULL;
+
+ /* This was taken almost verbatim from the example in WebKit's
+ * 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);
+ if (!js_result)
+ {
+ fprintf(stderr, __NAME__": Error running javascript: %s\n", err->message);
+ g_error_free(err);
+ return;
+ }
+
+ value = webkit_javascript_result_get_js_value(js_result);
+ if (jsc_value_is_string(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,
+ "application-rss+xml-symbolic");
+ gtk_entry_set_icon_activatable(GTK_ENTRY(c->location),
+ GTK_ENTRY_ICON_PRIMARY,
+ TRUE);
+ }
+ else
+ {
+ gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
+ GTK_ENTRY_ICON_PRIMARY,
+ NULL);
+ }
+
+ webkit_javascript_result_unref(js_result);
+}
+