]> git.0d.be Git - empathy.git/blobdiff - src/empathy-account-assistant.c
Updated Polish translation
[empathy.git] / src / empathy-account-assistant.c
index 964b691546c18625697170005472cb75459f1897..97b7f9692a37b459d215c922185b2dd52915a2d4 100644 (file)
@@ -75,6 +75,7 @@ typedef struct {
   gboolean enter_create_forward;
   TpAccountManager *account_mgr;
   EmpathyConnectionManagers *connection_mgrs;
+  gint current_page_id;
 
   /* enter or create page */
   GtkWidget *enter_or_create_page;
@@ -112,7 +113,7 @@ static void account_assistant_finish_enter_or_create_page (
 static void do_constructed (GObject *object);
 
 static GtkWidget *
-build_error_page (const gchar *primary_message,
+build_error_vbox (const gchar *primary_message,
     const gchar *secondary_message)
 {
   GtkWidget *main_vbox, *w, *hbox;
@@ -147,6 +148,7 @@ build_error_page (const gchar *primary_message,
   gtk_label_set_use_markup (GTK_LABEL (w), TRUE);
   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
   gtk_widget_show (w);
 
   return main_vbox;
@@ -157,7 +159,8 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self,
     GError *error, gint page_num)
 {
   GtkWidget *main_vbox, *w;
-  const char *primary_message, *secondary_message;
+  const char *primary_message;
+  gchar *secondary_message, *markup;
   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
 
   if (page_num == PAGE_IMPORT)
@@ -171,11 +174,11 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self,
   else
     primary_message = _("There was an error.");
 
-  secondary_message = g_markup_printf_escaped
-    (_("The error message was: <span style=\"italic\">%s</span>"),
-        error->message);
+  markup = g_markup_printf_escaped ("<span style=\"italic\">%s</span>",
+      error->message);
+  secondary_message = g_strdup_printf (_("The error message was: %s"), markup);
 
-  main_vbox = build_error_page (primary_message, secondary_message);
+  main_vbox = build_error_vbox (primary_message, secondary_message);
 
   w = gtk_label_new (_("You can either go back and try to enter your "
           "accounts' details again or quit this assistant and add accounts "
@@ -185,6 +188,8 @@ account_assistant_build_error_page (EmpathyAccountAssistant *self,
   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
   gtk_widget_show (w);
 
+  g_free (markup);
+  g_free (secondary_message);
   return main_vbox;
 }
 
@@ -272,6 +277,8 @@ account_assistant_account_enabled_cb (GObject *source,
   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
   const gchar *protocol;
   TpAccount *account = TP_ACCOUNT (source);
+  gint current_idx;
+  gboolean salut_created = FALSE;
 
   tp_account_set_enabled_finish (account, result, &error);
 
@@ -289,8 +296,18 @@ account_assistant_account_enabled_cb (GObject *source,
       empathy_conf_set_bool (empathy_conf_get (),
           EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
           TRUE);
+
+      salut_created = TRUE;
     }
 
+  empathy_connect_new_account (account, priv->account_mgr);
+
+  current_idx = gtk_assistant_get_current_page (GTK_ASSISTANT (self));
+  if (current_idx == PAGE_SALUT && !salut_created)
+    /* We are on the Salut page and aren't creating the salut account so don't
+     * terminate the assistant. */
+    return;
+
   if (priv->create_enter_resp == RESPONSE_CREATE_STOP)
     g_signal_emit_by_name (self, "close");
   else
@@ -307,22 +324,9 @@ account_assistant_apply_account_cb (GObject *source,
   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
   EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
   TpAccount *account;
-  gchar *display_name;
 
   empathy_account_settings_apply_finish (settings, result, &error);
 
-  if (empathy_account_settings_get_display_name (settings) == NULL)
-    {
-      /* set default display name */
-      display_name = empathy_account_widget_get_default_display_name (
-          priv->current_widget_object);
-
-      empathy_account_settings_set_display_name_async (settings,
-          display_name, NULL, NULL);
-
-      g_free (display_name);
-    }
-
   priv->is_creating = FALSE;
 
   if (error != NULL)
@@ -344,12 +348,22 @@ account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self,
     EmpathyAccountSettings *settings)
 {
   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
+  gchar *display_name;
 
   if (settings == NULL)
     return;
 
   priv->is_creating = TRUE;
 
+  /* set default display name */
+  display_name = empathy_account_widget_get_default_display_name (
+      priv->current_widget_object);
+
+  empathy_account_settings_set_display_name_async (settings,
+      display_name, NULL, NULL);
+
+  g_free (display_name);
+
   empathy_account_settings_apply_async (settings,
       account_assistant_apply_account_cb, self);
 }
@@ -376,28 +390,38 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser,
   char *str;
   GtkWidget *account_widget;
   EmpathyAccountWidget *widget_object = NULL;
-  gboolean is_gtalk;
+  gboolean is_gtalk, is_facebook;
+  const gchar *name;
 
   priv = GET_PRIV (self);
 
   cm = empathy_protocol_chooser_dup_selected (
-      EMPATHY_PROTOCOL_CHOOSER (chooser), &proto, &is_gtalk);
+      EMPATHY_PROTOCOL_CHOOSER (chooser), &proto, &is_gtalk, &is_facebook);
 
   if (cm == NULL || proto == NULL)
     /* we are not ready yet */
     return;
 
   /* Create account */
+  if (is_gtalk)
+    name = "gtalk";
+  else if (is_facebook)
+    name = "facebook";
+  else
+    name = proto->name;
+
   /* To translator: %s is the protocol name */
   str = g_strdup_printf (_("New %s account"),
-      empathy_protocol_name_to_display_name (
-          is_gtalk ? "gtalk" : proto->name));
+      empathy_protocol_name_to_display_name (name));
 
   settings = empathy_account_settings_new (cm->name, proto->name, str);
 
   if (is_gtalk)
     empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
       NULL, NULL);
+  else if (is_facebook)
+    empathy_account_settings_set_icon_name_async (settings, "im-facebook",
+      NULL, NULL);
 
   if (priv->first_resp == RESPONSE_CREATE_ACCOUNT)
     empathy_account_settings_set_boolean (settings, "register", TRUE);
@@ -423,6 +447,12 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser,
   g_signal_connect (priv->current_widget_object, "handle-apply",
       G_CALLBACK (account_assistant_handle_apply_cb), self);
 
+  if (empathy_account_settings_is_valid (settings))
+    {
+      gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
+          priv->enter_or_create_page, TRUE);
+    }
+
   gtk_box_pack_start (GTK_BOX (priv->enter_or_create_page), account_widget,
       FALSE, FALSE, 0);
   gtk_widget_show (account_widget);
@@ -435,6 +465,7 @@ account_assistant_chooser_enter_details_filter_func (
     TpConnectionManager *cm,
     TpConnectionManagerProtocol *protocol,
     gboolean is_gtalk,
+    gboolean is_facebook,
     gpointer user_data)
 {
   if (!tp_strdiff (protocol->name, "local-xmpp") ||
@@ -449,9 +480,10 @@ account_assistant_chooser_create_account_filter_func (
     TpConnectionManager *cm,
     TpConnectionManagerProtocol *protocol,
     gboolean is_gtalk,
+    gboolean is_facebook,
     gpointer user_data)
 {
-  if (is_gtalk)
+  if (is_gtalk || is_facebook)
     return FALSE;
 
   return tp_connection_manager_protocol_can_register (protocol);
@@ -534,6 +566,11 @@ account_assistant_page_forward_func (gint current_page,
         /* Don't go forward */
         retval = -1;
     }
+  else if (current_page == PAGE_SALUT)
+    {
+      /* Don't go forward */
+      retval = -1;
+    }
   else if (current_page >= PAGE_ENTER_CREATE)
     {
       if (priv->create_enter_resp == RESPONSE_CREATE_AGAIN)
@@ -849,12 +886,18 @@ impl_signal_apply (GtkAssistant *assistant)
 
   current_page = gtk_assistant_get_current_page (assistant);
 
-  if (current_page == PAGE_ENTER_CREATE)
-    account_assistant_apply_account_and_finish (self, priv->settings);
-  else if (current_page == PAGE_IMPORT)
-    empathy_import_widget_add_selected_accounts (priv->iw);
-  else if (current_page == PAGE_SALUT && priv->create_salut_account)
-    account_assistant_apply_account_and_finish (self, priv->salut_settings);
+  if (current_page == PAGE_SALUT)
+    {
+      if (priv->create_salut_account)
+        account_assistant_apply_account_and_finish (self, priv->salut_settings);
+      return;
+    }
+  else if (current_page == PAGE_ENTER_CREATE &&
+      priv->settings != NULL &&
+      empathy_account_settings_is_valid (priv->settings))
+    {
+      account_assistant_apply_account_and_finish (self, priv->settings);
+    }
 }
 
 static void
@@ -871,11 +914,20 @@ impl_signal_prepare (GtkAssistant *assistant,
   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
   gint current_idx;
 
+  /* check from which page we are coming from */
+  switch (priv->current_page_id)
+    {
+      case PAGE_IMPORT:
+        empathy_import_widget_add_selected_accounts (priv->iw);
+        break;
+    }
+
   current_idx = gtk_assistant_get_current_page (assistant);
+  priv->current_page_id = current_idx;
 
-  if (current_idx == PAGE_ENTER_CREATE)
+  if (current_idx >= PAGE_ENTER_CREATE)
     {
-      if (!priv->enter_create_forward)
+      if (!priv->enter_create_forward && current_idx != PAGE_SALUT)
         {
           account_assistant_finish_enter_or_create_page (self,
               priv->first_resp == RESPONSE_ENTER_ACCOUNT ?
@@ -884,7 +936,14 @@ impl_signal_prepare (GtkAssistant *assistant,
       else
         {
           priv->enter_create_forward = FALSE;
+        }
+
+      if (priv->settings != NULL &&
+          empathy_account_settings_is_valid (priv->settings))
+        {
           account_assistant_apply_account_and_finish (self, priv->settings);
+          g_object_unref (priv->settings);
+          priv->settings = NULL;
         }
     }
 }
@@ -1036,6 +1095,7 @@ account_assistant_build_salut_page (EmpathyAccountAssistant *self)
   EmpathyAccountSettings *settings;
   GtkWidget *account_widget;
   EmpathyAccountWidget *widget_object;
+  gchar *markup;
 
   main_vbox = gtk_vbox_new (FALSE, 12);
   gtk_widget_show (main_vbox);
@@ -1045,13 +1105,17 @@ account_assistant_build_salut_page (EmpathyAccountAssistant *self)
   gtk_box_pack_start (GTK_BOX (main_vbox), hbox_1, TRUE, TRUE, 0);
   gtk_widget_show (hbox_1);
 
-  w = gtk_label_new (
+  w = gtk_label_new ("");
+  markup = g_strdup_printf ("%s (<span style=\"italic\">%s</span>).",
       _("Empathy can automatically discover and chat with the people "
         "connected on the same network as you. "
         "If you want to use this feature, please check that the "
         "details below are correct. "
         "You can easily change these details later or disable this feature "
-        "by using the 'Accounts' dialog."));
+        "by using the 'Accounts' dialog"),
+      _("Edit->Accounts"));
+  gtk_label_set_markup (GTK_LABEL (w), markup);
+  g_free (markup);
   gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
   gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
   gtk_box_pack_start (GTK_BOX (hbox_1), w, FALSE, FALSE, 0);
@@ -1097,12 +1161,19 @@ account_assistant_build_salut_page (EmpathyAccountAssistant *self)
 static GtkWidget *
 account_assistant_build_salut_error_page (EmpathyAccountAssistant *self)
 {
-  return build_error_page (
-      _("telepathy-salut not installed"),
-      _("Empathy won't be able to see the people connected on the same "
-        "network as you because telepathy-salut is not installed.\n"
-        "If you want to enable this feature, you should install "
-        "telepathy-salut and activate it in the Accounts dialog"));
+  GtkWidget *vbox;
+  gchar *markup;
+
+  markup = g_strdup_printf ("%s (<span style=\"italic\">%s</span>).",
+      _("You won't be able to chat with people connected to your local "
+        "network, as telepathy-salut is not installed. If you want to enable "
+        "this feature, please install the telepathy-salut package and create "
+        "a People Nearby account from the Accounts dialog"),
+        _("Edit->Accounts"));
+
+  vbox = build_error_vbox (_("telepathy-salut not installed"), markup);
+  g_free (markup);
+  return vbox;
 }
 
 static void
@@ -1188,13 +1259,13 @@ do_constructed (GObject *object)
   gtk_assistant_set_page_title (assistant, page,
       _("Import your existing accounts"));
   gtk_assistant_set_page_complete (assistant, page, TRUE);
-  gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_INTRO);
+  gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
   priv->import_page = page;
 
   /* third page (enter account details) */
   page = account_assistant_build_enter_or_create_page (self);
   gtk_assistant_append_page (assistant, page);
-  gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_INTRO);
+  gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT);
   priv->enter_or_create_page = page;
 
   /* fourth page (salut details) */
@@ -1208,6 +1279,12 @@ do_constructed (GObject *object)
       gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONFIRM);
 
       priv->create_salut_account = TRUE;
+
+      if (empathy_account_settings_is_valid (priv->salut_settings))
+        {
+          gtk_assistant_set_page_complete (GTK_ASSISTANT (self),
+              page, TRUE);
+        }
     }
   else
     {