Esempio n. 1
0
static gboolean
handle_stdin (GIOChannel * ch, GIOCondition cond, gpointer d)
{
  gchar *buf;
  GBytes *data;
  GError *err = NULL;

  switch (g_io_channel_read_line (ch, &buf, NULL, NULL, &err))
    {
    case G_IO_STATUS_NORMAL:
      g_string_append (inbuf, buf);
      return TRUE;

    case G_IO_STATUS_ERROR:
      g_printerr ("yad_html_handle_stdin(): %s\n", err->message);
      g_error_free (err);
      return FALSE;

    case G_IO_STATUS_EOF:
      data = g_bytes_new (inbuf->str, inbuf->len);
      g_string_free (inbuf, TRUE);
      webkit_web_view_load_bytes (view, data, options.html_data.mime, options.html_data.encoding, NULL);
      g_bytes_unref (data);
      return FALSE;

    case G_IO_STATUS_AGAIN:
      return TRUE;
    }

  return FALSE;
}
Esempio n. 2
0
void wk_html_close(WkHtml *html)
{
	if (!html->priv->initialised) {
		html->priv->initialised = TRUE;
#ifndef USE_WEBKIT2
		webkit_web_view_set_maintains_back_forward_list(WEBKIT_WEB_VIEW(html), FALSE);
#endif
	}

#ifdef USE_WEBKIT2
	GBytes *html_bytes;
	html_bytes = g_bytes_new(html->priv->content, strlen(html->priv->content));

	webkit_web_view_load_bytes(WEBKIT_WEB_VIEW(html),
				   html_bytes,
				   html->priv->mime,
				   NULL,
				   html->priv->base_uri);

	g_bytes_unref(html_bytes);
#else
	webkit_web_view_load_string(WEBKIT_WEB_VIEW(html),
				    html->priv->content,
				    html->priv->mime,
				    NULL, html->priv->base_uri);
#endif

	g_free(html->priv->content);
	html->priv->content = NULL;
	g_free(html->priv->mime);
	html->priv->mime = NULL;
}
Esempio n. 3
0
void WebViewTest::loadBytes(GBytes* bytes, const char* mimeType, const char* encoding, const char* baseURI)
{
    if (!baseURI)
        m_activeURI = "about:blank";
    else
        m_activeURI = baseURI;
    webkit_web_view_load_bytes(m_webView, bytes, mimeType, encoding, baseURI);
#if 0
    // FIXME: Pending API request URL no set when loading data.
    // See https://bugs.webkit.org/show_bug.cgi?id=136916.
    g_assert(webkit_web_view_is_loading(m_webView));
    g_assert_cmpstr(webkit_web_view_get_uri(m_webView), ==, m_activeURI.data());
#endif
}