]> git.0d.be Git - empathy.git/blobdiff - src/empathy-preferences.c
GNOME Goal: Update icon names
[empathy.git] / src / empathy-preferences.c
index 4b3e0766f4c7b249e3efedada5040d076a75ae66..6901aa9c8b88e366ed27b78d925306df0a6dbec8 100644 (file)
  *          Danielle Madeley <danielle.madeley@collabora.co.uk>
  */
 
-#include <config.h>
-
-#include <string.h>
-#include <stdio.h>
+#include "config.h"
+#include "empathy-preferences.h"
 
-#include <gtk/gtk.h>
 #include <glib/gi18n.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/util.h>
-
-#include <libempathy/empathy-gsettings.h>
-#include <libempathy/empathy-utils.h>
-
-#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"
+#include "empathy-client-factory.h"
+#include "empathy-gsettings.h"
+#include "empathy-spell.h"
+#include "empathy-theme-manager.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
+#include "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 *checkbutton_separate_chat_windows;
        GtkWidget *checkbutton_events_notif_area;
-       GtkWidget *checkbutton_autoconnect;
-       GtkWidget *checkbutton_logging;
 
-       GtkWidget *checkbutton_sounds_enabled;
-       GtkWidget *checkbutton_sounds_disabled_away;
        GtkWidget *treeview_sounds;
-
-       GtkWidget *checkbutton_notifications_enabled;
-       GtkWidget *checkbutton_notifications_disabled_away;
-       GtkWidget *checkbutton_notifications_focus;
-       GtkWidget *checkbutton_notifications_contact_signin;
-       GtkWidget *checkbutton_notifications_contact_signout;
-
-       GtkWidget *scale_call_volume;
-       GtkWidget *adj_call_volume;
-
        GtkWidget *treeview_spell_checker;
 
-       GtkWidget *checkbutton_location_publish;
-       GtkWidget *checkbutton_location_reduce_accuracy;
-       GtkWidget *checkbutton_location_resource_network;
-       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;
+       EmpathyThemeAdium *chat_theme_preview;
        EmpathyThemeManager *theme_manager;
 
        GSettings *gsettings;
@@ -104,7 +79,8 @@ struct _EmpathyPreferencesPriv {
        GSettings *gsettings_logger;
 };
 
-static void     preferences_setup_widgets                (EmpathyPreferences      *preferences);
+static void     preferences_setup_widgets                (EmpathyPreferences      *preferences,
+                                                         GtkBuilder              *gui);
 static void     preferences_languages_setup              (EmpathyPreferences      *preferences);
 static void     preferences_languages_add                (EmpathyPreferences      *preferences);
 static void     preferences_languages_save               (EmpathyPreferences      *preferences);
@@ -130,9 +106,7 @@ enum {
 
 enum {
        COL_THEME_VISIBLE_NAME,
-       COL_THEME_NAME,
-       COL_THEME_IS_ADIUM,
-       COL_THEME_ADIUM_PATH,
+       COL_THEME_ADIUM_NAME,
        COL_THEME_ADIUM_INFO,
        COL_THEME_COUNT
 };
@@ -160,174 +134,108 @@ static SoundEventEntry sound_entries [] = {
        { N_("Message received"), EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE },
        { N_("Message sent"), EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE },
        { N_("New conversation"), EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION },
-       { N_("Contact goes online"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN },
+       { N_("Contact comes online"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN },
        { N_("Contact goes offline"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT },
        { N_("Account connected"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN },
        { N_("Account disconnected"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT }
 };
 
 static void
-preferences_setup_widgets (EmpathyPreferences *preferences)
+preferences_setup_widgets (EmpathyPreferences *preferences,
+                          GtkBuilder *gui)
 {
        EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
-
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
-                        priv->checkbutton_notifications_enabled,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
-                        priv->checkbutton_notifications_disabled_away,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_FOCUS,
-                        priv->checkbutton_notifications_focus,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN,
-                        priv->checkbutton_notifications_contact_signin,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT,
-                        priv->checkbutton_notifications_contact_signout,
-                        "active",
+#define BIND_ACTIVE(schema, key, widget) \
+       g_settings_bind (priv->gsettings_##schema, EMPATHY_PREFS_##key, \
+                        gtk_builder_get_object (gui, widget), "active", \
                         G_SETTINGS_BIND_DEFAULT);
 
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
-                        priv->checkbutton_notifications_disabled_away,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
-                        priv->checkbutton_notifications_focus,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
-                        priv->checkbutton_notifications_contact_signin,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-       g_settings_bind (priv->gsettings_notify,
-                        EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
-                        priv->checkbutton_notifications_contact_signout,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-
-       g_settings_bind (priv->gsettings_sound,
-                        EMPATHY_PREFS_SOUNDS_ENABLED,
-                        priv->checkbutton_sounds_enabled,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_sound,
-                        EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
-                        priv->checkbutton_sounds_disabled_away,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-
-       g_settings_bind (priv->gsettings_sound,
-                        EMPATHY_PREFS_SOUNDS_ENABLED,
-                        priv->checkbutton_sounds_disabled_away,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-       g_settings_bind (priv->gsettings_sound,
-                       EMPATHY_PREFS_SOUNDS_ENABLED,
-                       priv->treeview_sounds,
-                       "sensitive",
+       BIND_ACTIVE (notify, NOTIFICATIONS_ENABLED,
+                    "checkbutton_notifications_enabled");
+       BIND_ACTIVE (notify, NOTIFICATIONS_DISABLED_AWAY,
+                    "checkbutton_notifications_disabled_away");
+       BIND_ACTIVE (notify, NOTIFICATIONS_FOCUS,
+                    "checkbutton_notifications_focus");
+       BIND_ACTIVE (notify, NOTIFICATIONS_CONTACT_SIGNIN,
+                    "checkbutton_notifications_contact_signin");
+       BIND_ACTIVE (notify, NOTIFICATIONS_CONTACT_SIGNOUT,
+                    "checkbutton_notifications_contact_signout");
+
+       BIND_ACTIVE (sound, SOUNDS_ENABLED,
+                    "checkbutton_sounds_enabled");
+       BIND_ACTIVE (sound, SOUNDS_DISABLED_AWAY,
+                    "checkbutton_sounds_disabled_away");
+
+       BIND_ACTIVE (ui, UI_SHOW_OFFLINE,
+                    "checkbutton_show_offline");
+       BIND_ACTIVE (ui, UI_SHOW_GROUPS,
+                    "checkbutton_show_groups");
+       BIND_ACTIVE (ui, UI_SEPARATE_CHAT_WINDOWS,
+                    "radiobutton_chats_new_windows");
+       BIND_ACTIVE (ui, UI_EVENTS_NOTIFY_AREA,
+                    "checkbutton_events_notif_area");
+       BIND_ACTIVE (ui, UI_SHOW_BALANCES,
+                    "checkbutton_show_balances");
+
+       BIND_ACTIVE (chat, CHAT_SHOW_SMILEYS,
+                    "checkbutton_show_smileys");
+       BIND_ACTIVE (chat, CHAT_SHOW_CONTACTS_IN_ROOMS,
+                    "checkbutton_show_contacts_in_rooms");
+
+       BIND_ACTIVE (call, CALL_ECHO_CANCELLATION,
+                    "call_echo_cancellation");
+
+       BIND_ACTIVE (loc, LOCATION_PUBLISH,
+                    "checkbutton_location_publish");
+       BIND_ACTIVE (loc, LOCATION_RESOURCE_NETWORK,
+                    "checkbutton_location_resource_network");
+       BIND_ACTIVE (loc, LOCATION_RESOURCE_CELL,
+                    "checkbutton_location_resource_cell");
+       BIND_ACTIVE (loc, LOCATION_RESOURCE_GPS,
+                    "checkbutton_location_resource_gps");
+       BIND_ACTIVE (loc, LOCATION_REDUCE_ACCURACY,
+                    "checkbutton_location_reduce_accuracy");
+
+       BIND_ACTIVE (logger, LOGGER_ENABLED,
+                    "checkbutton_logging");
+
+#undef BIND_ACTIVE
+
+#define BIND_SENSITIVE(schema, key, widget) \
+       g_settings_bind (priv->gsettings_##schema, EMPATHY_PREFS_##key, \
+                        gtk_builder_get_object (gui, widget), "sensitive", \
                        G_SETTINGS_BIND_GET);
-
-       g_settings_bind (priv->gsettings_ui,
-                        EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
-                        priv->checkbutton_separate_chat_windows,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-
-       g_settings_bind (priv->gsettings_ui,
-                        EMPATHY_PREFS_UI_EVENTS_NOTIFY_AREA,
-                        priv->checkbutton_events_notif_area,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-
-       g_settings_bind (priv->gsettings_chat,
-                        EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
-                        priv->checkbutton_show_smileys,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_chat,
-                        EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
-                        priv->checkbutton_show_contacts_in_rooms,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-
-       g_settings_bind (priv->gsettings_call,
-                        EMPATHY_PREFS_CALL_SOUND_VOLUME,
-                        priv->adj_call_volume,
-                        "value",
-                        G_SETTINGS_BIND_DEFAULT);
+       /* N.B. BIND_SENSITIVE() is in addition to the sensitivity setting of
+        *      BIND_ACTIVE() */
+       BIND_SENSITIVE (notify, NOTIFICATIONS_ENABLED,
+                       "checkbutton_notifications_disabled_away");
+       BIND_SENSITIVE (notify, NOTIFICATIONS_ENABLED,
+                       "checkbutton_notifications_focus");
+       BIND_SENSITIVE (notify, NOTIFICATIONS_ENABLED,
+                       "checkbutton_notifications_contact_signin");
+       BIND_SENSITIVE (notify, NOTIFICATIONS_ENABLED,
+                       "checkbutton_notifications_contact_signout");
+
+       BIND_SENSITIVE (sound, SOUNDS_ENABLED,
+                       "checkbutton_sounds_disabled_away");
+       BIND_SENSITIVE (sound, SOUNDS_ENABLED,
+                       "treeview_sounds");
+
+       BIND_SENSITIVE (loc, LOCATION_PUBLISH,
+                       "checkbutton_location_resource_network");
+       BIND_SENSITIVE (loc, LOCATION_PUBLISH,
+                       "checkbutton_location_resource_cell");
+       BIND_SENSITIVE (loc, LOCATION_PUBLISH,
+                       "checkbutton_location_resource_gps");
+       BIND_SENSITIVE (loc, LOCATION_PUBLISH,
+                       "checkbutton_location_reduce_accuracy");
+
+#undef BIND_SENSITIVE
 
        g_settings_bind (priv->gsettings,
                         EMPATHY_PREFS_AUTOCONNECT,
-                        priv->checkbutton_autoconnect,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_PUBLISH,
-                        priv->checkbutton_location_publish,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
-                        priv->checkbutton_location_resource_network,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_PUBLISH,
-                        priv->checkbutton_location_resource_network,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
-                        priv->checkbutton_location_resource_cell,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_PUBLISH,
-                        priv->checkbutton_location_resource_cell,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
-                        priv->checkbutton_location_resource_gps,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_PUBLISH,
-                        priv->checkbutton_location_resource_gps,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
-                        priv->checkbutton_location_reduce_accuracy,
-                        "active",
-                        G_SETTINGS_BIND_DEFAULT);
-       g_settings_bind (priv->gsettings_loc,
-                        EMPATHY_PREFS_LOCATION_PUBLISH,
-                        priv->checkbutton_location_reduce_accuracy,
-                        "sensitive",
-                        G_SETTINGS_BIND_GET);
-
-       g_settings_bind (priv->gsettings_logger,
-                        EMPATHY_PREFS_LOGGER_ENABLED,
-                        priv->checkbutton_logging,
+                        gtk_builder_get_object (gui,
+                                                "checkbutton_autoconnect"),
                         "active",
                         G_SETTINGS_BIND_DEFAULT);
 }
@@ -500,7 +408,6 @@ preferences_languages_add (EmpathyPreferences *preferences)
        }
 
        for (l = codes; l; l = l->next) {
-               GtkTreeIter  iter;
                const gchar *code;
                const gchar *name;
 
@@ -510,8 +417,7 @@ preferences_languages_add (EmpathyPreferences *preferences)
                        continue;
                }
 
-               gtk_list_store_append (store, &iter);
-               gtk_list_store_set (store, &iter,
+               gtk_list_store_insert_with_values (store, NULL, -1,
                                    COL_LANG_CODE, code,
                                    COL_LANG_NAME, name,
                                    -1);
@@ -669,10 +575,11 @@ preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
 }
 
 static void
-preferences_preview_theme_append_message (EmpathyChatView *view,
+preferences_preview_theme_append_message (EmpathyThemeAdium *view,
                                          EmpathyContact *sender,
                                          EmpathyContact *receiver,
-                                         const gchar *text)
+                                         const gchar *text,
+                                         gboolean should_highlight)
 {
        EmpathyMessage *message;
 
@@ -682,7 +589,7 @@ preferences_preview_theme_append_message (EmpathyChatView *view,
                "body", text,
                NULL);
 
-       empathy_chat_view_append_message (view, message);
+       empathy_theme_adium_append_message (view, message, should_highlight);
        g_object_unref (message);
 }
 
@@ -691,7 +598,7 @@ preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
                                      EmpathyPreferences  *preferences)
 {
        EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
-       TpDBusDaemon *dbus;
+       EmpathyClientFactory *factory;
        TpAccount *account;
        EmpathyContact *juliet;
        EmpathyContact *romeo;
@@ -709,9 +616,11 @@ preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
        /* 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);
+       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",
@@ -729,27 +638,28 @@ preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
 
        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?"));
+               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;"));
+               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"));
+               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."));
+               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?"));
+               romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE);
 
        /* translators: Quote from Romeo & Julier, for chat theme preview */
-       empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected"));
+       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 (dbus);
+       g_object_unref (factory);
 }
 
 static void
@@ -831,24 +741,23 @@ preferences_theme_variant_notify_cb (GSettings   *gsettings,
        g_free (conf_name);
 }
 
-static void
+/* 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;
-#ifdef HAVE_WEBKIT
        GPtrArray    *variants;
        const gchar  *default_variant;
        guint         i;
-#endif /* HAVE_WEBKIT */
+       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);
 
-#ifdef HAVE_WEBKIT
        variants = empathy_adium_info_get_available_variants (info);
        default_variant = empathy_adium_info_get_default_variant (info);
        for (i = 0; i < variants->len; i++) {
@@ -858,13 +767,16 @@ preferences_theme_variants_fill (EmpathyPreferences *preferences,
                        COL_VARIANT_NAME, name,
                        COL_VARIANT_DEFAULT, !tp_strdiff (name, default_variant),
                        -1);
+
+               result = TRUE;
        }
-#endif /* HAVE_WEBKIT */
 
        /* 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
@@ -915,33 +827,24 @@ preferences_theme_changed_cb (GtkComboBox        *combo,
 
        if (gtk_combo_box_get_active_iter (combo, &iter)) {
                GtkTreeModel *model;
-               gboolean      is_adium;
                gchar        *name;
-               gchar        *path;
                GHashTable   *info;
+               gboolean variant;
 
                model = gtk_combo_box_get_model (combo);
                gtk_tree_model_get (model, &iter,
-                                   COL_THEME_IS_ADIUM, &is_adium,
-                                   COL_THEME_NAME, &name,
-                                   COL_THEME_ADIUM_PATH, &path,
+                                   COL_THEME_ADIUM_NAME, &name,
                                    COL_THEME_ADIUM_INFO, &info,
                                    -1);
 
                g_settings_set_string (priv->gsettings_chat,
                                       EMPATHY_PREFS_CHAT_THEME,
                                       name);
-               if (is_adium) {
-                       g_settings_set_string (priv->gsettings_chat,
-                                              EMPATHY_PREFS_CHAT_ADIUM_PATH,
-                                              path);
-                       preferences_theme_variants_fill (preferences, info);
-                       gtk_widget_show (priv->hbox_chat_theme_variant);
-               } else {
-                       gtk_widget_hide (priv->hbox_chat_theme_variant);
-               }
+
+               variant = preferences_theme_variants_fill (preferences, info);
+               gtk_widget_set_visible (priv->hbox_chat_theme_variant, variant);
+
                g_free (name);
-               g_free (path);
                tp_clear_pointer (&info, g_hash_table_unref);
        }
 }
@@ -954,39 +857,31 @@ preferences_theme_notify_cb (GSettings   *gsettings,
        EmpathyPreferences *preferences = user_data;
        EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
        GtkComboBox        *combo;
-       gchar              *conf_name;
-       gchar              *conf_path;
+       gchar              *theme;
        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);
+       theme = g_settings_get_string (gsettings, key);
 
        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,
+                                   COL_THEME_ADIUM_NAME, &name,
                                    -1);
 
-               if (!tp_strdiff (name, conf_name) &&
-                   (!is_adium || !tp_strdiff (path, conf_path))) {
+               if (!tp_strdiff (name, theme)) {
                        found = TRUE;
                        gtk_combo_box_set_active_iter (combo, &iter);
                }
 
                g_free (name);
-               g_free (path);
        }
 
        /* Fallback to the first one. */
@@ -996,8 +891,7 @@ preferences_theme_notify_cb (GSettings   *gsettings,
                }
        }
 
-       g_free (conf_name);
-       g_free (conf_path);
+       g_free (theme);
 }
 
 static void
@@ -1008,9 +902,7 @@ preferences_themes_setup (EmpathyPreferences *preferences)
        GtkCellLayout *cell_layout;
        GtkCellRenderer *renderer;
        GtkListStore  *store;
-       const gchar  **themes;
        GList         *adium_themes;
-       gint           i;
 
        preferences_theme_variants_setup (preferences);
 
@@ -1020,43 +912,32 @@ preferences_themes_setup (EmpathyPreferences *preferences)
        /* Create the model */
        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_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_THEME_VISIBLE_NAME, _(themes[i + 1]),
-                       COL_THEME_NAME, themes[i],
-                       COL_THEME_IS_ADIUM, FALSE,
-                       -1);
-       }
-
        adium_themes = empathy_theme_manager_get_adium_themes ();
        while (adium_themes != NULL) {
                GHashTable *info;
-               const gchar *name;
-               const gchar *path;
+               const gchar *visible_name;
+               gchar *name;
 
                info = adium_themes->data;
-               name = tp_asv_get_string (info, "CFBundleName");
-               path = tp_asv_get_string (info, "path");
+               visible_name = tp_asv_get_string (info, "CFBundleName");
+               name = empathy_theme_manager_dup_theme_name_from_path (
+                       tp_asv_get_string (info, "path"));
 
-               if (name != NULL && path != NULL) {
+               if (visible_name != NULL && name != NULL) {
                        gtk_list_store_insert_with_values (store, NULL, -1,
-                               COL_THEME_VISIBLE_NAME, name,
-                               COL_THEME_NAME, "adium",
-                               COL_THEME_IS_ADIUM, TRUE,
-                               COL_THEME_ADIUM_PATH, path,
+                               COL_THEME_VISIBLE_NAME, visible_name,
+                               COL_THEME_ADIUM_NAME, name,
                                COL_THEME_ADIUM_INFO, info,
                                -1);
                }
                g_hash_table_unref (info);
+               g_free (name);
                adium_themes = g_list_delete_link (adium_themes, adium_themes);
        }
 
@@ -1077,24 +958,13 @@ preferences_themes_setup (EmpathyPreferences *preferences)
        preferences_theme_notify_cb (priv->gsettings_chat,
                                     EMPATHY_PREFS_CHAT_THEME,
                                     preferences);
-       g_signal_connect (priv->gsettings_chat,
-                         "changed::" EMPATHY_PREFS_CHAT_THEME,
-                         G_CALLBACK (preferences_theme_notify_cb),
-                         preferences);
 
        g_signal_connect (priv->gsettings_chat,
-                         "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
+                         "changed::" EMPATHY_PREFS_CHAT_THEME,
                          G_CALLBACK (preferences_theme_notify_cb),
                          preferences);
 }
 
-static gchar*
-preferences_call_format_volume_cb (GtkScale *scale,
-                                  gdouble value)
-{
-       return g_strdup_printf ("%g%%", value);
-}
-
 static void
 empathy_preferences_response (GtkDialog *widget,
                              gint response)
@@ -1154,46 +1024,25 @@ empathy_preferences_init (EmpathyPreferences *preferences)
        gtk_window_set_role (GTK_WINDOW (preferences), "preferences");
        gtk_window_set_position (GTK_WINDOW (preferences),
                                 GTK_WIN_POS_CENTER_ON_PARENT);
-       gtk_window_set_icon_name (GTK_WINDOW (preferences), "gtk-preferences");
+       gtk_window_set_icon_name (GTK_WINDOW (preferences), "preferences-desktop");
 
        filename = empathy_file_lookup ("empathy-preferences.ui", "src");
        gui = empathy_builder_get_file (filename,
                "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,
-               "checkbutton_logging", &priv->checkbutton_logging,
-               "checkbutton_notifications_enabled", &priv->checkbutton_notifications_enabled,
-               "checkbutton_notifications_disabled_away", &priv->checkbutton_notifications_disabled_away,
-               "checkbutton_notifications_focus", &priv->checkbutton_notifications_focus,
-               "checkbutton_notifications_contact_signin", &priv->checkbutton_notifications_contact_signin,
-               "checkbutton_notifications_contact_signout", &priv->checkbutton_notifications_contact_signout,
-               "checkbutton_sounds_enabled", &priv->checkbutton_sounds_enabled,
-               "checkbutton_sounds_disabled_away", &priv->checkbutton_sounds_disabled_away,
                "treeview_sounds", &priv->treeview_sounds,
                "treeview_spell_checker", &priv->treeview_spell_checker,
-               "checkbutton_location_publish", &priv->checkbutton_location_publish,
-               "checkbutton_location_reduce_accuracy", &priv->checkbutton_location_reduce_accuracy,
-               "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_volume_scale", &priv->scale_call_volume,
-               "call_volume_adjustment", &priv->adj_call_volume,
                NULL);
        g_free (filename);
 
        gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (preferences))), priv->notebook);
        gtk_widget_show (priv->notebook);
 
-       g_object_unref (gui);
-
        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);
@@ -1210,13 +1059,9 @@ empathy_preferences_init (EmpathyPreferences *preferences)
                          preferences, 0);
        preferences_preview_theme_changed_cb (priv->theme_manager, preferences);
 
-       g_signal_connect (priv->scale_call_volume, "format-value",
-                         G_CALLBACK (preferences_call_format_volume_cb),
-                         preferences);
-
        preferences_themes_setup (preferences);
 
-       preferences_setup_widgets (preferences);
+       preferences_setup_widgets (preferences, gui);
 
        preferences_languages_setup (preferences);
        preferences_languages_add (preferences);
@@ -1225,6 +1070,8 @@ empathy_preferences_init (EmpathyPreferences *preferences)
        preferences_sound_setup (preferences);
        preferences_sound_load (preferences);
 
+       g_object_unref (gui);
+
        if (empathy_spell_supported ()) {
                page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_SPELL);
                gtk_widget_show (page);
@@ -1241,29 +1088,33 @@ empathy_preferences_init (EmpathyPreferences *preferences)
 static EmpathyPreferencesTab
 empathy_preferences_tab_from_string (const gchar *str)
 {
-  if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_GENERAL))
-    return EMPATHY_PREFERENCES_TAB_GENERAL;
-  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_NOTIFICATIONS))
-    return EMPATHY_PREFERENCES_TAB_NOTIFICATIONS;
-  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_SOUNDS))
-    return EMPATHY_PREFERENCES_TAB_SOUNDS;
-  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_CALLS))
-    return EMPATHY_PREFERENCES_TAB_CALLS;
-  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_LOCATION))
-    return EMPATHY_PREFERENCES_TAB_LOCATION;
-  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_SPELL))
-    return EMPATHY_PREFERENCES_TAB_SPELL;
-  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_THEMES))
-    return EMPATHY_PREFERENCES_TAB_THEMES;
+  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);
 
@@ -1274,6 +1125,19 @@ 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;
 }