2008-10-29 Gustavo Noronha Silva <gns@gnome.org>
authorzecke@webkit.org <zecke@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Oct 2008 22:39:18 +0000 (22:39 +0000)
committerzecke@webkit.org <zecke@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Oct 2008 22:39:18 +0000 (22:39 +0000)
        Reviewed by Holger Freyther.

        Added all the files that need to be installed for the Inspector to
        work.

WebCore/ChangeLog:
2008-10-29  Gustavo Noronha Silva  <gns@gnome.org>

        Reviewed and slightly changed by Holger Freyther.

        Added all the files that need to be installed for the Inspector to
        work.

        * GNUmakefile.am: Invoke the shell to get the files.

WebKit/gtk:
2008-10-29  Gustavo Noronha Silva  <gns@gnome.org>

        Reviewed and slightly changed by Holger Freyther.

        Implemented a new WebKitWebInspector class to provide a GObject
        API for the Web Inspector. Also implemented InspectorClient.

        * WebCoreSupport/InspectorClientGtk.cpp:
        (WebKit::notifyWebViewDestroyed):
        (WebKit::InspectorClient::InspectorClient):
        (WebKit::InspectorClient::inspectorDestroyed):
        (WebKit::InspectorClient::webViewDestroyed):
        (WebKit::InspectorClient::createPage):
        (WebKit::InspectorClient::showWindow):
        (WebKit::InspectorClient::closeWindow):
        (WebKit::InspectorClient::attachWindow):
        (WebKit::InspectorClient::detachWindow):
        (WebKit::InspectorClient::inspectedURLChanged):
        * WebCoreSupport/InspectorClientGtk.h:
        * webkit/webkit.h:
        * webkit/webkit-marshal.list:
        * webkit/webkitdefines.h:
        * webkit/webkitprivate.h:
        * webkit/webkitwebinspector.cpp: Added.
        (_WebKitWebInspectorPrivate::webkit_inspect_web_view_request_handled):
        (_WebKitWebInspectorPrivate::webkit_web_inspector_class_init):
        (_WebKitWebInspectorPrivate::webkit_web_inspector_init):
        (_WebKitWebInspectorPrivate::webkit_web_inspector_finalize):
        (_WebKitWebInspectorPrivate::webkit_web_inspector_set_property):
        (_WebKitWebInspectorPrivate::webkit_web_inspector_get_property):
        (_WebKitWebInspectorPrivate::webkit_web_inspector_set_web_view):
        * webkit/webkitwebinspector.h: Added.
        * webkit/webkitwebsettings.cpp:
        (_WebKitWebSettingsPrivate::):
        (_WebKitWebSettingsPrivate::webkit_web_settings_class_init):
        (_WebKitWebSettingsPrivate::webkit_web_settings_set_property):
        (_WebKitWebSettingsPrivate::webkit_web_settings_get_property):
        (_WebKitWebSettingsPrivate::webkit_web_settings_copy):
        * webkit/webkitwebview.cpp:
        * webkit/webkitwebview.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@37982 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
ChangeLog
GNUmakefile.am
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp
WebKit/gtk/WebCoreSupport/InspectorClientGtk.h
WebKit/gtk/webkit/webkit.h
WebKit/gtk/webkit/webkitdefines.h
WebKit/gtk/webkit/webkitprivate.h
WebKit/gtk/webkit/webkitwebinspector.cpp [new file with mode: 0644]
WebKit/gtk/webkit/webkitwebinspector.h [new file with mode: 0644]
WebKit/gtk/webkit/webkitwebsettings.cpp
WebKit/gtk/webkit/webkitwebview.cpp
WebKit/gtk/webkit/webkitwebview.h

index 144cc0e..9318bca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-29  Gustavo Noronha Silva  <gns@gnome.org>
+
+        Reviewed by Holger Freyther.
+
+        Added all the files that need to be installed for the Inspector to
+        work.
+
 2008-10-29  Mike Hommey  <glandium@debian.org>
 
         Reviewed by Holger Freyther.
index 037006b..2d63993 100644 (file)
@@ -309,6 +309,7 @@ webkitgtk_h_api += \
        WebKit/gtk/webkit/webkitwebbackforwardlist.h \
        WebKit/gtk/webkit/webkitwebframe.h \
        WebKit/gtk/webkit/webkitwebhistoryitem.h \
+       WebKit/gtk/webkit/webkitwebinspector.h \
        WebKit/gtk/webkit/webkitwebsettings.h \
        WebKit/gtk/webkit/webkitwebview.h
 
@@ -340,6 +341,7 @@ webkitgtk_sources += \
        WebKit/gtk/webkit/webkitwebbackforwardlist.cpp \
        WebKit/gtk/webkit/webkitwebframe.cpp \
        WebKit/gtk/webkit/webkitwebhistoryitem.cpp \
+       WebKit/gtk/webkit/webkitwebinspector.cpp \
        WebKit/gtk/webkit/webkitwebsettings.cpp \
        WebKit/gtk/webkit/webkitwebview.cpp
 
index ad38f6f..4a25323 100644 (file)
@@ -1,3 +1,12 @@
+2008-10-29  Gustavo Noronha Silva  <gns@gnome.org>
+
+        Reviewed and slightly changed by Holger Freyther.
+
+        Added all the files that need to be installed for the Inspector to
+        work.
+
+        * GNUmakefile.am: Invoke the shell to get the files.
+
 2008-10-29  Andrew Scherkus  <scherkus@chromium.org>
 
         Reviewed by Darin Adler
index 5858c5f..c014ac6 100644 (file)
@@ -2954,6 +2954,17 @@ webcore_dist += \
        WebCore/xml/xmlattrs.in \
        WebCore/xml/XPathGrammar.y
 
+# Installing web inspector files
+webcore_cppflags += -DDATA_DIR=\"${datadir}\"
+
+webinspectordir = ${datadir}/webkit-1.0/webinspector
+dist_webinspector_DATA = \
+       $(shell ls $(WebCore)/inspector/front-end/*.{js,html,css})
+
+webinspectorimagesdir = ${datadir}/webkit-1.0/webinspector/Images
+dist_webinspectorimages_DATA = \
+       $(shell ls $(WebCore)/inspector/front-end/Images/*.png)
+
 # Clean rules for WebCore
 
 CLEANFILES += \
index 7736728..bad8d14 100644 (file)
@@ -1,3 +1,44 @@
+2008-10-29  Gustavo Noronha Silva  <gns@gnome.org>
+
+        Reviewed and slightly changed by Holger Freyther.
+
+        Implemented a new WebKitWebInspector class to provide a GObject
+        API for the Web Inspector. Also implemented InspectorClient.
+
+        * WebCoreSupport/InspectorClientGtk.cpp:
+        (WebKit::notifyWebViewDestroyed):
+        (WebKit::InspectorClient::InspectorClient):
+        (WebKit::InspectorClient::inspectorDestroyed):
+        (WebKit::InspectorClient::webViewDestroyed):
+        (WebKit::InspectorClient::createPage):
+        (WebKit::InspectorClient::showWindow):
+        (WebKit::InspectorClient::closeWindow):
+        (WebKit::InspectorClient::attachWindow):
+        (WebKit::InspectorClient::detachWindow):
+        (WebKit::InspectorClient::inspectedURLChanged):
+        * WebCoreSupport/InspectorClientGtk.h:
+        * webkit/webkit.h:
+        * webkit/webkit-marshal.list:
+        * webkit/webkitdefines.h:
+        * webkit/webkitprivate.h:
+        * webkit/webkitwebinspector.cpp: Added.
+        (_WebKitWebInspectorPrivate::webkit_inspect_web_view_request_handled):
+        (_WebKitWebInspectorPrivate::webkit_web_inspector_class_init):
+        (_WebKitWebInspectorPrivate::webkit_web_inspector_init):
+        (_WebKitWebInspectorPrivate::webkit_web_inspector_finalize):
+        (_WebKitWebInspectorPrivate::webkit_web_inspector_set_property):
+        (_WebKitWebInspectorPrivate::webkit_web_inspector_get_property):
+        (_WebKitWebInspectorPrivate::webkit_web_inspector_set_web_view):
+        * webkit/webkitwebinspector.h: Added.
+        * webkit/webkitwebsettings.cpp:
+        (_WebKitWebSettingsPrivate::):
+        (_WebKitWebSettingsPrivate::webkit_web_settings_class_init):
+        (_WebKitWebSettingsPrivate::webkit_web_settings_set_property):
+        (_WebKitWebSettingsPrivate::webkit_web_settings_get_property):
+        (_WebKitWebSettingsPrivate::webkit_web_settings_copy):
+        * webkit/webkitwebview.cpp:
+        * webkit/webkitwebview.h:
+
 2008-10-27  Michael Tross  <michael@tross.org>
 
         Reviewed by Alp Toker. Landed by Jan Alonzo.
index 6d2b633..9406448 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * Copyright (C) 2008 Gustavo Noronha Silva
+ *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
  *  License as published by the Free Software Foundation; either
 #include "config.h"
 #include "InspectorClientGtk.h"
 
+#include "webkitwebview.h"
+#include "webkitwebinspector.h"
+#include "webkitprivate.h"
+#include "CString.h"
+#include "InspectorController.h"
 #include "NotImplemented.h"
 #include "PlatformString.h"
 
@@ -24,15 +31,71 @@ using namespace WebCore;
 
 namespace WebKit {
 
+static void notifyWebViewDestroyed(WebKitWebView* webView, InspectorClient* inspectorClient)
+{
+    inspectorClient->webViewDestroyed();
+}
+
+InspectorClient::InspectorClient(WebKitWebView* webView)
+    : m_webView(0)
+    , m_inspectedWebView(webView)
+    , m_webInspector(0)
+{}
+
 void InspectorClient::inspectorDestroyed()
 {
+    if (m_webView) {
+        gboolean handled = FALSE;
+        g_signal_emit_by_name(m_webInspector, "destroy", &handled);
+
+        /* we can now dispose our own reference */
+        g_object_unref(m_webInspector);
+    }
+
     delete this;
 }
 
+void InspectorClient::webViewDestroyed()
+{
+    m_webView = 0;
+    core(m_inspectedWebView)->inspectorController()->pageDestroyed();
+
+    // createPage will be called again, if the user chooses to inspect
+    // something else, and the inspector will be referenced again,
+    // there.
+    g_object_unref(m_webInspector);
+}
+
 Page* InspectorClient::createPage()
 {
-    notImplemented();
-    return 0;
+    if (m_webView)
+      return core(m_webView);
+
+    // This g_object_get will ref the inspector. We're not doing an
+    // unref if this method succeeds because the inspector object must
+    // be alive even after the inspected WebView is destroyed - the
+    // close-window and destroy signals still need to be
+    // emitted.
+    WebKitWebInspector* webInspector;
+    g_object_get(G_OBJECT(m_inspectedWebView), "web-inspector", &webInspector, NULL);
+    m_webInspector = webInspector;
+
+    g_signal_emit_by_name(m_webInspector, "inspect-web-view", m_inspectedWebView, &m_webView);
+
+    if (!m_webView) {
+        g_object_unref(m_webInspector);
+        return 0;
+    }
+
+    webkit_web_inspector_set_web_view(m_webInspector, m_webView);
+
+    g_signal_connect(G_OBJECT(m_webView), "destroy",
+                     G_CALLBACK(notifyWebViewDestroyed), (gpointer)this);
+
+    webkit_web_view_open(m_webView, "file://"DATA_DIR"/webkit-1.0/webinspector/inspector.html");
+    gtk_widget_show(GTK_WIDGET(m_webView));
+
+    return core(m_webView);
 }
 
 String InspectorClient::localizedStringsURL()
@@ -43,22 +106,42 @@ String InspectorClient::localizedStringsURL()
 
 void InspectorClient::showWindow()
 {
-    notImplemented();
+    if (!m_webView)
+        return;
+
+    gboolean handled = FALSE;
+    g_signal_emit_by_name(m_webInspector, "show-window", &handled);
+
+    core(m_inspectedWebView)->inspectorController()->setWindowVisible(true);
 }
 
 void InspectorClient::closeWindow()
 {
-    notImplemented();
+    if (!m_webView)
+        return;
+
+    gboolean handled = FALSE;
+    g_signal_emit_by_name(m_webInspector, "close-window", &handled);
+
+    core(m_inspectedWebView)->inspectorController()->setWindowVisible(false);
 }
 
 void InspectorClient::attachWindow()
 {
-    notImplemented();
+    if (!m_webView)
+        return;
+
+    gboolean handled = FALSE;
+    g_signal_emit_by_name(m_webInspector, "attach-window", &handled);
 }
 
 void InspectorClient::detachWindow()
 {
-    notImplemented();
+    if (!m_webView)
+        return;
+
+    gboolean handled = FALSE;
+    g_signal_emit_by_name(m_webInspector, "dettach-window", &handled);
 }
 
 void InspectorClient::setAttachedWindowHeight(unsigned height)
@@ -76,9 +159,12 @@ void InspectorClient::hideHighlight()
     notImplemented();
 }
 
-void InspectorClient::inspectedURLChanged(const String&)
+void InspectorClient::inspectedURLChanged(const String& newURL)
 {
-    notImplemented();
+    if (!m_webView)
+        return;
+
+    webkit_web_inspector_set_inspected_uri(m_webInspector, newURL.utf8().data());
 }
 
 void InspectorClient::populateSetting(const String& key, InspectorController::Setting& setting)
index e1a573a..4fba55d 100644 (file)
@@ -30,6 +30,8 @@
 #define InspectorClientGtk_h
 
 #include "InspectorClient.h"
+#include "webkitwebview.h"
+#include "webkitwebinspector.h"
 
 namespace WebCore {
     class Node;
@@ -41,7 +43,10 @@ namespace WebKit {
 
     class InspectorClient : public WebCore::InspectorClient {
     public:
+        InspectorClient(WebKitWebView* webView);
+
         virtual void inspectorDestroyed();
+        void webViewDestroyed();
 
         virtual WebCore::Page* createPage();
 
@@ -62,6 +67,11 @@ namespace WebKit {
         virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&);
         virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&);
         virtual void removeSetting(const WebCore::String& key);
+
+    private:
+        WebKitWebView* m_webView;
+        WebKitWebView* m_inspectedWebView;
+        WebKitWebInspector* m_webInspector;
     };
 }
 
index 10c214f..e19cbc7 100644 (file)
@@ -25,6 +25,7 @@
 #include <webkit/webkitnetworkrequest.h>
 #include <webkit/webkitwebframe.h>
 #include <webkit/webkitwebsettings.h>
+#include <webkit/webkitwebinspector.h>
 #include <webkit/webkitwebview.h>
 #include <webkit/webkitwebbackforwardlist.h>
 #include <webkit/webkitwebhistoryitem.h>
index 386c3e1..0c080f4 100644 (file)
@@ -55,6 +55,9 @@ typedef struct _WebKitWebFrameClass WebKitWebFrameClass;
 typedef struct _WebKitWebSettings WebKitWebSettings;
 typedef struct _WebKitWebSettingsClass WebKitWebSettingsClass;
 
+typedef struct _WebKitWebInspector WebKitWebInspector;
+typedef struct _WebKitWebInspectorClass WebKitWebInspectorClass;
+
 typedef struct _WebKitWebView WebKitWebView;
 typedef struct _WebKitWebViewClass WebKitWebViewClass;
 
index 3efa02a..3047af4 100644 (file)
@@ -37,6 +37,7 @@
 #include "Settings.h"
 #include "Page.h"
 #include "Frame.h"
+#include "InspectorClientGtk.h"
 #include "FrameLoaderClient.h"
 
 #include <glib.h>
@@ -67,6 +68,7 @@ extern "C" {
     struct _WebKitWebViewPrivate {
         WebCore::Page* corePage;
         WebKitWebSettings* webSettings;
+        WebKitWebInspector* webInspector;
 
         WebKitWebFrame* mainFrame;
         WebCore::String applicationNameForUserAgent;
@@ -110,6 +112,15 @@ extern "C" {
     WebKitWebHistoryItem*
     webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*);
 
+    void
+    webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebKit::InspectorClient*);
+
+    void
+    webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKitWebView *web_view);
+
+    void
+    webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri);
+
     // FIXME: Move these to webkitwebframe.h once their API has been discussed.
 
     WEBKIT_API GSList*
diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp
new file mode 100644 (file)
index 0000000..c7468ed
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+ * Copyright (C) 2008 Gustavo Noronha Silva
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "webkitwebinspector.h"
+#include "webkitmarshal.h"
+#include "InspectorClientGtk.h"
+#include "webkitprivate.h"
+
+using namespace WebKit;
+
+extern "C" {
+
+enum {
+    INSPECT_WEB_VIEW,
+    SHOW_WINDOW,
+    ATTACH_WINDOW,
+    DETTACH_WINDOW,
+    CLOSE_WINDOW,
+    FINISHED,
+    LAST_SIGNAL
+};
+
+static guint webkit_web_inspector_signals[LAST_SIGNAL] = { 0, };
+
+enum {
+    PROP_0,
+
+    PROP_WEB_VIEW,
+    PROP_INSPECTED_URI,
+};
+
+G_DEFINE_TYPE(WebKitWebInspector, webkit_web_inspector, G_TYPE_OBJECT)
+
+struct _WebKitWebInspectorPrivate {
+    InspectorClient* inspectorClient;
+    WebKitWebView* inspector_view;
+    gchar* inspected_uri;
+};
+
+#define WEBKIT_WEB_INSPECTOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorPrivate))
+
+static void webkit_web_inspector_finalize(GObject* object);
+
+static void webkit_web_inspector_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
+
+static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
+
+static gboolean webkit_inspect_web_view_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
+{
+    gboolean continueEmission = TRUE;
+    gpointer newWebView = g_value_get_object(handlerReturn);
+    g_value_set_object(returnAccu, newWebView);
+
+    if (newWebView)
+        continueEmission = FALSE;
+
+    return continueEmission;
+}
+
+static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
+{
+    GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+    gobject_class->finalize = webkit_web_inspector_finalize;
+    gobject_class->set_property = webkit_web_inspector_set_property;
+    gobject_class->get_property = webkit_web_inspector_get_property;
+
+    /**
+     * WebKitWebInspector::inspect-web-view:
+     * @web_inspector: the object on which the signal is emitted
+     * @web_view: the #WebKitWeb which will be inspected
+     * @return: a newly allocated #WebKitWebView or %NULL
+     *
+     * Emitted when the user activates the 'inspect' context menu item
+     * to inspect a web view. The application which is interested in
+     * the inspector should create a window, or otherwise add the
+     * #WebKitWebView it creates to an existing window.
+     *
+     * You don't need to handle the reference count of the
+     * #WebKitWebView instance you create; the widget to which you add
+     * it will do that.
+     *
+     * Since: 1.0.2
+     */
+    webkit_web_inspector_signals[INSPECT_WEB_VIEW] = g_signal_new("inspect-web-view",
+            G_TYPE_FROM_CLASS(klass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            webkit_inspect_web_view_request_handled,
+            NULL,
+            webkit_marshal_OBJECT__OBJECT,
+            WEBKIT_TYPE_WEB_VIEW , 1,
+            WEBKIT_TYPE_WEB_VIEW);
+
+    /**
+     * WebKitWebInspector::show-window:
+     * @web_inspector: the object on which the signal is emitted
+     * @return: %TRUE if the signal has been handled
+     *
+     * Emitted when the inspector window should be displayed. Notice
+     * that the window must have been created already by handling
+     * ::inspect-web-view.
+     *
+     * Since: 1.0.2
+     */
+    webkit_web_inspector_signals[SHOW_WINDOW] = g_signal_new("show-window",
+            G_TYPE_FROM_CLASS(klass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            g_signal_accumulator_true_handled,
+            NULL,
+            webkit_marshal_BOOLEAN__VOID,
+            G_TYPE_BOOLEAN , 0);
+
+    /**
+     * WebKitWebInspector::attach-window:
+     * @web_inspector: the object on which the signal is emitted
+     * @return: %TRUE if the signal has been handled
+     *
+     * Emitted when the inspector should appear at the same window as
+     * the #WebKitWebView being inspected.
+     *
+     * Since: 1.0.2
+     */
+    webkit_web_inspector_signals[ATTACH_WINDOW] = g_signal_new("attach-window",
+            G_TYPE_FROM_CLASS(klass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            g_signal_accumulator_true_handled,
+            NULL,
+            webkit_marshal_BOOLEAN__VOID,
+            G_TYPE_BOOLEAN , 0);
+
+    /**
+     * WebKitWebInspector::dettach-window:
+     * @web_inspector: the object on which the signal is emitted
+     * @return: %TRUE if the signal has been handled
+     *
+     * Emitted when the inspector should appear in a separate window.
+     *
+     * Since: 1.0.2
+     */
+    webkit_web_inspector_signals[DETTACH_WINDOW] = g_signal_new("dettach-window",
+            G_TYPE_FROM_CLASS(klass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            g_signal_accumulator_true_handled,
+            NULL,
+            webkit_marshal_BOOLEAN__VOID,
+            G_TYPE_BOOLEAN , 0);
+
+    /**
+     * WebKitWebInspector::close-window:
+     * @web_inspector: the object on which the signal is emitted
+     * @return: %TRUE if the signal has been handled
+     *
+     * Emitted when the inspector window should be closed. You can
+     * destroy the window or hide it so that it can be displayed again
+     * by handling ::show-window later on.
+     *
+     * Notice that the inspected #WebKitWebView may no longer exist
+     * when this signal is emitted.
+     *
+     * Notice, too, that if you decide to destroy the window,
+     * ::inspect-web-view will be emmited again, when the user
+     * inspects an element.
+     *
+     * Since: 1.0.2
+     */
+    webkit_web_inspector_signals[CLOSE_WINDOW] = g_signal_new("close-window",
+            G_TYPE_FROM_CLASS(klass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            g_signal_accumulator_true_handled,
+            NULL,
+            webkit_marshal_BOOLEAN__VOID,
+            G_TYPE_BOOLEAN , 0);
+
+    /**
+     * WebKitWebInspector::finished:
+     * @web_inspector: the object on which the signal is emitted
+     *
+     * Emitted when the inspection is done. You should release your
+     * references on the inspector at this time. The inspected
+     * #WebKitWebView may no longer exist when this signal is emitted.
+     *
+     * Since: 1.0.2
+     */
+    webkit_web_inspector_signals[FINISHED] = g_signal_new("finished",
+            G_TYPE_FROM_CLASS(klass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+            0,
+            NULL,
+            NULL,
+            g_cclosure_marshal_VOID__VOID,
+            G_TYPE_NONE , 0);
+
+    /*
+     * properties
+     */
+
+    /**
+     * WebKitWebInspector:web-view:
+     *
+     * The Web View that renders the Web Inspector itself.
+     *
+     * Since: 1.0.2
+     */
+    g_object_class_install_property(gobject_class, PROP_WEB_VIEW,
+                                    g_param_spec_object("web-view",
+                                                        "Web View",
+                                                        "The Web View that renders the Web Inspector itself",
+                                                        WEBKIT_TYPE_WEB_VIEW,
+                                                        WEBKIT_PARAM_READABLE));
+
+    /**
+     * WebKitWebInspector:inspected-uri:
+     *
+     * The URI that is currently being inspected.
+     *
+     * Since: 1.0.2
+     */
+    g_object_class_install_property(gobject_class, PROP_INSPECTED_URI,
+                                    g_param_spec_string("inspected-uri",
+                                                        "Inspected URI",
+                                                        "The URI that is currently being inspected",
+                                                        NULL,
+                                                        WEBKIT_PARAM_READABLE));
+
+    g_type_class_add_private(klass, sizeof(WebKitWebInspectorPrivate));
+}
+
+static void webkit_web_inspector_init(WebKitWebInspector* web_inspector)
+{
+    web_inspector->priv = WEBKIT_WEB_INSPECTOR_GET_PRIVATE(web_inspector);
+}
+
+static void webkit_web_inspector_finalize(GObject* object)
+{
+    WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object);
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    if (priv->inspector_view)
+        g_object_unref(priv->inspector_view);
+
+    if (priv->inspected_uri)
+        g_free(priv->inspected_uri);
+
+    G_OBJECT_CLASS(webkit_web_inspector_parent_class)->finalize(object);
+}
+
+static void webkit_web_inspector_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
+{
+    switch(prop_id) {
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
+{
+    WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object);
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    switch (prop_id) {
+    case PROP_WEB_VIEW:
+        g_value_set_object(value, priv->inspector_view);
+        break;
+    case PROP_INSPECTED_URI:
+        g_value_set_string(value, priv->inspected_uri);
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+// internal use only
+void webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKitWebView *web_view)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(web_inspector));
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(web_view));
+
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    if (priv->inspector_view)
+        g_object_unref(priv->inspector_view);
+
+    g_object_ref(web_view);
+    priv->inspector_view = web_view;
+}
+
+/**
+ * webkit_web_inspector_get_web_view:
+ *
+ * Obtains the #WebKitWebView that is used to render the
+ * inspector. The #WebKitWebView instance is created by the
+ * application, by handling the ::inspect-web-view signal. This means
+ * that this method may return %NULL if the user hasn't inspected
+ * anything.
+ *
+ * Returns: the #WebKitWebView instance that is used to render the
+ * inspector or %NULL if it is not yet created.
+ *
+ * Since: 1.0.2
+ **/
+WebKitWebView* webkit_web_inspector_get_web_view(WebKitWebInspector *web_inspector)
+{
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    return priv->inspector_view;
+}
+
+// internal use only
+void webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(web_inspector));
+
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    g_free(priv->inspected_uri);
+    priv->inspected_uri = g_strdup(inspected_uri);
+}
+
+/**
+ * webkit_web_inspector_get_inspected_uri:
+ *
+ * Obtains the URI that is currently being inspected.
+ *
+ * Returns: a pointer to the URI as an internally allocated string; it
+ * should not be freed, modified or stored.
+ *
+ * Since: 1.0.2
+ **/
+const gchar* webkit_web_inspector_get_inspected_uri(WebKitWebInspector *web_inspector)
+{
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    return priv->inspected_uri;
+}
+
+void
+webkit_web_inspector_set_inspector_client(WebKitWebInspector* web_inspector, WebKit::InspectorClient* inspectorClient)
+{
+    WebKitWebInspectorPrivate* priv = web_inspector->priv;
+
+    priv->inspectorClient = inspectorClient;
+}
+
+}
diff --git a/WebKit/gtk/webkit/webkitwebinspector.h b/WebKit/gtk/webkit/webkitwebinspector.h
new file mode 100644 (file)
index 0000000..41ccf92
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 Gustavo Noronha Silva
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __WEBKIT_WEB_INSPECTOR_H__
+#define __WEBKIT_WEB_INSPECTOR_H__
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_INSPECTOR            (webkit_web_inspector_get_type())
+#define WEBKIT_WEB_INSPECTOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspector))
+#define WEBKIT_WEB_INSPECTOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorClass))
+#define WEBKIT_IS_WEB_INSPECTOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_INSPECTOR))
+#define WEBKIT_IS_WEB_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_INSPECTOR))
+#define WEBKIT_WEB_INSPECTOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorClass))
+
+typedef struct _WebKitWebInspectorPrivate WebKitWebInspectorPrivate;
+
+struct _WebKitWebInspector {
+    GObject parent_instance;
+
+    WebKitWebInspectorPrivate* priv;
+};
+
+struct _WebKitWebInspectorClass {
+    GObjectClass parent_class;
+
+    /* Padding for future expansion */
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+    void (*_webkit_reserved4) (void);
+};
+
+WEBKIT_API GType
+webkit_web_inspector_get_type (void);
+
+WEBKIT_API WebKitWebView*
+webkit_web_inspector_get_web_view(WebKitWebInspector* web_inspector);
+
+WEBKIT_API const gchar*
+webkit_web_inspector_get_inspected_uri(WebKitWebInspector* web_inspector);
+
+G_END_DECLS
+
+#endif /* __WEBKIT_WEB_INSPECTOR_H__ */
index 08e409d..bd99a66 100644 (file)
@@ -48,6 +48,7 @@ struct _WebKitWebSettingsPrivate {
     gboolean resizable_text_areas;
     gchar* user_stylesheet_uri;
     gfloat zoom_step;
+    gboolean enable_developer_extras;
 };
 
 #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -73,7 +74,8 @@ enum {
     PROP_ENABLE_PLUGINS,
     PROP_RESIZABLE_TEXT_AREAS,
     PROP_USER_STYLESHEET_URI,
-    PROP_ZOOM_STEP
+    PROP_ZOOM_STEP,
+    PROP_ENABLE_DEVELOPER_EXTRAS
 };
 
 static void webkit_web_settings_finalize(GObject* object);
@@ -268,6 +270,25 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
                                     0.0f, G_MAXFLOAT, 0.1f,
                                     flags));
 
+    /**
+    * WebKitWebSettings:enable-developer-extras:
+    *
+    * Whether developer extensions should be enabled. This enables,
+    * for now, the Web Inspector, which can be controlled using the
+    * #WebKitWebInspector instance held by the #WebKitWebView this
+    * setting is enabled for.
+    *
+    * Since: 1.0.2
+    */
+    g_object_class_install_property(gobject_class,
+                                    PROP_ENABLE_DEVELOPER_EXTRAS,
+                                    g_param_spec_boolean(
+                                    "enable-developer-extras",
+                                    "Enable Developer Extras",
+                                    "Enables special extensions that help developers",
+                                    FALSE,
+                                    flags));
+
     g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
 }
 
@@ -364,6 +385,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
     case PROP_ZOOM_STEP:
         priv->zoom_step = g_value_get_float(value);
         break;
+    case PROP_ENABLE_DEVELOPER_EXTRAS:
+        priv->enable_developer_extras = g_value_get_boolean(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -433,6 +457,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
     case PROP_ZOOM_STEP:
         g_value_set_float(value, priv->zoom_step);
         break;
+    case PROP_ENABLE_DEVELOPER_EXTRAS:
+        g_value_set_boolean(value, priv->enable_developer_extras);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -483,6 +510,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
                  "resizable-text-areas", priv->resizable_text_areas,
                  "user-stylesheet-uri", priv->user_stylesheet_uri,
                  "zoom-step", priv->zoom_step,
+                 "enable-developer-extras", priv->enable_developer_extras,
                  NULL));
 
     return copy;
index 59f12f8..0ffb828 100644 (file)
@@ -27,6 +27,7 @@
 #include "webkitwebview.h"
 #include "webkitmarshal.h"
 #include "webkitprivate.h"
+#include "webkitwebinspector.h"
 #include "webkitwebbackforwardlist.h"
 #include "webkitwebhistoryitem.h"
 
@@ -101,6 +102,7 @@ enum {
     PROP_PASTE_TARGET_LIST,
     PROP_EDITABLE,
     PROP_SETTINGS,
+    PROP_WEB_INSPECTOR,
     PROP_TRANSPARENT,
     PROP_ZOOM_LEVEL,
     PROP_FULL_CONTENT_ZOOM
@@ -240,6 +242,9 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
     case PROP_SETTINGS:
         g_value_set_object(value, webkit_web_view_get_settings(webView));
         break;
+    case PROP_WEB_INSPECTOR:
+        g_value_set_object(value, webkit_web_view_get_inspector(webView));
+        break;
     case PROP_TRANSPARENT:
         g_value_set_boolean(value, webkit_web_view_get_transparent(webView));
         break;
@@ -763,6 +768,7 @@ static void webkit_web_view_finalize(GObject* object)
     g_object_unref(priv->backForwardList);
     g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView);
     g_object_unref(priv->webSettings);
+    g_object_unref(priv->webInspector);
     g_object_unref(priv->mainFrame);
     g_object_unref(priv->imContext);
     gtk_target_list_unref(priv->copy_target_list);
@@ -1265,6 +1271,20 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
                                                         WEBKIT_TYPE_WEB_SETTINGS,
                                                         WEBKIT_PARAM_READWRITE));
 
+    /**
+    * WebKitWebView:web-inspector:
+    *
+    * The associated WebKitWebInspector instance.
+    *
+    * Since: 1.0.2
+    */
+    g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR,
+                                    g_param_spec_object("web-inspector",
+                                                        "Web Inspector",
+                                                        "The associated WebKitWebInspector instance",
+                                                        WEBKIT_TYPE_WEB_INSPECTOR,
+                                                        WEBKIT_PARAM_READABLE));
+
     g_object_class_install_property(objectClass, PROP_EDITABLE,
                                     g_param_spec_boolean("editable",
                                                          "Editable",
@@ -1351,7 +1371,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
     Settings* settings = core(webView)->settings();
 
     gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri;
-    gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, resizableTextAreas;
+    gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas;
 
     g_object_get(G_OBJECT(webSettings),
                  "default-encoding", &defaultEncoding,
@@ -1368,6 +1388,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
                  "enable-plugins", &enablePlugins,
                  "resizable-text-areas", &resizableTextAreas,
                  "user-stylesheet-uri", &userStylesheetUri,
+                 "enable-developer-extras", &enableDeveloperExtras,
                  NULL);
 
     settings->setDefaultTextEncodingName(defaultEncoding);
@@ -1384,6 +1405,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
     settings->setPluginsEnabled(enablePlugins);
     settings->setTextAreasAreResizable(resizableTextAreas);
     settings->setUserStyleSheetLocation(KURL(userStylesheetUri));
+    settings->setDeveloperExtrasEnabled(enableDeveloperExtras);
 
     g_free(defaultEncoding);
     g_free(cursiveFontFamily);
@@ -1453,7 +1475,14 @@ static void webkit_web_view_init(WebKitWebView* webView)
     webView->priv = priv;
 
     priv->imContext = gtk_im_multicontext_new();
-    priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient, new WebKit::InspectorClient);
+
+    WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView);
+    priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient, inspectorClient);
+
+    // We also add a simple wrapper class to provide the public
+    // interface for the Web Inspector.
+    priv->webInspector = WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL));
+    webkit_web_inspector_set_inspector_client(priv->webInspector, inspectorClient);
 
     priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
     priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
@@ -1529,6 +1558,30 @@ WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView)
 }
 
 /**
+ * webkit_web_view_get_inspector:
+ * @webView: a #WebKitWebView
+ *
+ * Obtains the #WebKitWebInspector associated with the
+ * #WebKitWebView. Every #WebKitWebView object has a
+ * #WebKitWebInspector object attached to it as soon as it is created,
+ * so this function will only return NULL if the argument is not a
+ * valid #WebKitWebView.
+ *
+ * Returns: the #WebKitWebInspector instance associated with the
+ * #WebKitWebView; %NULL is only returned if the argument is not a
+ * valid #WebKitWebView.
+ *
+ * Since: 1.0.2
+ */
+WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
+
+    WebKitWebViewPrivate* priv = webView->priv;
+    return priv->webInspector;
+}
+
+/**
  * webkit_web_view_set_maintains_back_forward_list:
  * @webView: a #WebKitWebView
  * @flag: to tell the view to maintain a back or forward list
index ebd1aa1..7371959 100644 (file)
@@ -247,6 +247,9 @@ webkit_web_view_set_settings                    (WebKitWebView        *web_view,
 WEBKIT_API WebKitWebSettings *
 webkit_web_view_get_settings                    (WebKitWebView        *web_view);
 
+WEBKIT_API WebKitWebInspector *
+webkit_web_view_get_inspector                   (WebKitWebView        *web_view);
+
 WEBKIT_API gboolean
 webkit_web_view_get_transparent                 (WebKitWebView        *web_view);