[evolution/webkit-composer] Add View->Open Inspector action to composer



commit f801f926f3bf099543d620748a30edc9aeb94001
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Nov 29 21:24:49 2012 +0100

    Add View->Open Inspector action to composer
    
    The action is hidden by default and visible only when you set
    org.gnome.evolution.mail.composer-developer-mode to true.
    
    Note: we could do something similar to EMailReader...

 data/org.gnome.evolution.mail.gschema.xml.in |    5 ++++
 widgets/editor/e-editor-actions.c            |   27 ++++++++++++++++++++++++++
 widgets/editor/e-editor-actions.h            |    3 +-
 widgets/editor/e-editor-manager.ui           |   10 ++++++--
 widgets/editor/e-editor-widget.c             |   24 +++++++++++++++++++++++
 5 files changed, 65 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index bb6725c..a37aa7f 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -125,6 +125,11 @@
       <_summary>List of localized 'Re'</_summary>
       <_description>Comma-separated list of localized 'Re' abbreviations to skip in a subject text when replying to a message, as an addition to the standard "Re" prefix. An example is 'SV,AV'.</_description>
     </key>
+    <key name="composer-developer-mode" type="b">
+      <default>false</default>
+      <_summary>Enable developer mode</_summary>
+      <_description>Enables some hidden actions and tools aimed for development and debugging.</_description>
+    </key>
     <key name="drag-and-drop-save-file-format" type="s">
       <default>'mbox'</default>
       <_summary>Save file format for drag-and-drop operation</_summary>
diff --git a/widgets/editor/e-editor-actions.c b/widgets/editor/e-editor-actions.c
index 480b8c8..1f106f2 100644
--- a/widgets/editor/e-editor-actions.c
+++ b/widgets/editor/e-editor-actions.c
@@ -889,6 +889,19 @@ action_wrap_lines_cb (GtkAction *action,
 	e_editor_selection_wrap_lines (editor->priv->selection);
 }
 
+static void
+action_show_webkit_inspector_cb (GtkAction *action,
+                                 EEditor *editor)
+{
+        WebKitWebInspector *inspector;
+        EEditorWidget *widget;
+
+        widget = e_editor_get_editor_widget (editor);
+        inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (widget));
+
+        webkit_web_inspector_show (inspector);
+}
+
 /*****************************************************************************
  * Core Actions
  *
@@ -1009,6 +1022,13 @@ static GtkActionEntry core_entries[] = {
 	  NULL,
 	  G_CALLBACK (action_wrap_lines_cb) },
 
+	{ "webkit-inspector",
+          NULL,
+          N_("Open Inspector"),
+          NULL,
+          NULL,
+          G_CALLBACK (action_show_webkit_inspector_cb) },
+
 	/* Menus */
 
 	{ "edit-menu",
@@ -1771,6 +1791,7 @@ editor_actions_init (EEditor *editor)
 	GtkUIManager *manager;
 	const gchar *domain;
 	EEditorWidget *editor_widget;
+	GSettings *settings;
 
 	g_return_if_fail (E_IS_EDITOR (editor));
 
@@ -1973,4 +1994,10 @@ editor_actions_init (EEditor *editor)
 		editor_widget, "editable",
 		editor->priv->suggestion_actions, "sensitive",
 		G_BINDING_SYNC_CREATE);
+
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	gtk_action_set_visible (
+		ACTION (WEBKIT_INSPECTOR),
+		g_settings_get_boolean (settings, "composer-developer-mode"));
+	g_object_unref (settings);
 }
diff --git a/widgets/editor/e-editor-actions.h b/widgets/editor/e-editor-actions.h
index 3f83528..f78fa81 100644
--- a/widgets/editor/e-editor-actions.h
+++ b/widgets/editor/e-editor-actions.h
@@ -142,5 +142,6 @@
 	E_EDITOR_ACTION ((editor), "undo")
 #define E_EDITOR_ACTION_UNINDENT(editor) \
 	E_EDITOR_ACTION ((editor), "unindent")
-
+#define E_EDITOR_ACTION_WEBKIT_INSPECTOR(editor) \
+	E_EDITOR_ACTION ((editor), "webkit-inspector")
 #endif /* E_EDITOR_ACTIONS_H */
diff --git a/widgets/editor/e-editor-manager.ui b/widgets/editor/e-editor-manager.ui
index 610b3ef..75f2c34 100644
--- a/widgets/editor/e-editor-manager.ui
+++ b/widgets/editor/e-editor-manager.ui
@@ -23,9 +23,13 @@
       <menuitem action='spell-check'/>
       <menu action='language-menu'/>
     </menu>
-    <placeholder name='pre-view-menu'/>
-    <menu action='view-menu'/>
-    <placeholder name='pre-insert-menu'/>
+    <placeholder name='pre-insert-menu'>
+      <menu action='view-menu'>
+        <placeholder name='view-menu-top'/>
+        <menuitem action='webkit-inspector'/>
+        <separator/>
+      </menu>
+    </placeholder>
     <menu action='insert-menu'>
       <placeholder name='insert-menu-top'/>
       <menuitem action='insert-image'/>
diff --git a/widgets/editor/e-editor-widget.c b/widgets/editor/e-editor-widget.c
index 680e3a7..082fc6e 100644
--- a/widgets/editor/e-editor-widget.c
+++ b/widgets/editor/e-editor-widget.c
@@ -236,6 +236,25 @@ editor_widget_load_status_changed (EEditorWidget *widget)
 	}
 }
 
+static WebKitWebView *
+editor_widget_open_inspector (WebKitWebInspector *inspector,
+			      WebKitWebView *webview,
+			      gpointer user_data)
+{
+	GtkWidget *window;
+	GtkWidget *inspector_view;
+
+	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+	inspector_view = webkit_web_view_new ();
+
+	gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (inspector_view));
+
+	gtk_widget_set_size_request (window, 600, 480);
+	gtk_widget_show (window);
+
+	return WEBKIT_WEB_VIEW (inspector_view);
+}
+
 static gboolean
 editor_widget_button_press_event (GtkWidget *gtk_widget,
 				  GdkEventButton *event)
@@ -827,6 +846,7 @@ static void
 e_editor_widget_init (EEditorWidget *editor)
 {
 	WebKitWebSettings *settings;
+	WebKitWebInspector *inspector;
 	WebKitDOMDocument *document;
 	GSettings *g_settings;
 	GSettingsSchema *settings_schema;
@@ -870,6 +890,10 @@ e_editor_widget_init (EEditorWidget *editor)
 	g_signal_connect (editor, "notify::load-status",
 		G_CALLBACK (editor_widget_load_status_changed), NULL);
 
+	inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (editor));
+	g_signal_connect (inspector, "inspect-web-view",
+		G_CALLBACK (editor_widget_open_inspector), NULL);
+
 	editor->priv->selection = e_editor_selection_new (
 					WEBKIT_WEB_VIEW (editor));
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]