[evolution/webkit-composer: 78/147] Disable composer UI when editor is not editable



commit 9fb12f73bc8bd0be38cd382ac14cee5e259b773b
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 df2ebb4..a7b7f33 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -529,7 +529,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 591a5fa..1f020e2 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -261,8 +261,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);
 
@@ -283,6 +283,11 @@ e_composer_private_constructed (EMsgComposer *composer)
 	gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
 	gtk_widget_set_hexpand (widget, TRUE);
 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+	g_object_bind_property (
+		editor_widget, "editable",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
 	/* FIXME WEBKIT
 	if (small_screen_mode)
 		gtk_box_reorder_child (GTK_BOX (container), widget, 1);
@@ -317,7 +322,7 @@ e_composer_private_constructed (EMsgComposer *composer)
 
 	g_object_bind_property (
 		editor_widget, "editable",
-		widget, "editable",
+		widget, "sensitive",
 		G_BINDING_SYNC_CREATE);
 
 	/* FIXME WEBKIT Port this if small_screen_mode works */
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]