summaryrefslogtreecommitdiff
path: root/libempathy-gtk/empathy-account-widget.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-12 17:13:21 +0000
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-13 10:21:33 +0000
commit07cb259462d9958e65d2f94aef6e5728e83ccf29 (patch)
treefda228e3ecd55e0d8d25044561b2dbae80d37106 /libempathy-gtk/empathy-account-widget.c
parent801db029900423dd230edfda4731205c3c2a91a3 (diff)
downloadempathy-07cb259462d9958e65d2f94aef6e5728e83ccf29.tar.gz
move code generating the default display name of new account to account-widget
This will allow us to: - Use this function from other places, like in the assistant. - Delegate special cases to the specialized versions of the widget.
Diffstat (limited to 'libempathy-gtk/empathy-account-widget.c')
-rw-r--r--libempathy-gtk/empathy-account-widget.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index d77378765..77f93e2f6 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -1594,3 +1594,55 @@ empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
return self;
}
+
+gchar *
+empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ const gchar *login_id;
+ const gchar *protocol, *p;
+ gchar *default_display_name;
+
+ login_id = empathy_account_settings_get_string (priv->settings, "account");
+ protocol = empathy_account_settings_get_protocol (priv->settings);
+
+ if (login_id != NULL)
+ {
+ if (!tp_strdiff (protocol, "irc"))
+ {
+ const gchar* server;
+ server = empathy_account_settings_get_string (priv->settings,
+ "server");
+
+ /* To translators: The first parameter is the login id and the
+ * second one is the server. The resulting string will be something
+ * like: "MyUserName on chat.freenode.net".
+ * You should reverse the order of these arguments if the
+ * server should come before the login id in your locale.*/
+ default_display_name = g_strdup_printf (_("%1$s on %2$s"),
+ login_id, server);
+ }
+ else
+ {
+ default_display_name = g_strdup (login_id);
+ }
+
+ return default_display_name;
+ }
+
+ if ((p = empathy_protocol_name_to_display_name (protocol)) != NULL)
+ protocol = p;
+
+ if (protocol != NULL)
+ {
+ /* To translators: The parameter is the protocol name. The resulting
+ * string will be something like: "Jabber Account" */
+ default_display_name = g_strdup_printf (_("%s Account"), protocol);
+ }
+ else
+ {
+ default_display_name = g_strdup (_("New account"));
+ }
+
+ return default_display_name;
+}