Diff
Modified: trunk/Tools/ChangeLog (88911 => 88912)
--- trunk/Tools/ChangeLog 2011-06-15 07:08:41 UTC (rev 88911)
+++ trunk/Tools/ChangeLog 2011-06-15 07:51:35 UTC (rev 88912)
@@ -1,3 +1,30 @@
+2011-06-15 Carlos Garcia Campos <[email protected]>
+
+ Reviewed by Martin Robinson.
+
+ [GTK] Add a statusbar to MiniBrowser
+ https://bugs.webkit.org/show_bug.cgi?id=62634
+
+ It shows the url of the current hovered link.
+
+ * MiniBrowser/gtk/BrowserWindow.c:
+ (browserWindowConstructed): Create the GtkSatusbar.
+ (mouseDidMoveOverElement): Update statusbar text.
+ (browserWindowUIClientInit): Add implementation for
+ mouseDidMoveOverElement().
+ * MiniBrowser/gtk/GNUmakefile.am: Add new files to compilation.
+ * MiniBrowser/gtk/WebBundle/WebBundleMain.c: Added.
+ (mouseDidMoveOverElement): Pass the url of the current hovered
+ link to the UI process.
+ (didCreatePage): Set the UI client adding an implementation for
+ mouseDidMoveOverElement().
+ (WKBundleInitialize):
+ * MiniBrowser/gtk/main.c:
+ (createWKContextWithInjectedBundle): Create a global context with
+ the injected bundle.
+ (loadURI): Use the global context.
+ (main):
+
2011-06-14 Lucas Forschler <[email protected]>
Reviewed by Stephanie Lewis.
Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (88911 => 88912)
--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2011-06-15 07:08:41 UTC (rev 88911)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2011-06-15 07:51:35 UTC (rev 88912)
@@ -36,11 +36,14 @@
struct _BrowserWindow {
GtkWindow parent;
- GtkWidget* mainBox;
- GtkWidget* uriEntry;
+ GtkWidget *mainBox;
+ GtkWidget *uriEntry;
+ GtkWidget *statusBar;
WKViewRef webView;
- gchar* title;
+ guint statusBarContextId;
+
+ gchar *title;
gdouble loadProgress;
};
@@ -164,6 +167,11 @@
gtk_box_pack_start(GTK_BOX(window->mainBox), GTK_WIDGET(window->webView), TRUE, TRUE, 0);
gtk_widget_show(GTK_WIDGET(window->webView));
+ window->statusBar = gtk_statusbar_new();
+ window->statusBarContextId = gtk_statusbar_get_context_id(GTK_STATUSBAR(window->statusBar), "Link Hover");
+ gtk_box_pack_start(GTK_BOX(window->mainBox), window->statusBar, FALSE, FALSE, 0);
+ gtk_widget_show(window->statusBar);
+
browserWindowLoaderClientInit(window);
browserWindowUIClientInit(window);
}
@@ -463,6 +471,22 @@
return returnValue;
}
+static void mouseDidMoveOverElement(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo)
+{
+ BrowserWindow *window = BROWSER_WINDOW(clientInfo);
+ gtk_statusbar_pop(GTK_STATUSBAR(window->statusBar), window->statusBarContextId);
+
+ if (!userData)
+ return;
+
+ if (WKGetTypeID(userData) != WKURLGetTypeID())
+ return;
+
+ gchar *link = WKURLGetCString((WKURLRef)userData);
+ gtk_statusbar_push(GTK_STATUSBAR(window->statusBar), window->statusBarContextId, link);
+ g_free(link);
+}
+
static void browserWindowUIClientInit(BrowserWindow *window)
{
WKPageUIClient uiClient = {
@@ -478,7 +502,7 @@
runJavaScriptConfirm,
runJavaScriptPrompt,
0, /* setStatusText */
- 0, /* mouseDidMoveOverElement */
+ mouseDidMoveOverElement,
0, /* missingPluginButtonClicked */
0, /* didNotHandleKeyEvent */
0, /* didNotHandleWheelEvent */
Modified: trunk/Tools/MiniBrowser/gtk/GNUmakefile.am (88911 => 88912)
--- trunk/Tools/MiniBrowser/gtk/GNUmakefile.am 2011-06-15 07:08:41 UTC (rev 88911)
+++ trunk/Tools/MiniBrowser/gtk/GNUmakefile.am 2011-06-15 07:51:35 UTC (rev 88912)
@@ -33,3 +33,21 @@
CLEANFILES += \
$(top_builddir)/Programs/MiniBrowser
+
+# Injected bundle
+noinst_LTLIBRARIES += Libraries/libMiniBrowserWebBundle.la
+Libraries_libMiniBrowserWebBundle_la_SOURCES = \
+ Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c
+
+Libraries_libMiniBrowserWebBundle_la_LDFLAGS = \
+ -rpath ${shell pwd}/$(top_builddir)/../unix/TestNetscapePlugin/.libs \
+ $(no_undefined) \
+ -avoid-version \
+ -module
+
+Libraries_libMiniBrowserWebBundle_la_CPPFLAGS = \
+ -I$(top_builddir)/DerivedSources/InjectedBundle \
+ -I$(top_builddir)/DerivedSources/WebKit2/include \
+ $(global_cppflags) \
+ $(_javascript_core_cppflags) \
+ $(GLIB_CFLAGS)
Added: trunk/Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c (0 => 88912)
--- trunk/Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c (rev 0)
+++ trunk/Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c 2011-06-15 07:51:35 UTC (rev 88912)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <WebKit2/WKBundle.h>
+#include <WebKit2/WKBundleHitTestResult.h>
+#include <WebKit2/WKBundleInitialize.h>
+#include <WebKit2/WKBundlePage.h>
+#include <glib.h>
+#include <string.h>
+
+static WKBundleRef globalBundle;
+
+static void mouseDidMoveOverElement(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef *userData, const void *clientInfo)
+{
+ *userData = WKBundleHitTestResultCopyAbsoluteLinkURL(hitTestResult);
+}
+
+static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
+{
+ WKBundlePageUIClient uiClient;
+ memset(&uiClient, 0, sizeof(uiClient));
+ uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
+
+ WKBundlePageSetUIClient(page, &uiClient);
+}
+
+void WKBundleInitialize(WKBundleRef bundle, WKTypeRef initializationUserData)
+{
+ globalBundle = bundle;
+
+ WKBundleClient client = {
+ 0,
+ 0,
+ didCreatePage,
+ 0, /* willDestroyPage */
+ 0, /* didInitializePageGroup */
+ 0, /* didRecieveMessage */
+ };
+ WKBundleSetClient(bundle, &client);
+}
Modified: trunk/Tools/MiniBrowser/gtk/main.c (88911 => 88912)
--- trunk/Tools/MiniBrowser/gtk/main.c 2011-06-15 07:08:41 UTC (rev 88911)
+++ trunk/Tools/MiniBrowser/gtk/main.c 2011-06-15 07:51:35 UTC (rev 88912)
@@ -31,6 +31,22 @@
static const gchar **uriArguments = NULL;
+static WKContextRef createWKContextWithInjectedBundle()
+{
+ WKStringRef bundlePath = WKStringCreateWithUTF8CString("Libraries/.libs/libMiniBrowserWebBundle.so");
+ WKContextRef processContext = WKContextCreateWithInjectedBundlePath(bundlePath);
+ WKContextInjectedBundleClient bundleClient = {
+ 0, /* version */
+ 0, /* clientInfo */
+ 0, /* didRecieveMessageFromInjectedBundle,*/
+ 0
+ };
+ WKContextSetInjectedBundleClient(processContext, &bundleClient);
+ WKRelease(bundlePath);
+
+ return processContext;
+}
+
static gchar *argumentToURL(const char *filename)
{
GFile *gfile = g_file_new_for_commandline_arg(filename);
@@ -40,9 +56,9 @@
return fileURL;
}
-static void loadURI(const gchar *uri)
+static void loadURI(const gchar *uri, WKContextRef processContext)
{
- WKViewRef webView = WKViewCreate(WKContextGetSharedProcessContext(), 0);
+ WKViewRef webView = WKViewCreate(processContext, 0);
GtkWidget *mainWindow = browser_window_new(webView);
gchar *url = ""
WKPageLoadURL(WKViewGetPage(webView), WKURLCreateWithUTF8CString(url));
@@ -77,13 +93,15 @@
}
g_option_context_free (context);
+ WKContextRef processContext = createWKContextWithInjectedBundle();
+
if (uriArguments) {
int i;
for (i = 0; uriArguments[i]; i++)
- loadURI(uriArguments[i]);
+ loadURI(uriArguments[i], processContext);
} else
- loadURI("http://www.webkitgtk.org/");
+ loadURI("http://www.webkitgtk.org/", processContext);
gtk_main();