aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-06-18 04:17:33 +0800
committerWill Thompson <will.thompson@collabora.co.uk>2009-06-18 18:14:24 +0800
commit564562fd34a7a456e042041118ee326d3fae0069 (patch)
tree43ce226d53fc0cc5bcfbad09426e2f23a0d48216
parent17fb8fcf2f5cb1b535815dcabdc790b04969e6d5 (diff)
downloadgsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.tar
gsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.tar.gz
gsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.tar.bz2
gsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.tar.lz
gsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.tar.xz
gsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.tar.zst
gsoc2013-empathy-564562fd34a7a456e042041118ee326d3fae0069.zip
Extract part message building to a function
-rw-r--r--libempathy-gtk/empathy-chat.c79
1 files changed, 44 insertions, 35 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 44f37a868..44983004d 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1153,6 +1153,48 @@ chat_contacts_completion_func (const gchar *s1,
return ret;
}
+static gchar *
+build_part_message (guint reason,
+ const gchar *name,
+ const gchar *message)
+{
+ const gchar *template;
+
+ if (message == NULL) {
+ switch (reason) {
+ case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE:
+ template = _("%s has disconnected");
+ break;
+ case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
+ template = _("%s was kicked");
+ break;
+ case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
+ template = _("%s was banned");
+ break;
+ default:
+ template = _("%s has left the room");
+ }
+
+ return g_strdup_printf (template, name);
+ } else {
+ switch (reason) {
+ case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE:
+ template = _("%s has disconnected (%s)");
+ break;
+ case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
+ template = _("%s was kicked (%s)");
+ break;
+ case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
+ template = _("%s was banned (%s)");
+ break;
+ default:
+ template = _("%s has left the room (%s)");
+ }
+
+ return g_strdup_printf (template, name, message);
+ }
+}
+
static void
chat_members_changed_cb (EmpathyTpChat *tp_chat,
EmpathyContact *contact,
@@ -1173,41 +1215,8 @@ chat_members_changed_cb (EmpathyTpChat *tp_chat,
str = g_strdup_printf (_("%s has joined the room"),
name);
} else {
- const gchar *action;
-
- if (EMP_STR_EMPTY (message)) {
- switch (reason) {
- case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE:
- action = _("%s has disconnected");
- break;
- case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
- action = _("%s was kicked");
- break;
- case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
- action = _("%s was banned");
- break;
- default:
- action = _("%s has left the room");
- }
-
- str = g_strdup_printf (action, name);
- } else {
- switch (reason) {
- case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE:
- action = _("%s has disconnected (%s)");
- break;
- case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
- action = _("%s was kicked (%s)");
- break;
- case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
- action = _("%s was banned (%s)");
- break;
- default:
- action = _("%s has left the room (%s)");
- }
-
- str = g_strdup_printf (action, name, message);
- }
+ str = build_part_message (reason, name,
+ EMP_STR_EMPTY (message) ? NULL : message);
}
empathy_chat_view_append_event (chat->view, str);