[empathy: 5/11] Include actor in part message if possible



commit 28acd3ce10a88f912f0d3f42d14c2e5a98d619bd
Author: Will Thompson <will thompson collabora co uk>
Date:   Thu Jun 18 11:04:54 2009 +0100

    Include actor in part message if possible

 libempathy-gtk/empathy-chat.c |   68 ++++++++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 21 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 4498300..c3fc794 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);
 	}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]