/dev/qulogic/ckeditor: 724c0317ac90: Load custom HTML file and d...

Elliott Sales de Andrade qulogic at pidgin.im
Mon Aug 5 19:00:10 EDT 2013


Changeset: 724c0317ac90d4f0f177fb19ea36fc24615399f1
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2013-08-05 18:35 -0400
Branch:	 default
URL: https://hg.pidgin.im/dev/qulogic/ckeditor/rev/724c0317ac90

Description:

Load custom HTML file and drop toolbar in editor mode.

diffstat:

 pidgin/Makefile.am           |   5 +--
 pidgin/gtkutils.c            |  27 ++++------------------
 pidgin/gtkwebview.c          |  53 +++++++------------------------------------
 pidgin/gtkwebvieweditor.html |  15 ++++++++++++
 4 files changed, 31 insertions(+), 69 deletions(-)

diffs (224 lines):

diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -4,6 +4,7 @@ EXTRA_DIST = \
 		getopt1.c \
 		gtk3compat.h \
 		gtkdebug.html \
+		gtkwebvieweditor.html \
 		Makefile.mingw \
 		pidgin-3.pc.in \
 		pidgin-3-uninstalled.pc.in \
@@ -88,7 +89,6 @@ pidgin_SOURCES = \
 	gtkthemes.c \
 	gtkutils.c \
 	gtkwebview.c \
-	gtkwebviewtoolbar.c \
 	gtkwhiteboard.c \
 	minidialog.c \
 	pidgintooltip.c \
@@ -143,7 +143,6 @@ pidgin_headers = \
 	gtkthemes.h \
 	gtkutils.h \
 	gtkwebview.h \
-	gtkwebviewtoolbar.h \
 	gtkwhiteboard.h \
 	minidialog.h \
 	pidgintooltip.h \
@@ -154,7 +153,7 @@ pidginincludedir=$(includedir)/pidgin
 pidgininclude_HEADERS = \
 	$(pidgin_headers)
 
-pidgin_builtheaders = gtkdebug.html.h
+pidgin_builtheaders = gtkdebug.html.h gtkwebvieweditor.html.h
 
 BUILT_SOURCES = $(pidgin_builtheaders)
 
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -64,7 +64,6 @@
 #include "gtkthemes.h"
 #include "gtkutils.h"
 #include "gtkwebview.h"
-#include "gtkwebviewtoolbar.h"
 #include "pidgin/minidialog.h"
 
 #include "gtk3compat.h"
@@ -217,44 +216,28 @@ pidgin_create_webview(gboolean editable,
 {
 	GtkWidget *frame;
 	GtkWidget *webview;
-	GtkWidget *sep;
 	GtkWidget *sw;
-	GtkWidget *toolbar = NULL;
-	GtkWidget *vbox;
 
 	frame = gtk_frame_new(NULL);
 	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
 
-	vbox = gtk_vbox_new(FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(frame), vbox);
-	gtk_widget_show(vbox);
-
-	if (editable) {
-		toolbar = gtk_webviewtoolbar_new();
-		gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
-		gtk_widget_show(toolbar);
-
-		sep = gtk_hseparator_new();
-		gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
-		g_signal_connect_swapped(G_OBJECT(toolbar), "show", G_CALLBACK(gtk_widget_show), sep);
-		g_signal_connect_swapped(G_OBJECT(toolbar), "hide", G_CALLBACK(gtk_widget_hide), sep);
-		gtk_widget_show(sep);
-	}
-
 	webview = gtk_webview_new(editable);
 	if (editable && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck"))
 		pidgin_webview_set_spellcheck(GTK_WEBVIEW(webview), TRUE);
 	gtk_widget_show(webview);
 
+#if 0
+	/* TODO: Make sure smileys in toolbar are correct. */
 	if (editable) {
 		gtk_webviewtoolbar_attach(GTK_WEBVIEWTOOLBAR(toolbar), webview);
 		gtk_webviewtoolbar_associate_smileys(GTK_WEBVIEWTOOLBAR(toolbar), "default");
-		gtk_webview_set_toolbar(webview, toolbar);
 	}
+#endif
+
 	pidgin_setup_webview(webview);
 
 	sw = pidgin_make_scrollable(webview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_NONE, -1, -1);
-	gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(frame), sw, TRUE, TRUE, 0);
 
 	gtk_webview_set_vadjustment(GTK_WEBVIEW(webview),
 			gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw)));
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -32,7 +32,7 @@
 #include <gdk/gdkkeysyms.h>
 #include "gtkutils.h"
 #include "gtkwebview.h"
-#include "gtkwebviewtoolbar.h"
+#include "gtkwebvieweditor.html.h"
 
 #include "gtk3compat.h"
 
@@ -121,7 +121,6 @@ typedef struct _GtkWebViewPriv {
 
 	/* Format options */
 	GtkWebViewButtons format_functions;
-	GtkWebViewToolbar *toolbar;
 	struct {
 		gboolean wbfo:1;	/* Whole buffer formatting only. */
 		gboolean block_changed:1;
@@ -1341,14 +1340,6 @@ webview_toggle_format(GtkWebView *webvie
 	}
 }
 
-static void
-editable_input_cb(GtkWebView *webview, gpointer data)
-{
-	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
-	if (!priv->edit.block_changed && gtk_widget_is_sensitive(GTK_WIDGET(webview)))
-		g_signal_emit(webview, signals[CHANGED], 0);
-}
-
 /******************************************************************************
  * GObject Stuff
  *****************************************************************************/
@@ -1376,10 +1367,7 @@ gtk_webview_new(gboolean editable)
 	webkit_web_view_set_settings(webview, settings);
 
 	if (editable) {
-		webkit_web_view_set_editable(WEBKIT_WEB_VIEW(webview), editable);
-
-		g_signal_connect(G_OBJECT(webview), "user-changed-contents",
-		                 G_CALLBACK(editable_input_cb), NULL);
+		gtk_webview_load_html_string(GTK_WEBVIEW(result), gtkwebvieweditor_html);
 	}
 
 	return result;
@@ -2199,52 +2187,29 @@ gtk_webview_insert_image(GtkWebView *web
 }
 
 void
-gtk_webview_set_toolbar(GtkWebView *webview, GtkWidget *toolbar)
+gtk_webview_show_toolbar(GtkWebView *webview)
 {
-	GtkWebViewPriv *priv;
-
 	g_return_if_fail(webview != NULL);
 
-	priv = GTK_WEBVIEW_GET_PRIVATE(webview);
-	priv->toolbar = GTK_WEBVIEWTOOLBAR(toolbar);
-}
-
-void
-gtk_webview_show_toolbar(GtkWebView *webview)
-{
-	GtkWebViewPriv *priv;
-
-	g_return_if_fail(webview != NULL);
-
-	priv = GTK_WEBVIEW_GET_PRIVATE(webview);
-	g_return_if_fail(priv->toolbar != NULL);
-
-	gtk_widget_show(GTK_WIDGET(priv->toolbar));
+	/* TODO: Toolbar visibility */
+	gtk_webview_safe_execute_script(webview, "");
 }
 
 void
 gtk_webview_hide_toolbar(GtkWebView *webview)
 {
-	GtkWebViewPriv *priv;
-
 	g_return_if_fail(webview != NULL);
 
-	priv = GTK_WEBVIEW_GET_PRIVATE(webview);
-	g_return_if_fail(priv->toolbar != NULL);
-
-	gtk_widget_hide(GTK_WIDGET(priv->toolbar));
+	/* TODO: Toolbar visibility */
+	gtk_webview_safe_execute_script(webview, "");
 }
 
 void
 gtk_webview_activate_toolbar(GtkWebView *webview, GtkWebViewAction action)
 {
-	GtkWebViewPriv *priv;
-
 	g_return_if_fail(webview != NULL);
 
-	priv = GTK_WEBVIEW_GET_PRIVATE(webview);
-	g_return_if_fail(priv->toolbar != NULL);
-
-	gtk_webviewtoolbar_activate(priv->toolbar, action);
+	/* TODO: Toolbar actions */
+	//gtk_webviewtoolbar_activate(priv->toolbar, action);
 }
 
diff --git a/pidgin/gtkwebvieweditor.html b/pidgin/gtkwebvieweditor.html
new file mode 100644
--- /dev/null
+++ b/pidgin/gtkwebvieweditor.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<style>
+	body {margin: 0px; height:100%;}
+	#inform {height:100%;}
+	#input {width: 100%; height:100%; border: none; box-sizing: border-box;}
+	</style>
+</head>
+<body>
+	<form id="inform">
+	<textarea id="input" autofocus></textarea>
+	</form>
+</body>
+</html>



More information about the Commits mailing list