ChangeLog

 12011-03-25 Vamshikrishna.Yellenki <vamshi@motorola.com> and Alejandro G. Castro <alex@igalia.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Implement MiniBrowser for Gtk port.
 6 https://bugs.webkit.org/show_bug.cgi?id=48512
 7
 8 Initial implementation of the Gtk MiniBrowser.
 9
 10 * GNUmakefile.am:
 11
1122011-03-29 Csaba Osztrogonác <ossy@webkit.org>
213
314 Rubber-stamped by Andreas Kling.

GNUmakefile.am

@@include Source/JavaScriptCore/GNUmakefile.am
229229include Source/WebCore/GNUmakefile.am
230230if ENABLE_WEBKIT2
231231include Source/WebKit2/GNUmakefile.am
 232include Tools/MiniBrowser/gtk/GNUmakefile.am
232233# [GTK] Refactor the translations now that we have webkit2
233234# https://bugs.webkit.org/show_bug.cgi?id=55153
234235stamp-po:

Source/WebKit2/ChangeLog

 12011-03-25 Vamshikrishna.Yellenki <vamshi@motorola.com> and Alejandro G. Castro <alex@igalia.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Implement MiniBrowser for Gtk port.
 6 https://bugs.webkit.org/show_bug.cgi?id=48512
 7
 8 * Shared/API/c/gtk/WKBaseGtk.h: Add the stdbool.h include.
 9
1102011-03-11 Amruth Raj <amruthraj@motorola.com> and Martin Robinson <mrobinson@igalia.com>
211
312 Reviewed by NOBODY (OOPS!).

Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h

3232#error "Please #include \"WKBase.h\" instead of this file directly."
3333#endif
3434
 35#include <stdbool.h>
 36
3537typedef const struct OpaqueWKView* WKViewRef;
3638
3739#endif /* WKBaseGtk_h */

Tools/ChangeLog

 12011-03-25 Vamshikrishna.Yellenki <vamshi@motorola.com> and Alejandro G. Castro <alex@igalia.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Implement MiniBrowser for Gtk port.
 6 https://bugs.webkit.org/show_bug.cgi?id=48512
 7
 8 Initial implementation of the Gtk MiniBrowser.
 9
 10 * MiniBrowser/gtk/GNUmakefile.am: Added.
 11 * MiniBrowser/gtk/main.c: Added.
 12 (activateUriEntryCallback):
 13 (destroyCallback):
 14 (goBackCallback):
 15 (goForwardCallback):
 16 (createToolbar):
 17 (createWebView):
 18 (createWindow):
 19 (filenameToURL):
 20 (main):
 21
1222011-03-30 Maciej Stachowiak <mjs@apple.com>
223
324 Reviewed by Adam Barth.

Tools/MiniBrowser/gtk/GNUmakefile.am

 1bin_PROGRAMS += \
 2 Programs/MiniBrowser
 3
 4Programs_MiniBrowser_CPPFLAGS = \
 5 -I$(srcdir)/Source \
 6 -I$(top_builddir)/DerivedSources/WebKit2/include \
 7 $(global_cppflags) \
 8 $(GLIB_CFLAGS) \
 9 $(GTK_CFLAGS)
 10
 11Programs_MiniBrowser_SOURCES = \
 12 Tools/MiniBrowser/gtk/main.c
 13
 14BUILT_SOURCES += \
 15 generate-minibrowser-forward-headers
 16
 17MiniBrowser := $(srcdir)/Tools/MiniBrowser/gtk
 18MiniBrowserFwdHeaders := $(GENSOURCES_WEBKIT2)/include
 19generate-minibrowser-forward-headers: $(WebKit2)/Scripts/generate-forwarding-headers.pl $(Programs_MiniBrowser_SOURCES)
 20 $(AM_V_GEN)$(PERL) $< $(MiniBrowser) $(MiniBrowserFwdHeaders) gtk
 21 $(AM_V_GEN)$(PERL) $< $(MiniBrowser) $(MiniBrowserFwdHeaders) soup
 22
 23Programs_MiniBrowser_LDADD = \
 24 libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
 25 $(GLIB_LIBS) \
 26 $(GTK_LIBS)
 27
 28Programs_MiniBrowser_LDFLAGS = \
 29 -no-fast-install \
 30 -no-install
 31
 32CLEANFILES += \
 33 $(top_builddir)/Programs/MiniBrowser

Tools/MiniBrowser/gtk/main.c

 1/*
 2 * Copyright (C) 2006, 2007 Apple Inc.
 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
 4 * Copyright (C) 2011 Igalia S.L.
 5 *
 6 * Redistribution and use in source and binary forms, with or without
 7 * modification, are permitted provided that the following conditions
 8 * are met:
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer in the
 13 * documentation and/or other materials provided with the distribution.
 14 *
 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 26 */
 27
 28#include <WebKit2/WebKit2.h>
 29#include <gtk/gtk.h>
 30
 31static void activateUriEntryCallback(GtkWidget *entry, gpointer data)
 32{
 33 WKViewRef webView = g_object_get_data(G_OBJECT(entry), "web-view");
 34 const gchar *uri = gtk_entry_get_text(GTK_ENTRY(entry));
 35 WKPageLoadURL(WKViewGetPage(webView), WKURLCreateWithURL(uri));
 36}
 37
 38static void destroyCallback(GtkWidget *widget, GtkWidget *window)
 39{
 40 gtk_main_quit();
 41}
 42
 43static void goBackCallback(GtkWidget *widget, WKViewRef webView)
 44{
 45 WKPageGoBack(WKViewGetPage(webView));
 46}
 47
 48static void goForwardCallback(GtkWidget *widget, WKViewRef webView)
 49{
 50 WKPageGoForward(WKViewGetPage(webView));
 51}
 52
 53static GtkWidget *createToolbar(GtkWidget *uriEntry, WKViewRef webView)
 54{
 55 GtkWidget *toolbar = gtk_toolbar_new();
 56
 57#if GTK_CHECK_VERSION(2, 15, 0)
 58 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
 59#else
 60 gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
 61#endif
 62 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
 63
 64 GtkToolItem *item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
 65 g_signal_connect(item, "clicked", G_CALLBACK(goBackCallback), (gpointer)webView);
 66 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
 67
 68 item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
 69 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(goForwardCallback), (gpointer)webView);
 70 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
 71
 72 item = gtk_tool_item_new();
 73 gtk_tool_item_set_expand(item, TRUE);
 74 gtk_container_add(GTK_CONTAINER(item), uriEntry);
 75 g_signal_connect(uriEntry, "activate", G_CALLBACK(activateUriEntryCallback), NULL);
 76 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
 77
 78 g_object_set_data(G_OBJECT(uriEntry), "web-view", (gpointer)webView);
 79 item = gtk_tool_button_new_from_stock(GTK_STOCK_OK);
 80 g_signal_connect_swapped(item, "clicked", G_CALLBACK(activateUriEntryCallback), (gpointer)uriEntry);
 81 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
 82
 83 return toolbar;
 84}
 85
 86static WKViewRef createWebView()
 87{
 88 return WKViewCreate(WKContextGetSharedProcessContext(), 0);
 89}
 90
 91static GtkWidget *createWindow(WKViewRef webView)
 92{
 93 GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 94 gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
 95 gtk_widget_set_name(window, "MiniBrowser");
 96
 97 GtkWidget *uriEntry = gtk_entry_new();
 98
 99 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
 100 gtk_box_pack_start(GTK_BOX(vbox), createToolbar(uriEntry, webView), FALSE, FALSE, 0);
 101 gtk_box_pack_start(GTK_BOX(vbox), WKViewGetWindow(webView), TRUE, TRUE, 0);
 102
 103 gtk_container_add(GTK_CONTAINER(window), vbox);
 104
 105 g_signal_connect(window, "destroy", G_CALLBACK(destroyCallback), NULL);
 106
 107 return window;
 108}
 109
 110static gchar *filenameToURL(const char *filename)
 111{
 112 GFile *gfile = g_file_new_for_commandline_arg(filename);
 113 gchar *fileURL = g_file_get_uri(gfile);
 114 g_object_unref(gfile);
 115
 116 return fileURL;
 117}
 118
 119int main(int argc, char *argv[])
 120{
 121 gtk_init(&argc, &argv);
 122
 123 if (!g_thread_supported())
 124 g_thread_init(NULL);
 125
 126 WKViewRef webView = createWebView();
 127 GtkWidget *mainWindow = createWindow(webView);
 128
 129 const gchar *uri = argc > 1 ? argv[1] : "http://www.webkitgtk.org/";
 130 gchar *fileURL = filenameToURL(uri);
 131
 132 WKPageLoadURL(WKViewGetPage(webView), WKURLCreateWithURL(fileURL));
 133 g_free(fileURL);
 134
 135 gtk_widget_grab_focus(WKViewGetWindow(webView));
 136 gtk_widget_show_all(mainWindow);
 137 gtk_main();
 138
 139 return 0;
 140}