[bijiben] HTML from plain text: remove duplicate functions



commit b2fa84a73a6673fe0f6d31c68d9978657f402a8e
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Sun Apr 27 15:34:06 2014 +0200

    HTML from plain text: remove duplicate functions
    
    There is now a single function, html_from_plain_text
    which works for both new notes, and notes using
    pseudo html from plain text.
    
    This way we do not ship twice the same code.
    See #699249

 src/libbiji/biji-note-obj.h             |    3 ++-
 src/libbiji/editor/biji-webkit-editor.c |   11 ++---------
 src/libbiji/provider/biji-local-note.c  |    2 +-
 3 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/src/libbiji/biji-note-obj.h b/src/libbiji/biji-note-obj.h
index 03010b2..ec08a40 100644
--- a/src/libbiji/biji-note-obj.h
+++ b/src/libbiji/biji-note-obj.h
@@ -60,7 +60,8 @@ struct _BijiNoteObjClass
 
   /*
    * Mandatory. Provide the latest note html.
-   * Use html_from_plain_text if needed. */
+   * Use html_from_plain_text if needed.
+   * This sring must be allocated. use g_strdup if needed. */
   gchar*        (*get_html)          (BijiNoteObj *note);
 
   /*
diff --git a/src/libbiji/editor/biji-webkit-editor.c b/src/libbiji/editor/biji-webkit-editor.c
index 7718107..98ef470 100644
--- a/src/libbiji/editor/biji-webkit-editor.c
+++ b/src/libbiji/editor/biji-webkit-editor.c
@@ -350,17 +350,10 @@ biji_webkit_editor_constructed (GObject *obj)
   body = biji_note_obj_get_html (priv->note);
 
   if (!body)
-    body = "<html xmlns='http://www.w3.org/1999/xhtml'>"
-           "<body contenteditable='true' id='editable'>"
-           "<script type='text/javascript'>"
-           "    window.onload = function() {"
-           "        document.getElementById('editable').focus();"
-           "    };"
-           "</script>"
-           "</body>"
-           "</html>";
+    body = html_from_plain_text ("");
 
   webkit_web_view_load_string (view, body, "application/xhtml+xml", NULL, NULL);
+  g_free (body);
 
 
   /* Do not be a browser */
diff --git a/src/libbiji/provider/biji-local-note.c b/src/libbiji/provider/biji-local-note.c
index 3a9a9b6..3c7b071 100644
--- a/src/libbiji/provider/biji-local-note.c
+++ b/src/libbiji/provider/biji-local-note.c
@@ -55,7 +55,7 @@ gchar *
 local_note_get_html (BijiNoteObj *note)
 {
   if (BIJI_IS_LOCAL_NOTE (note))
-    return BIJI_LOCAL_NOTE (note)->priv->html;
+    return g_strdup (BIJI_LOCAL_NOTE (note)->priv->html);
 
   else
     return NULL;


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