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



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

    Break citation on Enter keypress

 widgets/editor/e-editor-widget.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/widgets/editor/e-editor-widget.c b/widgets/editor/e-editor-widget.c
index 082fc6e..c661003 100644
--- a/widgets/editor/e-editor-widget.c
+++ b/widgets/editor/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]