changeset 32729:512d781a5849

Update the variant in existing conversations when changed. Actually, this doesn't really work since opening the prefs re-scans the themes and creates new GObjects.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 08 Oct 2011 02:51:52 +0000
parents f28a09bfe22c
children 29f1a6b07b9b
files pidgin/gtkconv.c
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Sat Oct 08 02:44:27 2011 +0000
+++ b/pidgin/gtkconv.c	Sat Oct 08 02:51:52 2011 +0000
@@ -5130,6 +5130,19 @@
 		webkit_web_view_set_transparent(webview, g_value_get_boolean(val));
 }
 
+static void
+conv_variant_changed_cb(GObject *gobject, GParamSpec *pspec, gpointer user_data)
+{
+	PidginConversation *gtkconv = user_data;
+	const char *path;
+	char *js;
+
+	path = pidgin_conversation_theme_get_css_path(PIDGIN_CONV_THEME(gobject));
+	js = g_strdup_printf("setStylesheet(\"mainStyle\", \"file://%s\");", path);
+	gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview), js);
+	g_free(js);
+}
+
 static GtkWidget *
 setup_common_pane(PidginConversation *gtkconv)
 {
@@ -5258,6 +5271,9 @@
 		if (chat)
 			gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview), "document.getElementById('Chat').className = 'groupchat'");
 
+		g_signal_connect(G_OBJECT(gtkconv->theme), "notify::variant",
+		                 G_CALLBACK(conv_variant_changed_cb), gtkconv);
+
 		g_free(basedir);
 		g_free(baseuri);
 		g_free(template);
@@ -5805,6 +5821,8 @@
 		g_source_remove(gtkconv->attach.timer);
 	}
 
+	g_object_disconnect(G_OBJECT(gtkconv->theme), "any_signal::notify",
+	                    conv_variant_changed_cb, gtkconv, NULL);
 	g_object_unref(gtkconv->theme);
 
 	g_free(gtkconv);