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



commit ded0253187d253a784549db720edc6cb3eeaae53
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]