1/*
2 * Copyright (C) 2012 Igalia S.L.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2,1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include "config.h"
21
22#include <gtk/gtk.h>
23#include <webkit2/webkit2.h>
24
25static void loadChangedCallback(WebKitWebView*, WebKitLoadEvent loadEvent, gpointer)
26{
27    // Send a message to the parent process when we're ready.
28    if (loadEvent == WEBKIT_LOAD_FINISHED)
29        g_print("OK");
30}
31
32int main(int argc, char** argv)
33{
34    // Make sure that both GAIL and the ATK bridge are loaded.
35    g_setenv("GTK_MODULES", "gail:atk-bridge", TRUE);
36
37    gtk_init(&argc, &argv);
38
39    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
40    webkit_web_view_load_html(webView,
41                              "<html>"
42                              "  <body>"
43                              "   <h1>This is a test</h1>"
44                              "   <p>This is a paragraph with some plain text.</p>"
45                              "   <p>This paragraph contains <a href=\"http://www.webkitgtk.org\">a link</a> in the middle.</p>"
46                              "  </body>"
47                              "</html>",
48                              0);
49
50    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
51    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
52    gtk_widget_show_all(window);
53
54    g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0);
55    g_signal_connect(webView, "load-changed", G_CALLBACK(loadChangedCallback), 0);
56
57    gtk_main();
58}
59