/dev/qulogic/ckeditor: c8823c14239d: Set up allowed formatting i...
Elliott Sales de Andrade
qulogic at pidgin.im
Fri Aug 9 03:13:29 EDT 2013
Changeset: c8823c14239d3974f2578c593658f9f445711782
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2013-08-06 17:53 -0400
Branch: default
URL: https://hg.pidgin.im/dev/qulogic/ckeditor/rev/c8823c14239d
Description:
Set up allowed formatting in CKEditor.
diffstat:
pidgin/gtkwebview.c | 78 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 64 insertions(+), 14 deletions(-)
diffs (105 lines):
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -50,7 +50,6 @@ enum {
};
enum {
- BUTTONS_UPDATE,
TOGGLE_FORMAT,
CLEAR_FORMAT,
UPDATE_FORMAT,
@@ -1424,12 +1423,6 @@ gtk_webview_class_init(GtkWebViewClass *
/* Signals */
- signals[BUTTONS_UPDATE] = g_signal_new("allowed-formats-updated",
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(GtkWebViewClass, buttons_update),
- NULL, 0, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
signals[TOGGLE_FORMAT] = g_signal_new("format-toggled",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
@@ -1844,16 +1837,73 @@ gtk_webview_set_whole_buffer_formatting_
void
gtk_webview_set_format_functions(GtkWebView *webview, GtkWebViewButtons buttons)
{
- GtkWebViewPriv *priv;
- GObject *object;
+ GString *script;
+ int i;
g_return_if_fail(webview != NULL);
- priv = GTK_WEBVIEW_GET_PRIVATE(webview);
- object = g_object_ref(G_OBJECT(webview));
- priv->format_functions = buttons;
- g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons);
- g_object_unref(object);
+ script = g_string_new("CKEDITOR.instances.input.config.allowedContent = \"");
+
+ for (i = 0; i < 32; i++) {
+ if ((buttons & 1<<i) == 0)
+ continue;
+
+ switch (1<<i) {
+ case GTK_WEBVIEW_BOLD:
+ script = g_string_append(script, "b ");
+ break;
+ case GTK_WEBVIEW_ITALIC:
+ script = g_string_append(script, "i ");
+ break;
+ case GTK_WEBVIEW_UNDERLINE:
+ script = g_string_append(script, "u ");
+ break;
+ case GTK_WEBVIEW_GROW:
+ case GTK_WEBVIEW_SHRINK:
+ script = g_string_append(script, "span{!font-size} ");
+ break;
+ case GTK_WEBVIEW_FACE:
+ script = g_string_append(script, "span{!font-family} ");
+ break;
+ case GTK_WEBVIEW_FORECOLOR:
+ script = g_string_append(script, "span{!color} ");
+ break;
+ case GTK_WEBVIEW_BACKCOLOR:
+ script = g_string_append(script, "span{!background-color} ");
+ break;
+ case GTK_WEBVIEW_LINK:
+ script = g_string_append(script, "a[!href] ");
+ break;
+ case GTK_WEBVIEW_IMAGE:
+ script = g_string_append(script, "img[!src] ");
+ break;
+ case GTK_WEBVIEW_SMILEY:
+ script = g_string_append(script, "img[!isEmoticon] ");
+ break;
+#if 0
+ /* TODO: Distinguish this case from GTK_WEBVIEW_LINK */
+ case GTK_WEBVIEW_LINKDESC:
+ script = g_string_append(script, "a[!href,!alt] ");
+ break;
+#endif
+ case GTK_WEBVIEW_STRIKE:
+ script = g_string_append(script, "strike ");
+ break;
+ case GTK_WEBVIEW_CUSTOM_SMILEY:
+ /* TODO: This is probably no different from GTK_WEBVIEW_SMILEY */
+ script = g_string_append(script, "img[!isEmoticon] ");
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ script = g_string_append(script, "\";");
+
+ gtk_webview_safe_execute_script(webview, script->str);
+
+ g_string_free(script, TRUE);
}
void
More information about the Commits
mailing list