[evolution/wip/webkit-composer: 144/372] Disable composer UI when editor is not editable



commit af917250f1ae57727179c80a9e3e97222289ca9a
Author: Dan Vrátil <dvratil redhat com>
Date:   Tue Sep 11 11:06:05 2012 +0200

    Disable composer UI when editor is not editable

 composer/e-composer-actions.c |    1 -
 composer/e-composer-private.c |   11 ++++++++---
 e-util/e-editor-actions.c     |   18 ++++++++++++++++++
 e-util/e-editor.c             |    4 ++++
 e-util/test-editor.c          |   21 +++++++++++++++++++++
 5 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index fca3acc..1a19cc3 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -510,7 +510,6 @@ e_composer_actions_init (EMsgComposer *composer)
                ACTION (PICTURE_GALLERY), "sensitive",
                G_BINDING_SYNC_CREATE);
 
-       /* FIXME WEBKIT Make sure this works */
        g_object_bind_property (
                editor_widget, "editable",
                e_editor_get_action (editor, "edit-menu"), "sensitive",
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 96fa4f0..88c0d29 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -241,8 +241,8 @@ e_composer_private_constructed (EMsgComposer *composer)
 
        priv->focus_tracker = focus_tracker;
 
-       container = gtk_hbox_new (FALSE, 0);
-       gtk_widget_set_hexpand (container, TRUE);
+       container = gtk_vbox_new (FALSE, 0);
+       gtk_widget_set_vexpand (container, FALSE);
        gtk_widget_show (container);
        e_editor_window_pack_above (E_EDITOR_WINDOW (composer), container);
 
@@ -267,6 +267,11 @@ e_composer_private_constructed (EMsgComposer *composer)
        priv->header_table = g_object_ref (widget);
        gtk_widget_show (widget);
 
+       g_object_bind_property (
+               editor_widget, "editable",
+               widget, "sensitive",
+               G_BINDING_SYNC_CREATE);
+
        g_signal_connect_swapped (
                editor_widget, "notify::spell-languages",
                G_CALLBACK (composer_spell_languages_changed), composer);
@@ -280,7 +285,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 
        g_object_bind_property (
                editor_widget, "editable",
-               widget, "editable",
+               widget, "sensitive",
                G_BINDING_SYNC_CREATE);
 
        container = e_attachment_paned_get_content_area (
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 99c5ea3..fbbe518 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -1985,4 +1985,22 @@ editor_actions_init (EEditor *editor)
                editor->priv->selection, "underline",
                ACTION (UNDERLINE), "active",
                G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
+       /* Disable all actions and toolbars when editor is not editable */
+       g_object_bind_property (
+               editor_widget, "editable",
+               editor->priv->core_actions, "sensitive",
+               G_BINDING_SYNC_CREATE);
+       g_object_bind_property (
+               editor_widget, "editable",
+               editor->priv->html_actions, "sensitive",
+               G_BINDING_SYNC_CREATE);
+       g_object_bind_property (
+               editor_widget, "editable",
+               editor->priv->spell_check_actions, "sensitive",
+               G_BINDING_SYNC_CREATE);
+       g_object_bind_property (
+               editor_widget, "editable",
+               editor->priv->suggestion_actions, "sensitive",
+               G_BINDING_SYNC_CREATE);
 }
diff --git a/e-util/e-editor.c b/e-util/e-editor.c
index 0c4d667..3e25ec9 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -646,6 +646,10 @@ editor_constructed (GObject *object)
                priv->color_combo_box, "current-color",
                priv->selection, "font-color",
                G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+       g_object_bind_property (
+               priv->editor_widget, "editable",
+               priv->color_combo_box, "sensitive",
+               G_BINDING_SYNC_CREATE);
 
        tool_item = gtk_tool_item_new ();
        widget = e_action_combo_box_new_with_action (
diff --git a/e-util/test-editor.c b/e-util/test-editor.c
index 5e4136c..ed5cd17 100644
--- a/e-util/test-editor.c
+++ b/e-util/test-editor.c
@@ -35,6 +35,8 @@ static const gchar *file_ui =
 "     <menuitem action='print-preview'/>\n"
 "     <menuitem action='print'/>\n"
 "     <separator/>\n"
+"     <menuitem action='disable-editor'/>\n"
+"     <separator/>\n"
 "     <menuitem action='quit'/>\n"
 "    </menu>\n"
 "  </menubar>\n"
@@ -252,6 +254,18 @@ action_save_as_cb (GtkAction *action,
 }
 
 static void
+action_toggle_editor (GtkAction *action,
+                     EEditor *editor)
+{
+       EEditorWidget *widget;
+
+       widget = e_editor_get_editor_widget (editor);
+       webkit_web_view_set_editable (
+               WEBKIT_WEB_VIEW (widget),
+               ! webkit_web_view_get_editable (WEBKIT_WEB_VIEW (widget)));
+}
+
+static void
 action_view_html_output (GtkAction *action,
                          EEditor *editor)
 {
@@ -322,6 +336,13 @@ static GtkActionEntry file_entries[] = {
          NULL,
          G_CALLBACK (action_save_as_cb) },
 
+       { "disable-editor",
+         NULL,
+         N_("Disable/Enable Editor"),
+         NULL,
+         NULL,
+         G_CALLBACK (action_toggle_editor) },
+
        { "file-menu",
          NULL,
          N_("_File"),


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