[evolution/webkit-composer: 92/181] Break citation on Enter keypress



commit 0cc90d2376b29ef3d84869e1a486e20accaa3aea
Author: Dan VrÃtil <dvratil redhat com>
Date:   Sun Dec 2 12:30:02 2012 +0100

    Break citation on Enter keypress

 e-util/e-editor-widget.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 082fc6e..c661003 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -459,11 +459,26 @@ static gboolean
 editor_widget_key_press_event (GtkWidget *gtk_widget,
 			       GdkEventKey *event)
 {
+	EEditorWidget *editor = E_EDITOR_WIDGET (gtk_widget);
+
 	if ((event->keyval == GDK_KEY_Control_L) ||
 	    (event->keyval == GDK_KEY_Control_R)) {
 
-		editor_widget_set_links_active (
-			E_EDITOR_WIDGET (gtk_widget), TRUE);
+		editor_widget_set_links_active (editor, TRUE);
+	}
+
+	if ((event->keyval == GDK_KEY_Return) ||
+	    (event->keyval == GDK_KEY_KP_Enter)) {
+
+		/* When user presses ENTER in a citation block, WebKit does not
+		 * break the citation automatically, so we need to use the special
+		 * command to do it. */
+		EEditorSelection *selection = e_editor_widget_get_selection (E_EDITOR_WIDGET (gtk_widget));
+		if (e_editor_selection_is_citation (selection)) {
+			WebKitDOMDocument *document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor));
+			webkit_dom_document_exec_command (document,  "InsertNewlineInQuotedContent", FALSE, "");
+			return TRUE;
+		}
 	}
 
 	/* Propagate the event to WebKit */


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