]> git.0d.be Git - empathy.git/commitdiff
Add empathy_service_name_to_display_name()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 17 Sep 2010 13:35:07 +0000 (15:35 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 29 Sep 2010 10:54:37 +0000 (12:54 +0200)
Also makes empathy_protocol_name_to_display_name() fallbacks to the protocol
name so caller doesn't have to.

libempathy-gtk/empathy-protocol-chooser.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h
src/empathy-account-assistant.c
src/empathy-accounts-dialog.c

index 2017b3363008d6a033768f28c4e53e1579eb27f2..0ac268015ea89c6482028f2aba2cd0b13216338b 100644 (file)
@@ -225,10 +225,8 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser,
           g_strdup (proto->name), g_strdup (cm->name));
 
       icon_name = empathy_protocol_icon_name (proto->name);
-      display_name = empathy_protocol_name_to_display_name (proto->name);
 
-      if (display_name == NULL)
-        display_name = proto->name;
+      display_name = empathy_protocol_name_to_display_name (proto->name);
 
       gtk_list_store_insert_with_values (priv->store,
           NULL, 0,
@@ -241,7 +239,7 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser,
       if (!tp_strdiff (proto->name, "jabber") &&
           !tp_strdiff (cm->name, "gabble"))
         {
-          display_name = empathy_protocol_name_to_display_name ("gtalk");
+          display_name = empathy_service_name_to_display_name ("google-talk");
           gtk_list_store_insert_with_values (priv->store,
              NULL, 0,
              COL_ICON, "im-google-talk",
@@ -251,7 +249,7 @@ protocol_choosers_add_cm (EmpathyProtocolChooser *chooser,
              COL_SERVICE, "google-talk",
              -1);
 
-          display_name = empathy_protocol_name_to_display_name ("facebook");
+          display_name = empathy_service_name_to_display_name ("facebook");
           gtk_list_store_insert_with_values (priv->store,
              NULL, 0,
              COL_ICON, "im-facebook",
index 85953f8f9e0c520e81da0a1fa428331296a55811..e2e1f8a28a54910861b0ad875676f377a0245e1a 100644 (file)
@@ -539,7 +539,6 @@ empathy_protocol_name_to_display_name (const gchar *proto_name)
     gboolean translated;
   } names[] = {
     { "jabber", "Jabber", FALSE },
-    { "gtalk", "Google Talk", FALSE },
     { "msn", "MSN", FALSE, },
     { "local-xmpp", N_("People Nearby"), TRUE },
     { "irc", "IRC", FALSE },
@@ -547,7 +546,6 @@ empathy_protocol_name_to_display_name (const gchar *proto_name)
     { "aim", "AIM", FALSE },
     { "yahoo", "Yahoo!", FALSE },
     { "yahoojp", N_("Yahoo! Japan"), TRUE },
-    { "facebook", N_("Facebook Chat"), TRUE },
     { "groupwise", "GroupWise", FALSE },
     { "sip", "SIP", FALSE },
     { NULL, NULL }
@@ -564,7 +562,35 @@ empathy_protocol_name_to_display_name (const gchar *proto_name)
         }
     }
 
-  return NULL;
+  return proto_name;
+}
+
+const char *
+empathy_service_name_to_display_name (const gchar *service_name)
+{
+  int i;
+  static struct {
+    const gchar *service;
+    const gchar *display;
+    gboolean translated;
+  } names[] = {
+    { "google-talk", "Google Talk", FALSE },
+    { "facebook", N_("Facebook Chat"), TRUE },
+    { NULL, NULL }
+  };
+
+  for (i = 0; names[i].service != NULL; i++)
+    {
+      if (!tp_strdiff (service_name, names[i].service))
+        {
+          if (names[i].translated)
+            return _(names[i].display);
+          else
+            return names[i].display;
+        }
+    }
+
+  return service_name;
 }
 
 /* Note: this function depends on the account manager having its core feature
index 6a67321d9fc7e22461d7cd037e75c92c169c571c..0f8adc33e5c1622eb968111e35094327cddfa598 100644 (file)
@@ -83,6 +83,7 @@ const gchar * empathy_account_get_error_message (TpAccount *account,
 
 gchar *empathy_protocol_icon_name (const gchar *protocol);
 const gchar *empathy_protocol_name_to_display_name (const gchar *proto_name);
+const gchar *empathy_service_name_to_display_name (const gchar *proto_name);
 
 #define EMPATHY_ARRAY_TYPE_OBJECT (empathy_type_dbus_ao ())
 GType empathy_type_dbus_ao (void);
index 2a350e982ac495ca68aba18b367df9fd624e30f7..046e2377eec06f1d778c268c1bf469c19332c8c5 100644 (file)
@@ -389,8 +389,8 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser,
   GtkWidget *account_widget;
   EmpathyAccountWidget *widget_object = NULL;
   gboolean is_gtalk = FALSE, is_facebook = FALSE;
-  const gchar *name;
   gchar *service;
+  const gchar *display_name;
 
   priv = GET_PRIV (self);
 
@@ -405,21 +405,19 @@ account_assistant_protocol_changed_cb (GtkComboBox *chooser,
   if (!tp_strdiff (service, "google-talk"))
     {
       is_gtalk = TRUE;
-      name = "gtalk";
     }
   else if (!tp_strdiff (service, "facebook"))
     {
       is_facebook = TRUE;
-      name ="facebook";
     }
+
+  if (service != NULL)
+    display_name = empathy_service_name_to_display_name (service);
   else
-    {
-      name = proto->name;
-    }
+    display_name = empathy_protocol_name_to_display_name (proto->name);
 
   /* To translator: %s is the protocol name */
-  str = g_strdup_printf (_("New %s account"),
-      empathy_protocol_name_to_display_name (name));
+  str = g_strdup_printf (_("New %s account"), display_name);
 
   settings = empathy_account_settings_new (cm->name, proto->name, str);
 
index a8339a58ba0ba0e8cae74228eeda9fe6ab455153..fd68213687635044f08b711ff852ac1fdb2dcfaf 100644 (file)
@@ -585,7 +585,7 @@ accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog)
   EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
   EmpathyAccountSettings *settings;
   gchar *str;
-  const gchar *name, *display_name;
+  const gchar *display_name;
   TpConnectionManager *cm;
   TpConnectionManagerProtocol *proto;
   gboolean is_gtalk = FALSE, is_facebook = FALSE;
@@ -599,22 +599,16 @@ accounts_dialog_setup_ui_to_add_account (EmpathyAccountsDialog *dialog)
   if (!tp_strdiff (service, "google-talk"))
     {
       is_gtalk = TRUE;
-      name = "gtalk";
     }
   else if (!tp_strdiff (service, "facebook"))
     {
       is_facebook = TRUE;
-      name ="facebook";
-    }
-  else
-    {
-      name = proto->name;
     }
 
-  /* TODO: pass the service name to empathy_protocol_name_to_display_name */
-  display_name = empathy_protocol_name_to_display_name (name);
-  if (display_name == NULL)
-    display_name = proto->name;
+  if (service != NULL)
+    display_name = empathy_service_name_to_display_name (service);
+  else
+    display_name = empathy_protocol_name_to_display_name (proto->name);
 
   /* Create account */
   /* To translator: %s is the name of the protocol, such as "Google Talk" or