+preferences_preview_theme_append_message (EmpathyThemeAdium *view,
+ EmpathyContact *sender,
+ EmpathyContact *receiver,
+ const gchar *text,
+ gboolean should_highlight)
+{
+ EmpathyMessage *message;
+
+ message = g_object_new (EMPATHY_TYPE_MESSAGE,
+ "sender", sender,
+ "receiver", receiver,
+ "body", text,
+ NULL);
+
+ empathy_theme_adium_append_message (view, message, should_highlight);
+ g_object_unref (message);
+}
+
+static void
+preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
+ EmpathyPreferences *preferences)
+{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+ EmpathyClientFactory *factory;
+ TpAccount *account;
+ EmpathyContact *juliet;
+ EmpathyContact *romeo;
+
+ DEBUG ("Theme changed, update preview widget");
+
+ if (priv->chat_theme_preview != NULL) {
+ gtk_widget_destroy (GTK_WIDGET (priv->chat_theme_preview));
+ }
+ priv->chat_theme_preview = empathy_theme_manager_create_view (manager);
+ gtk_container_add (GTK_CONTAINER (priv->sw_chat_theme_preview),
+ GTK_WIDGET (priv->chat_theme_preview));
+ gtk_widget_show (GTK_WIDGET (priv->chat_theme_preview));
+
+ /* FIXME: It is ugly to add a fake conversation like that.
+ * Would be cool if we could request a TplLogManager for a fake
+ * conversation */
+ factory = empathy_client_factory_dup ();
+
+ account = tp_simple_client_factory_ensure_account (
+ TP_SIMPLE_CLIENT_FACTORY (factory),
+ TP_ACCOUNT_OBJECT_PATH_BASE "cm/jabber/account", NULL, NULL);
+ juliet = g_object_new (EMPATHY_TYPE_CONTACT,
+ "account", account,
+ "id", "juliet",
+ /* translators: Contact name for the chat theme preview */
+ "alias", _("Juliet"),
+ "is-user", FALSE,
+ NULL);
+ romeo = g_object_new (EMPATHY_TYPE_CONTACT,
+ "account", account,
+ "id", "romeo",
+ /* translators: Contact name for the chat theme preview */
+ "alias", _("Romeo"),
+ "is-user", TRUE,
+ NULL);
+
+ preferences_preview_theme_append_message (priv->chat_theme_preview,
+ /* translators: Quote from Romeo & Julier, for chat theme preview */
+ juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"),
+ TRUE /* this message mentions Romeo */);
+ preferences_preview_theme_append_message (priv->chat_theme_preview,
+ /* translators: Quote from Romeo & Julier, for chat theme preview */
+ juliet, romeo, _("Deny thy father and refuse thy name;"), FALSE);
+ preferences_preview_theme_append_message (priv->chat_theme_preview,
+ /* translators: Quote from Romeo & Julier, for chat theme preview */
+ juliet, romeo, _("Or if thou wilt not, be but sworn my love"), FALSE);
+ preferences_preview_theme_append_message (priv->chat_theme_preview,
+ /* translators: Quote from Romeo & Julier, for chat theme preview */
+ juliet, romeo, _("And I'll no longer be a Capulet."), FALSE);
+ preferences_preview_theme_append_message (priv->chat_theme_preview,
+ /* translators: Quote from Romeo & Julier, for chat theme preview */
+ romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE);
+
+ /* translators: Quote from Romeo & Julier, for chat theme preview */
+ empathy_theme_adium_append_event (priv->chat_theme_preview, _("Juliet has disconnected"));
+
+ g_object_unref (juliet);
+ g_object_unref (romeo);
+ g_object_unref (account);
+ g_object_unref (factory);
+}
+
+static void
+preferences_theme_variant_changed_cb (GtkComboBox *combo,
+ EmpathyPreferences *preferences)
+{
+ EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+ GtkTreeIter iter;
+
+ if (gtk_combo_box_get_active_iter (combo, &iter)) {
+ GtkTreeModel *model;
+ gchar *name;
+
+ model = gtk_combo_box_get_model (combo);
+ gtk_tree_model_get (model, &iter,
+ COL_VARIANT_NAME, &name,
+ -1);
+
+ g_settings_set_string (priv->gsettings_chat,
+ EMPATHY_PREFS_CHAT_THEME_VARIANT,
+ name);
+
+ g_free (name);
+ }
+}
+
+static void
+preferences_theme_variant_notify_cb (GSettings *gsettings,
+ const gchar *key,
+ gpointer user_data)