From 28acd3ce10a88f912f0d3f42d14c2e5a98d619bd Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 18 Jun 2009 11:04:54 +0100 Subject: Include actor in part message if possible --- libempathy-gtk/empathy-chat.c | 68 ++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'libempathy-gtk/empathy-chat.c') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 44983004d..c3fc7948f 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -1156,42 +1156,62 @@ chat_contacts_completion_func (const gchar *s1, static gchar * build_part_message (guint reason, const gchar *name, + const gchar *actor, const gchar *message) { - const gchar *template; - + /* Having an actor only really makes sense for a few actions... */ if (message == NULL) { switch (reason) { case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE: - template = _("%s has disconnected"); - break; + return g_strdup_printf (_("%s has disconnected"), name); case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED: - template = _("%s was kicked"); - break; + if (actor != NULL) { + return g_strdup_printf ( + _("%s was kicked by %s"), name, actor); + } else { + return g_strdup_printf (_("%s was kicked"), + name); + } case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED: - template = _("%s was banned"); - break; + if (actor != NULL) { + return g_strdup_printf ( + _("%s was banned by %s"), name, actor); + } else { + return g_strdup_printf (_("%s was banned"), + name); + } default: - template = _("%s has left the room"); + return g_strdup_printf (_("%s has left the room"), + name); } - - return g_strdup_printf (template, name); } else { switch (reason) { case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE: - template = _("%s has disconnected (%s)"); - break; + return g_strdup_printf (_("%s has disconnected (%s)"), + name, message); case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED: - template = _("%s was kicked (%s)"); - break; + if (actor != NULL) { + return g_strdup_printf ( + _("%s was kicked by %s (%s)"), name, + actor, message); + } else { + return g_strdup_printf ( + _("%s was kicked (%s)"), + name, message); + } case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED: - template = _("%s was banned (%s)"); - break; + if (actor != NULL) { + return g_strdup_printf ( + _("%s was banned by %s (%s)"), name, + actor, message); + } else { + return g_strdup_printf (_("%s was banned (%s)"), + name, message); + } default: - template = _("%s has left the room (%s)"); + return g_strdup_printf (_("%s has left the room (%s)"), + name, message); } - - return g_strdup_printf (template, name, message); } } @@ -1215,7 +1235,13 @@ chat_members_changed_cb (EmpathyTpChat *tp_chat, str = g_strdup_printf (_("%s has joined the room"), name); } else { - str = build_part_message (reason, name, + const gchar *actor_name = NULL; + + if (actor != NULL) { + actor_name = empathy_contact_get_name (actor); + } + + str = build_part_message (reason, name, actor_name, EMP_STR_EMPTY (message) ? NULL : message); } -- cgit v1.2.3