comparison pidgin/plugins/adiumthemes/webkit.c @ 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 ef8d9e44cc73
comparison
equal deleted inserted replaced
32541:b89351c7580b 32542:3bd8fb942ea4
492 { 492 {
493 pidgin_message_style_unref ((PidginMessageStyle*) data); 493 pidgin_message_style_unref ((PidginMessageStyle*) data);
494 g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL); 494 g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
495 } 495 }
496 496
497 struct webkit_script {
498 GtkWidget *webkit;
499 char *script;
500 };
501
502 static gboolean purple_webkit_execute_script(gpointer _script)
503 {
504 struct webkit_script *script = (struct webkit_script*) _script;
505 printf ("%s\n", script->script);
506 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(script->webkit), script->script);
507 g_free(script->script);
508 g_free(script);
509 return FALSE;
510 }
511
512
513 static gboolean webkit_on_displaying_im_msg (PurpleAccount *account, 497 static gboolean webkit_on_displaying_im_msg (PurpleAccount *account,
514 const char* name, 498 const char* name,
515 char **pmessage, 499 char **pmessage,
516 PurpleConversation *conv, 500 PurpleConversation *conv,
517 PurpleMessageFlags flags, 501 PurpleMessageFlags flags,
527 char *script; 511 char *script;
528 char *func = "appendMessage"; 512 char *func = "appendMessage";
529 char *smileyed; 513 char *smileyed;
530 time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */ 514 time_t mtime = time (NULL); /* FIXME: this should come from the write_conv calback, but the signal doesn't pass this to me */
531 515
532 struct webkit_script *wk_script;
533 PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags")); 516 PurpleMessageFlags old_flags = GPOINTER_TO_INT(purple_conversation_get_data(conv, "webkit-lastflags"));
534 PidginMessageStyle *style; 517 PidginMessageStyle *style;
535 518
536 fprintf (stderr, "hmm.. here %s %s\n", name, message); 519 fprintf (stderr, "hmm.. here %s %s\n", name, message);
537 webkit = get_webkit(conv); 520 webkit = get_webkit(conv);
558 smileyed = smiley_parse_markup(stripped, conv->account->protocol_id); 541 smileyed = smiley_parse_markup(stripped, conv->account->protocol_id);
559 msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime); 542 msg = replace_message_tokens(message_html, 0, conv, name, alias, smileyed, flags, mtime);
560 escape = gtk_webview_quote_js_string (msg); 543 escape = gtk_webview_quote_js_string (msg);
561 script = g_strdup_printf("%s(%s)", func, escape); 544 script = g_strdup_printf("%s(%s)", func, escape);
562 545
563 wk_script = g_new0(struct webkit_script, 1); 546 gtk_webview_safe_execute_script (GTK_WEBVIEW (webkit), script);
564 wk_script->script = script; 547
565 wk_script->webkit = webkit; 548 g_free(script);
566
567 g_idle_add (purple_webkit_execute_script, wk_script);
568
569 g_free(smileyed); 549 g_free(smileyed);
570 g_free(msg); 550 g_free(msg);
571 g_free(stripped); 551 g_free(stripped);
572 g_free(escape); 552 g_free(escape);
573 553
759 char *script; 739 char *script;
760 740
761 g_assert (style && style->css_path); 741 g_assert (style && style->css_path);
762 742
763 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path); 743 script = g_strdup_printf ("setStylesheet(\"mainStyle\",\"%s\")", style->css_path);
764 webkit_web_view_execute_script (webview, script); 744 gtk_webview_safe_execute_script (GTK_WEBVIEW(webview), script);
765 g_free (script); 745 g_free (script);
766 } 746 }
767 747
768 static void 748 static void
769 variant_changed (GtkWidget* combobox, gpointer null) 749 variant_changed (GtkWidget* combobox, gpointer null)