]> git.0d.be Git - empathy.git/blobdiff - src/empathy-preferences.c
Remove obsolete contact-list-{store,view}
[empathy.git] / src / empathy-preferences.c
index 9db4739d6ed0d4d0c28b6c52613edaa6abad5bcb..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"
 
@@ -55,6 +51,17 @@ 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;
 
@@ -75,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;
@@ -93,6 +102,7 @@ struct _EmpathyPreferencesPriv {
 
        GSettings *gsettings;
        GSettings *gsettings_chat;
+       GSettings *gsettings_call;
        GSettings *gsettings_loc;
        GSettings *gsettings_notify;
        GSettings *gsettings_sound;
@@ -259,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,
@@ -821,24 +837,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++) {
@@ -848,13 +863,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
@@ -922,11 +940,14 @@ preferences_theme_changed_cb (GtkComboBox        *combo,
                                       EMPATHY_PREFS_CHAT_THEME,
                                       name);
                if (is_adium) {
+                       gboolean variant;
+
                        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);
+
+                       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);
                }
@@ -1094,6 +1115,7 @@ empathy_preferences_finalize (GObject *self)
 
        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);
@@ -1166,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);
 
@@ -1176,6 +1199,7 @@ 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);
@@ -1201,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
@@ -1213,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);
 
@@ -1227,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));
+}