[evolution/wip/webkit-composer: 411/966] Prevent Backspace from removing the body element.



commit a8d08672f721dd1cad6881c2db2404547039642b
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jun 27 14:26:53 2013 +0200

    Prevent Backspace from removing the body element.

 e-util/e-editor-widget.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index e65225e..6b151fa 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -874,6 +874,18 @@ editor_widget_button_release_event (GtkWidget *widget,
 }
 
 static gboolean
+is_something_to_remove (EEditorWidget *widget)
+{
+       WebKitDOMDocument *document;
+       WebKitDOMHTMLElement *body;
+
+       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+       body = webkit_dom_document_get_body (document);
+
+       return (g_utf8_strlen (webkit_dom_node_get_text_content (WEBKIT_DOM_NODE (body)), -1) > 0);
+}
+
+static gboolean
 editor_widget_key_press_event (GtkWidget *widget,
                                GdkEventKey *event)
 {
@@ -885,6 +897,11 @@ editor_widget_key_press_event (GtkWidget *widget,
                editor_widget_set_links_active (editor, TRUE);
        }
 
+       if (event->keyval == GDK_KEY_BackSpace) {
+               if (!is_something_to_remove (editor))
+                       return FALSE;
+       }
+
        if ((event->keyval == GDK_KEY_Return) ||
            (event->keyval == GDK_KEY_KP_Enter)) {
 


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