]> git.0d.be Git - empathy.git/commitdiff
Include actor in part message if possible
authorWill Thompson <will.thompson@collabora.co.uk>
Thu, 18 Jun 2009 10:04:54 +0000 (11:04 +0100)
committerWill Thompson <will.thompson@collabora.co.uk>
Thu, 18 Jun 2009 10:14:24 +0000 (11:14 +0100)
libempathy-gtk/empathy-chat.c

index 44983004d2e021ce5d2c56d86b66c5a86cbbd083..c3fc7948f0e803352a821b61e9e00f80f67f30c3 100644 (file)
@@ -1156,42 +1156,62 @@ chat_contacts_completion_func (const gchar *s1,
 static gchar *
 build_part_message (guint        reason,
                    const gchar *name,
 static gchar *
 build_part_message (guint        reason,
                    const gchar *name,
+                   const gchar *actor,
                    const gchar *message)
 {
                    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:
        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:
                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:
                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:
                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:
        } 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:
                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:
                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:
                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 = 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);
        }
 
                        EMP_STR_EMPTY (message) ? NULL : message);
        }