[gnome-online-accounts] webview: Add some debug code to show an inspector
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] webview: Add some debug code to show an inspector
- Date: Wed, 30 Oct 2013 08:57:39 +0000 (UTC)
commit 634ca473c970ac9582edb4679ba2fcaa9aa22f6b
Author: Bastien Nocera <hadess hadess net>
Date: Sat Oct 5 01:45:43 2013 +0200
webview: Add some debug code to show an inspector
This makes it easier to find the various nodes, and check why the
mobile view might not work.
Note that you'll need to remove the modality on gnome-control-center's
"add accounts" dialogue for this to work.
FIXME: Mouse and keyboard events don't seem to get to the inspector.
https://bugzilla.gnome.org/show_bug.cgi?id=704564
configure.ac | 10 +++++++
src/goabackend/goawebview.c | 56 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 51525ee..4f33528 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,15 @@ ac_configure_args=$prev_ac_configure_args
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$ac_top_build_prefix"telepathy-account-widgets/
PKG_CHECK_MODULES(TPAW, telepathy-account-widgets)
+AC_ARG_ENABLE([inspector],
+ [AS_HELP_STRING([--enable-inspector],
+ [Enable a WebKitWebInspector for the embedded web view])],
+ [],
+ [enable_inspector=no])
+if test "$enable_inspector" != "no"; then
+ AC_DEFINE(GOA_INSPECTOR_ENABLED, 1, [Enable a WebKitWebInspector for the embedded web view])
+fi
+
# service providers
#
@@ -499,6 +508,7 @@ echo "
compiler: ${CC}
cflags: ${CFLAGS}
cppflags: ${CPPFLAGS}
+ inspector: ${enable_inspector}
introspection: ${found_introspection}
Flickr provider: ${enable_flickr} (OAuth 1.0, key:${with_flickr_consumer_key}
secret:${with_flickr_consumer_secret})
diff --git a/src/goabackend/goawebview.c b/src/goabackend/goawebview.c
index ba999e5..73930ae 100644
--- a/src/goabackend/goawebview.c
+++ b/src/goabackend/goawebview.c
@@ -221,6 +221,48 @@ goa_web_view_dispose (GObject *object)
G_OBJECT_CLASS (goa_web_view_parent_class)->dispose (object);
}
+#ifdef GOA_INSPECTOR_ENABLED
+static WebKitWebView *
+web_inspector_inspect_web_view_cb (WebKitWebInspector *inspector,
+ WebKitWebView *web_view,
+ gpointer user_data)
+{
+ GtkWidget *inspector_web_view;
+ GtkWidget *scrolled_window;
+ GtkWidget *window;
+
+ inspector_web_view = webkit_web_view_new ();
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_resize (GTK_WINDOW (window), 800, 600);
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ gtk_container_add (GTK_CONTAINER (window), scrolled_window);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), inspector_web_view);
+
+ g_object_set_data (G_OBJECT (inspector), "window", window);
+
+ return WEBKIT_WEB_VIEW (inspector_web_view);
+}
+
+static gboolean
+web_inspector_show_window_cb (WebKitWebInspector *inspector,
+ gpointer user_data)
+{
+ GtkWidget *window;
+
+ window = g_object_get_data (G_OBJECT (inspector), "window");
+ gtk_widget_show_all (window);
+ gtk_window_present (GTK_WINDOW (window));
+
+ return GDK_EVENT_STOP;
+}
+#endif /* GOA_INSPECTOR_ENABLED */
+
static void
goa_web_view_init (GoaWebView *self)
{
@@ -265,6 +307,20 @@ goa_web_view_init (GoaWebView *self)
settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (priv->web_view));
g_object_set (settings, "user-stylesheet-uri", "file://" PACKAGE_DATA_DIR "/goawebview.css", NULL);
+#ifdef GOA_INSPECTOR_ENABLED
+ {
+ WebKitWebInspector *inspector;
+
+ /* Setup the inspector */
+ g_object_set (settings, "enable-developer-extras", TRUE, NULL);
+ inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (priv->web_view));
+ webkit_web_inspector_show (WEBKIT_WEB_INSPECTOR (inspector));
+
+ g_signal_connect (inspector, "inspect-web-view", G_CALLBACK (web_inspector_inspect_web_view_cb), NULL);
+ g_signal_connect (inspector, "show-window", G_CALLBACK (web_inspector_show_window_cb), NULL);
+ }
+#endif /* GOA_INSPECTOR_ENABLED */
+
/* statusbar is hidden by default */
priv->floating_bar = nautilus_floating_bar_new (NULL, FALSE);
gtk_widget_set_halign (priv->floating_bar, GTK_ALIGN_START);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]