Diff
Modified: trunk/Tools/ChangeLog (114719 => 114720)
--- trunk/Tools/ChangeLog 2012-04-20 06:44:45 UTC (rev 114719)
+++ trunk/Tools/ChangeLog 2012-04-20 06:47:52 UTC (rev 114720)
@@ -1,3 +1,27 @@
+2012-04-19 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Allow to use WebInspector in GtkLauncher
+ https://bugs.webkit.org/show_bug.cgi?id=84143
+
+ Reviewed by Martin Robinson.
+
+ * GNUmakefile.am: Add new files to compilation.
+ * GtkLauncher/LauncherInspectorWindow.c: Added.
+ (launcherInspectorWindowFinalize):
+ (launcher_inspector_window_init):
+ (launcher_inspector_window_class_init):
+ (inspectedURIChanged): Update the window title based on current
+ inspected URI.
+ (showInspectorWindow): Show inspector window.
+ (closeInspectorWindow): Hide inspector window.
+ (launcherInspectorWindowNew): Create an inspector window.
+ (launcherInspectorWindowGetWebView): Return the inspected web view.
+ * GtkLauncher/LauncherInspectorWindow.h: Added.
+ * GtkLauncher/main.c:
+ (inspectorInspectWebViewCb): Create an inspector window.
+ (createBrowser): Connect to inspect-web-view signal of the view
+ inspector.
+
2012-04-19 Jeremy Mao <[email protected]>
Media Stream API: Piece of code cleanup for the chromium port
Modified: trunk/Tools/GNUmakefile.am (114719 => 114720)
--- trunk/Tools/GNUmakefile.am 2012-04-20 06:44:45 UTC (rev 114719)
+++ trunk/Tools/GNUmakefile.am 2012-04-20 06:47:52 UTC (rev 114720)
@@ -12,6 +12,8 @@
$(_javascript_core_cppflags)
Programs_GtkLauncher_SOURCES = \
+ Tools/GtkLauncher/LauncherInspectorWindow.c \
+ Tools/GtkLauncher/LauncherInspectorWindow.h \
Tools/GtkLauncher/main.c
Programs_GtkLauncher_CFLAGS = \
Added: trunk/Tools/GtkLauncher/LauncherInspectorWindow.c (0 => 114720)
--- trunk/Tools/GtkLauncher/LauncherInspectorWindow.c (rev 0)
+++ trunk/Tools/GtkLauncher/LauncherInspectorWindow.c 2012-04-20 06:47:52 UTC (rev 114720)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "LauncherInspectorWindow.h"
+
+struct _LauncherInspectorWindow {
+ GtkWindow parent;
+
+ WebKitWebInspector *inspector;
+ GtkWidget *webView;
+};
+
+struct _LauncherInspectorWindowClass {
+ GtkWindowClass parent;
+};
+
+G_DEFINE_TYPE(LauncherInspectorWindow, launcher_inspector_window, GTK_TYPE_WINDOW)
+
+static void launcherInspectorWindowFinalize(GObject *gObject)
+{
+ LauncherInspectorWindow *inspectorWindow = LAUNCHER_INSPECTOR_WINDOW(gObject);
+ if (inspectorWindow->inspector)
+ g_object_unref(inspectorWindow->inspector);
+
+ G_OBJECT_CLASS(launcher_inspector_window_parent_class)->finalize(gObject);
+}
+
+static void launcher_inspector_window_init(LauncherInspectorWindow *inspectorWindow)
+{
+ gtk_window_set_title(GTK_WINDOW(inspectorWindow), "Web Inspector");
+ gtk_window_set_default_size(GTK_WINDOW(inspectorWindow), 800, 600);
+}
+
+static void launcher_inspector_window_class_init(LauncherInspectorWindowClass *klass)
+{
+ GObjectClass *gobjectClass = G_OBJECT_CLASS(klass);
+ gobjectClass->finalize = launcherInspectorWindowFinalize;
+}
+
+static void inspectedURIChanged(WebKitWebInspector *inspector, GParamSpec *paramSpec, LauncherInspectorWindow *inspectorWindow)
+{
+ gchar *title = g_strdup_printf("Web Inspector - %s", webkit_web_inspector_get_inspected_uri(inspector));
+ gtk_window_set_title(GTK_WINDOW(inspectorWindow), title);
+ g_free(title);
+}
+
+static gboolean showInspectorWindow(WebKitWebInspector *inspector, LauncherInspectorWindow *inspectorWindow)
+{
+ gtk_widget_show(GTK_WIDGET(inspectorWindow));
+ return TRUE;
+}
+
+static gboolean closeInspectorWindow(WebKitWebInspector *inspector, LauncherInspectorWindow *inspectorWindow)
+{
+ gtk_widget_hide(GTK_WIDGET(inspectorWindow));
+ return TRUE;
+}
+
+GtkWidget *launcherInspectorWindowNew(WebKitWebInspector *inspector, GtkWindow *parent)
+{
+ LauncherInspectorWindow *inspectorWindow = LAUNCHER_INSPECTOR_WINDOW(g_object_new(LAUNCHER_TYPE_INSPECTOR_WINDOW, "type", GTK_WINDOW_TOPLEVEL, NULL));
+ inspectorWindow->inspector = g_object_ref(inspector);
+ inspectorWindow->webView = webkit_web_view_new();
+ gtk_window_set_transient_for(GTK_WINDOW(inspectorWindow), parent);
+
+ GtkWidget *scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(scrolledWindow), inspectorWindow->webView);
+ gtk_widget_show(inspectorWindow->webView);
+
+ gtk_container_add(GTK_CONTAINER(inspectorWindow), scrolledWindow);
+ gtk_widget_show(scrolledWindow);
+
+ g_signal_connect(inspector, "notify::inspected-uri", G_CALLBACK(inspectedURIChanged), inspectorWindow);
+ g_signal_connect(inspector, "show-window", G_CALLBACK(showInspectorWindow), inspectorWindow);
+ g_signal_connect(inspector, "close-window", G_CALLBACK(closeInspectorWindow), inspectorWindow);
+
+ return GTK_WIDGET(inspectorWindow);
+}
+
+WebKitWebView *launcherInspectorWindowGetWebView(LauncherInspectorWindow *inspectorWindow)
+{
+ g_return_val_if_fail(LAUNCHER_IS_INSPECTOR_WINDOW(inspectorWindow), 0);
+
+ return WEBKIT_WEB_VIEW(inspectorWindow->webView);
+}
Added: trunk/Tools/GtkLauncher/LauncherInspectorWindow.h (0 => 114720)
--- trunk/Tools/GtkLauncher/LauncherInspectorWindow.h (rev 0)
+++ trunk/Tools/GtkLauncher/LauncherInspectorWindow.h 2012-04-20 06:47:52 UTC (rev 114720)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef LauncherInspectorWindow_h
+#define LauncherInspectorWindow_h
+
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+G_BEGIN_DECLS
+
+#define LAUNCHER_TYPE_INSPECTOR_WINDOW (launcher_inspector_window_get_type())
+#define LAUNCHER_INSPECTOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LAUNCHER_TYPE_INSPECTOR_WINDOW, LauncherInspectorWindow))
+#define LAUNCHER_IS_INSPECTOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LAUNCHER_TYPE_INSPECTOR_WINDOW))
+#define LAUNCHER_INSPECTOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LAUNCHER_TYPE_INSPECTOR_WINDOW, LauncherInspectorWindowClass))
+#define LAUNCHER_IS_INSPECTOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), LAUNCHER_TYPE_INSPECTOR_WINDOW))
+#define LAUNCHER_INSPECTOR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LAUNCHER_TYPE_INSPECTOR_WINDOW, LauncherInspectorWindowClass))
+
+typedef struct _LauncherInspectorWindow LauncherInspectorWindow;
+typedef struct _LauncherInspectorWindowClass LauncherInspectorWindowClass;
+
+GType launcher_inspector_window_get_type(void);
+
+GtkWidget *launcherInspectorWindowNew(WebKitWebInspector *, GtkWindow *parent);
+WebKitWebView *launcherInspectorWindowGetWebView(LauncherInspectorWindow *);
+
+G_END_DECLS
+
+#endif
Modified: trunk/Tools/GtkLauncher/main.c (114719 => 114720)
--- trunk/Tools/GtkLauncher/main.c 2012-04-20 06:44:45 UTC (rev 114719)
+++ trunk/Tools/GtkLauncher/main.c 2012-04-20 06:47:52 UTC (rev 114720)
@@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "LauncherInspectorWindow.h"
#include <errno.h>
#include <gtk/gtk.h>
#include <stdlib.h>
@@ -206,6 +207,12 @@
g_object_unref(icon);
}
+static GtkWidget *inspectorInspectWebViewCb(WebKitWebInspector *inspector, WebKitWebView *webView, GtkWindow* window)
+{
+ GtkWidget *inspectorWindow = launcherInspectorWindowNew(inspector, window);
+ return GTK_WIDGET(launcherInspectorWindowGetWebView(LAUNCHER_INSPECTOR_WINDOW(inspectorWindow)));
+}
+
static GtkWidget* createBrowser(GtkWidget* window, GtkWidget* uriEntry, GtkWidget* statusbar, WebKitWebView* webView, GtkWidget* vbox)
{
char *iconDatabasePath;
@@ -228,6 +235,7 @@
g_signal_connect(webView, "close-web-view", G_CALLBACK(closeWebViewCb), window);
g_signal_connect(webView, "entering-fullscreen", G_CALLBACK(webViewEnteringFullScreen), vbox);
g_signal_connect(webView, "leaving-fullscreen", G_CALLBACK(webViewLeavingFullScreen), vbox);
+ g_signal_connect(webkit_web_view_get_inspector(webView), "inspect-web-view", G_CALLBACK(inspectorInspectWebViewCb), window);
return scrolledWindow;
}