pidgin: 874feebb: Add some code for manipulating the WebVi...

qulogic at pidgin.im qulogic at pidgin.im
Thu Jan 5 23:01:25 EST 2012


----------------------------------------------------------------------
Revision: 874feebb31b13ceb4c6789225711244d51bc8e88
Parent:   6d815c8ea345d03d3c22e9ac06945a06a04bae6c
Author:   qulogic at pidgin.im
Date:     01/05/12 21:37:42
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/874feebb31b13ceb4c6789225711244d51bc8e88

Changelog: 

Add some code for manipulating the WebView in edit-mode. Thanks to
an Ars Technica article [1] for some ideas here.

[1] http://arstechnica.com/open-source/guides/2009/07/how-to-build-a-desktop-wysiwyg-editor-with-webkit-and-html-5.ars

Changes against parent 6d815c8ea345d03d3c22e9ac06945a06a04bae6c

  patched  pidgin/gtkwebview.c

-------------- next part --------------
============================================================
--- pidgin/gtkwebview.c	c5c824e1e80918647be3362250cc139d4545dbf0
+++ pidgin/gtkwebview.c	45ddb830a7c0788fb76a009a5c3405c1e1b117d4
@@ -843,38 +843,62 @@ gtk_webview_toggle_bold(GtkWebView *webv
 gtk_webview_toggle_bold(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+
 	priv->edit.bold = !priv->edit.bold;
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "bold", FALSE, "");
 }
 
 void
 gtk_webview_toggle_italic(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+
 	priv->edit.italic = !priv->edit.italic;
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "italic", FALSE, "");
 }
 
 void
 gtk_webview_toggle_underline(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+
 	priv->edit.underline = !priv->edit.underline;
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "underline", FALSE, "");
 }
 
 void
 gtk_webview_toggle_strike(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+
 	priv->edit.strike = !priv->edit.strike;
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "strikethrough", FALSE, "");
 }
 
 gboolean
 gtk_webview_toggle_forecolor(GtkWebView *webview, const char *color)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
 
 	g_free(priv->edit.forecolor);
 	priv->edit.forecolor = g_strdup(color);
 
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "forecolor", FALSE, color);
+
 	return FALSE;
 }
 
@@ -882,10 +906,14 @@ gtk_webview_toggle_backcolor(GtkWebView 
 gtk_webview_toggle_backcolor(GtkWebView *webview, const char *color)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
 
 	g_free(priv->edit.backcolor);
 	priv->edit.backcolor = g_strdup(color);
 
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "backcolor", FALSE, color);
+
 	return FALSE;
 }
 
@@ -904,10 +932,14 @@ gtk_webview_toggle_fontface(GtkWebView *
 gtk_webview_toggle_fontface(GtkWebView *webview, const char *face)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
 
 	g_free(priv->edit.fontface);
 	priv->edit.fontface = g_strdup(face);
 
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	webkit_dom_document_exec_command(dom, "fontname", FALSE, face);
+
 	return FALSE;
 }
 
@@ -915,20 +947,44 @@ gtk_webview_font_set_size(GtkWebView *we
 gtk_webview_font_set_size(GtkWebView *webview, gint size)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+	char *tmp;
+
 	priv->edit.fontsize = size;
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	tmp = g_strdup_printf("%d", size);
+	webkit_dom_document_exec_command(dom, "fontsize", FALSE, tmp);
+	g_free(tmp);
 }
 
 void
 gtk_webview_font_shrink(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+	char *tmp;
+
 	priv->edit.fontsize = MAX(priv->edit.fontsize - 1, 1);
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	tmp = g_strdup_printf("%d", priv->edit.fontsize);
+	webkit_dom_document_exec_command(dom, "fontsize", FALSE, tmp);
+	g_free(tmp);
 }
 
 void
 gtk_webview_font_grow(GtkWebView *webview)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitDOMDocument *dom;
+	char *tmp;
+
 	priv->edit.fontsize = MIN(priv->edit.fontsize + 1, MAX_FONT_SIZE);
+
+	dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	tmp = g_strdup_printf("%d", priv->edit.fontsize);
+	webkit_dom_document_exec_command(dom, "fontsize", FALSE, tmp);
+	g_free(tmp);
 }
 


More information about the Commits mailing list