[evolution/wip/webkit2] Replace EContentEditor::show_inspector() with EContentEditor::initialize()



commit bb2a955224aac8452e84076ae8f2fc103f174552
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 10 11:45:44 2016 +0200

    Replace EContentEditor::show_inspector() with EContentEditor::initialize()

 data/org.gnome.evolution.mail.gschema.xml.in |    5 ---
 e-util/e-content-editor.c                    |   44 +++++++++++++++++---------
 e-util/e-content-editor.h                    |   12 ++++---
 e-util/e-html-editor-actions.c               |   26 +--------------
 e-util/e-html-editor-actions.h               |    2 -
 e-util/e-html-editor-manager.ui              |    2 +-
 e-util/e-html-editor.c                       |    3 ++
 modules/webkit-editor/e-webkit-editor.c      |   34 ++++++++++++--------
 8 files changed, 61 insertions(+), 67 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 66bb9cb..28680b9 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -180,11 +180,6 @@
       <_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="composer-word-wrap-length" type="i">
       <default>71</default>
       <_summary>Number of characters for wrapping</_summary>
diff --git a/e-util/e-content-editor.c b/e-util/e-content-editor.c
index 1e2b0e7..b6b2075 100644
--- a/e-util/e-content-editor.c
+++ b/e-util/e-content-editor.c
@@ -24,6 +24,7 @@
 
 #include <libedataserver/libedataserver.h>
 
+#include "e-html-editor.h"
 #include "e-util-enumtypes.h"
 #include "e-content-editor.h"
 
@@ -1241,6 +1242,33 @@ e_content_editor_is_underline (EContentEditor *editor)
        return value;
 }
 
+/**
+ * e_content_editor_initialize:
+ * @content_editor: an #EContentEditor
+ * @html_editor: an #EHTMLEditor
+ *
+ * Called the first time the @content_editor is picked to be used within
+ * the @html_editor. This is typically used to modify the UI
+ * of the @html_editor. This method implementation is optional.
+ *
+ * Since: 3.22
+ **/
+void
+e_content_editor_initialize (EContentEditor *content_editor,
+                            EHTMLEditor *html_editor)
+{
+       EContentEditorInterface *iface;
+
+       g_return_if_fail (E_IS_CONTENT_EDITOR (content_editor));
+       g_return_if_fail (E_IS_HTML_EDITOR (html_editor));
+
+       iface = E_CONTENT_EDITOR_GET_IFACE (content_editor);
+       g_return_if_fail (iface != NULL);
+
+       if (iface->initialize)
+               iface->initialize (content_editor, html_editor);
+}
+
 void
 e_content_editor_update_styles (EContentEditor *editor)
 {
@@ -1843,20 +1871,6 @@ e_content_editor_selection_wrap (EContentEditor *editor)
        iface->selection_wrap (editor);
 }
 
-void
-e_content_editor_show_inspector (EContentEditor *editor)
-{
-       EContentEditorInterface *iface;
-
-       g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
-
-       iface = E_CONTENT_EDITOR_GET_IFACE (editor);
-       g_return_if_fail (iface != NULL);
-       g_return_if_fail (iface->show_inspector != NULL);
-
-       iface->show_inspector (editor);
-}
-
 guint
 e_content_editor_get_caret_position (EContentEditor *editor)
 {
@@ -1913,7 +1927,7 @@ e_content_editor_is_ready (EContentEditor *editor)
        return iface->is_ready (editor);
 }
 
-char *
+gchar *
 e_content_editor_insert_signature (EContentEditor *editor,
                                    const gchar *content,
                                    gboolean is_html,
diff --git a/e-util/e-content-editor.h b/e-util/e-content-editor.h
index ee6eb07..3714476 100644
--- a/e-util/e-content-editor.h
+++ b/e-util/e-content-editor.h
@@ -34,6 +34,8 @@
 
 G_BEGIN_DECLS
 
+struct _EHTMLEditor;
+
 #define E_TYPE_CONTENT_EDITOR e_content_editor_get_type ()
 G_DECLARE_INTERFACE (EContentEditor, e_content_editor, E, CONTENT_EDITOR, GtkWidget)
 
@@ -45,6 +47,8 @@ typedef struct {
 struct _EContentEditorInterface {
        GTypeInterface parent_interface;
 
+       void            (*initialize)                   (EContentEditor *content_editor,
+                                                        struct _EHTMLEditor *html_editor);
        void            (*update_styles)                (EContentEditor *editor);
        void            (*insert_content)               (EContentEditor *editor,
                                                         const gchar *content,
@@ -128,8 +132,6 @@ struct _EContentEditorInterface {
 
        void            (*selection_wrap)               (EContentEditor *editor);
 
-       void            (*show_inspector)               (EContentEditor *editor);
-
        guint           (*get_caret_position)           (EContentEditor *editor);
 
        guint           (*get_caret_offset)             (EContentEditor *editor);
@@ -138,7 +140,7 @@ struct _EContentEditorInterface {
 
        gboolean        (*is_ready)                     (EContentEditor *editor);
 
-       char *          (*insert_signature)             (EContentEditor *editor,
+       gchar *         (*insert_signature)             (EContentEditor *editor,
                                                         const gchar *content,
                                                         gboolean is_html,
                                                         const gchar *signature_id,
@@ -513,6 +515,8 @@ gboolean    e_content_editor_is_underline   (EContentEditor *editor);
 
 /* Methods */
 
+void           e_content_editor_initialize     (EContentEditor *content_editor,
+                                                struct _EHTMLEditor *html_editor);
 void           e_content_editor_update_styles  (EContentEditor *editor);
 void           e_content_editor_insert_content (EContentEditor *editor,
                                                 const gchar *content,
@@ -609,8 +613,6 @@ void                e_content_editor_selection_restore
 
 void           e_content_editor_selection_wrap (EContentEditor *editor);
 
-void           e_content_editor_show_inspector (EContentEditor *editor);
-
 guint          e_content_editor_get_caret_position
                                                (EContentEditor *editor);
 
diff --git a/e-util/e-html-editor-actions.c b/e-util/e-html-editor-actions.c
index 005d2ec..cf5fc31 100644
--- a/e-util/e-html-editor-actions.c
+++ b/e-util/e-html-editor-actions.c
@@ -797,16 +797,6 @@ action_wrap_lines_cb (GtkAction *action,
                e_content_editor_selection_wrap (cnt_editor);
 }
 
-static void
-action_show_webkit_inspector_cb (GtkAction *action,
-                                 EHTMLEditor *editor)
-{
-       EContentEditor *cnt_editor;
-
-       cnt_editor = e_html_editor_get_content_editor (editor);
-       e_content_editor_show_inspector (cnt_editor);
-}
-
 /*****************************************************************************
  * Core Actions
  *
@@ -986,14 +976,7 @@ static GtkActionEntry core_editor_entries[] = {
          N_("_Wrap Lines"),
          "<Control>k",
          NULL,
-         G_CALLBACK (action_wrap_lines_cb) },
-
-       { "webkit-inspector",
-          NULL,
-          N_("Open Inspector"),
-          NULL,
-          NULL,
-          G_CALLBACK (action_show_webkit_inspector_cb) },
+         G_CALLBACK (action_wrap_lines_cb) }
 };
 
 static GtkRadioActionEntry core_justify_entries[] = {
@@ -1721,7 +1704,6 @@ editor_actions_init (EHTMLEditor *editor)
        GtkActionGroup *action_group;
        GtkUIManager *manager;
        const gchar *domain;
-       GSettings *settings;
 
        g_return_if_fail (E_IS_HTML_EDITOR (editor));
 
@@ -1846,12 +1828,6 @@ editor_actions_init (EHTMLEditor *editor)
 
        gtk_action_set_sensitive (ACTION (UNINDENT), FALSE);
        gtk_action_set_sensitive (ACTION (FIND_AGAIN), FALSE);
-
-       settings = e_util_ref_settings ("org.gnome.evolution.mail");
-       gtk_action_set_visible (
-               ACTION (WEBKIT_INSPECTOR),
-               g_settings_get_boolean (settings, "composer-developer-mode"));
-       g_object_unref (settings);
 }
 
 void
diff --git a/e-util/e-html-editor-actions.h b/e-util/e-html-editor-actions.h
index b45d0e6..5211cce 100644
--- a/e-util/e-html-editor-actions.h
+++ b/e-util/e-html-editor-actions.h
@@ -155,7 +155,5 @@
        E_HTML_EDITOR_ACTION ((editor), "undo")
 #define E_HTML_EDITOR_ACTION_UNINDENT(editor) \
        E_HTML_EDITOR_ACTION ((editor), "unindent")
-#define E_HTML_EDITOR_ACTION_WEBKIT_INSPECTOR(editor) \
-       E_HTML_EDITOR_ACTION ((editor), "webkit-inspector")
 
 #endif /* E_HTML_EDITOR_ACTIONS_H */
diff --git a/e-util/e-html-editor-manager.ui b/e-util/e-html-editor-manager.ui
index ca81cdf..b4fc430 100644
--- a/e-util/e-html-editor-manager.ui
+++ b/e-util/e-html-editor-manager.ui
@@ -27,7 +27,7 @@
     <placeholder name='pre-insert-menu'>
       <menu action='view-menu'>
         <placeholder name='view-menu-top'/>
-        <menuitem action='webkit-inspector'/>
+        <placeholder name='view-menu-custom'/>
         <separator/>
       </menu>
     </placeholder>
diff --git a/e-util/e-html-editor.c b/e-util/e-html-editor.c
index 212df01..3e436fb 100644
--- a/e-util/e-html-editor.c
+++ b/e-util/e-html-editor.c
@@ -932,6 +932,9 @@ e_html_editor_get_content_editor (EHTMLEditor *editor)
                                editor->priv->use_content_editor = value;
                        }
                }
+
+               if (editor->priv->use_content_editor)
+                       e_content_editor_initialize (editor->priv->use_content_editor, editor);
        }
 
        return editor->priv->use_content_editor;
diff --git a/modules/webkit-editor/e-webkit-editor.c b/modules/webkit-editor/e-webkit-editor.c
index fc7a073..99ae870 100644
--- a/modules/webkit-editor/e-webkit-editor.c
+++ b/modules/webkit-editor/e-webkit-editor.c
@@ -661,6 +661,18 @@ webkit_editor_queue_post_reload_operation (EWebKitEditor *wk_editor,
 }
 
 static void
+webkit_editor_show_inspector (EWebKitEditor *wk_editor)
+{
+       WebKitWebInspector *inspector;
+
+       g_return_if_fail (E_IS_WEBKIT_EDITOR (wk_editor));
+
+       inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (wk_editor));
+
+       webkit_web_inspector_show (inspector);
+}
+
+static void
 webkit_editor_update_styles (EContentEditor *editor)
 {
        EWebKitEditor *wk_editor;
@@ -1672,19 +1684,6 @@ webkit_editor_select_all (EContentEditor *editor)
 }
 
 static void
-webkit_editor_show_inspector (EContentEditor *editor)
-{
-       EWebKitEditor *wk_editor;
-       WebKitWebInspector *inspector;
-
-       wk_editor = E_WEBKIT_EDITOR (editor);
-
-       inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (wk_editor));
-
-       webkit_web_inspector_show (inspector);
-}
-
-static void
 webkit_editor_selection_wrap (EContentEditor *editor)
 {
        EWebKitEditor *wk_editor;
@@ -4901,6 +4900,7 @@ webkit_editor_constructed (GObject *object)
 
        web_settings = webkit_web_view_get_settings (web_view);
        webkit_settings_set_allow_file_access_from_file_urls (web_settings, TRUE);
+       webkit_settings_set_enable_developer_extras (web_settings, TRUE);
 
        /* Make WebKit think we are displaying a local file, so that it
         * does not block loading resources from file:// protocol */
@@ -5707,6 +5707,13 @@ webkit_editor_key_press_event (GtkWidget *widget,
                return TRUE;
        }
 
+       if (((event)->state & GDK_CONTROL_MASK) &&
+           ((event)->state & GDK_SHIFT_MASK) &&
+           ((event)->keyval == GDK_KEY_I)) {
+               webkit_editor_show_inspector (wk_editor);
+               return TRUE;
+       }
+
        /* Chain up to parent's key_press_event() method. */
        return GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->key_press_event (widget, event);
 }
@@ -5903,7 +5910,6 @@ e_webkit_editor_content_editor_init (EContentEditorInterface *iface)
        iface->selection_save = webkit_editor_selection_save;
        iface->selection_restore = webkit_editor_selection_restore;
        iface->selection_wrap = webkit_editor_selection_wrap;
-       iface->show_inspector = webkit_editor_show_inspector;
        iface->get_caret_position = webkit_editor_get_caret_position;
        iface->get_caret_offset = webkit_editor_get_caret_offset;
        iface->get_current_signature_uid =  webkit_editor_get_current_signature_uid;


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