2 * Browser D-Bus Bridge, JavaScriptCore version
4 * Copyright © 2008 Movial Creative Technologies Inc
5 * Contact: Movial Creative Technologies Inc, <info@movial.com>
6 * Authors: Kalle Vahlman, <kalle.vahlman@movial.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 * To build, execute this (on one line):
26 * gcc -o jscorebus-webkit jscorebus-webkit.c \
27 * $(pkg-config --cflags --libs webkit-1.0 dbus-glib-1 jscorebus)
31 #include <dbus/dbus.h>
32 #include <dbus/dbus-glib-lowlevel.h>
33 #include <webkit/webkit.h>
34 #include <JavaScriptCore/JavaScript.h>
35 #include <jscorebus/jscorebus.h>
40 void _window_object_cleared (WebKitWebView* web_view,
41 WebKitWebFrame* frame,
42 JSGlobalContextRef context,
43 JSObjectRef windowObject,
46 jscorebus_export(context);
50 _window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
52 gtk_widget_destroy(widget);
57 int main(int argc, char *argv[])
61 DBusConnection *session_connection;
62 DBusConnection *system_connection;
64 gtk_init(&argc, &argv);
68 g_print("Usage: %s <url>\n", argv[0]);
72 session_connection = dbus_bus_get(DBUS_BUS_SESSION, NULL);
73 system_connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
75 dbus_connection_setup_with_g_main(session_connection, NULL);
76 dbus_connection_setup_with_g_main(system_connection, NULL);
78 jscorebus_init(session_connection, system_connection);
80 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
81 swin = gtk_scrolled_window_new(NULL, NULL);
82 view = webkit_web_view_new();
84 gtk_container_add(GTK_CONTAINER(swin), view);
85 gtk_container_add(GTK_CONTAINER(window), swin);
87 g_signal_connect(window, "delete-event",
88 G_CALLBACK(_window_delete_event), NULL);
91 * Connect to the window-object-cleared signal. This is the moment when we
92 * need to install the D-Bus bindings into the DOM.
94 g_signal_connect(view, "window-object-cleared",
95 G_CALLBACK(_window_object_cleared), session_connection);
97 webkit_web_view_open(WEBKIT_WEB_VIEW(view), argv[1]);
98 gtk_widget_set_size_request(window,
101 gtk_widget_show_all(window);