]> git.0d.be Git - empathy.git/blobdiff - src/empathy-accounts-dialog.c
accounts-dialog: don't automatically open the add account
[empathy.git] / src / empathy-accounts-dialog.c
index 29a61ffdbe3c42b6ff6daff04d0d3ea73497daaf..978ad1630f59e90c3660a3729bc9e6d5023bf273 100644 (file)
@@ -161,21 +161,13 @@ enum {
 static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings (
     EmpathyAccountsDialog *dialog);
 
-static gboolean accounts_dialog_get_settings_iter (
-    EmpathyAccountsDialog *dialog,
-    EmpathyAccountSettings *settings,
-    GtkTreeIter *iter);
-
 static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
 
 static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
     EmpathyAccountSettings *settings);
 
-static void accounts_dialog_add (EmpathyAccountsDialog *dialog,
-    EmpathyAccountSettings *settings);
-
 static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
-    EmpathyAccountSettings *settings);
+    TpAccount *account);
 
 static void accounts_dialog_connection_changed_cb (TpAccount *account,
     guint old_status,
@@ -220,6 +212,9 @@ accounts_dialog_status_infobar_set_message (EmpathyAccountsDialog *dialog,
 
   message_markup = g_markup_printf_escaped ("<i>%s</i>", message);
   gtk_label_set_markup (GTK_LABEL (priv->label_status), message_markup);
+
+  gtk_widget_set_tooltip_text (priv->label_status, message);
+
   g_free (message_markup);
 }
 
@@ -940,12 +935,16 @@ accounts_dialog_button_add_clicked_cb (GtkWidget *button,
   if (response == GTK_RESPONSE_OK)
     {
       EmpathyAccountSettings *settings;
+      TpAccount *account;
 
       settings = empathy_new_account_dialog_get_settings (
           EMPATHY_NEW_ACCOUNT_DIALOG (dialog));
 
-      accounts_dialog_add (self, settings);
-      accounts_dialog_model_set_selected (self, settings);
+      /* The newly created account has already been added by
+       * accounts_dialog_account_validity_changed_cb so we just
+       * have to select it. */
+      account = empathy_account_settings_get_account (settings);
+      accounts_dialog_model_set_selected (self, account);
     }
 
   gtk_widget_destroy (dialog);
@@ -984,15 +983,6 @@ accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
 
           return;
         }
-      if (empathy_connection_managers_get_cms_num (priv->cms) > 0)
-        {
-          /* We have no account configured but we have some
-           * profiles installed. The user obviously wants to add
-           * an account. Click on the Add button for him. */
-          accounts_dialog_button_add_clicked_cb (priv->button_add,
-              dialog);
-          return;
-        }
 
       /* No account and no profile, warn the user */
       gtk_widget_hide (priv->vbox_details);
@@ -1584,41 +1574,6 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
   g_object_unref (store);
 }
 
-static gboolean
-accounts_dialog_get_settings_iter (EmpathyAccountsDialog *dialog,
-    EmpathyAccountSettings *settings,
-    GtkTreeIter *iter)
-{
-  GtkTreeView      *view;
-  GtkTreeModel     *model;
-  gboolean          ok;
-  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
-  /* Update the status in the model */
-  view = GTK_TREE_VIEW (priv->treeview);
-  model = gtk_tree_view_get_model (view);
-
-  for (ok = gtk_tree_model_get_iter_first (model, iter);
-       ok;
-       ok = gtk_tree_model_iter_next (model, iter))
-    {
-      EmpathyAccountSettings *this_settings;
-      gboolean   equal;
-
-      gtk_tree_model_get (model, iter,
-          COL_ACCOUNT_SETTINGS, &this_settings,
-          -1);
-
-      equal = (this_settings == settings);
-      g_object_unref (this_settings);
-
-      if (equal)
-        return TRUE;
-    }
-
-  return FALSE;
-}
-
 static gboolean
 accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
     TpAccount *account,
@@ -1678,11 +1633,11 @@ select_and_scroll_to_iter (EmpathyAccountsDialog *dialog,
 
 static void
 accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
-    EmpathyAccountSettings *settings)
+    TpAccount *account)
 {
   GtkTreeIter       iter;
 
-  if (accounts_dialog_get_settings_iter (dialog, settings, &iter))
+  if (accounts_dialog_get_account_iter (dialog, account, &iter))
     select_and_scroll_to_iter (dialog, &iter);
 }
 
@@ -1780,27 +1735,6 @@ finally:
   return FALSE;
 }
 
-static void
-accounts_dialog_add (EmpathyAccountsDialog *dialog,
-    EmpathyAccountSettings *settings)
-{
-  GtkTreeModel       *model;
-  GtkTreeIter         iter;
-  const gchar        *name;
-  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
-  model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
-  name = empathy_account_settings_get_display_name (settings);
-
-  gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-
-  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-      COL_NAME, name,
-      COL_STATUS, TP_CONNECTION_STATUS_DISCONNECTED,
-      COL_ACCOUNT_SETTINGS, settings,
-      -1);
-}
-
 static void
 accounts_dialog_connection_changed_cb (TpAccount *account,
     guint old_status,
@@ -2064,15 +1998,24 @@ accounts_dialog_account_enabled_cb (TpAccountManager *manager,
   enable_or_disable_account (dialog, account, TRUE);
 }
 
-static void
-accounts_dialog_button_import_clicked_cb (GtkWidget *button,
-    EmpathyAccountsDialog *dialog)
+static GtkWidget *
+display_import_dialog (EmpathyAccountsDialog *dialog)
 {
+  EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   GtkWidget *import_dialog;
 
   import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog),
-      FALSE);
+      FALSE, priv->cms);
   gtk_widget_show (import_dialog);
+
+  return import_dialog;
+}
+
+static void
+accounts_dialog_button_import_clicked_cb (GtkWidget *button,
+    EmpathyAccountsDialog *dialog)
+{
+  display_import_dialog (dialog);
 }
 
 static void
@@ -2368,7 +2311,7 @@ accounts_dialog_build_ui (EmpathyAccountsDialog *dialog)
             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_label_set_ellipsize (GTK_LABEL (priv->label_status), PANGO_ELLIPSIZE_END);
 
   gtk_box_pack_start (GTK_BOX (hbox), priv->throbber, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (hbox), priv->image_status, FALSE, FALSE, 0);