/* gcc webkit-google.c $(pkg-config --cflags --libs webkitgtk-3.0
   gtk+-3.0) */

#include <gtk/gtk.h>
#include <webkit/webkit.h>

static const gchar *URI
  = "https://docs.google.com/document/d/1_9N6FhwytTA74igjVE7hG2W38IBgk4tZF5ciJBVOCg8/edit?usp=docslist_api";

int
main (void)
{
  GtkWidget *window;
  GtkWidget *view;
  SoupCookieJar *cookie_jar;
  SoupSession *session;

  gtk_init (NULL, NULL);

  session = webkit_get_default_session();

  soup_session_add_feature_by_type (session, SOUP_TYPE_PROXY_RESOLVER_DEFAULT);

  soup_session_remove_feature_by_type (session, SOUP_TYPE_COOKIE_JAR);
  cookie_jar = soup_cookie_jar_db_new ("/tmp/cookies.sqlite", FALSE);
  soup_session_add_feature (session, SOUP_SESSION_FEATURE (cookie_jar));
  g_object_unref (cookie_jar);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
  g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);

  view = webkit_web_view_new ();

  webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), URI);
  gtk_container_add (GTK_CONTAINER (window), view);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
