aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-06-19 04:26:04 +0800
committerWill Thompson <will.thompson@collabora.co.uk>2009-06-19 17:04:37 +0800
commitecbd33430aa9005131327e413d3e6eb267c6721a (patch)
tree7ca711f57cf63dd380b71cad139b7f36095c9a1b /libempathy-gtk/empathy-chat.c
parent08f02f53a10fd653cac56e23817f3c40d636ca5e (diff)
downloadgsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.tar
gsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.tar.gz
gsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.tar.bz2
gsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.tar.lz
gsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.tar.xz
gsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.tar.zst
gsoc2013-empathy-ecbd33430aa9005131327e413d3e6eb267c6721a.zip
Move string manipulation into build_part_message
Xavier said he preferred this, and it's shorter, so...
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 04b0cbd0f..f25734a10 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1154,12 +1154,17 @@ chat_contacts_completion_func (const gchar *s1,
}
static gchar *
-build_part_message (guint reason,
- const gchar *name,
- const gchar *actor,
- const gchar *message)
+build_part_message (guint reason,
+ const gchar *name,
+ EmpathyContact *actor,
+ const gchar *message)
{
GString *s = g_string_new ("");
+ const gchar *actor_name = NULL;
+
+ if (actor != NULL) {
+ actor_name = empathy_contact_get_name (actor);
+ }
/* Having an actor only really makes sense for a few actions... */
switch (reason) {
@@ -1167,17 +1172,17 @@ build_part_message (guint reason,
g_string_append_printf (s, _("%s has disconnected"), name);
break;
case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED:
- if (actor != NULL) {
+ if (actor_name != NULL) {
g_string_append_printf (s, _("%s was kicked by %s"),
- name, actor);
+ name, actor_name);
} else {
g_string_append_printf (s, _("%s was kicked"), name);
}
break;
case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED:
- if (actor != NULL) {
+ if (actor_name != NULL) {
g_string_append_printf (s, _("%s was banned by %s"),
- name, actor);
+ name, actor_name);
} else {
g_string_append_printf (s, _("%s was banned"), name);
}
@@ -1186,7 +1191,7 @@ build_part_message (guint reason,
g_string_append_printf (s, _("%s has left the room"), name);
}
- if (message != NULL) {
+ if (!EMP_STR_EMPTY (message)) {
/* Note to translators: this string is appended to
* notifications like "foo has left the room", with the message
* given by the user living the room. If this poses a problem,
@@ -1218,14 +1223,7 @@ chat_members_changed_cb (EmpathyTpChat *tp_chat,
str = g_strdup_printf (_("%s has joined the room"),
name);
} else {
- 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);
+ str = build_part_message (reason, name, actor, message);
}
empathy_chat_view_append_event (chat->view, str);