]> git.0d.be Git - empathy.git/blobdiff - src/empathy-preferences.c
Remove obsolete contact-list-{store,view}
[empathy.git] / src / empathy-preferences.c
index 813637dca9de3bd1b16eafbd2e9450a3732742f2..6775d4a245bb5f7c88a00e3a5cfe9c3abd57c6ee 100644 (file)
 #include <libempathy-gtk/empathy-ui-utils.h>
 #include <libempathy-gtk/empathy-theme-manager.h>
 #include <libempathy-gtk/empathy-spell.h>
-#include <libempathy-gtk/empathy-contact-list-store.h>
 #include <libempathy-gtk/empathy-gtk-enum-types.h>
-
-#ifdef HAVE_WEBKIT
 #include <libempathy-gtk/empathy-theme-adium.h>
-#endif
 
 #include "empathy-preferences.h"
 
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
+
 G_DEFINE_TYPE (EmpathyPreferences, empathy_preferences, GTK_TYPE_DIALOG);
 
 #define GET_PRIV(self) ((EmpathyPreferencesPriv *)((EmpathyPreferences *) self)->priv)
 
+static const gchar * empathy_preferences_tabs[] =
+{
+  "general",
+  "notifications",
+  "sounds",
+  "calls",
+  "location",
+  "spell",
+  "themes",
+};
+
 struct _EmpathyPreferencesPriv {
        GtkWidget *notebook;
 
        GtkWidget *checkbutton_show_smileys;
        GtkWidget *checkbutton_show_contacts_in_rooms;
-       GtkWidget *combobox_chat_theme;
        GtkWidget *checkbutton_separate_chat_windows;
        GtkWidget *checkbutton_events_notif_area;
        GtkWidget *checkbutton_autoconnect;
@@ -73,6 +82,8 @@ struct _EmpathyPreferencesPriv {
        GtkWidget *checkbutton_notifications_contact_signin;
        GtkWidget *checkbutton_notifications_contact_signout;
 
+       GtkWidget *echo_cancellation;
+
        GtkWidget *treeview_spell_checker;
 
        GtkWidget *checkbutton_location_publish;
@@ -81,8 +92,17 @@ struct _EmpathyPreferencesPriv {
        GtkWidget *checkbutton_location_resource_cell;
        GtkWidget *checkbutton_location_resource_gps;
 
+       GtkWidget *vbox_chat_theme;
+       GtkWidget *combobox_chat_theme;
+       GtkWidget *combobox_chat_theme_variant;
+       GtkWidget *hbox_chat_theme_variant;
+       GtkWidget *sw_chat_theme_preview;
+       EmpathyChatView *chat_theme_preview;
+       EmpathyThemeManager *theme_manager;
+
        GSettings *gsettings;
        GSettings *gsettings_chat;
+       GSettings *gsettings_call;
        GSettings *gsettings_loc;
        GSettings *gsettings_notify;
        GSettings *gsettings_sound;
@@ -115,11 +135,18 @@ enum {
 };
 
 enum {
-       COL_COMBO_IS_ADIUM,
-       COL_COMBO_VISIBLE_NAME,
-       COL_COMBO_NAME,
-       COL_COMBO_PATH,
-       COL_COMBO_COUNT
+       COL_THEME_VISIBLE_NAME,
+       COL_THEME_NAME,
+       COL_THEME_IS_ADIUM,
+       COL_THEME_ADIUM_PATH,
+       COL_THEME_ADIUM_INFO,
+       COL_THEME_COUNT
+};
+
+enum {
+       COL_VARIANT_NAME,
+       COL_VARIANT_DEFAULT,
+       COL_VARIANT_COUNT
 };
 
 enum {
@@ -242,6 +269,12 @@ preferences_setup_widgets (EmpathyPreferences *preferences)
                         "active",
                         G_SETTINGS_BIND_DEFAULT);
 
+       g_settings_bind (priv->gsettings_call,
+                        EMPATHY_PREFS_CALL_ECHO_CANCELLATION,
+                        priv->echo_cancellation,
+                        "active",
+                        G_SETTINGS_BIND_DEFAULT);
+
        g_settings_bind (priv->gsettings,
                         EMPATHY_PREFS_AUTOCONNECT,
                         priv->checkbutton_autoconnect,
@@ -312,7 +345,7 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
 {
        EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
        GtkTreePath *path;
-       gboolean toggled, instore;
+       gboolean instore;
        GtkTreeIter iter;
        GtkTreeView *view;
        GtkTreeModel *model;
@@ -322,7 +355,6 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
        model = gtk_tree_view_get_model (view);
 
        path = gtk_tree_path_new_from_string (path_string);
-       toggled = gtk_cell_renderer_toggle_get_active (toggle);
 
        gtk_tree_model_get_iter (model, &iter, path);
        gtk_tree_model_get (model, &iter, COL_SOUND_KEY, &key,
@@ -411,7 +443,6 @@ preferences_languages_setup (EmpathyPreferences *preferences)
        GtkTreeView       *view;
        GtkListStore      *store;
        GtkTreeSelection  *selection;
-       GtkTreeModel      *model;
        GtkTreeViewColumn *column;
        GtkCellRenderer   *renderer;
        guint              col_offset;
@@ -428,8 +459,6 @@ preferences_languages_setup (EmpathyPreferences *preferences)
        selection = gtk_tree_view_get_selection (view);
        gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
 
-       model = GTK_TREE_MODEL (store);
-
        renderer = gtk_cell_renderer_toggle_new ();
        g_signal_connect (renderer, "toggled",
                          G_CALLBACK (preferences_languages_cell_toggled_cb),
@@ -646,61 +675,243 @@ preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
 }
 
 static void
-preferences_theme_notify_cb (GSettings   *gsettings,
-                            const gchar *key,
-                            gpointer     user_data)
+preferences_preview_theme_append_message (EmpathyChatView *view,
+                                         EmpathyContact *sender,
+                                         EmpathyContact *receiver,
+                                         const gchar *text)
+{
+       EmpathyMessage *message;
+
+       message = g_object_new (EMPATHY_TYPE_MESSAGE,
+               "sender", sender,
+               "receiver", receiver,
+               "body", text,
+               NULL);
+
+       empathy_chat_view_append_message (view, message);
+       g_object_unref (message);
+}
+
+static void
+preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
+                                     EmpathyPreferences  *preferences)
+{
+       EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+       TpDBusDaemon *dbus;
+       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 */
+       dbus = tp_dbus_daemon_dup (NULL);
+       account = tp_account_new (dbus,
+               TP_ACCOUNT_OBJECT_PATH_BASE "cm/jabber/account", 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?"));
+       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;"));
+       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"));
+       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."));
+       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?"));
+
+       /* translators: Quote from Romeo & Julier, for chat theme preview */
+       empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected"));
+
+       g_object_unref (juliet);
+       g_object_unref (romeo);
+       g_object_unref (account);
+       g_object_unref (dbus);
+}
+
+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)
 {
        EmpathyPreferences *preferences = user_data;
        EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
        GtkComboBox        *combo;
        gchar              *conf_name;
-       gchar              *conf_path;
        GtkTreeModel       *model;
        GtkTreeIter         iter;
+       GtkTreeIter         default_iter;
+       gboolean            found_default = FALSE;
        gboolean            found = FALSE;
+       gboolean            ok;
 
-       conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME);
-       conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);
-
-       combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
+       conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME_VARIANT);
+       combo = GTK_COMBO_BOX (priv->combobox_chat_theme_variant);
        model = gtk_combo_box_get_model (combo);
-       if (gtk_tree_model_get_iter_first (model, &iter)) {
-               gboolean is_adium;
+
+       for (ok = gtk_tree_model_get_iter_first (model, &iter);
+            ok && !found;
+            ok = gtk_tree_model_iter_next (model, &iter)) {
                gchar *name;
-               gchar *path;
+               gboolean is_default;
+
+               gtk_tree_model_get (model, &iter,
+                                   COL_VARIANT_NAME, &name,
+                                   COL_VARIANT_DEFAULT, &is_default,
+                                   -1);
+
+               if (!tp_strdiff (name, conf_name)) {
+                       found = TRUE;
+                       gtk_combo_box_set_active_iter (combo, &iter);
+               }
+               if (is_default) {
+                       found_default = TRUE;
+                       default_iter = iter;
+               }
 
-               do {
-                       gtk_tree_model_get (model, &iter,
-                                           COL_COMBO_IS_ADIUM, &is_adium,
-                                           COL_COMBO_NAME, &name,
-                                           COL_COMBO_PATH, &path,
-                                           -1);
-
-                       if (!tp_strdiff (name, conf_name)) {
-                               if (tp_strdiff (name, "adium") ||
-                                   !tp_strdiff (path, conf_path)) {
-                                       found = TRUE;
-                                       gtk_combo_box_set_active_iter (combo, &iter);
-                                       g_free (name);
-                                       g_free (path);
-                                       break;
-                               }
-                       }
-
-                       g_free (name);
-                       g_free (path);
-               } while (gtk_tree_model_iter_next (model, &iter));
+               g_free (name);
        }
 
        /* Fallback to the first one. */
        if (!found) {
-               if (gtk_tree_model_get_iter_first (model, &iter)) {
+               if (found_default) {
+                       gtk_combo_box_set_active_iter (combo, &default_iter);
+               } else if (gtk_tree_model_get_iter_first (model, &iter)) {
                        gtk_combo_box_set_active_iter (combo, &iter);
                }
        }
 
        g_free (conf_name);
-       g_free (conf_path);
+}
+
+/* return TRUE if we added at least one variant */
+static gboolean
+preferences_theme_variants_fill (EmpathyPreferences *preferences,
+                                GHashTable         *info)
+{
+       EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+       GtkTreeModel *model;
+       GtkListStore *store;
+       GPtrArray    *variants;
+       const gchar  *default_variant;
+       guint         i;
+       gboolean      result = FALSE;
+
+       model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->combobox_chat_theme_variant));
+       store = GTK_LIST_STORE (model);
+       gtk_list_store_clear (store);
+
+       variants = empathy_adium_info_get_available_variants (info);
+       default_variant = empathy_adium_info_get_default_variant (info);
+       for (i = 0; i < variants->len; i++) {
+               gchar *name = g_ptr_array_index (variants, i);
+
+               gtk_list_store_insert_with_values (store, NULL, -1,
+                       COL_VARIANT_NAME, name,
+                       COL_VARIANT_DEFAULT, !tp_strdiff (name, default_variant),
+                       -1);
+
+               result = TRUE;
+       }
+
+       /* Select the variant from the GSetting key */
+       preferences_theme_variant_notify_cb (priv->gsettings_chat,
+                                            EMPATHY_PREFS_CHAT_THEME_VARIANT,
+                                            preferences);
+
+       return result;
+}
+
+static void
+preferences_theme_variants_setup (EmpathyPreferences *preferences)
+{
+       EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+       GtkComboBox   *combo;
+       GtkCellLayout *cell_layout;
+       GtkCellRenderer *renderer;
+       GtkListStore  *store;
+
+       combo = GTK_COMBO_BOX (priv->combobox_chat_theme_variant);
+       cell_layout = GTK_CELL_LAYOUT (combo);
+
+       /* Create the model */
+       store = gtk_list_store_new (COL_VARIANT_COUNT,
+                                   G_TYPE_STRING,      /* name */
+                                   G_TYPE_BOOLEAN);    /* is default */
+       gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+               COL_VARIANT_NAME, GTK_SORT_ASCENDING);
+
+       /* Add cell renderer */
+       renderer = gtk_cell_renderer_text_new ();
+       gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
+       gtk_cell_layout_set_attributes (cell_layout, renderer,
+               "text", COL_VARIANT_NAME, NULL);
+
+       gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
+       g_object_unref (store);
+
+       g_signal_connect (combo, "changed",
+                         G_CALLBACK (preferences_theme_variant_changed_cb),
+                         preferences);
+
+       /* Track changes of the GSetting key */
+       g_signal_connect (priv->gsettings_chat,
+                         "changed::" EMPATHY_PREFS_CHAT_THEME_VARIANT,
+                         G_CALLBACK (preferences_theme_variant_notify_cb),
+                         preferences);
 }
 
 static void
@@ -708,31 +919,96 @@ preferences_theme_changed_cb (GtkComboBox        *combo,
                              EmpathyPreferences *preferences)
 {
        EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
-       GtkTreeModel *model;
        GtkTreeIter   iter;
-       gboolean      is_adium;
-       gchar        *name;
-       gchar        *path;
 
        if (gtk_combo_box_get_active_iter (combo, &iter)) {
-               model = gtk_combo_box_get_model (combo);
+               GtkTreeModel *model;
+               gboolean      is_adium;
+               gchar        *name;
+               gchar        *path;
+               GHashTable   *info;
 
+               model = gtk_combo_box_get_model (combo);
                gtk_tree_model_get (model, &iter,
-                                   COL_COMBO_IS_ADIUM, &is_adium,
-                                   COL_COMBO_NAME, &name,
-                                   COL_COMBO_PATH, &path,
+                                   COL_THEME_IS_ADIUM, &is_adium,
+                                   COL_THEME_NAME, &name,
+                                   COL_THEME_ADIUM_PATH, &path,
+                                   COL_THEME_ADIUM_INFO, &info,
                                    -1);
 
                g_settings_set_string (priv->gsettings_chat,
                                       EMPATHY_PREFS_CHAT_THEME,
                                       name);
-               if (is_adium == TRUE)
+               if (is_adium) {
+                       gboolean variant;
+
                        g_settings_set_string (priv->gsettings_chat,
                                               EMPATHY_PREFS_CHAT_ADIUM_PATH,
                                               path);
+
+                       variant = preferences_theme_variants_fill (preferences, info);
+                       gtk_widget_set_visible (priv->hbox_chat_theme_variant, variant);
+               } else {
+                       gtk_widget_hide (priv->hbox_chat_theme_variant);
+               }
+               g_free (name);
+               g_free (path);
+               tp_clear_pointer (&info, g_hash_table_unref);
+       }
+}
+
+static void
+preferences_theme_notify_cb (GSettings   *gsettings,
+                            const gchar *key,
+                            gpointer     user_data)
+{
+       EmpathyPreferences *preferences = user_data;
+       EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
+       GtkComboBox        *combo;
+       gchar              *conf_name;
+       gchar              *conf_path;
+       GtkTreeModel       *model;
+       GtkTreeIter         iter;
+       gboolean            found = FALSE;
+       gboolean            ok;
+
+       conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME);
+       conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);
+
+       combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
+       model = gtk_combo_box_get_model (combo);
+       for (ok = gtk_tree_model_get_iter_first (model, &iter);
+            ok && !found;
+            ok = gtk_tree_model_iter_next (model, &iter)) {
+               gboolean is_adium;
+               gchar *name;
+               gchar *path;
+
+               gtk_tree_model_get (model, &iter,
+                                   COL_THEME_IS_ADIUM, &is_adium,
+                                   COL_THEME_NAME, &name,
+                                   COL_THEME_ADIUM_PATH, &path,
+                                   -1);
+
+               if (!tp_strdiff (name, conf_name) &&
+                   (!is_adium || !tp_strdiff (path, conf_path))) {
+                       found = TRUE;
+                       gtk_combo_box_set_active_iter (combo, &iter);
+               }
+
                g_free (name);
                g_free (path);
        }
+
+       /* Fallback to the first one. */
+       if (!found) {
+               if (gtk_tree_model_get_iter_first (model, &iter)) {
+                       gtk_combo_box_set_active_iter (combo, &iter);
+               }
+       }
+
+       g_free (conf_name);
+       g_free (conf_path);
 }
 
 static void
@@ -747,26 +1023,28 @@ preferences_themes_setup (EmpathyPreferences *preferences)
        GList         *adium_themes;
        gint           i;
 
+       preferences_theme_variants_setup (preferences);
+
        combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
        cell_layout = GTK_CELL_LAYOUT (combo);
 
        /* Create the model */
-       store = gtk_list_store_new (COL_COMBO_COUNT,
-                                   G_TYPE_BOOLEAN, /* Is an Adium theme */
-                                   G_TYPE_STRING,  /* Display name */
-                                   G_TYPE_STRING,  /* Theme name */
-                                   G_TYPE_STRING); /* Theme path */
+       store = gtk_list_store_new (COL_THEME_COUNT,
+                                   G_TYPE_STRING,      /* Display name */
+                                   G_TYPE_STRING,      /* Theme name */
+                                   G_TYPE_BOOLEAN,     /* Is an Adium theme */
+                                   G_TYPE_STRING,      /* Adium theme path */
+                                   G_TYPE_HASH_TABLE); /* Adium theme info */
        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
-               COL_COMBO_VISIBLE_NAME, GTK_SORT_ASCENDING);
+               COL_THEME_VISIBLE_NAME, GTK_SORT_ASCENDING);
 
        /* Fill the model */
        themes = empathy_theme_manager_get_themes ();
        for (i = 0; themes[i]; i += 2) {
                gtk_list_store_insert_with_values (store, NULL, -1,
-                       COL_COMBO_IS_ADIUM, FALSE,
-                       COL_COMBO_VISIBLE_NAME, _(themes[i + 1]),
-                       COL_COMBO_NAME, themes[i],
-                       COL_COMBO_PATH, NULL,
+                       COL_THEME_VISIBLE_NAME, _(themes[i + 1]),
+                       COL_THEME_NAME, themes[i],
+                       COL_THEME_IS_ADIUM, FALSE,
                        -1);
        }
 
@@ -782,10 +1060,11 @@ preferences_themes_setup (EmpathyPreferences *preferences)
 
                if (name != NULL && path != NULL) {
                        gtk_list_store_insert_with_values (store, NULL, -1,
-                               COL_COMBO_IS_ADIUM, TRUE,
-                               COL_COMBO_VISIBLE_NAME, name,
-                               COL_COMBO_NAME, "adium",
-                               COL_COMBO_PATH, path,
+                               COL_THEME_VISIBLE_NAME, name,
+                               COL_THEME_NAME, "adium",
+                               COL_THEME_IS_ADIUM, TRUE,
+                               COL_THEME_ADIUM_PATH, path,
+                               COL_THEME_ADIUM_INFO, info,
                                -1);
                }
                g_hash_table_unref (info);
@@ -796,7 +1075,7 @@ preferences_themes_setup (EmpathyPreferences *preferences)
        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
        gtk_cell_layout_set_attributes (cell_layout, renderer,
-               "text", COL_COMBO_VISIBLE_NAME, NULL);
+               "text", COL_THEME_VISIBLE_NAME, NULL);
 
        gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
        g_object_unref (store);
@@ -832,8 +1111,11 @@ empathy_preferences_finalize (GObject *self)
 {
        EmpathyPreferencesPriv *priv = GET_PRIV (self);
 
+       g_object_unref (priv->theme_manager);
+
        g_object_unref (priv->gsettings);
        g_object_unref (priv->gsettings_chat);
+       g_object_unref (priv->gsettings_call);
        g_object_unref (priv->gsettings_loc);
        g_object_unref (priv->gsettings_notify);
        g_object_unref (priv->gsettings_sound);
@@ -883,7 +1165,11 @@ empathy_preferences_init (EmpathyPreferences *preferences)
                "notebook", &priv->notebook,
                "checkbutton_show_smileys", &priv->checkbutton_show_smileys,
                "checkbutton_show_contacts_in_rooms", &priv->checkbutton_show_contacts_in_rooms,
+               "vbox_chat_theme", &priv->vbox_chat_theme,
                "combobox_chat_theme", &priv->combobox_chat_theme,
+               "combobox_chat_theme_variant", &priv->combobox_chat_theme_variant,
+               "hbox_chat_theme_variant", &priv->hbox_chat_theme_variant,
+               "sw_chat_theme_preview", &priv->sw_chat_theme_preview,
                "checkbutton_separate_chat_windows", &priv->checkbutton_separate_chat_windows,
                "checkbutton_events_notif_area", &priv->checkbutton_events_notif_area,
                "checkbutton_autoconnect", &priv->checkbutton_autoconnect,
@@ -902,6 +1188,7 @@ empathy_preferences_init (EmpathyPreferences *preferences)
                "checkbutton_location_resource_network", &priv->checkbutton_location_resource_network,
                "checkbutton_location_resource_cell", &priv->checkbutton_location_resource_cell,
                "checkbutton_location_resource_gps", &priv->checkbutton_location_resource_gps,
+               "call_echo_cancellation", &priv->echo_cancellation,
                NULL);
        g_free (filename);
 
@@ -912,12 +1199,20 @@ empathy_preferences_init (EmpathyPreferences *preferences)
 
        priv->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
        priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+       priv->gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
        priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
        priv->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
        priv->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
        priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
        priv->gsettings_logger = g_settings_new (EMPATHY_PREFS_LOGGER_SCHEMA);
 
+       /* Create chat theme preview, and track changes */
+       priv->theme_manager = empathy_theme_manager_dup_singleton ();
+       tp_g_signal_connect_object (priv->theme_manager, "theme-changed",
+                         G_CALLBACK (preferences_preview_theme_changed_cb),
+                         preferences, 0);
+       preferences_preview_theme_changed_cb (priv->theme_manager, preferences);
+
        preferences_themes_setup (preferences);
 
        preferences_setup_widgets (preferences);
@@ -930,11 +1225,11 @@ empathy_preferences_init (EmpathyPreferences *preferences)
        preferences_sound_load (preferences);
 
        if (empathy_spell_supported ()) {
-               page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 2);
+               page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_SPELL);
                gtk_widget_show (page);
        }
 
-       page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 3);
+       page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_LOCATION);
 #ifdef HAVE_GEOCLUE
        gtk_widget_show (page);
 #else
@@ -942,10 +1237,36 @@ empathy_preferences_init (EmpathyPreferences *preferences)
 #endif
 }
 
+static EmpathyPreferencesTab
+empathy_preferences_tab_from_string (const gchar *str)
+{
+  guint i;
+
+  for (i = 0; i < G_N_ELEMENTS (empathy_preferences_tabs); i++)
+    {
+      if (!tp_strdiff (str, empathy_preferences_tabs[i]))
+        return i;
+    }
+
+  g_warn_if_reached ();
+  return -1;
+}
+
+const gchar *
+empathy_preferences_tab_to_string (EmpathyPreferencesTab tab)
+{
+  g_return_val_if_fail (tab < G_N_ELEMENTS (empathy_preferences_tabs), NULL);
+
+  return empathy_preferences_tabs[tab];
+}
+
 GtkWidget *
-empathy_preferences_new (GtkWindow *parent)
+empathy_preferences_new (GtkWindow *parent,
+                         gboolean  shell_running)
 {
-       GtkWidget *self;
+       GtkWidget              *self;
+       EmpathyPreferencesPriv *priv;
+       GtkWidget              *notif_page;
 
        g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
 
@@ -956,5 +1277,28 @@ empathy_preferences_new (GtkWindow *parent)
                                              parent);
        }
 
+       /* when running in Gnome Shell we must hide these options since they
+        * are meaningless in that context:
+        * - 'Display incoming events in the notification area' (General->Behavior)
+        * - 'Notifications' tab
+        */
+       priv = GET_PRIV (self);
+       if (shell_running) {
+               gtk_widget_hide (priv->checkbutton_events_notif_area);
+               notif_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook),
+                                                       EMPATHY_PREFERENCES_TAB_NOTIFICATIONS);
+               gtk_widget_hide (notif_page);
+       }
+
        return self;
 }
+
+void
+empathy_preferences_show_tab (EmpathyPreferences *self,
+                             const gchar *page)
+{
+       EmpathyPreferencesPriv *priv = GET_PRIV (self);
+
+       gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
+                                      empathy_preferences_tab_from_string (page));
+}