diff options
author | Xan Lopez <xan@src.gnome.org> | 2008-12-12 08:14:24 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2008-12-12 08:14:24 +0800 |
commit | 666d79684f69b4ca1bc775dff0f157747c5e6204 (patch) | |
tree | 0a6d9f7901b4e7cfeaee91de2fdedeb288b98274 /embed | |
parent | 6bc97bfc06e1ab3ca9041cae66c1524b7c14284a (diff) | |
download | gsoc2013-epiphany-666d79684f69b4ca1bc775dff0f157747c5e6204.tar.gz gsoc2013-epiphany-666d79684f69b4ca1bc775dff0f157747c5e6204.tar.zst gsoc2013-epiphany-666d79684f69b4ca1bc775dff0f157747c5e6204.zip |
Enable Web Inspector.
Bug #562446
svn path=/trunk/; revision=8634
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-embed-prefs.h | 1 | ||||
-rw-r--r-- | embed/webkit/webkit-embed-prefs.c | 5 | ||||
-rw-r--r-- | embed/webkit/webkit-embed.c | 64 |
3 files changed, 69 insertions, 1 deletions
diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h index 0222c96cb..79c381816 100644 --- a/embed/ephy-embed-prefs.h +++ b/embed/ephy-embed-prefs.h @@ -17,6 +17,7 @@ #define CONF_IMAGE_ANIMATION_MODE "/apps/epiphany/web/image_animation" #define CONF_IMAGE_LOADING_MODE "/apps/epiphany/web/image_loading" #define CONF_DISPLAY_SMOOTHSCROLL "/apps/epiphany/web/smooth_scroll" +#define CONF_WEB_INSPECTOR_ENABLED "/apps/epiphany/web/inspector_enabled" /* These are defined gnome wide now */ #define CONF_NETWORK_PROXY_MODE "/system/proxy/mode" diff --git a/embed/webkit/webkit-embed-prefs.c b/embed/webkit/webkit-embed-prefs.c index 978be49fb..4ee0d0ea0 100644 --- a/embed/webkit/webkit-embed-prefs.c +++ b/embed/webkit/webkit-embed-prefs.c @@ -111,7 +111,10 @@ static const PrefData webkit_pref_entries[] = webkit_pref_callback_boolean }, { CONF_LANGUAGE_DEFAULT_ENCODING, "default-encoding", - webkit_pref_callback_string } + webkit_pref_callback_string }, + { CONF_WEB_INSPECTOR_ENABLED, + "enable-developer-extras", + webkit_pref_callback_boolean } }; static void diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index 198ff07f8..59bf4aeee 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -1,4 +1,5 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ +/* vim: set sw=2 ts=2 sts=2 et: */ /* * Copyright © 2007 Xan Lopez * Copyright © 2008 Jan Alonzo @@ -32,6 +33,7 @@ #include <webkit/webkit.h> #include <string.h> +#include <glib/gi18n.h> #include "webkit-embed.h" #include "webkit-embed-prefs.h" @@ -59,6 +61,7 @@ struct WebKitEmbedPrivate WebKitEmbedLoadState load_state; char *loading_uri; EphyHistory *history; + GtkWidget *inspector_window; guint is_setting_zoom : 1; }; @@ -301,11 +304,45 @@ webkit_embed_class_init (WebKitEmbedClass *klass) g_type_class_add_private (object_class, sizeof(WebKitEmbedPrivate)); } +static WebKitWebView * +webkit_embed_inspect_web_view_cb (WebKitWebInspector *inspector, + WebKitWebView *web_view, + gpointer data) +{ + GtkWidget *inspector_sw = GTK_WIDGET (data); + GtkWidget *inspector_web_view; + + inspector_web_view = webkit_web_view_new (); + gtk_container_add (GTK_CONTAINER (inspector_sw), inspector_web_view); + + gtk_widget_show_all (gtk_widget_get_toplevel (inspector_sw)); + + return WEBKIT_WEB_VIEW (inspector_web_view); +} + +static gboolean +webkit_embed_inspect_show_cb (WebKitWebInspector *inspector, + GtkWidget *widget) +{ + gtk_widget_show (widget); + return TRUE; +} + +static gboolean +webkit_embed_inspect_close_cb (WebKitWebInspector *inspector, + GtkWidget *widget) +{ + gtk_widget_hide (widget); + return TRUE; +} + static void webkit_embed_init (WebKitEmbed *embed) { WebKitWebView *web_view; + WebKitWebInspector *inspector; GtkWidget *sw; + GtkWidget *inspector_sw; embed->priv = WEBKIT_EMBED_GET_PRIVATE (embed); @@ -334,6 +371,33 @@ webkit_embed_init (WebKitEmbed *embed) g_signal_connect (web_view, "notify::zoom-level", G_CALLBACK (webkit_web_view_zoom_change_cb), embed); + embed->priv->inspector_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + inspector = webkit_web_view_get_inspector (web_view); + + inspector_sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (inspector_sw), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_container_add (GTK_CONTAINER (embed->priv->inspector_window), + inspector_sw); + + gtk_window_set_title (GTK_WINDOW (embed->priv->inspector_window), + _("Web Inspector")); + gtk_window_set_default_size (GTK_WINDOW (embed->priv->inspector_window), + 400, 300); + + g_signal_connect (embed->priv->inspector_window, + "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), + NULL); + + g_object_connect (inspector, + "signal::inspect-web-view", G_CALLBACK (webkit_embed_inspect_web_view_cb), + inspector_sw, + "signal::show-window", G_CALLBACK (webkit_embed_inspect_show_cb), + embed->priv->inspector_window, + "signal::close-window", G_CALLBACK (webkit_embed_inspect_close_cb), + embed->priv->inspector_window, + NULL); + webkit_embed_prefs_add_embed (embed); embed->priv->history = EPHY_HISTORY (ephy_embed_shell_get_global_history (ephy_embed_shell_get_default ())); |