comparison pidgin/plugins/adiumthemes/webkit.c @ 32540:7b92a2b852db

Cleanly handle webkit destroy events.
author tdrhq@soc.pidgin.im
date Mon, 10 Aug 2009 05:56:08 +0000
parents 7194ddfc8158
children b89351c7580b
comparison
equal deleted inserted replaced
32539:7194ddfc8158 32540:7b92a2b852db
120 style_list = g_list_remove (style_list, style); 120 style_list = g_list_remove (style_list, style);
121 g_free (style); 121 g_free (style);
122 } 122 }
123 123
124 static void variant_set_default (PidginMessageStyle* style); 124 static void variant_set_default (PidginMessageStyle* style);
125 static void webkit_on_webview_destroy (GtkObject* obj, gpointer data);
125 126
126 static PidginMessageStyle* 127 static PidginMessageStyle*
127 pidgin_message_style_load (const char* styledir) 128 pidgin_message_style_load (const char* styledir)
128 { 129 {
129 /* is this style already loaded? */ 130 /* is this style already loaded? */
460 461
461 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri); 462 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webkit), template, "text/html", "UTF-8", baseuri);
462 463
463 g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style); 464 g_object_set_data (G_OBJECT(webkit), MESSAGE_STYLE_KEY, style);
464 465
466 /* I need to unref this style when the webkit object destroys */
467 g_signal_connect (G_OBJECT(webkit), "destroy", G_CALLBACK(webkit_on_webview_destroy), style);
465 468
466 g_free (basedir); 469 g_free (basedir);
467 g_free (baseuri); 470 g_free (baseuri);
468 g_free (header); 471 g_free (header);
469 g_free (footer); 472 g_free (footer);
480 483
481 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", ""); 484 webkit_web_view_load_string(WEBKIT_WEB_VIEW(webview), "", "text/html", "UTF-8", "");
482 485
483 g_object_set_data (G_OBJECT(webview), MESSAGE_STYLE_KEY, NULL); 486 g_object_set_data (G_OBJECT(webview), MESSAGE_STYLE_KEY, NULL);
484 pidgin_message_style_unref (style); 487 pidgin_message_style_unref (style);
488 }
489
490 static void
491 webkit_on_webview_destroy (GtkObject *object, gpointer data)
492 {
493 pidgin_message_style_unref ((PidginMessageStyle*) data);
494 g_object_set_data (G_OBJECT(object), MESSAGE_STYLE_KEY, NULL);
485 } 495 }
486 496
487 struct webkit_script { 497 struct webkit_script {
488 GtkWidget *webkit; 498 GtkWidget *webkit;
489 char *script; 499 char *script;