]> git.0d.be Git - empathy.git/blobdiff - src/empathy-account-assistant.c
Update Simplified Chinese help translation.
[empathy.git] / src / empathy-account-assistant.c
index 9860259fa9a5e2d67dd8cba4dfaabf0e51828fc9..1b39000cdb4ba3a58b846eff7dd4ea92fabf0719 100644 (file)
@@ -20,7 +20,8 @@
 
 /* empathy-account-assistant.c */
 
-#include <glib/gi18n.h>
+#include <config.h>
+#include <glib/gi18n-lib.h>
 #include <telepathy-glib/util.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -35,7 +36,6 @@
 #include <libempathy-gtk/empathy-account-widget.h>
 #include <libempathy-gtk/empathy-protocol-chooser.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-conf.h>
 
 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
 #include <libempathy/empathy-debug.h>
@@ -57,12 +57,12 @@ typedef enum {
   RESPONSE_CREATE_STOP = 2
 } CreateEnterPageResponse;
 
-enum {
+typedef enum {
   PAGE_INTRO = 0,
   PAGE_IMPORT = 1,
   PAGE_ENTER_CREATE = 2,
   PAGE_SALUT = 3,
-};
+} PageID;
 
 enum {
   PROP_PARENT = 1,
@@ -75,7 +75,7 @@ typedef struct {
   gboolean enter_create_forward;
   TpAccountManager *account_mgr;
   EmpathyConnectionManagers *connection_mgrs;
-  gint current_page_id;
+  PageID current_page_id;
 
   /* enter or create page */
   GtkWidget *enter_or_create_page;
@@ -319,7 +319,7 @@ account_assistant_apply_account_cb (GObject *source,
   EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
   TpAccount *account;
 
-  empathy_account_settings_apply_finish (settings, result, &error);
+  empathy_account_settings_apply_finish (settings, result, NULL, &error);
 
   priv->is_creating = FALSE;
 
@@ -339,7 +339,8 @@ account_assistant_apply_account_cb (GObject *source,
 
 static void
 account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self,
-    EmpathyAccountSettings *settings)
+    EmpathyAccountSettings *settings,
+    gboolean set_display_name)
 {
   EmpathyAccountAssistantPriv *priv = GET_PRIV (self);
 
@@ -348,9 +349,7 @@ account_assistant_apply_account_and_finish (EmpathyAccountAssistant *self,
 
   priv->is_creating = TRUE;
 
-  /* set default display name, if there is no current widget then assume the
-   * display name was already set correctly. e.g. salut account creation */
-  if (priv->current_widget_object != NULL)
+  if (set_display_name)
     {
       gchar *display_name;
 
@@ -382,54 +381,19 @@ static void
 account_assistant_protocol_changed_cb (GtkComboBox *chooser,
     EmpathyAccountAssistant *self)
 {
-  TpConnectionManager *cm;
-  TpConnectionManagerProtocol *proto;
   EmpathyAccountSettings *settings;
   EmpathyAccountAssistantPriv *priv;
-  char *str;
   GtkWidget *account_widget;
   EmpathyAccountWidget *widget_object = NULL;
-  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, &is_facebook);
+  settings = empathy_protocol_chooser_create_account_settings (
+      EMPATHY_PROTOCOL_CHOOSER (chooser));
 
-  if (cm == NULL || proto == NULL)
-    /* we are not ready yet */
+  if (settings == NULL)
     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 (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);
-      /* We should not have to set the server but that may cause issue with
-       * buggy router. */
-      empathy_account_settings_set_string (settings, "server",
-          "talk.google.com");
-    }
-  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);
 
@@ -463,20 +427,16 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser,
   gtk_box_pack_start (GTK_BOX (priv->enter_or_create_page), account_widget,
       FALSE, FALSE, 0);
   gtk_widget_show (account_widget);
-
-  g_free (str);
 }
 
 static gboolean
 account_assistant_chooser_enter_details_filter_func (
     TpConnectionManager *cm,
     TpConnectionManagerProtocol *protocol,
-    gboolean is_gtalk,
-    gboolean is_facebook,
+    const gchar *service,
     gpointer user_data)
 {
-  if (!tp_strdiff (protocol->name, "local-xmpp") ||
-      !tp_strdiff (protocol->name, "irc"))
+  if (!tp_strdiff (protocol->name, "local-xmpp"))
     return FALSE;
 
   return TRUE;
@@ -486,11 +446,10 @@ static gboolean
 account_assistant_chooser_create_account_filter_func (
     TpConnectionManager *cm,
     TpConnectionManagerProtocol *protocol,
-    gboolean is_gtalk,
-    gboolean is_facebook,
+    const gchar *service,
     gpointer user_data)
 {
-  if (is_gtalk || is_facebook)
+  if (service != NULL)
     return FALSE;
 
   return tp_connection_manager_protocol_can_register (protocol);
@@ -696,8 +655,8 @@ account_assistant_build_introduction_page (EmpathyAccountAssistant *self)
           GINT_TO_POINTER (RESPONSE_IMPORT));
       gtk_widget_show (radio);
 
-      w = gtk_combo_box_new_text ();
-      gtk_combo_box_append_text (GTK_COMBO_BOX (w), "Pidgin");
+      w = gtk_combo_box_text_new ();
+      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (w), "Pidgin");
       gtk_box_pack_start (GTK_BOX (hbox_1), w, TRUE, TRUE, 0);
       gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0);
       gtk_widget_show (w);
@@ -769,9 +728,9 @@ account_assistant_build_import_page (EmpathyAccountAssistant *self)
   gtk_widget_show (w);
   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 6);
 
-  w = gtk_alignment_new (0, 0, 0, 0);
+  w = gtk_alignment_new (0, 0, 1, 1);
   gtk_alignment_set_padding (GTK_ALIGNMENT (w), 0, 0, 12, 0);
-  gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), w, TRUE, TRUE, 0);
   gtk_widget_show (w);
 
   /* NOTE: this is hardcoded as we support pidgin only */
@@ -812,9 +771,12 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self)
   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
   gtk_widget_show (main_vbox);
 
+  hbox = gtk_hbox_new (FALSE, 6);
+  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
+  gtk_widget_show (hbox);
+
   w = gtk_label_new (NULL);
-  gtk_misc_set_alignment (GTK_MISC (w), 0, 0);
-  gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
   gtk_widget_show (w);
   priv->first_label = w;
 
@@ -824,7 +786,7 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self)
   gtk_widget_show (w);
 
   chooser = empathy_protocol_chooser_new ();
-  gtk_container_add (GTK_CONTAINER (w), chooser);
+  gtk_box_pack_start (GTK_BOX (hbox), chooser, FALSE, FALSE, 0);
   gtk_widget_show (chooser);
   priv->chooser = chooser;
 
@@ -896,14 +858,23 @@ impl_signal_apply (GtkAssistant *assistant)
   if (current_page == PAGE_SALUT)
     {
       if (priv->create_salut_account)
-        account_assistant_apply_account_and_finish (self, priv->salut_settings);
+        /* create_salut_account_settings() already set the display name of the
+         * account so there is no need to set it again. */
+        account_assistant_apply_account_and_finish (self, priv->salut_settings,
+            FALSE);
       return;
     }
-  else if (current_page == PAGE_ENTER_CREATE &&
+  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);
+      account_assistant_apply_account_and_finish (self, priv->settings, TRUE);
+      g_object_unref (priv->settings);
+      priv->settings = NULL;
+    }
+  else if (current_page == PAGE_IMPORT)
+    {
+      empathy_import_widget_add_selected_accounts (priv->iw);
     }
 }
 
@@ -922,12 +893,8 @@ impl_signal_prepare (GtkAssistant *assistant,
   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;
-    }
+  if (priv->current_page_id == PAGE_IMPORT)
+    empathy_import_widget_add_selected_accounts (priv->iw);
 
   current_idx = gtk_assistant_get_current_page (assistant);
   priv->current_page_id = current_idx;
@@ -948,7 +915,8 @@ impl_signal_prepare (GtkAssistant *assistant,
       if (priv->settings != NULL &&
           empathy_account_settings_is_valid (priv->settings))
         {
-          account_assistant_apply_account_and_finish (self, priv->settings);
+          account_assistant_apply_account_and_finish (self, priv->settings,
+              TRUE);
           g_object_unref (priv->settings);
           priv->settings = NULL;
         }
@@ -1112,7 +1080,7 @@ 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 (NULL);
   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. "
@@ -1135,8 +1103,8 @@ account_assistant_build_salut_page (EmpathyAccountAssistant *self)
 
   g_object_unref (pix);
 
-  w = gtk_check_button_new_with_label (
-      _("I don't want to enable this feature for now"));
+  w = gtk_check_button_new_with_mnemonic (
+      _("I do _not want to enable this feature for now"));
   gtk_box_pack_start (GTK_BOX (main_vbox), w, FALSE, FALSE, 0);
   g_signal_connect (w, "toggled",
       G_CALLBACK (create_salut_check_box_toggled_cb), self);