]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-theme-manager.c
Merge branch 'irc-dialog-579800'
[empathy.git] / libempathy-gtk / empathy-theme-manager.c
index 268760a549031a15b751f35ae42d6828eb124385..841e26297c6c355527e1e37f3bdb3c7faeed7762 100644 (file)
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2005-2007 Imendio AB
+ * Copyright (C) 2008 Collabora Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * License along with this program; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- * 
- * Authors: Richard Hult <richard@imendio.com>
+ *
+ * Authors: Xavier Claessens <xclaesse@gmail.com>
  */
 
 #include "config.h"
 
 #include <string.h>
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
-#include <libempathy/empathy-conf.h>
+#include <telepathy-glib/util.h>
 #include <libempathy/empathy-utils.h>
 
-#include "empathy-chat-view.h"
-#include "empathy-preferences.h"
 #include "empathy-theme-manager.h"
+#include "empathy-chat-view.h"
+#include "empathy-conf.h"
+#include "empathy-chat-text-view.h"
+#include "empathy-theme-boxes.h"
+#include "empathy-theme-irc.h"
 
-#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManagerPriv))
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeManager)
 typedef struct {
-       gchar    *name;
-       guint     name_notify_id;
-       guint     room_notify_id;
-
-       gboolean  show_avatars;
-       guint     show_avatars_notify_id;
-
-       gboolean  irc_style;
+       gchar       *name;
+       guint        name_notify_id;
+       GtkSettings *settings;
+       GList       *boxes_views;
 } EmpathyThemeManagerPriv;
 
-static void        theme_manager_finalize                 (GObject            *object);
-static void        theme_manager_notify_name_cb           (EmpathyConf         *conf,
-                                                          const gchar        *key,
-                                                          gpointer            user_data);
-static void        theme_manager_notify_room_cb           (EmpathyConf         *conf,
-                                                          const gchar        *key,
-                                                          gpointer            user_data);
-static void        theme_manager_notify_show_avatars_cb   (EmpathyConf         *conf,
-                                                          const gchar        *key,
-                                                          gpointer            user_data);
-static void        theme_manager_ensure_tag_by_name       (GtkTextBuffer      *buffer,
-                                                          const gchar        *name);
-static gboolean    theme_manager_ensure_theme_exists      (const gchar        *name);
-static GtkTextTag *theme_manager_init_tag_by_name         (GtkTextTagTable    *table,
-                                                          const gchar        *name);
-static void        theme_manager_add_tag                  (GtkTextTagTable    *table,
-                                                          GtkTextTag         *tag);
-static void        theme_manager_fixup_tag_table          (EmpathyThemeManager *theme_manager,
-                                                          EmpathyChatView     *view);
-static void        theme_manager_apply_theme_classic      (EmpathyThemeManager *manager,
-                                                          EmpathyChatView     *view);
-static void        theme_manager_apply_theme_clean        (EmpathyThemeManager *manager,
-                                                          EmpathyChatView     *view);
-static void        theme_manager_apply_theme_blue         (EmpathyThemeManager *manager,
-                                                          EmpathyChatView     *view);
-static void        theme_manager_apply_theme              (EmpathyThemeManager *manager,
-                                                          EmpathyChatView     *view,
-                                                          const gchar        *name);
-
 enum {
        THEME_CHANGED,
        LAST_SIGNAL
@@ -94,143 +67,283 @@ static const gchar *themes[] = {
 G_DEFINE_TYPE (EmpathyThemeManager, empathy_theme_manager, G_TYPE_OBJECT);
 
 static void
-empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass)
+theme_manager_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-       signals[THEME_CHANGED] =
-               g_signal_new ("theme-changed",
-                             G_OBJECT_CLASS_TYPE (object_class),
-                             G_SIGNAL_RUN_LAST,
-                             0,
-                             NULL, NULL,
-                             g_cclosure_marshal_VOID__VOID,
-                             G_TYPE_NONE,
-                             0);
-
-       g_type_class_add_private (object_class, sizeof (EmpathyThemeManagerPriv));
+       g_snprintf (str_color, 10, 
+                   "#%02x%02x%02x", 
+                   gdk_color->red >> 8,
+                   gdk_color->green >> 8,
+                   gdk_color->blue >> 8);
+}
 
-       object_class->finalize = theme_manager_finalize;
+static EmpathyThemeIrc *
+theme_manager_create_irc_view (EmpathyThemeManager *manager)
+{
+       EmpathyChatTextView *view;
+       EmpathyThemeIrc     *theme;
+
+       theme = empathy_theme_irc_new ();
+       view = EMPATHY_CHAT_TEXT_VIEW (theme);
+
+       /* Define base tags */
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING,
+                                       "size", 2000,
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME,
+                                       "foreground", "darkgrey",
+                                       "justification", GTK_JUSTIFY_CENTER,
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION,
+                                       "foreground", "brown4",
+                                       "style", PANGO_STYLE_ITALIC,
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY,
+                                       "foreground-set", FALSE,
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT,
+                                       "foreground", "PeachPuff4",
+                                       "justification", GTK_JUSTIFY_LEFT,
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK,
+                                       "foreground", "steelblue",
+                                       "underline", PANGO_UNDERLINE_SINGLE,
+                                       NULL);
+
+       /* Define IRC tags */
+       empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_SELF,
+                                       "foreground", "sea green",
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_OTHER,
+                                       "foreground", "skyblue4",
+                                       NULL);
+       empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT,
+                                       "foreground", "indian red",
+                                       "weight", PANGO_WEIGHT_BOLD,
+                                       NULL);
+
+       return theme;
 }
 
 static void
-empathy_theme_manager_init (EmpathyThemeManager *manager)
+theme_manager_boxes_weak_notify_cb (gpointer data,
+                                   GObject *where_the_object_was)
 {
-       EmpathyThemeManagerPriv *priv;
+       EmpathyThemeManagerPriv *priv = GET_PRIV (data);
 
-       priv = GET_PRIV (manager);
-
-       priv->name_notify_id =
-               empathy_conf_notify_add (empathy_conf_get (),
-                                       EMPATHY_PREFS_CHAT_THEME,
-                                       theme_manager_notify_name_cb,
-                                       manager);
-
-       priv->room_notify_id =
-               empathy_conf_notify_add (empathy_conf_get (),
-                                       EMPATHY_PREFS_CHAT_THEME_CHAT_ROOM,
-                                       theme_manager_notify_room_cb,
-                                       manager);
+       priv->boxes_views = g_list_remove (priv->boxes_views, where_the_object_was);
+}
 
-       empathy_conf_get_string (empathy_conf_get (),
-                               EMPATHY_PREFS_CHAT_THEME,
-                               &priv->name);
+static EmpathyThemeBoxes *
+theme_manager_create_boxes_view (EmpathyThemeManager *manager)
+{
+       EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
+       EmpathyThemeBoxes       *theme;
 
-       /* Unused right now, but will be used soon. */
-       priv->show_avatars_notify_id =
-               empathy_conf_notify_add (empathy_conf_get (),
-                                       EMPATHY_PREFS_UI_SHOW_AVATARS,
-                                       theme_manager_notify_show_avatars_cb,
-                                       manager);
+       theme = empathy_theme_boxes_new ();
+       priv->boxes_views = g_list_prepend (priv->boxes_views, theme);
+       g_object_weak_ref (G_OBJECT (theme),
+                          theme_manager_boxes_weak_notify_cb,
+                          manager);
 
-       empathy_conf_get_bool (empathy_conf_get (),
-                             EMPATHY_PREFS_UI_SHOW_AVATARS,
-                             &priv->show_avatars);
+       return theme;
 }
 
 static void
-theme_manager_finalize (GObject *object)
-{
-       EmpathyThemeManagerPriv *priv;
+theme_manager_update_boxes_tags (EmpathyThemeBoxes *theme,
+                                const gchar       *header_foreground,
+                                const gchar       *header_background,
+                                const gchar       *header_line_background,
+                                const gchar       *action_foreground,
+                                const gchar       *time_foreground,
+                                const gchar       *event_foreground,
+                                const gchar       *link_foreground,
+                                const gchar       *text_foreground,
+                                const gchar       *text_background,
+                                const gchar       *highlight_foreground)
 
-       priv = GET_PRIV (object);
-
-       empathy_conf_notify_remove (empathy_conf_get (), priv->name_notify_id);
-       empathy_conf_notify_remove (empathy_conf_get (), priv->room_notify_id);
-       empathy_conf_notify_remove (empathy_conf_get (), priv->show_avatars_notify_id);
-
-       g_free (priv->name);
+{
+       EmpathyChatTextView *view = EMPATHY_CHAT_TEXT_VIEW (theme);
+       GtkTextTag          *tag;
+
+       DEBUG ("Update view with new colors:\n"
+               "header_foreground = %s\n"
+               "header_background = %s\n"
+               "header_line_background = %s\n"
+               "action_foreground = %s\n"
+               "time_foreground = %s\n"
+               "event_foreground = %s\n"
+               "link_foreground = %s\n"
+               "text_foreground = %s\n"
+               "text_background = %s\n"
+               "highlight_foreground = %s\n",
+               header_foreground, header_background, header_line_background,
+               action_foreground, time_foreground, event_foreground,
+               link_foreground, text_foreground, text_background,
+               highlight_foreground);
+
+
+       /* FIXME: GtkTextTag don't support to set color properties to NULL.
+        * See bug #542523 */
+       
+       #define TAG_SET(prop, prop_set, value) \
+               if (value != NULL) { \
+                       g_object_set (tag, prop, value, NULL); \
+               } else { \
+                       g_object_set (tag, prop_set, FALSE, NULL); \
+               }
 
-       G_OBJECT_CLASS (empathy_theme_manager_parent_class)->finalize (object);
+       /* Define base tags */
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT,
+                                             "weight", PANGO_WEIGHT_BOLD,
+                                             "pixels-above-lines", 4,
+                                             NULL);
+       TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
+       TAG_SET ("foreground", "foreground-set",highlight_foreground);
+
+       empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING,
+                                       "size", 3000,
+                                       "pixels-above-lines", 8,
+                                       NULL);
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME,
+                                             "justification", GTK_JUSTIFY_CENTER,
+                                             NULL);
+       TAG_SET ("foreground", "foreground-set", time_foreground);
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION,
+                                             "style", PANGO_STYLE_ITALIC,
+                                             "pixels-above-lines", 4,
+                                             NULL);
+       TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
+       TAG_SET ("foreground", "foreground-set", action_foreground);
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY,
+                                             "pixels-above-lines", 4,
+                                             NULL);
+       TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
+       TAG_SET ("foreground", "foreground-set", text_foreground);
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT,
+                                             "justification", GTK_JUSTIFY_LEFT,
+                                             NULL);
+       TAG_SET ("foreground", "foreground-set", event_foreground);
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK,
+                                             "underline", PANGO_UNDERLINE_SINGLE,
+                                             NULL);
+       TAG_SET ("foreground", "foreground-set", link_foreground);
+
+       /* Define BOXES tags */
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER,
+                                             "weight", PANGO_WEIGHT_BOLD,
+                                             NULL);
+       TAG_SET ("foreground", "foreground-set", header_foreground);
+       TAG_SET ("paragraph-background", "paragraph-background-set", header_background);
+       tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER_LINE,
+                                             "size", 1,
+                                             NULL);
+       TAG_SET ("paragraph-background", "paragraph-background-set", header_line_background);
+
+       #undef TAG_SET
 }
 
 static void
-theme_manager_notify_name_cb (EmpathyConf  *conf,
-                             const gchar *key,
-                             gpointer     user_data)
+theme_manager_update_simple_tags (EmpathyThemeBoxes *theme)
 {
-       EmpathyThemeManager     *manager;
-       EmpathyThemeManagerPriv *priv;
-       gchar                  *name;
-
-       manager = user_data;
-       priv = GET_PRIV (manager);
-
-       g_free (priv->name);
-
-       name = NULL;
-       if (!empathy_conf_get_string (conf, key, &name) ||
-           name == NULL || name[0] == 0) {
-               priv->name = g_strdup ("classic");
-               g_free (name);
-       } else {
-               priv->name = name;
-       }
-
-       g_signal_emit (manager, signals[THEME_CHANGED], 0, NULL);
+       GtkStyle *style;
+       gchar     color1[10];
+       gchar     color2[10];
+       gchar     color3[10];
+       gchar     color4[10];
+
+       style = gtk_widget_get_default_style ();
+
+       theme_manager_gdk_color_to_hex (&style->base[GTK_STATE_SELECTED], color1);
+       theme_manager_gdk_color_to_hex (&style->bg[GTK_STATE_SELECTED], color2);
+       theme_manager_gdk_color_to_hex (&style->dark[GTK_STATE_SELECTED], color3);
+       theme_manager_gdk_color_to_hex (&style->fg[GTK_STATE_SELECTED], color4);
+
+       theme_manager_update_boxes_tags (theme,
+                                        color4,     /* header_foreground */
+                                        color2,     /* header_background */
+                                        color3,     /* header_line_background */
+                                        color1,     /* action_foreground */
+                                        "darkgrey", /* time_foreground */
+                                        "darkgrey", /* event_foreground */
+                                        color1,     /* link_foreground */
+                                        NULL,       /* text_foreground */
+                                        NULL,       /* text_background */
+                                        NULL);      /* highlight_foreground */
 }
 
 static void
-theme_manager_notify_room_cb (EmpathyConf  *conf,
-                             const gchar *key,
-                             gpointer     user_data)
+theme_manager_update_boxes_theme (EmpathyThemeManager *manager,
+                                 EmpathyThemeBoxes   *theme)
 {
-       g_signal_emit (user_data, signals[THEME_CHANGED], 0, NULL);
+       EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
+
+       if (strcmp (priv->name, "simple") == 0) {
+               theme_manager_update_simple_tags (theme);
+       }
+       else if (strcmp (priv->name, "clean") == 0) {
+               theme_manager_update_boxes_tags (theme,
+                                                "black",    /* header_foreground */
+                                                "#efefdf",  /* header_background */
+                                                "#e3e3d3",  /* header_line_background */
+                                                "brown4",   /* action_foreground */
+                                                "darkgrey", /* time_foreground */
+                                                "darkgrey", /* event_foreground */
+                                                "#49789e",  /* link_foreground */
+                                                NULL,       /* text_foreground */
+                                                NULL,       /* text_background */
+                                                NULL);      /* highlight_foreground */
+       }
+       else if (strcmp (priv->name, "blue") == 0) {
+               theme_manager_update_boxes_tags (theme,
+                                                "black",    /* header_foreground */
+                                                "#88a2b4",  /* header_background */
+                                                "#7f96a4",  /* header_line_background */
+                                                "brown4",   /* action_foreground */
+                                                "darkgrey", /* time_foreground */
+                                                "#7f96a4",  /* event_foreground */
+                                                "#49789e",  /* link_foreground */
+                                                "black",    /* text_foreground */
+                                                "#adbdc8",  /* text_background */
+                                                "black");   /* highlight_foreground */
+       }
 }
 
-static void
-theme_manager_notify_show_avatars_cb (EmpathyConf  *conf,
-                                     const gchar *key,
-                                     gpointer     user_data)
+EmpathyChatView *
+empathy_theme_manager_create_view (EmpathyThemeManager *manager)
 {
-       EmpathyThemeManager     *manager;
-       EmpathyThemeManagerPriv *priv;
-       gboolean                value;
+       EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
+       EmpathyThemeBoxes       *theme;
 
-       manager = user_data;
-       priv = GET_PRIV (manager);
+       g_return_val_if_fail (EMPATHY_IS_THEME_MANAGER (manager), NULL);
 
-       if (!empathy_conf_get_bool (conf, key, &value)) {
-               priv->show_avatars = FALSE;
-       } else {
-               priv->show_avatars = value;
+       DEBUG ("Using theme %s", priv->name);
+
+       if (strcmp (priv->name, "classic") == 0)  {
+               return EMPATHY_CHAT_VIEW (theme_manager_create_irc_view (manager));
        }
+
+       theme = theme_manager_create_boxes_view (manager);
+       theme_manager_update_boxes_theme (manager, theme);
+
+       return EMPATHY_CHAT_VIEW (theme);
 }
 
 static void
-theme_manager_ensure_tag_by_name (GtkTextBuffer *buffer,
-                                 const gchar   *name)
+theme_manager_color_hash_notify_cb (EmpathyThemeManager *manager)
 {
-       GtkTextTagTable *table;
-       GtkTextTag      *tag;
+       EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
+
+       /* FIXME: Make that work, it should update color when theme changes but
+        * it doesnt seems to work with all themes. */
 
-       table = gtk_text_buffer_get_tag_table (buffer);
-       tag = gtk_text_tag_table_lookup (table, name);
+       if (strcmp (priv->name, "simple") == 0) {
+               GList *l;
 
-       if (!tag) {
-               gtk_text_buffer_create_tag (buffer,
-                                           name,
-                                           NULL);
+               /* We are using the simple theme which use the GTK theme color,
+                * Update views to use the new color. */
+               for (l = priv->boxes_views; l; l = l->next) {
+                       theme_manager_update_simple_tags (EMPATHY_THEME_BOXES (l->data));
+               }
        }
 }
 
@@ -239,7 +352,7 @@ theme_manager_ensure_theme_exists (const gchar *name)
 {
        gint i;
 
-       if (G_STR_EMPTY (name)) {
+       if (EMP_STR_EMPTY (name)) {
                return FALSE;
        }
 
@@ -252,690 +365,106 @@ theme_manager_ensure_theme_exists (const gchar *name)
        return FALSE;
 }
 
-static GtkTextTag *
-theme_manager_init_tag_by_name (GtkTextTagTable *table,
-                               const gchar     *name)
+static void
+theme_manager_notify_name_cb (EmpathyConf *conf,
+                             const gchar *key,
+                             gpointer     user_data)
 {
-       GtkTextTag *tag;
+       EmpathyThemeManager     *manager = EMPATHY_THEME_MANAGER (user_data);
+       EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
+       gchar                   *name = NULL;
 
-       tag = gtk_text_tag_table_lookup (table, name);
+       if (!empathy_conf_get_string (conf, key, &name) ||
+           !theme_manager_ensure_theme_exists (name) ||
+           !tp_strdiff (priv->name, name)) {
+               if (!priv->name) {
+                       priv->name = g_strdup ("classic");
+               }
 
-       if (!tag) {
-               return gtk_text_tag_new (name);
+               g_free (name);
+               return;
        }
 
-       /* Clear the old values so that we don't affect the new theme. */
-       g_object_set (tag,
-                     "background-set", FALSE,
-                     "foreground-set", FALSE,
-                     "invisible-set", FALSE,
-                     "justification-set", FALSE,
-                     "paragraph-background-set", FALSE,
-                     "pixels-above-lines-set", FALSE,
-                     "pixels-below-lines-set", FALSE,
-                     "rise-set", FALSE,
-                     "scale-set", FALSE,
-                     "size-set", FALSE,
-                     "style-set", FALSE,
-                     "weight-set", FALSE,
-                     NULL);
-
-       return tag;
-}
+       g_free (priv->name);
+       priv->name = name;
 
-static void
-theme_manager_add_tag (GtkTextTagTable *table,
-                      GtkTextTag      *tag)
-{
-       gchar      *name;
-       GtkTextTag *check_tag;
+       if (!tp_strdiff (priv->name, "simple") ||
+           !tp_strdiff (priv->name, "clean") ||
+           !tp_strdiff (priv->name, "blue")) {
+               GList *l;
 
-       g_object_get (tag, "name", &name, NULL);
-       check_tag = gtk_text_tag_table_lookup (table, name);
-       g_free (name);
-       if (check_tag) {
-               return;
+               /* The theme changes to a boxed one, we can update boxed views */
+               for (l = priv->boxes_views; l; l = l->next) {
+                       theme_manager_update_boxes_theme (manager,
+                                                         EMPATHY_THEME_BOXES (l->data));
+               }
        }
 
-       gtk_text_tag_table_add (table, tag);
-
-       g_object_unref (tag);
+       g_signal_emit (manager, signals[THEME_CHANGED], 0, NULL);
 }
 
 static void
-theme_manager_fixup_tag_table (EmpathyThemeManager *theme_manager,
-                              EmpathyChatView     *view)
+theme_manager_finalize (GObject *object)
 {
-       GtkTextBuffer *buffer;
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
-       /* "Fancy" style tags. */
-       theme_manager_ensure_tag_by_name (buffer, "fancy-header-self");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-header-self-avatar");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-avatar-self");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-line-top-self");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-line-bottom-self");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-body-self");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-action-self");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-highlight-self");
-
-       theme_manager_ensure_tag_by_name (buffer, "fancy-header-other");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-header-other-avatar");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-avatar-other");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-line-top-other");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-line-bottom-other");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-body-other");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-action-other");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-highlight-other");
-
-       theme_manager_ensure_tag_by_name (buffer, "fancy-spacing");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-time");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-event");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-invite");
-       theme_manager_ensure_tag_by_name (buffer, "fancy-link");
-
-       /* IRC style tags. */
-       theme_manager_ensure_tag_by_name (buffer, "irc-nick-self");
-       theme_manager_ensure_tag_by_name (buffer, "irc-body-self");
-       theme_manager_ensure_tag_by_name (buffer, "irc-action-self");
-
-       theme_manager_ensure_tag_by_name (buffer, "irc-nick-other");
-       theme_manager_ensure_tag_by_name (buffer, "irc-body-other");
-       theme_manager_ensure_tag_by_name (buffer, "irc-action-other");
-
-       theme_manager_ensure_tag_by_name (buffer, "irc-nick-highlight");
-       theme_manager_ensure_tag_by_name (buffer, "irc-spacing");
-       theme_manager_ensure_tag_by_name (buffer, "irc-time");
-       theme_manager_ensure_tag_by_name (buffer, "irc-event");
-       theme_manager_ensure_tag_by_name (buffer, "irc-invite");
-       theme_manager_ensure_tag_by_name (buffer, "irc-link");
-}
+       EmpathyThemeManagerPriv *priv = GET_PRIV (object);
+       GList                   *l;
 
-static void
-theme_manager_apply_theme_classic (EmpathyThemeManager *manager,
-                                  EmpathyChatView     *view)
-{
-       EmpathyThemeManagerPriv *priv;
-       GtkTextBuffer          *buffer;
-       GtkTextTagTable        *table;
-       GtkTextTag             *tag;
-
-       priv = GET_PRIV (manager);
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-       table = gtk_text_buffer_get_tag_table (buffer);
-
-       priv->irc_style = TRUE;
-
-       tag = theme_manager_init_tag_by_name (table, "irc-spacing");
-       g_object_set (tag,
-                     "size", 2000,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-nick-self");
-       g_object_set (tag,
-                     "foreground", "sea green",
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-body-self");
-       g_object_set (tag,
-                     /* To get the default theme color: */
-                     "foreground-set", FALSE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-action-self");
-       g_object_set (tag,
-                     "foreground", "brown4",
-                     "style", PANGO_STYLE_ITALIC,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-nick-highlight");
-       g_object_set (tag,
-                     "foreground", "indian red",
-                     "weight", PANGO_WEIGHT_BOLD,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-nick-other");
-       g_object_set (tag,
-                     "foreground", "skyblue4",
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-body-other");
-       g_object_set (tag,
-                     /* To get the default theme color: */
-                     "foreground-set", FALSE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-action-other");
-       g_object_set (tag,
-                     "foreground", "brown4",
-                     "style", PANGO_STYLE_ITALIC,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-time");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     "justification", GTK_JUSTIFY_CENTER,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-event");
-       g_object_set (tag,
-                     "foreground", "PeachPuff4",
-                     "justification", GTK_JUSTIFY_LEFT,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-invite");
-       g_object_set (tag,
-                     "foreground", "sienna",
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "irc-link");
-       g_object_set (tag,
-                     "foreground", "steelblue",
-                     "underline", PANGO_UNDERLINE_SINGLE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-}
+       empathy_conf_notify_remove (empathy_conf_get (), priv->name_notify_id);
+       g_free (priv->name);
 
-static void
-theme_manager_apply_theme_simple (EmpathyThemeManager *manager,
-                                 EmpathyChatView     *view)
-{
-       EmpathyThemeManagerPriv *priv;
-       GtkTextBuffer          *buffer;
-       GtkTextTagTable        *table;
-       GtkTextTag             *tag;
-       GtkWidget              *widget;
-       GtkStyle               *style;
-
-       priv = GET_PRIV (manager);
-
-       widget = gtk_entry_new ();
-       style = gtk_widget_get_style (widget);
-       gtk_widget_destroy (widget);
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-       table = gtk_text_buffer_get_tag_table (buffer);
-
-       priv->irc_style = FALSE;
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-spacing");
-       g_object_set (tag,
-                     "size", 3000,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-self");
-       g_object_set (tag,
-                     "weight", PANGO_WEIGHT_BOLD,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-self-avatar");
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-avatar-self");
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-top-self");
-       g_object_set (tag,
-                     "size", 6 * PANGO_SCALE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-bottom-self");
-       g_object_set (tag,
-                     "size", 1,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-body-self");
-       g_object_set (tag,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-action-self");
-       g_object_set (tag,
-                     "foreground-gdk", &style->base[GTK_STATE_SELECTED],
-                     "style", PANGO_STYLE_ITALIC,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-highlight-self");
-       g_object_set (tag,
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-other");
-       g_object_set (tag,
-                     "weight", PANGO_WEIGHT_BOLD,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-other-avatar");
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-avatar-other");
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-top-other");
-       g_object_set (tag,
-                     "size", 6 * PANGO_SCALE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-bottom-other");
-       g_object_set (tag,
-                     "size", 1,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-body-other");
-       g_object_set (tag,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-action-other");
-       g_object_set (tag,
-                     "foreground-gdk", &style->base[GTK_STATE_SELECTED],
-                     "style", PANGO_STYLE_ITALIC,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-highlight-other");
-       g_object_set (tag,
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-time");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     "justification", GTK_JUSTIFY_CENTER,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-event");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     "justification", GTK_JUSTIFY_LEFT,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-invite");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-link");
-       g_object_set (tag,
-                     "foreground-gdk", &style->base[GTK_STATE_SELECTED],
-                     "underline", PANGO_UNDERLINE_SINGLE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-}
+       for (l = priv->boxes_views; l; l = l->next) {
+               g_object_weak_unref (G_OBJECT (l->data),
+                                    theme_manager_boxes_weak_notify_cb,
+                                    object);
+       }
+       g_list_free (priv->boxes_views);
 
-static void
-theme_manager_apply_theme_clean (EmpathyThemeManager *manager,
-                                EmpathyChatView     *view)
-{
-       EmpathyThemeManagerPriv *priv;
-       GtkTextBuffer          *buffer;
-       GtkTextTagTable        *table;
-       GtkTextTag             *tag;
-
-       priv = GET_PRIV (manager);
-
-       /* Inherit the simple theme. */
-       theme_manager_apply_theme_simple (manager, view);
-
-#define ELEGANT_HEAD "#efefdf"
-#define ELEGANT_LINE "#e3e3d3"
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-       table = gtk_text_buffer_get_tag_table (buffer);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-spacing");
-       g_object_set (tag,
-                     "size", PANGO_SCALE * 10,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-self");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "paragraph-background", ELEGANT_HEAD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-avatar-self");
-       g_object_set (tag,
-                     "paragraph-background", ELEGANT_HEAD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-top-self");
-       g_object_set (tag,
-                     "size", 1 * PANGO_SCALE,
-                     "paragraph-background", ELEGANT_LINE,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-bottom-self");
-       g_object_set (tag,
-                     "size", 1 * PANGO_SCALE,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-action-self");
-       g_object_set (tag,
-                     "foreground", "brown4",
-                     "style", PANGO_STYLE_ITALIC,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-highlight-self");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "weight", PANGO_WEIGHT_BOLD,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-other");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "paragraph-background", ELEGANT_HEAD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-avatar-other");
-       g_object_set (tag,
-                     "paragraph-background", ELEGANT_HEAD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-top-other");
-       g_object_set (tag,
-                     "size", 1 * PANGO_SCALE,
-                     "paragraph-background", ELEGANT_LINE,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-bottom-other");
-       g_object_set (tag,
-                     "size", 1 * PANGO_SCALE,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-action-other");
-       g_object_set (tag,
-                     "foreground", "brown4",
-                     "style", PANGO_STYLE_ITALIC,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-time");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     "justification", GTK_JUSTIFY_CENTER,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-event");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     "justification", GTK_JUSTIFY_LEFT,
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-invite");
-       g_object_set (tag,
-                     "foreground", "sienna",
-                     NULL);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-link");
-       g_object_set (tag,
-                     "foreground", "#49789e",
-                     "underline", PANGO_UNDERLINE_SINGLE,
-                     NULL);
+       G_OBJECT_CLASS (empathy_theme_manager_parent_class)->finalize (object);
 }
 
 static void
-theme_manager_apply_theme_blue (EmpathyThemeManager *manager,
-                               EmpathyChatView     *view)
+empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass)
 {
-       EmpathyThemeManagerPriv *priv;
-       GtkTextBuffer          *buffer;
-       GtkTextTagTable        *table;
-       GtkTextTag             *tag;
-
-       priv = GET_PRIV (manager);
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-       table = gtk_text_buffer_get_tag_table (buffer);
-
-       priv->irc_style = FALSE;
-
-#define BLUE_BODY_SELF "#dcdcdc"
-#define BLUE_HEAD_SELF "#b9b9b9"
-#define BLUE_LINE_SELF "#aeaeae"
-
-#define BLUE_BODY_OTHER "#adbdc8"
-#define BLUE_HEAD_OTHER "#88a2b4"
-#define BLUE_LINE_OTHER "#7f96a4"
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-spacing");
-       g_object_set (tag,
-                     "size", 3000,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-self");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "paragraph-background", BLUE_HEAD_SELF,
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-self-avatar");
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-avatar-self");
-       g_object_set (tag,
-                     "paragraph-background", BLUE_HEAD_SELF,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-top-self");
-       g_object_set (tag,
-                     "size", 1,
-                     "paragraph-background", BLUE_LINE_SELF,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-bottom-self");
-       g_object_set (tag,
-                     "size", 1,
-                     "paragraph-background", BLUE_LINE_SELF,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-body-self");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "paragraph-background", BLUE_BODY_SELF,
-                     "pixels-above-lines", 4,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-action-self");
-       g_object_set (tag,
-                     "foreground", "brown4",
-                     "style", PANGO_STYLE_ITALIC,
-                     "paragraph-background", BLUE_BODY_SELF,
-                     "pixels-above-lines", 4,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-highlight-self");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "paragraph-background", BLUE_BODY_SELF,
-                     "pixels-above-lines", 4,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-other");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "paragraph-background", BLUE_HEAD_OTHER,
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "pixels-above-lines", 2,
-                     "pixels-below-lines", 2,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-header-other-avatar");
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-avatar-other");
-       g_object_set (tag,
-                     "paragraph-background", BLUE_HEAD_OTHER,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-top-other");
-       g_object_set (tag,
-                     "size", 1,
-                     "paragraph-background", BLUE_LINE_OTHER,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-line-bottom-other");
-       g_object_set (tag,
-                     "size", 1,
-                     "paragraph-background", BLUE_LINE_OTHER,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-body-other");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "paragraph-background", BLUE_BODY_OTHER,
-                     "pixels-above-lines", 4,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-action-other");
-       g_object_set (tag,
-                     "foreground", "brown4",
-                     "style", PANGO_STYLE_ITALIC,
-                     "paragraph-background", BLUE_BODY_OTHER,
-                     "pixels-above-lines", 4,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-highlight-other");
-       g_object_set (tag,
-                     "foreground", "black",
-                     "weight", PANGO_WEIGHT_BOLD,
-                     "paragraph-background", BLUE_BODY_OTHER,
-                     "pixels-above-lines", 4,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-time");
-       g_object_set (tag,
-                     "foreground", "darkgrey",
-                     "justification", GTK_JUSTIFY_CENTER,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-event");
-       g_object_set (tag,
-                     "foreground", BLUE_LINE_OTHER,
-                     "justification", GTK_JUSTIFY_LEFT,
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-invite");
-       g_object_set (tag,
-                     "foreground", "sienna",
-                     NULL);
-       theme_manager_add_tag (table, tag);
-
-       tag = theme_manager_init_tag_by_name (table, "fancy-link");
-       g_object_set (tag,
-                     "foreground", "#49789e",
-                     "underline", PANGO_UNDERLINE_SINGLE,
-                     NULL);
-       theme_manager_add_tag (table, tag);
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       signals[THEME_CHANGED] =
+               g_signal_new ("theme-changed",
+                             G_OBJECT_CLASS_TYPE (object_class),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__VOID,
+                             G_TYPE_NONE,
+                             0);
+
+       g_type_class_add_private (object_class, sizeof (EmpathyThemeManagerPriv));
+
+       object_class->finalize = theme_manager_finalize;
 }
 
 static void
-theme_manager_apply_theme (EmpathyThemeManager *manager,
-                          EmpathyChatView     *view,
-                          const gchar        *name)
+empathy_theme_manager_init (EmpathyThemeManager *manager)
 {
-       EmpathyThemeManagerPriv *priv;
-       gint                    margin;
-
-       priv = GET_PRIV (manager);
+       EmpathyThemeManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
+               EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManagerPriv);
 
-       /* Make sure all tags are present. Note: not useful now but when we have
-        * user defined theme it will be.
-        */
-       theme_manager_fixup_tag_table (manager, view);
-
-       if (theme_manager_ensure_theme_exists (name)) {
-               if (strcmp (name, "clean") == 0) {
-                       theme_manager_apply_theme_clean (manager, view);
-                       margin = 3;
-               }
-               else if (strcmp (name, "simple") == 0) {
-                       theme_manager_apply_theme_simple (manager, view);
-                       margin = 3;
-               }
-               else if (strcmp (name, "blue") == 0) {
-                       theme_manager_apply_theme_blue (manager, view);
-                       margin = 0;
-               } else {
-                       theme_manager_apply_theme_classic (manager, view);
-                       margin = 3;
-               }
-       } else {
-               theme_manager_apply_theme_classic (manager, view);
-               margin = 3;
-       }
+       manager->priv = priv;
 
-       empathy_chat_view_set_margin (view, margin);
-       empathy_chat_view_set_irc_style (view, priv->irc_style);
+       /* Take the theme name and track changes */
+       priv->name_notify_id =
+               empathy_conf_notify_add (empathy_conf_get (),
+                                        EMPATHY_PREFS_CHAT_THEME,
+                                        theme_manager_notify_name_cb,
+                                        manager);
+       theme_manager_notify_name_cb (empathy_conf_get (),
+                                     EMPATHY_PREFS_CHAT_THEME,
+                                     manager);
+
+       /* Track GTK color changes */
+       priv->settings = gtk_settings_get_default ();
+       g_signal_connect_swapped (priv->settings, "notify::color-hash",
+                                 G_CALLBACK (theme_manager_color_hash_notify_cb),
+                                 manager);
 }
 
 EmpathyThemeManager *
@@ -956,90 +485,3 @@ empathy_theme_manager_get_themes (void)
        return themes;
 }
 
-void
-empathy_theme_manager_apply (EmpathyThemeManager *manager,
-                           EmpathyChatView     *view,
-                           const gchar        *name)
-{
-       EmpathyThemeManagerPriv *priv;
-
-       priv = GET_PRIV (manager);
-
-       theme_manager_apply_theme (manager, view, name);
-}
-
-void
-empathy_theme_manager_apply_saved (EmpathyThemeManager *manager,
-                                 EmpathyChatView     *view)
-{
-       EmpathyThemeManagerPriv *priv;
-
-       priv = GET_PRIV (manager);
-
-       theme_manager_apply_theme (manager, view, priv->name);
-}
-
-/* FIXME: A bit ugly. We should probably change the scheme so that instead of
- * the manager signalling, views are registered and applied to automatically.
- */
-void
-empathy_theme_manager_update_show_avatars (EmpathyThemeManager *manager,
-                                         EmpathyChatView     *view,
-                                         gboolean            show)
-{
-       EmpathyThemeManagerPriv *priv;
-       GtkTextBuffer          *buffer;
-       GtkTextTagTable        *table;
-       GtkTextTag             *tag_text_self, *tag_text_other;
-       GtkTextTag             *tag_image_self, *tag_image_other;
-
-       priv = GET_PRIV (manager);
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-       table = gtk_text_buffer_get_tag_table (buffer);
-
-       tag_text_self = gtk_text_tag_table_lookup (table, "fancy-header-self-avatar");
-       tag_text_other = gtk_text_tag_table_lookup (table, "fancy-header-other-avatar");
-
-       tag_image_self = gtk_text_tag_table_lookup (table, "fancy-avatar-self");
-       tag_image_other = gtk_text_tag_table_lookup (table, "fancy-avatar-other");
-
-       if (!show) {
-               g_object_set (tag_text_self,
-                             "rise", 0,
-                             NULL);
-               g_object_set (tag_text_other,
-                             "rise", 0,
-                             NULL);
-               g_object_set (tag_image_self,
-                             "invisible", TRUE,
-                             NULL);
-               g_object_set (tag_image_other,
-                             "invisible", TRUE,
-                             NULL);
-       } else {
-               GtkTextAttributes *attrs;
-               gint               size;
-               gint               rise;
-
-               attrs = gtk_text_view_get_default_attributes (GTK_TEXT_VIEW (view));
-               size = pango_font_description_get_size (attrs->font);
-               rise = MAX (0, (32 * PANGO_SCALE - size) / 2.0);
-
-               g_object_set (tag_text_self,
-                             "rise", rise,
-                             NULL);
-               g_object_set (tag_text_other,
-                             "rise", rise,
-                             NULL);
-               g_object_set (tag_image_self,
-                             "invisible", FALSE,
-                             NULL);
-               g_object_set (tag_image_other,
-                             "invisible", FALSE,
-                             NULL);
-
-               gtk_text_attributes_unref (attrs);
-       }
-}
-