]> git.0d.be Git - empathy.git/blobdiff - src/empathy-accounts-dialog.c
Merge branch 'sasl'
[empathy.git] / src / empathy-accounts-dialog.c
index 96d97cb14c820d9807cfc2ba424ec52445be19eb..8eda73bb41ac3615955cdb16b83047e4cd8baa23 100644 (file)
 #include <stdlib.h>
 
 #include <gtk/gtk.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <dbus/dbus-glib.h>
 
 #include <telepathy-glib/account-manager.h>
+#include <telepathy-glib/defs.h>
 #include <telepathy-glib/util.h>
 
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-connection-managers.h>
 #include <libempathy/empathy-connectivity.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
 
+#include <libempathy-gtk/empathy-ui-utils.h>
 #include <libempathy-gtk/empathy-protocol-chooser.h>
 #include <libempathy-gtk/empathy-account-widget.h>
 #include <libempathy-gtk/empathy-account-widget-irc.h>
 #include <libempathy-gtk/empathy-account-widget-sip.h>
 #include <libempathy-gtk/empathy-cell-renderer-activatable.h>
-#include <libempathy-gtk/empathy-conf.h>
 #include <libempathy-gtk/empathy-images.h>
 
 #include "empathy-accounts-dialog.h"
 #include "empathy-import-dialog.h"
 #include "empathy-import-utils.h"
-#include "ephy-spinner.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
 #include <libempathy/empathy-debug.h>
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountsDialog)
 G_DEFINE_TYPE (EmpathyAccountsDialog, empathy_accounts_dialog, GTK_TYPE_DIALOG);
 
-static EmpathyAccountsDialog *dialog_singleton = NULL;
+enum
+{
+  NOTEBOOK_PAGE_ACCOUNT = 0,
+  NOTEBOOK_PAGE_LOADING
+};
 
 typedef struct {
   GtkWidget *alignment_settings;
@@ -87,6 +90,7 @@ typedef struct {
   GtkWidget *treeview;
 
   GtkWidget *button_add;
+  GtkWidget *button_remove;
   GtkWidget *button_import;
 
   GtkWidget *combobox_protocol;
@@ -97,6 +101,10 @@ typedef struct {
   GtkWidget *label_type;
   GtkWidget *settings_widget;
 
+  GtkWidget *notebook_account;
+  GtkWidget *spinner;
+  gboolean loading;
+
   /* We have to keep a reference on the actual EmpathyAccountWidget, not just
    * his GtkWidget. It is the only reliable source we can query to know if
    * there are any unsaved changes to the currently selected account. We can't
@@ -113,6 +121,7 @@ typedef struct {
 
   TpAccountManager *account_manager;
   EmpathyConnectionManagers *cms;
+  EmpathyConnectivity *connectivity;
 
   GtkWindow *parent_window;
   TpAccount *initial_selection;
@@ -124,15 +133,13 @@ typedef struct {
    * EmpathyAccountsDialog object. */
   gboolean force_change_row;
   GtkTreeRowReference *destination_row;
-
-  gboolean dispose_has_run;
 } EmpathyAccountsDialogPriv;
 
 enum {
   COL_NAME,
   COL_STATUS,
-  COL_ACCOUNT_POINTER,
-  COL_ACCOUNT_SETTINGS_POINTER,
+  COL_ACCOUNT,
+  COL_ACCOUNT_SETTINGS,
   COL_COUNT
 };
 
@@ -173,6 +180,10 @@ static void accounts_dialog_presence_changed_cb (TpAccount *account,
     gchar *status_message,
     EmpathyAccountsDialog *dialog);
 
+static void accounts_dialog_model_selection_changed (
+    GtkTreeSelection *selection,
+    EmpathyAccountsDialog *dialog);
+
 static void
 accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
     const gchar *display_name)
@@ -180,23 +191,33 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
   gchar *text;
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
-  text = g_markup_printf_escaped ("<big><b>%s</b></big>", display_name);
+  text = g_markup_printf_escaped ("<b>%s</b>", display_name);
   gtk_label_set_markup (GTK_LABEL (priv->label_name), text);
 
   g_free (text);
 }
 
+static void
+accounts_dialog_status_infobar_set_message (EmpathyAccountsDialog *dialog,
+    const gchar *message)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  gchar *message_markup;
+
+  message_markup = g_markup_printf_escaped ("<i>%s</i>", message);
+  gtk_label_set_markup (GTK_LABEL (priv->label_status), message_markup);
+  g_free (message_markup);
+}
+
 static void
 accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
     TpAccount *account)
 {
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-  const gchar               *message;
   gchar                     *status_message = NULL;
   guint                     status;
   guint                     reason;
   guint                     presence;
-  EmpathyConnectivity       *connectivity;
   GtkTreeView               *view;
   GtkTreeModel              *model;
   GtkTreeSelection          *selection;
@@ -211,8 +232,9 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
   if (!gtk_tree_selection_get_selected (selection, &model, &iter))
     return;
 
-  gtk_tree_model_get (model, &iter,
-      COL_ACCOUNT_POINTER, &selected_account, -1);
+  gtk_tree_model_get (model, &iter, COL_ACCOUNT, &selected_account, -1);
+  if (selected_account != NULL)
+    g_object_unref (selected_account);
 
   /* do not update the infobar when the account is not selected */
   if (account != selected_account)
@@ -254,25 +276,36 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
       switch (status)
         {
           case TP_CONNECTION_STATUS_CONNECTING:
-            message = _("Connecting…");
+            accounts_dialog_status_infobar_set_message (dialog,
+                _("Connecting…"));
             gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
                 GTK_MESSAGE_INFO);
 
-            ephy_spinner_start (EPHY_SPINNER (priv->throbber));
+            gtk_spinner_start (GTK_SPINNER (priv->throbber));
             gtk_widget_show (priv->throbber);
             gtk_widget_hide (priv->image_status);
             break;
           case TP_CONNECTION_STATUS_CONNECTED:
             if (g_strcmp0 (status_message, "") == 0)
               {
+                gchar *message;
+
                 message = g_strdup_printf ("%s",
                     empathy_presence_get_default_message (presence));
+
+                accounts_dialog_status_infobar_set_message (dialog, message);
+                g_free (message);
               }
             else
               {
+                gchar *message;
+
                 message = g_strdup_printf ("%s — %s",
                     empathy_presence_get_default_message (presence),
                     status_message);
+
+                accounts_dialog_status_infobar_set_message (dialog, message);
+                g_free (message);
               }
             gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
                 GTK_MESSAGE_INFO);
@@ -281,53 +314,61 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
             gtk_widget_hide (priv->throbber);
             break;
           case TP_CONNECTION_STATUS_DISCONNECTED:
-            message = g_strdup_printf (_("Disconnected — %s"),
-                empathy_status_reason_get_default_message (reason));
-
             if (reason == TP_CONNECTION_STATUS_REASON_REQUESTED)
               {
+                gchar *message;
+
                 message = g_strdup_printf (_("Offline — %s"),
-                    empathy_status_reason_get_default_message (reason));
+                    empathy_account_get_error_message (account, NULL));
                 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
                     GTK_MESSAGE_WARNING);
+
+                accounts_dialog_status_infobar_set_message (dialog, message);
+                g_free (message);
               }
             else
               {
+                gchar *message;
+
+                message = g_strdup_printf (_("Disconnected — %s"),
+                    empathy_account_get_error_message (account, NULL));
                 gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
                     GTK_MESSAGE_ERROR);
+
+                accounts_dialog_status_infobar_set_message (dialog, message);
+                g_free (message);
               }
 
-            connectivity = empathy_connectivity_dup_singleton ();
-            if (!empathy_connectivity_is_online (connectivity))
-               message = _("Offline — No Network Connection");
+            if (!empathy_connectivity_is_online (priv->connectivity))
+               accounts_dialog_status_infobar_set_message (dialog,
+                    _("Offline — No Network Connection"));
 
-            g_object_unref (connectivity);
-            ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
+            gtk_spinner_stop (GTK_SPINNER (priv->throbber));
             gtk_widget_show (priv->image_status);
             gtk_widget_hide (priv->throbber);
             break;
           default:
-            message = _("Unknown Status");
+            accounts_dialog_status_infobar_set_message (dialog, _("Unknown Status"));
             gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
                 GTK_MESSAGE_WARNING);
 
-            ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
+            gtk_spinner_stop (GTK_SPINNER (priv->throbber));
             gtk_widget_hide (priv->image_status);
             gtk_widget_hide (priv->throbber);
         }
     }
   else
     {
-      message = _("Offline — Account Disabled");
+      accounts_dialog_status_infobar_set_message (dialog,
+          _("Offline — Account Disabled"));
 
       gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
           GTK_MESSAGE_WARNING);
-      ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
+      gtk_spinner_stop (GTK_SPINNER (priv->throbber));
       gtk_widget_show (priv->image_status);
       gtk_widget_hide (priv->throbber);
     }
 
-  gtk_label_set_text (GTK_LABEL (priv->label_status), message);
   gtk_widget_show (priv->label_status);
 
   if (!creating_account)
@@ -338,10 +379,8 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
   g_free (status_message);
 }
 
-static void
-empathy_account_dialog_widget_cancelled_cb (
-    EmpathyAccountWidget *widget_object,
-    EmpathyAccountsDialog *dialog)
+void
+empathy_account_dialog_cancel (EmpathyAccountsDialog *dialog)
 {
   GtkTreeView *view;
   GtkTreeModel *model;
@@ -358,8 +397,8 @@ empathy_account_dialog_widget_cancelled_cb (
     return;
 
   gtk_tree_model_get (model, &iter,
-      COL_ACCOUNT_SETTINGS_POINTER, &settings,
-      COL_ACCOUNT_POINTER, &account, -1);
+      COL_ACCOUNT_SETTINGS, &settings,
+      COL_ACCOUNT, &account, -1);
 
   empathy_account_widget_discard_pending_changes (priv->setting_widget_object);
 
@@ -378,58 +417,80 @@ empathy_account_dialog_widget_cancelled_cb (
 
   gtk_widget_set_sensitive (priv->treeview, TRUE);
   gtk_widget_set_sensitive (priv->button_add, TRUE);
+  gtk_widget_set_sensitive (priv->button_remove, TRUE);
   gtk_widget_set_sensitive (priv->button_import, TRUE);
 
   if (settings != NULL)
     g_object_unref (settings);
 }
 
+static void
+empathy_account_dialog_widget_cancelled_cb (
+    EmpathyAccountWidget *widget_object,
+    EmpathyAccountsDialog *dialog)
+{
+  empathy_account_dialog_cancel (dialog);
+}
+
 static void
 empathy_account_dialog_account_created_cb (EmpathyAccountWidget *widget_object,
     TpAccount *account,
     EmpathyAccountsDialog *dialog)
 {
-  gchar *display_name;
   EmpathyAccountSettings *settings =
       accounts_dialog_model_get_selected_settings (dialog);
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
-  display_name = empathy_account_widget_get_default_display_name (
-      widget_object);
-
-  empathy_account_settings_set_display_name_async (settings,
-      display_name, NULL, NULL);
-
-  g_free (display_name);
-
   accounts_dialog_update_settings (dialog, settings);
   accounts_dialog_update_status_infobar (dialog,
       empathy_account_settings_get_account (settings));
 
   gtk_widget_set_sensitive (priv->treeview, TRUE);
   gtk_widget_set_sensitive (priv->button_add, TRUE);
+  gtk_widget_set_sensitive (priv->button_remove, TRUE);
   gtk_widget_set_sensitive (priv->button_import, TRUE);
 
-  empathy_signal_connect_weak (account, "status-changed",
-      G_CALLBACK (accounts_dialog_connection_changed_cb), G_OBJECT (dialog));
-  empathy_signal_connect_weak (account, "presence-changed",
-      G_CALLBACK (accounts_dialog_presence_changed_cb), G_OBJECT (dialog));
-
   if (settings)
     g_object_unref (settings);
 }
 
+static gboolean
+accounts_dialog_has_valid_accounts (EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gboolean creating;
+
+  g_object_get (priv->setting_widget_object,
+      "creating-account", &creating, NULL);
+
+  if (!creating)
+    return TRUE;
+
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+
+  if (gtk_tree_model_get_iter_first (model, &iter))
+    return gtk_tree_model_iter_next (model, &iter);
+
+  return FALSE;
+}
+
 static void
 account_dialog_create_settings_widget (EmpathyAccountsDialog *dialog,
     EmpathyAccountSettings *settings)
 {
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-  gchar                     *icon_name;
+  const gchar               *icon_name;
   TpAccount                 *account;
 
   priv->setting_widget_object =
       empathy_account_widget_new_for_protocol (settings, FALSE);
 
+  if (accounts_dialog_has_valid_accounts (dialog))
+    empathy_account_widget_set_other_accounts_exist (
+        priv->setting_widget_object, TRUE);
+
   priv->settings_widget =
       empathy_account_widget_get_widget (priv->setting_widget_object);
 
@@ -510,7 +571,7 @@ accounts_dialog_has_pending_change (EmpathyAccountsDialog *dialog,
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
 
   if (gtk_tree_selection_get_selected (selection, &model, &iter))
-    gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, account, -1);
+    gtk_tree_model_get (model, &iter, COL_ACCOUNT, account, -1);
 
   return priv->setting_widget_object != NULL
       && empathy_account_widget_contains_pending_changes (
@@ -522,43 +583,18 @@ accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog)
 {
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   EmpathyAccountSettings *settings;
-  gchar *str;
-  const gchar *display_name;
-  TpConnectionManager *cm;
-  TpConnectionManagerProtocol *proto;
-  gboolean is_gtalk;
 
-  cm = empathy_protocol_chooser_dup_selected (
-      EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, &is_gtalk);
-  if (cm == NULL)
+  settings = empathy_protocol_chooser_create_account_settings (
+      EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol));
+  if (settings == NULL)
     return;
 
-  display_name = empathy_protocol_name_to_display_name (
-      is_gtalk ? "gtalk" : proto->name);
-
-  if (display_name == NULL)
-    display_name = proto->name;
-
-  /* Create account */
-  /* To translator: %s is the name of the protocol, such as "Google Talk" or
-   * "Yahoo!"
-   */
-  str = g_strdup_printf (_("New %s account"), display_name);
-  settings = empathy_account_settings_new (cm->name, proto->name, str);
-
-  g_free (str);
-
-  if (is_gtalk)
-    empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
-        NULL, NULL);
-
   accounts_dialog_add (dialog, settings);
   accounts_dialog_model_set_selected (dialog, settings);
 
   gtk_widget_show_all (priv->hbox_protocol);
 
   g_object_unref (settings);
-  g_object_unref (cm);
 }
 
 static void
@@ -604,8 +640,17 @@ accounts_dialog_protocol_changed_cb (GtkWidget *widget,
   /* We are creating a new widget to replace the current one, don't ask
    * confirmation to the user. */
   priv->force_change_row = TRUE;
+
+  /* We'll update the selection after we create the new account widgets;
+   * updating it right now causes problems for the # of accounts = zero case */
+  g_signal_handlers_block_by_func (selection,
+      accounts_dialog_model_selection_changed, dialog);
+
   gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 
+  g_signal_handlers_unblock_by_func (selection,
+      accounts_dialog_model_selection_changed, dialog);
+
   accounts_dialog_setup_ui_to_add_account (dialog);
 
   /* Restore "account" and "password" parameters in the new widget */
@@ -725,8 +770,12 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button,
       accounts_dialog_setup_ui_to_add_account (dialog);
       gtk_widget_set_sensitive (priv->treeview, FALSE);
       gtk_widget_set_sensitive (priv->button_add, FALSE);
+      gtk_widget_set_sensitive (priv->button_remove, FALSE);
       gtk_widget_set_sensitive (priv->button_import, FALSE);
     }
+
+  if (account != NULL)
+    g_object_unref (account);
 }
 
 static void
@@ -842,7 +891,7 @@ get_status_icon_for_account (EmpathyAccountsDialog *self,
         /* An error occured */
         return GTK_STOCK_DIALOG_ERROR;
 
-        presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+      presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
     }
   else if (status == TP_CONNECTION_STATUS_CONNECTING)
     {
@@ -878,7 +927,7 @@ accounts_dialog_model_status_pixbuf_data_func (GtkTreeViewColumn *tree_column,
 {
   TpAccount *account;
 
-  gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1);
+  gtk_tree_model_get (model, iter, COL_ACCOUNT, &account, -1);
 
   g_object_set (cell,
       "icon-name", get_status_icon_for_account (dialog, account),
@@ -899,39 +948,15 @@ accounts_dialog_model_protocol_pixbuf_data_func (GtkTreeViewColumn *tree_column,
   gchar              *icon_name;
   GdkPixbuf          *pixbuf;
   TpConnectionStatus  status;
-  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
   gtk_tree_model_get (model, iter,
       COL_STATUS, &status,
-      COL_ACCOUNT_SETTINGS_POINTER, &settings,
+      COL_ACCOUNT_SETTINGS, &settings,
       -1);
 
   icon_name = empathy_account_settings_get_icon_name (settings);
   pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
 
-  if (pixbuf)
-    {
-      if (status == TP_CONNECTION_STATUS_DISCONNECTED ||
-          (status == TP_CONNECTION_STATUS_CONNECTING &&
-              !priv->connecting_show))
-        {
-          GdkPixbuf *modded_pixbuf;
-
-          modded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
-              TRUE,
-              8,
-              gdk_pixbuf_get_width (pixbuf),
-              gdk_pixbuf_get_height (pixbuf));
-
-          gdk_pixbuf_saturate_and_pixelate (pixbuf,
-              modded_pixbuf,
-              1.0,
-              TRUE);
-          g_object_unref (pixbuf);
-          pixbuf = modded_pixbuf;
-        }
-    }
-
   g_object_set (cell,
       "visible", TRUE,
       "pixbuf", pixbuf,
@@ -997,7 +1022,7 @@ accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
   treepath = gtk_tree_path_new_from_string (path);
   gtk_tree_model_get_iter (model, &iter, treepath);
   gtk_tree_model_get (model, &iter,
-      COL_ACCOUNT_SETTINGS_POINTER, &settings,
+      COL_ACCOUNT_SETTINGS, &settings,
       -1);
   gtk_list_store_set (GTK_LIST_STORE (model), &iter,
       COL_NAME, new_text,
@@ -1029,7 +1054,7 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
       if (!gtk_tree_selection_get_selected (selection, &model, &iter))
         return;
 
-      gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
+      gtk_tree_model_get (model, &iter, COL_ACCOUNT, &account, -1);
 
       if (account != NULL)
         {
@@ -1038,7 +1063,17 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
           account = NULL;
         }
 
+      /* No need to call accounts_dialog_model_selection_changed while
+       * removing as we are going to call accounts_dialog_model_select_first
+       * right after which will update the selection. */
+      g_signal_handlers_block_by_func (selection,
+          accounts_dialog_model_selection_changed, account_dialog);
+
       gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+
+      g_signal_handlers_unblock_by_func (selection,
+          accounts_dialog_model_selection_changed, account_dialog);
+
       accounts_dialog_model_select_first (account_dialog);
     }
 
@@ -1046,26 +1081,23 @@ accounts_dialog_delete_account_response_cb (GtkDialog *message_dialog,
 }
 
 static void
-accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
-    const gchar *path_string,
-    EmpathyAccountsDialog *dialog)
+accounts_dialog_remove_account_iter (EmpathyAccountsDialog *dialog,
+    GtkTreeIter *iter)
 {
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   TpAccount *account;
   GtkTreeModel *model;
-  GtkTreeIter iter;
   gchar *question_dialog_primary_text;
-  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
   model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
 
-  if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string))
-    return;
-
-  gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1);
+  gtk_tree_model_get (model, iter, COL_ACCOUNT, &account, -1);
 
   if (account == NULL || !tp_account_is_valid (account))
     {
-      gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+      if (account != NULL)
+        g_object_unref (account);
+      gtk_list_store_remove (GTK_LIST_STORE (model), iter);
       accounts_dialog_model_select_first (dialog);
       return;
     }
@@ -1082,13 +1114,45 @@ accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
       GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL);
 
   g_free (question_dialog_primary_text);
+  g_object_unref (account);
+}
 
-  if (account != NULL)
-    {
-      g_object_unref (account);
-      account = NULL;
-    }
+static void
+accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
+    EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  GtkTreeView  *view;
+  GtkTreeModel *model;
+  GtkTreeSelection *selection;
+  GtkTreeIter iter;
+
+  view = GTK_TREE_VIEW (priv->treeview);
+  model = gtk_tree_view_get_model (view);
+  selection = gtk_tree_view_get_selection (view);
+  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+      return;
+
+  accounts_dialog_remove_account_iter (dialog, &iter);
+}
+
+#ifdef HAVE_MEEGO
+static void
+accounts_dialog_view_delete_activated_cb (EmpathyCellRendererActivatable *cell,
+    const gchar *path_string,
+    EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+  if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string))
+    return;
+
+  accounts_dialog_remove_account_iter (dialog, &iter);
 }
+#endif /* HAVE_MEEGO */
 
 static void
 accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
@@ -1141,6 +1205,7 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
       dialog);
   g_object_set (cell, "ypad", 4, NULL);
 
+#ifdef HAVE_MEEGO
   /* Delete column */
   cell = empathy_cell_renderer_activatable_new ();
   gtk_tree_view_column_pack_start (column, cell, FALSE);
@@ -1152,6 +1217,7 @@ accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
   g_signal_connect (cell, "path-activated",
       G_CALLBACK (accounts_dialog_view_delete_activated_cb),
       dialog);
+#endif /* HAVE_MEEGO */
 }
 
 static EmpathyAccountSettings *
@@ -1171,7 +1237,7 @@ accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog)
     return NULL;
 
   gtk_tree_model_get (model, &iter,
-      COL_ACCOUNT_SETTINGS_POINTER, &settings, -1);
+      COL_ACCOUNT_SETTINGS, &settings, -1);
 
   return settings;
 }
@@ -1180,10 +1246,12 @@ static void
 accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
     EmpathyAccountsDialog *dialog)
 {
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   EmpathyAccountSettings *settings;
   GtkTreeModel *model;
   GtkTreeIter   iter;
   gboolean      is_selection;
+  gboolean creating = FALSE;
 
   is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
 
@@ -1192,6 +1260,16 @@ accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
 
   if (settings != NULL)
     g_object_unref (settings);
+
+  if (priv->setting_widget_object != NULL)
+    {
+      g_object_get (priv->setting_widget_object,
+          "creating-account", &creating, NULL);
+    }
+
+  /* Update remove button sensitivity */
+  gtk_widget_set_sensitive (priv->button_remove, is_selection && !creating &&
+      !priv->loading);
 }
 
 static void
@@ -1246,6 +1324,7 @@ accounts_dialog_account_selection_change (GtkTreeSelection *selection,
   TpAccount *account = NULL;
   EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (data);
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  gboolean ret;
 
   if (priv->force_change_row)
     {
@@ -1274,13 +1353,17 @@ accounts_dialog_account_selection_change (GtkTreeSelection *selection,
           GTK_STOCK_DISCARD, GTK_RESPONSE_YES, NULL);
 
       g_free (question_dialog_primary_text);
+      ret = FALSE;
     }
   else
     {
-      return TRUE;
+      ret = TRUE;
     }
 
-  return FALSE;
+  if (account != NULL)
+    g_object_unref (account);
+
+  return ret;
 }
 
 static void
@@ -1340,7 +1423,7 @@ accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog,
       gboolean   equal;
 
       gtk_tree_model_get (model, iter,
-          COL_ACCOUNT_SETTINGS_POINTER, &this_settings,
+          COL_ACCOUNT_SETTINGS, &this_settings,
           -1);
 
       equal = (this_settings == settings);
@@ -1377,7 +1460,7 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
       gboolean   equal;
 
       gtk_tree_model_get (model, iter,
-          COL_ACCOUNT_SETTINGS_POINTER, &settings,
+          COL_ACCOUNT_SETTINGS, &settings,
           -1);
 
       equal = empathy_account_settings_has_account (settings, account);
@@ -1419,7 +1502,7 @@ accounts_dialog_add (EmpathyAccountsDialog *dialog,
   gtk_list_store_set (GTK_LIST_STORE (model), &iter,
       COL_NAME, name,
       COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED,
-      COL_ACCOUNT_SETTINGS_POINTER, settings,
+      COL_ACCOUNT_SETTINGS, settings,
       -1);
 }
 
@@ -1561,8 +1644,8 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
   gtk_list_store_set (GTK_LIST_STORE (model), &iter,
       COL_NAME, name,
       COL_STATUS, status,
-      COL_ACCOUNT_POINTER, account,
-      COL_ACCOUNT_SETTINGS_POINTER, settings,
+      COL_ACCOUNT, account,
+      COL_ACCOUNT_SETTINGS, settings,
       -1);
 
   accounts_dialog_connection_changed_cb (account,
@@ -1573,9 +1656,14 @@ accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
       NULL,
       dialog);
 
-  empathy_signal_connect_weak (account, "notify::display-name",
+  tp_g_signal_connect_object (account, "notify::display-name",
       G_CALLBACK (accounts_dialog_account_display_name_changed_cb),
-      G_OBJECT (dialog));
+      dialog, 0);
+
+  tp_g_signal_connect_object (account, "status-changed",
+      G_CALLBACK (accounts_dialog_connection_changed_cb), dialog, 0);
+  tp_g_signal_connect_object (account, "presence-changed",
+      G_CALLBACK (accounts_dialog_presence_changed_cb), dialog, 0);
 
   g_object_unref (settings);
 }
@@ -1608,6 +1696,37 @@ accounts_dialog_account_validity_changed_cb (TpAccountManager *manager,
   tp_account_prepare_async (account, NULL, account_prepare_cb, dialog);
 }
 
+static void
+accounts_dialog_accounts_model_row_inserted_cb (GtkTreeModel *model,
+    GtkTreePath *path,
+    GtkTreeIter *iter,
+    EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+  if (priv->setting_widget_object != NULL &&
+      accounts_dialog_has_valid_accounts (dialog))
+    {
+      empathy_account_widget_set_other_accounts_exist (
+          priv->setting_widget_object, TRUE);
+    }
+}
+
+static void
+accounts_dialog_accounts_model_row_deleted_cb (GtkTreeModel *model,
+    GtkTreePath *path,
+    EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+
+  if (priv->setting_widget_object != NULL &&
+      !accounts_dialog_has_valid_accounts (dialog))
+    {
+      empathy_account_widget_set_other_accounts_exist (
+          priv->setting_widget_object, FALSE);
+    }
+}
+
 static void
 accounts_dialog_account_removed_cb (TpAccountManager *manager,
     TpAccount *account,
@@ -1619,7 +1738,7 @@ accounts_dialog_account_removed_cb (TpAccountManager *manager,
   if (accounts_dialog_get_account_iter (dialog, account, &iter))
     {
       gtk_list_store_remove (GTK_LIST_STORE (
-            gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter);
+          gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview))), &iter);
     }
 }
 
@@ -1634,9 +1753,8 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
   /* Update the status in the model */
   model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
 
-  /* Update the status-infobar in the details view when disabling */
-  if (!enabled)
-    accounts_dialog_update_status_infobar (dialog, account);
+  /* Update the status-infobar in the details view */
+  accounts_dialog_update_status_infobar (dialog, account);
 
   DEBUG ("Account %s is now %s",
       tp_account_get_display_name (account),
@@ -1707,24 +1825,51 @@ accounts_dialog_set_selected_account (EmpathyAccountsDialog *dialog,
 }
 
 static void
-accounts_dialog_cms_ready_cb (EmpathyConnectionManagers *cms,
-    GParamSpec *pspec,
-    EmpathyAccountsDialog *dialog)
+finished_loading (EmpathyAccountsDialog *self)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (self);
+  GtkTreeSelection *selection;
+  gboolean has_selected;
+
+  priv->loading = FALSE;
+
+  gtk_widget_set_sensitive (priv->button_add, TRUE);
+  gtk_widget_set_sensitive (priv->button_import, TRUE);
+  gtk_widget_set_sensitive (priv->treeview, TRUE);
+
+  /* Sensitive the remove button if there is an account selected */
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+  has_selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
+  gtk_widget_set_sensitive (priv->button_remove, has_selected);
+
+  gtk_spinner_stop (GTK_SPINNER (priv->spinner));
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_account),
+      NOTEBOOK_PAGE_ACCOUNT);
+}
+
+static void
+accounts_dialog_cms_prepare_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
 {
+  EmpathyConnectionManagers *cms = EMPATHY_CONNECTION_MANAGERS (source);
+  EmpathyAccountsDialog *dialog = user_data;
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
-  if (empathy_connection_managers_is_ready (cms))
-    {
-      accounts_dialog_update_settings (dialog, NULL);
+  if (!empathy_connection_managers_prepare_finish (cms, result, NULL))
+    goto out;
 
-      if (priv->initial_selection != NULL)
-        {
-          accounts_dialog_set_selected_account
-              (dialog, priv->initial_selection);
-          g_object_unref (priv->initial_selection);
-          priv->initial_selection = NULL;
-        }
+  accounts_dialog_update_settings (dialog, NULL);
+
+  if (priv->initial_selection != NULL)
+    {
+      accounts_dialog_set_selected_account (dialog, priv->initial_selection);
+      g_object_unref (priv->initial_selection);
+      priv->initial_selection = NULL;
     }
+
+out:
+  finished_loading (dialog);
 }
 
 static void
@@ -1751,18 +1896,13 @@ accounts_dialog_accounts_setup (EmpathyAccountsDialog *dialog)
   for (l = accounts; l; l = l->next)
     {
       accounts_dialog_add_account (dialog, l->data);
-
-      empathy_signal_connect_weak (l->data, "status-changed",
-          G_CALLBACK (accounts_dialog_connection_changed_cb), G_OBJECT (dialog));
-      empathy_signal_connect_weak (l->data, "presence-changed",
-          G_CALLBACK (accounts_dialog_presence_changed_cb), G_OBJECT (dialog));
     }
   g_list_free (accounts);
 
   priv->cms = empathy_connection_managers_dup_singleton ();
-  if (!empathy_connection_managers_is_ready (priv->cms))
-    g_signal_connect (priv->cms, "notify::ready",
-        G_CALLBACK (accounts_dialog_cms_ready_cb), dialog);
+
+  empathy_connection_managers_prepare_async (priv->cms,
+      accounts_dialog_cms_prepare_cb, dialog);
 
   accounts_dialog_model_select_first (dialog);
 }
@@ -1821,6 +1961,9 @@ dialog_response_cb (GtkWidget *widget,
         {
           gtk_widget_destroy (widget);
         }
+
+      if (account != NULL)
+        g_object_unref (account);
     }
 }
 
@@ -1832,7 +1975,8 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
   gchar                        *filename;
   EmpathyAccountsDialogPriv    *priv = GET_PRIV (dialog);
   GtkWidget                    *content_area;
-  GtkWidget *action_area;
+  GtkWidget *action_area, *vbox, *hbox, *align;
+  GtkWidget *alig;
 
   filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src");
 
@@ -1843,30 +1987,57 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
       "alignment_settings", &priv->alignment_settings,
       "alignment_infobar", &priv->alignment_infobar,
       "treeview", &priv->treeview,
-      "image_type", &priv->image_type,
-      "label_name", &priv->label_name,
       "button_add", &priv->button_add,
+      "button_remove", &priv->button_remove,
       "button_import", &priv->button_import,
       "hbox_protocol", &priv->hbox_protocol,
+      "notebook_account", &priv->notebook_account,
+      "alignment_loading", &alig,
       NULL);
   g_free (filename);
 
+  gtk_widget_set_no_show_all (priv->frame_no_protocol, TRUE);
+
   empathy_builder_connect (gui, dialog,
       "button_add", "clicked", accounts_dialog_button_add_clicked_cb,
+      "button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
       "button_import", "clicked", accounts_dialog_button_import_clicked_cb,
       NULL);
 
   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 
-  gtk_container_add (GTK_CONTAINER (content_area), top_hbox);
+  gtk_box_pack_start (GTK_BOX (content_area), top_hbox, TRUE, TRUE, 0);
 
   g_object_unref (gui);
 
   action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
 
-#ifdef HAVE_MOBLIN
+#ifdef HAVE_MEEGO
   gtk_widget_hide (action_area);
-#endif
+  gtk_widget_hide (priv->button_remove);
+#endif /* HAVE_MEEGO */
+
+  /* Display loading page */
+  priv->loading = TRUE;
+
+  priv->spinner = gtk_spinner_new ();
+
+  gtk_spinner_start (GTK_SPINNER (priv->spinner));
+  gtk_widget_show (priv->spinner);
+
+  gtk_container_add (GTK_CONTAINER (alig), priv->spinner);
+
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_account),
+      NOTEBOOK_PAGE_LOADING);
+
+  /* Remove button is insensitive until we have a selected account */
+  gtk_widget_set_sensitive (priv->button_remove, FALSE);
+
+  /* Add and Import buttons and treeview are insensitive while the dialog
+   * is loading */
+  gtk_widget_set_sensitive (priv->button_add, FALSE);
+  gtk_widget_set_sensitive (priv->button_import, FALSE);
+  gtk_widget_set_sensitive (priv->treeview, FALSE);
 
   priv->combobox_protocol = empathy_protocol_chooser_new ();
   gtk_box_pack_start (GTK_BOX (priv->hbox_protocol), priv->combobox_protocol,
@@ -1879,38 +2050,65 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
     gtk_window_set_transient_for (GTK_WINDOW (dialog),
         priv->parent_window);
 
-  /* set up spinner */
-  priv->throbber = ephy_spinner_new ();
-  ephy_spinner_set_size (EPHY_SPINNER (priv->throbber), GTK_ICON_SIZE_SMALL_TOOLBAR);
-
   priv->infobar = gtk_info_bar_new ();
   gtk_container_add (GTK_CONTAINER (priv->alignment_infobar),
       priv->infobar);
   gtk_widget_show (priv->infobar);
 
+  content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->infobar));
+
+  priv->image_type = gtk_image_new_from_stock (GTK_STOCK_CUT,
+      GTK_ICON_SIZE_DIALOG);
+  gtk_misc_set_alignment (GTK_MISC (priv->image_type), 0.0, 0.5);
+  gtk_box_pack_start (GTK_BOX (content_area), priv->image_type, FALSE, FALSE, 0);
+  gtk_widget_show (priv->image_type);
+
+  vbox = gtk_vbox_new (FALSE, 6);
+  gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
+  gtk_widget_show (vbox);
+
+  /* first row */
+  align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
+  gtk_widget_show (align);
+
+  priv->label_name = gtk_label_new (NULL);
+  gtk_container_add (GTK_CONTAINER (align), priv->label_name);
+  gtk_widget_show (priv->label_name);
+
+  gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
+
+  /* second row */
+  align = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
+  gtk_widget_show (align);
+  hbox = gtk_hbox_new (FALSE, 6);
+  gtk_widget_show (hbox);
+  gtk_container_add (GTK_CONTAINER (align), hbox);
+
+  gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
+
+  /* set up spinner */
+  priv->throbber = gtk_spinner_new ();
+
   priv->image_status = gtk_image_new_from_icon_name (
             empathy_icon_name_for_presence (
             TP_CONNECTION_PRESENCE_TYPE_OFFLINE), GTK_ICON_SIZE_SMALL_TOOLBAR);
 
   priv->label_status = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (priv->label_status), TRUE);
+  gtk_widget_show (priv->label_status);
 
-  content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (priv->infobar));
-  gtk_box_pack_start (GTK_BOX (content_area), priv->throbber,
-      FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (content_area), priv->image_status,
-      FALSE, FALSE, 0);
-  gtk_container_add (GTK_CONTAINER (content_area), priv->label_status);
+  gtk_box_pack_start (GTK_BOX (hbox), priv->throbber, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), priv->image_status, FALSE, FALSE, 3);
+  gtk_box_pack_start (GTK_BOX (hbox), priv->label_status, TRUE, TRUE, 0);
 
   /* Tweak the dialog */
-  gtk_window_set_title (GTK_WINDOW (dialog), _("Accounts"));
+  gtk_window_set_title (GTK_WINDOW (dialog), _("Messaging and VoIP Accounts"));
   gtk_window_set_role (GTK_WINDOW (dialog), "accounts");
 
-  gtk_window_set_default_size (GTK_WINDOW (dialog), 640, -1);
+  gtk_window_set_default_size (GTK_WINDOW (dialog), 640, 450);
 
   gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
 
-  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-
   /* add dialog buttons */
   gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END);
 
@@ -1932,30 +2130,11 @@ do_dispose (GObject *obj)
   EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (obj);
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
 
-  if (priv->dispose_has_run)
-    return;
-
-  priv->dispose_has_run = TRUE;
-
-  /* Disconnect signals */
-  g_signal_handlers_disconnect_by_func (priv->account_manager,
-      accounts_dialog_account_validity_changed_cb,
-      dialog);
-  g_signal_handlers_disconnect_by_func (priv->account_manager,
-      accounts_dialog_account_removed_cb,
-      dialog);
-  g_signal_handlers_disconnect_by_func (priv->account_manager,
-      accounts_dialog_account_enabled_cb,
-      dialog);
-  g_signal_handlers_disconnect_by_func (priv->account_manager,
-      accounts_dialog_account_disabled_cb,
-      dialog);
-  g_signal_handlers_disconnect_by_func (priv->account_manager,
-      accounts_dialog_manager_ready_cb,
-      dialog);
-
-  if (priv->connecting_id)
-    g_source_remove (priv->connecting_id);
+  if (priv->connecting_id != 0)
+    {
+      g_source_remove (priv->connecting_id);
+      priv->connecting_id = 0;
+    }
 
   if (priv->account_manager != NULL)
     {
@@ -1969,35 +2148,19 @@ do_dispose (GObject *obj)
       priv->cms = NULL;
     }
 
-  if (priv->initial_selection != NULL)
-    g_object_unref (priv->initial_selection);
-  priv->initial_selection = NULL;
-
-  G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj);
-}
-
-static GObject *
-do_constructor (GType type,
-    guint n_props,
-    GObjectConstructParam *props)
-{
-  GObject *retval;
-
-  if (dialog_singleton)
+  if (priv->connectivity)
     {
-      retval = G_OBJECT (dialog_singleton);
+      g_object_unref (priv->connectivity);
+      priv->connectivity = NULL;
     }
-  else
-    {
-      retval =
-        G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->constructor
-            (type, n_props, props);
 
-      dialog_singleton = EMPATHY_ACCOUNTS_DIALOG (retval);
-      g_object_add_weak_pointer (retval, (gpointer) &dialog_singleton);
+  if (priv->initial_selection != NULL)
+    {
+      g_object_unref (priv->initial_selection);
+      priv->initial_selection = NULL;
     }
 
-  return retval;
+  G_OBJECT_CLASS (empathy_accounts_dialog_parent_class)->dispose (obj);
 }
 
 static void
@@ -2041,35 +2204,24 @@ do_constructed (GObject *object)
 {
   EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object);
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-  gboolean import_asked;
+  GtkTreeModel *model;
 
   accounts_dialog_build_ui (dialog);
   accounts_dialog_model_setup (dialog);
 
+  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
+  g_signal_connect (model, "row-inserted",
+      (GCallback) accounts_dialog_accounts_model_row_inserted_cb, dialog);
+  g_signal_connect (model, "row-deleted",
+      (GCallback) accounts_dialog_accounts_model_row_deleted_cb, dialog);
+
   /* Set up signalling */
   priv->account_manager = tp_account_manager_dup ();
 
   tp_account_manager_prepare_async (priv->account_manager, NULL,
       accounts_dialog_manager_ready_cb, dialog);
 
-  empathy_conf_get_bool (empathy_conf_get (),
-      EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
-
-  if (empathy_import_accounts_to_import ())
-    {
-      gtk_widget_show (priv->button_import);
-
-      if (!import_asked)
-        {
-          GtkWidget *import_dialog;
-
-          empathy_conf_set_bool (empathy_conf_get (),
-              EMPATHY_PREFS_IMPORT_ASKED, TRUE);
-          import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog),
-              FALSE);
-          gtk_widget_show (import_dialog);
-        }
-    }
+  priv->connectivity = empathy_connectivity_dup_singleton ();
 }
 
 static void
@@ -2078,7 +2230,6 @@ empathy_accounts_dialog_class_init (EmpathyAccountsDialogClass *klass)
   GObjectClass *oclass = G_OBJECT_CLASS (klass);
   GParamSpec *param_spec;
 
-  oclass->constructor = do_constructor;
   oclass->dispose = do_dispose;
   oclass->constructed = do_constructed;
   oclass->set_property = do_set_property;
@@ -2133,3 +2284,80 @@ empathy_accounts_dialog_show (GtkWindow *parent,
 
   return GTK_WIDGET (dialog);
 }
+
+void
+empathy_accounts_dialog_show_application (GdkScreen *screen,
+    TpAccount *selected_account,
+    gboolean if_needed,
+    gboolean hidden)
+{
+  GError *error = NULL;
+  const gchar *argv[4] = { NULL, };
+  gint i = 0;
+  gchar *account_option = NULL;
+  gchar *path;
+
+  g_return_if_fail (GDK_IS_SCREEN (screen));
+  g_return_if_fail (!selected_account || TP_IS_ACCOUNT (selected_account));
+
+  /* Try to run from source directory if possible */
+  path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
+      "empathy-accounts", NULL);
+
+  if (!g_file_test (path, G_FILE_TEST_EXISTS))
+    {
+      g_free (path);
+      path = g_build_filename (BIN_DIR, "empathy-accounts", NULL);
+    }
+
+  argv[i++] = path;
+
+  if (selected_account != NULL)
+    {
+      const gchar *account_path;
+
+      account_path = tp_proxy_get_object_path (TP_PROXY (selected_account));
+      account_option = g_strdup_printf ("--select-account=%s",
+          &account_path[strlen (TP_ACCOUNT_OBJECT_PATH_BASE)]);
+
+      argv[i++] = account_option;
+    }
+
+  if (if_needed)
+    argv[i++] = "--if-needed";
+
+  if (hidden)
+    argv[i++] = "--hidden";
+
+  DEBUG ("Launching empathy-accounts (if_needed: %d, hidden: %d, account: %s)",
+    if_needed, hidden,
+    selected_account == NULL ? "<none selected>" :
+      tp_proxy_get_object_path (TP_PROXY (selected_account)));
+
+  gdk_spawn_on_screen (screen, NULL, (gchar**) argv, NULL, G_SPAWN_SEARCH_PATH,
+      NULL, NULL, NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Failed to open accounts dialog: %s", error->message);
+      g_error_free (error);
+    }
+
+  g_free (account_option);
+  g_free (path);
+}
+
+gboolean
+empathy_accounts_dialog_is_creating (EmpathyAccountsDialog *dialog)
+{
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+  gboolean result = FALSE;
+
+  if (priv->setting_widget_object == NULL)
+    goto out;
+
+  g_object_get (priv->setting_widget_object,
+      "creating-account", &result, NULL);
+
+out:
+  return result;
+}