changeset 32542:3bd8fb942ea4

Yep, tested, and changed some code from previous commit. This is a hard to test code, so I just hope it works flawlessly. :)
author tdrhq@soc.pidgin.im
date Mon, 10 Aug 2009 07:42:54 +0000
parents b89351c7580b
children 25d99f3621bb
files pidgin/gtkwebview.c pidgin/plugins/adiumthemes/webkit.c
diffstat 2 files changed, 10 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkwebview.c	Mon Aug 10 07:33:21 2009 +0000
+++ b/pidgin/gtkwebview.c	Mon Aug 10 07:42:54 2009 +0000
@@ -155,6 +155,12 @@
 static void
 gtk_webview_finalize (GObject *view)
 {
+	gpointer temp;
+	
+	while ((temp = g_queue_pop_head (GTK_WEBVIEW(view)->priv->js_queue)))
+		g_free (temp);
+	g_queue_free (GTK_WEBVIEW(view)->priv->js_queue);
+
 	clear_images (GTK_WEBVIEW (view));
 	g_free (GTK_WEBVIEW(view)->priv);
 	G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT(view));
@@ -260,6 +266,7 @@
 			  view);
 			  
 	view->priv->empty = TRUE;
+	view->priv->js_queue = g_queue_new ();
 }
 
 
--- a/pidgin/plugins/adiumthemes/webkit.c	Mon Aug 10 07:33:21 2009 +0000
+++ b/pidgin/plugins/adiumthemes/webkit.c	Mon Aug 10 07:42:54 2009 +0000
@@ -494,22 +494,6 @@
 	g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
 }
 
-struct webkit_script {
-	GtkWidget *webkit;
-	char *script;
-};
-
-static gboolean purple_webkit_execute_script(gpointer _script)
-{
-	struct webkit_script *script = (struct webkit_script*) _script;
-	printf ("%s\n", script->script);
-	webkit_web_view_execute_script(WEBKIT_WEB_VIEW(script->webkit), script->script);
-	g_free(script->script);
-	g_free(script);
-	return FALSE;
-}
-
-
 static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
 						 const char* name,
 						 char **pmessage,
@@ -529,7 +513,6 @@
 	char *smileyed;
 	time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */
 
-	struct webkit_script *wk_script;
 	PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags")); 
 	PidginMessageStyle *style;
 
@@ -560,12 +543,9 @@
 	escape = gtk_webview_quote_js_string (msg);
 	script = g_strdup_printf("%s(%s)", func, escape);
 
-	wk_script = g_new0(struct webkit_script, 1);
-	wk_script->script = script;
-	wk_script->webkit = webkit;
+	gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script);
 
-	g_idle_add (purple_webkit_execute_script, wk_script);
-
+	g_free(script);
 	g_free(smileyed);
 	g_free(msg);
 	g_free(stripped);
@@ -761,7 +741,7 @@
 	g_assert (style && style->css_path);
 
 	script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
-	webkit_web_view_execute_script (webview, script);
+	gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
 	g_free (script);
 }