/dev/qulogic/ckeditor: 21ffdcc884d9: Fix clearing of editable we...

Elliott Sales de Andrade qulogic at pidgin.im
Fri Aug 9 03:13:32 EDT 2013


Changeset: 21ffdcc884d906c962688878c7fce1fcae6112ba
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2013-08-09 02:40 -0400
Branch:	 default
URL: https://hg.pidgin.im/dev/qulogic/ckeditor/rev/21ffdcc884d9

Description:

Fix clearing of editable webview.

diffstat:

 pidgin/gtkwebview.c          |  22 +++++++++++++++++++---
 pidgin/gtkwebvieweditor.html |   4 ++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diffs (55 lines):

diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -1452,7 +1452,8 @@ gtk_webview_new(gboolean editable)
 		ck = g_build_filename(DATADIR, "pidgin", "ckeditor", "ckeditor.js", NULL);
 #endif
 		tmp = g_strdup_printf(gtkwebvieweditor_html, ck);
-		gtk_webview_load_html_string(GTK_WEBVIEW(result), tmp);
+		webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), tmp, NULL, NULL,
+		                            "file:///");
 		g_free(tmp);
 		g_free(ck);
 
@@ -1671,10 +1672,25 @@ gtk_webview_safe_execute_script(GtkWebVi
 void
 gtk_webview_load_html_string(GtkWebView *webview, const char *html)
 {
+	GtkWebViewPriv *priv;
+
 	g_return_if_fail(webview != NULL);
 
-	webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), html, NULL, NULL,
-	                            "file:///");
+	priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	if (priv->edit.enabled) {
+		char *quoted;
+		char *tmp;
+
+		quoted = gtk_webview_quote_js_string(html);
+		tmp = g_strdup_printf("loadHtmlString(%s);", quoted);
+		g_free(quoted);
+
+		push_to_load_queue(webview, LOAD_JS, tmp);
+
+	} else {
+		webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), html, NULL, NULL,
+		                            "file:///");
+	}
 }
 
 void
diff --git a/pidgin/gtkwebvieweditor.html b/pidgin/gtkwebvieweditor.html
--- a/pidgin/gtkwebvieweditor.html
+++ b/pidgin/gtkwebvieweditor.html
@@ -9,6 +9,10 @@
 			alert('resize:' + event.data.newHeight);
 		});
 	});
+	function loadHtmlString(str) {
+		CKEDITOR.instances.input.setData('');
+		CKEDITOR.instances.input.insertHtml(str);
+	}
 	function setSmileyBasePath(path) {
 		CKEDITOR.instances.input.config.smiley_path = path;
 	}



More information about the Commits mailing list